mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
Merge 7cd5d46c36 into e52f05566d
This commit is contained in:
commit
9fae3615a2
4 changed files with 66 additions and 0 deletions
|
|
@ -175,6 +175,9 @@ class OpenAIGPTConfig(BaseLLMModelInfo, BaseConfig):
|
|||
model_specific_params.append(
|
||||
"user"
|
||||
) # user is not a param supported by all openai-compatible endpoints - e.g. azure ai
|
||||
|
||||
if litellm.utils.supports_reasoning(model=model, custom_llm_provider="openai") and not model.startswith("gpt-5-chat"):
|
||||
model_specific_params.append("reasoning_effort")
|
||||
return base_params + model_specific_params
|
||||
|
||||
def _map_openai_params(
|
||||
|
|
|
|||
|
|
@ -162,6 +162,8 @@ class ProviderSpecificModelInfo(TypedDict, total=False):
|
|||
supports_none_reasoning_effort: bool | None
|
||||
supports_minimal_reasoning_effort: bool | None
|
||||
supports_low_reasoning_effort: bool | None
|
||||
supports_medium_reasoning_effort: bool | None
|
||||
supports_high_reasoning_effort: bool | None
|
||||
supports_xhigh_reasoning_effort: bool | None
|
||||
supports_max_reasoning_effort: bool | None
|
||||
supports_output_config: bool | None
|
||||
|
|
|
|||
|
|
@ -2722,6 +2722,20 @@ def supports_reasoning(model: str, custom_llm_provider: str | None = None) -> bo
|
|||
return _supports_factory(model=model, custom_llm_provider=custom_llm_provider, key="supports_reasoning")
|
||||
|
||||
|
||||
def supports_medium_reasoning_effort(model: str, custom_llm_provider: str | None = None) -> bool:
|
||||
"""
|
||||
Check if the given model supports medium reasoning effort and return a boolean value.
|
||||
"""
|
||||
return _supports_factory(model=model, custom_llm_provider=custom_llm_provider, key="supports_medium_reasoning_effort")
|
||||
|
||||
|
||||
def supports_high_reasoning_effort(model: str, custom_llm_provider: str | None = None) -> bool:
|
||||
"""
|
||||
Check if the given model supports high reasoning effort and return a boolean value.
|
||||
"""
|
||||
return _supports_factory(model=model, custom_llm_provider=custom_llm_provider, key="supports_high_reasoning_effort")
|
||||
|
||||
|
||||
def supports_native_structured_output(model: str, custom_llm_provider: str | None = None) -> bool:
|
||||
"""
|
||||
Check if the given model supports native structured outputs and return a boolean value.
|
||||
|
|
|
|||
47
tests/test_litellm/test_reasoning_effort_config.py
Normal file
47
tests/test_litellm/test_reasoning_effort_config.py
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import pytest
|
||||
import litellm
|
||||
from litellm.llms.openai.chat.gpt_transformation import OpenAIGPTConfig
|
||||
from litellm.utils import (
|
||||
supports_reasoning,
|
||||
supports_medium_reasoning_effort,
|
||||
supports_high_reasoning_effort,
|
||||
)
|
||||
|
||||
|
||||
def test_openai_gpt_config_supported_params_includes_reasoning_effort_when_supported():
|
||||
config = OpenAIGPTConfig()
|
||||
|
||||
litellm.register_model({
|
||||
"custom-reasoning-model": {
|
||||
"max_tokens": 4096,
|
||||
"input_cost_per_token": 0.00001,
|
||||
"output_cost_per_token": 0.00002,
|
||||
"litellm_provider": "openai",
|
||||
"mode": "chat",
|
||||
"supports_reasoning": True,
|
||||
"supports_medium_reasoning_effort": True,
|
||||
"supports_high_reasoning_effort": True,
|
||||
}
|
||||
})
|
||||
|
||||
supported_params = config.get_supported_openai_params(model="custom-reasoning-model")
|
||||
assert "reasoning_effort" in supported_params
|
||||
assert supports_reasoning("custom-reasoning-model", custom_llm_provider="openai") is True
|
||||
assert supports_medium_reasoning_effort("custom-reasoning-model", custom_llm_provider="openai") is True
|
||||
assert supports_high_reasoning_effort("custom-reasoning-model", custom_llm_provider="openai") is True
|
||||
|
||||
|
||||
def test_supports_medium_and_high_reasoning_effort_helpers():
|
||||
litellm.register_model({
|
||||
"plain-chat-model": {
|
||||
"max_tokens": 4096,
|
||||
"input_cost_per_token": 0.00001,
|
||||
"output_cost_per_token": 0.00002,
|
||||
"litellm_provider": "openai",
|
||||
"mode": "chat",
|
||||
"supports_reasoning": False,
|
||||
}
|
||||
})
|
||||
|
||||
assert supports_medium_reasoning_effort("plain-chat-model", custom_llm_provider="openai") is False
|
||||
assert supports_high_reasoning_effort("plain-chat-model", custom_llm_provider="openai") is False
|
||||
Loading…
Add table
Reference in a new issue