mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-01 02:02:20 +00:00
chore(compact_20260112): non-greedy summary regex; use COMPACT_EDIT_TYPE in bedrock filter
- Make _SUMMARY_TAG_RE non-greedy so a response with multiple <summary> blocks captures only the first complete block. - Replace the hardcoded 'compact_20260112' literal in _filter_context_management_for_bedrock_converse with the shared COMPACT_EDIT_TYPE constant.
This commit is contained in:
parent
d3178bf12c
commit
ad2e1ba916
2 changed files with 5 additions and 2 deletions
|
|
@ -52,7 +52,7 @@ _PROPAGATED_METADATA_KEYS = (
|
|||
"litellm_parent_otel_span",
|
||||
)
|
||||
|
||||
_SUMMARY_TAG_RE = re.compile(r"<summary>(.*)</summary>", re.IGNORECASE | re.DOTALL)
|
||||
_SUMMARY_TAG_RE = re.compile(r"<summary>(.*?)</summary>", re.IGNORECASE | re.DOTALL)
|
||||
|
||||
|
||||
def _read_summary_model_setting() -> Optional[str]:
|
||||
|
|
|
|||
|
|
@ -1477,6 +1477,9 @@ class AmazonConverseConfig(BaseConfig):
|
|||
anthropic_beta_list: list,
|
||||
) -> None:
|
||||
"""Keep only compact_20260112 edits for Bedrock; add beta header or drop field."""
|
||||
from litellm.llms.anthropic.experimental_pass_through.context_management.constants import (
|
||||
COMPACT_EDIT_TYPE,
|
||||
)
|
||||
from litellm.types.llms.anthropic import ANTHROPIC_BETA_HEADER_VALUES
|
||||
|
||||
cm = additional_request_params.get("context_management")
|
||||
|
|
@ -1491,7 +1494,7 @@ class AmazonConverseConfig(BaseConfig):
|
|||
compact_edits = [
|
||||
e
|
||||
for e in edits
|
||||
if isinstance(e, dict) and e.get("type") == "compact_20260112"
|
||||
if isinstance(e, dict) and e.get("type") == COMPACT_EDIT_TYPE
|
||||
]
|
||||
if compact_edits:
|
||||
compact_beta = ANTHROPIC_BETA_HEADER_VALUES.COMPACT_2026_01_12.value
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue