mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-13 08:52:02 +00:00
fix(anthropic): skip non-string anthropic-beta list entries instead of raising
This commit is contained in:
parent
ff857389c5
commit
af175185e1
2 changed files with 19 additions and 2 deletions
|
|
@ -517,7 +517,7 @@ def merge_anthropic_beta_headers(existing: str | Sequence[str] | None, new_beta:
|
|||
return ",".join(sorted(betas))
|
||||
|
||||
|
||||
_HEADER_VALUE_LIST: Final = TypeAdapter(tuple[JsonValue, ...])
|
||||
_HEADER_VALUE_LIST: Final = TypeAdapter(tuple[object, ...])
|
||||
|
||||
|
||||
def _header_strings(value: object) -> tuple[str, ...]:
|
||||
|
|
|
|||
|
|
@ -26,7 +26,12 @@ import pytest
|
|||
import respx
|
||||
|
||||
import litellm
|
||||
from litellm.llms.anthropic.common_utils import ToolsWithoutStrict, is_claude_tool_target, tools_without_strict
|
||||
from litellm.llms.anthropic.common_utils import (
|
||||
ToolsWithoutStrict,
|
||||
is_claude_tool_target,
|
||||
merge_header_sources,
|
||||
tools_without_strict,
|
||||
)
|
||||
from litellm.llms.custom_httpx.http_handler import HTTPHandler
|
||||
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../../..")))
|
||||
|
|
@ -4728,3 +4733,15 @@ def test_tools_without_strict_drops_only_the_strict_key_and_counts_the_strict_to
|
|||
assert tools_without_strict(tools) == ToolsWithoutStrict(
|
||||
tools=({"name": "a"}, {"name": "b"}, {"name": "c"}), dropped_count=1
|
||||
)
|
||||
|
||||
|
||||
def test_merge_header_sources_keeps_only_the_string_betas_of_a_mixed_list() -> None:
|
||||
merged: Final = merge_header_sources(
|
||||
{"anthropic-beta": ["context-1m-2025-08-07", b"bytes-beta", ("nested",), object(), 3]},
|
||||
{"Anthropic-Beta": "message-threads-2026-08-12", "x-other": "kept"},
|
||||
)
|
||||
|
||||
assert dict(merged) == {
|
||||
"anthropic-beta": "context-1m-2025-08-07,message-threads-2026-08-12",
|
||||
"x-other": "kept",
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue