Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/crewai/src/crewai/llms/base_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ def get_current_call_id() -> str:
return call_id


# Providers that do not support the response_format parameter.
# Deepseek: returns "response_format type is unavailable now"
PROVIDERS_WITHOUT_RESPONSE_FORMAT: set[str] = {"deepseek"}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

class BaseLLM(BaseModel, ABC):
"""Abstract base class for LLM implementations.

Expand Down
10 changes: 8 additions & 2 deletions lib/crewai/src/crewai/llms/providers/openai/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from crewai.events.types.llm_events import LLMCallType
from crewai.llms._finish_reason_utils import extract_choices_finish_reason_and_id
from crewai.llms.base_llm import BaseLLM, JsonResponseFormat, llm_call_context
from crewai.llms.base_llm import PROVIDERS_WITHOUT_RESPONSE_FORMAT, BaseLLM, JsonResponseFormat, llm_call_context
from crewai.llms.hooks.base import BaseInterceptor
from crewai.llms.hooks.transport import AsyncHTTPTransport, HTTPTransport
from crewai.llms.providers.utils.common import safe_tool_conversion
Expand Down Expand Up @@ -1569,7 +1569,13 @@ def _prepare_completion_params(
if self.is_o1_model and self.reasoning_effort:
params["reasoning_effort"] = self.reasoning_effort

if self.response_format is not None:
# Skip response_format for providers that don't support it
# (e.g., Deepseek returns "response_format type is unavailable")
if (
self.response_format is not None
and self._extract_provider(self.model)
not in PROVIDERS_WITHOUT_RESPONSE_FORMAT
):
if isinstance(self.response_format, type) and issubclass(
self.response_format, BaseModel
):
Expand Down