mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 08:38:30 +00:00
Fix segmentation fault in Python 3.11 tests by improving provider comparison and replacing logging with print
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -1031,18 +1031,10 @@ class LLM(BaseLLM):
|
||||
return
|
||||
|
||||
provider = self._get_custom_llm_provider()
|
||||
provider_lower = provider.lower() if provider else ""
|
||||
|
||||
# Check if we're bypassing validation for OpenRouter
|
||||
is_openrouter_bypass = (
|
||||
provider_lower == OPENROUTER_PROVIDER.lower() and self.force_structured_output
|
||||
)
|
||||
|
||||
if is_openrouter_bypass:
|
||||
logging.warning(
|
||||
f"Forcing structured output for OpenRouter model {self.model}. "
|
||||
"Please ensure the model supports the expected response format."
|
||||
)
|
||||
is_openrouter = provider and provider.lower() == OPENROUTER_PROVIDER.lower()
|
||||
is_openrouter_bypass = is_openrouter and self.force_structured_output
|
||||
|
||||
# Check if the model supports response schema
|
||||
is_schema_supported = supports_response_schema(
|
||||
@@ -1050,6 +1042,12 @@ class LLM(BaseLLM):
|
||||
custom_llm_provider=provider,
|
||||
)
|
||||
|
||||
if is_openrouter_bypass:
|
||||
print(
|
||||
f"Warning: Forcing structured output for OpenRouter model {self.model}. "
|
||||
"Please ensure the model supports the expected response format."
|
||||
)
|
||||
|
||||
if not (is_schema_supported or is_openrouter_bypass):
|
||||
raise ValueError(
|
||||
f"The model {self.model} does not support response_format for provider '{provider}'. "
|
||||
|
||||
Reference in New Issue
Block a user