mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
update strategy and remove it in the transformation
This commit is contained in:
parent
7f54e60a71
commit
a61abd856e
3 changed files with 29 additions and 9 deletions
|
|
@ -2,7 +2,6 @@ from typing import List, Optional, Tuple
|
|||
|
||||
import httpx
|
||||
|
||||
import litellm
|
||||
from litellm._logging import verbose_logger
|
||||
from litellm.litellm_core_utils.prompt_templates.common_utils import (
|
||||
filter_value_from_dict,
|
||||
|
|
@ -63,15 +62,13 @@ class XAIChatConfig(OpenAIGPTConfig):
|
|||
base_openai_params.append("frequency_penalty")
|
||||
|
||||
#########################################################
|
||||
# reasoning check
|
||||
# reasoning_effort check
|
||||
# Only grok-3-mini models accept the reasoning_effort parameter.
|
||||
# Other xAI reasoning models (like grok-4-1-fast-reasoning) are
|
||||
# reasoning models by nature but don't accept this parameter.
|
||||
#########################################################
|
||||
try:
|
||||
if litellm.supports_reasoning(
|
||||
model=model, custom_llm_provider=self.custom_llm_provider
|
||||
):
|
||||
base_openai_params.append("reasoning_effort")
|
||||
except Exception as e:
|
||||
verbose_logger.debug(f"Error checking if model supports reasoning: {e}")
|
||||
if self._supports_reasoning_effort(model):
|
||||
base_openai_params.append("reasoning_effort")
|
||||
|
||||
return base_openai_params
|
||||
|
||||
|
|
@ -96,6 +93,17 @@ class XAIChatConfig(OpenAIGPTConfig):
|
|||
return False
|
||||
return True
|
||||
|
||||
def _supports_reasoning_effort(self, model: str) -> bool:
|
||||
"""
|
||||
Only grok-3-mini models accept the reasoning_effort parameter.
|
||||
|
||||
Other xAI reasoning models (like grok-4-1-fast-reasoning) are reasoning
|
||||
models by nature but don't accept this parameter via the API.
|
||||
"""
|
||||
if "grok-3-mini" in model:
|
||||
return True
|
||||
return False
|
||||
|
||||
def map_openai_params(
|
||||
self,
|
||||
non_default_params: dict,
|
||||
|
|
|
|||
|
|
@ -30727,6 +30727,7 @@
|
|||
"source": "https://docs.x.ai/docs/models/grok-4-1-fast-reasoning",
|
||||
"supports_audio_input": true,
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_response_schema": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_vision": true,
|
||||
|
|
@ -30746,6 +30747,7 @@
|
|||
"source": "https://docs.x.ai/docs/models/grok-4-1-fast-reasoning",
|
||||
"supports_audio_input": true,
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_response_schema": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_vision": true,
|
||||
|
|
@ -30765,6 +30767,7 @@
|
|||
"source": "https://docs.x.ai/docs/models/grok-4-1-fast-reasoning",
|
||||
"supports_audio_input": true,
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_response_schema": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_vision": true,
|
||||
|
|
@ -30832,6 +30835,7 @@
|
|||
"output_cost_per_token": 1.5e-06,
|
||||
"source": "https://docs.x.ai/docs/models",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_tool_choice": true
|
||||
},
|
||||
"xai/grok-code-fast-1": {
|
||||
|
|
@ -30845,6 +30849,7 @@
|
|||
"output_cost_per_token": 1.5e-06,
|
||||
"source": "https://docs.x.ai/docs/models",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_tool_choice": true
|
||||
},
|
||||
"xai/grok-code-fast-1-0825": {
|
||||
|
|
@ -30858,6 +30863,7 @@
|
|||
"output_cost_per_token": 1.5e-06,
|
||||
"source": "https://docs.x.ai/docs/models",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_tool_choice": true
|
||||
},
|
||||
"xai/grok-vision-beta": {
|
||||
|
|
|
|||
|
|
@ -30727,6 +30727,7 @@
|
|||
"source": "https://docs.x.ai/docs/models/grok-4-1-fast-reasoning",
|
||||
"supports_audio_input": true,
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_response_schema": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_vision": true,
|
||||
|
|
@ -30746,6 +30747,7 @@
|
|||
"source": "https://docs.x.ai/docs/models/grok-4-1-fast-reasoning",
|
||||
"supports_audio_input": true,
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_response_schema": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_vision": true,
|
||||
|
|
@ -30765,6 +30767,7 @@
|
|||
"source": "https://docs.x.ai/docs/models/grok-4-1-fast-reasoning",
|
||||
"supports_audio_input": true,
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_response_schema": true,
|
||||
"supports_tool_choice": true,
|
||||
"supports_vision": true,
|
||||
|
|
@ -30832,6 +30835,7 @@
|
|||
"output_cost_per_token": 1.5e-06,
|
||||
"source": "https://docs.x.ai/docs/models",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_tool_choice": true
|
||||
},
|
||||
"xai/grok-code-fast-1": {
|
||||
|
|
@ -30845,6 +30849,7 @@
|
|||
"output_cost_per_token": 1.5e-06,
|
||||
"source": "https://docs.x.ai/docs/models",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_tool_choice": true
|
||||
},
|
||||
"xai/grok-code-fast-1-0825": {
|
||||
|
|
@ -30858,6 +30863,7 @@
|
|||
"output_cost_per_token": 1.5e-06,
|
||||
"source": "https://docs.x.ai/docs/models",
|
||||
"supports_function_calling": true,
|
||||
"supports_reasoning": true,
|
||||
"supports_tool_choice": true
|
||||
},
|
||||
"xai/grok-vision-beta": {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue