fix: skip response_format for Deepseek (provider doesn't support it)#6171
fix: skip response_format for Deepseek (provider doesn't support it)#6171tcconnally wants to merge 2 commits into
Conversation
Deepseek's API returns 'response_format type is unavailable now' when the response_format parameter is included. Added a provider blocklist check in both base_llm.py (constant) and openai/completion.py (gate). Closes crewAIInc#5990
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughA new module-level constant ChangesDeepSeek response_format guard
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lib/crewai/src/crewai/llms/base_llm.py`:
- Around line 129-131: The completion.py file uses a hardcoded {"deepseek"}
literal to check if a provider supports response_format, instead of importing
and using the PROVIDERS_WITHOUT_RESPONSE_FORMAT constant already defined in
base_llm.py. To fix this, add an import statement for
PROVIDERS_WITHOUT_RESPONSE_FORMAT from the base_llm module into completion.py,
then replace the hardcoded {"deepseek"} set literal in the provider check logic
with the imported PROVIDERS_WITHOUT_RESPONSE_FORMAT constant to eliminate
duplication and centralize the provider blocklist.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 708376cb-d6b0-4a1c-9a9b-8a3875b4b02f
📒 Files selected for processing (2)
lib/crewai/src/crewai/llms/base_llm.pylib/crewai/src/crewai/llms/providers/openai/completion.py
Addresses CodeRabbit review: import the centralized provider blocklist instead of duplicating a hardcoded set literal.
Problem
When using CrewAI with Deepseek, the API returns:
Deepseek's API does not support OpenAI's
response_formatparameter. Whilellm.pyhas asupports_response_schemacheck (via LiteLLM), the native OpenAI completion handler inopenai/completion.pyaddsresponse_formatunconditionally.Fix
Two changes:
base_llm.py: AddedPROVIDERS_WITHOUT_RESPONSE_FORMATconstantopenai/completion.py: Gate theresponse_formatparameter on the provider checkBefore
After
Closes #5990
Summary by CodeRabbit
response_format(notably DeepSeek). The system now appliesresponse_formatonly when the selected provider supports it, avoiding errors and improving stability when using alternative model providers.