refactor(types): revert anthropic chat response seam

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
mateo 2026-10-18 13:09:09 +00:00
parent 6f3f9fbe2c
commit cca41c9ce3
3 changed files with 5 additions and 38 deletions

View file

@ -3100,7 +3100,7 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig):
## RESPONSE OBJECT
try:
completion_response: Final = _COMPLETION_RESPONSE.validate_python(raw_response.json())
completion_response: Final = raw_response.json()
except Exception as e:
response_headers: Final = getattr(raw_response, "headers", None)
raise AnthropicError(
@ -3186,7 +3186,6 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig):
_DECODED_JSON: Final = TypeAdapter(object)
_COMPLETION_RESPONSE: Final = TypeAdapter(dict[str, object], config=ConfigDict(strict=True))
_REQUEST_TOOLS: Final = TypeAdapter(tuple[Mapping[str, object], ...])

View file

@ -55,22 +55,6 @@ class TestCustomPromptManagement(CustomPromptManagement):
return model, messages, non_default_params
def _anthropic_chat_response() -> httpx.Response:
return httpx.Response(
200,
json={
"id": "msg_123",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello"}],
"model": "claude-3-5-sonnet",
"stop_reason": "end_turn",
"stop_sequence": None,
"usage": {"input_tokens": 1, "output_tokens": 1},
},
)
@pytest.mark.asyncio
async def test_custom_prompt_management_with_prompt_id(monkeypatch):
custom_prompt_management = TestCustomPromptManagement()
@ -78,7 +62,7 @@ async def test_custom_prompt_management_with_prompt_id(monkeypatch):
# Mock AsyncHTTPHandler.post method
client = AsyncHTTPHandler()
with patch.object(client, "post", return_value=_anthropic_chat_response()) as mock_post:
with patch.object(client, "post", return_value=MagicMock()) as mock_post:
await litellm.acompletion(
model="anthropic/claude-3-5-sonnet",
messages=[{"role": "user", "content": "Hello, how are you?"}],
@ -106,7 +90,7 @@ async def test_custom_prompt_management_with_prompt_id_and_prompt_variables():
# Mock AsyncHTTPHandler.post method
client = AsyncHTTPHandler()
with patch.object(client, "post", return_value=_anthropic_chat_response()) as mock_post:
with patch.object(client, "post", return_value=MagicMock()) as mock_post:
await litellm.acompletion(
model="anthropic/claude-3-5-sonnet",
messages=[],
@ -135,7 +119,7 @@ async def test_custom_prompt_management_without_prompt_id():
# Mock AsyncHTTPHandler.post method
client = AsyncHTTPHandler()
with patch.object(client, "post", return_value=_anthropic_chat_response()) as mock_post:
with patch.object(client, "post", return_value=MagicMock()) as mock_post:
await litellm.acompletion(
model="anthropic/claude-3-5-sonnet",
messages=[{"role": "user", "content": "Hello, how are you?"}],

View file

@ -317,23 +317,7 @@ def test_router_pattern_match_e2e():
]
)
with patch.object(
client,
"post",
return_value=httpx.Response(
200,
json={
"id": "msg_123",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello"}],
"model": "claude-3-5-sonnet",
"stop_reason": "end_turn",
"stop_sequence": None,
"usage": {"input_tokens": 1, "output_tokens": 1},
},
),
) as mock_post:
with patch.object(client, "post", new=MagicMock()) as mock_post:
router.completion(
model="llmengine/my-custom-model",