mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-23 15:18:14 +00:00
Address PR feedback: Improve documentation, refactor validation logic, add logging, and expand test coverage
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -257,6 +257,10 @@ def test_validate_call_params_no_response_format():
|
||||
|
||||
|
||||
def test_validate_call_params_openrouter_force_structured_output():
|
||||
"""
|
||||
Test that force_structured_output parameter allows bypassing response schema
|
||||
validation for OpenRouter models.
|
||||
"""
|
||||
class DummyResponse(BaseModel):
|
||||
a: int
|
||||
|
||||
@@ -282,6 +286,26 @@ def test_validate_call_params_openrouter_force_structured_output():
|
||||
assert "does not support response_format" in str(excinfo.value)
|
||||
|
||||
|
||||
def test_force_structured_output_bypasses_only_openrouter():
|
||||
"""
|
||||
Test that force_structured_output parameter only bypasses validation for
|
||||
OpenRouter models and not for other providers.
|
||||
"""
|
||||
class DummyResponse(BaseModel):
|
||||
a: int
|
||||
|
||||
# Test with non-OpenRouter provider and force_structured_output=True
|
||||
with patch("crewai.llm.supports_response_schema", return_value=False):
|
||||
llm = LLM(
|
||||
model="otherprovider/model-name",
|
||||
response_format=DummyResponse,
|
||||
force_structured_output=True
|
||||
)
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
llm._validate_call_params()
|
||||
assert "does not support response_format" in str(excinfo.value)
|
||||
|
||||
|
||||
@pytest.mark.vcr(filter_headers=["authorization"], filter_query_parameters=["key"])
|
||||
@pytest.mark.parametrize(
|
||||
"model",
|
||||
|
||||
Reference in New Issue
Block a user