Skip to content

Commit ce0ddb4

Browse files
committed
formatting
1 parent 26411eb commit ce0ddb4

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/strands/models/litellm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ async def structured_output(
216216

217217
if len(response.choices) > 1:
218218
raise ValueError("Multiple choices found in the response.")
219-
219+
220220
# Find the first choice with tool_calls
221221
for choice in response.choices:
222222
if choice.finish_reason == "tool_calls":

tests/strands/models/test_litellm.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,18 @@ async def test_structured_output(litellm_acompletion, model, test_output_model_c
289289
assert tru_result == exp_result
290290

291291

292+
@pytest.mark.asyncio
293+
async def test_structured_output_unsupported_model(litellm_acompletion, model, test_output_model_cls):
294+
messages = [{"role": "user", "content": [{"text": "Generate a person"}]}]
295+
296+
with unittest.mock.patch.object(strands.models.litellm, "supports_response_schema", return_value=False):
297+
with pytest.raises(ValueError, match="Model does not support response_format"):
298+
stream = model.structured_output(test_output_model_cls, messages)
299+
await stream.__anext__()
300+
301+
litellm_acompletion.assert_not_called()
302+
303+
292304
def test_config_validation_warns_on_unknown_keys(litellm_acompletion, captured_warnings):
293305
"""Test that unknown config keys emit a warning."""
294306
LiteLLMModel(client_args={"api_key": "test"}, model_id="test-model", invalid_param="test")

tests_integ/models/test_model_litellm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ class Weather(pydantic.BaseModel):
4444
def yellow_color():
4545
class Color(pydantic.BaseModel):
4646
"""Describes a color with its basic name.
47-
47+
4848
Used to extract and normalize color names from text or images.
4949
The color name should be a simple, common color like 'red', 'blue', 'yellow', etc.
5050
"""
5151

5252
simple_color_name: str = pydantic.Field(
53-
description="The basic color name (e.g., 'red', 'blue', 'yellow', 'green', 'orange', 'purple', 'black', 'white')"
53+
description="The basic color name (e.g., 'red', 'blue', 'yellow', 'green', 'orange', 'purple')"
5454
)
5555

5656
@pydantic.field_validator("simple_color_name", mode="after")

0 commit comments

Comments
 (0)