mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-16 23:41:43 +00:00
Merge pull request #41335 from BerriAI/litellm_fireworks_dict_reasoning_effort
fix(fireworks_ai): flatten dict-form reasoning_effort to its effort string
This commit is contained in:
commit
737929f338
2 changed files with 36 additions and 6 deletions
|
|
@ -49,6 +49,17 @@ if TYPE_CHECKING:
|
|||
import tiktoken
|
||||
|
||||
|
||||
def _map_reasoning_effort(value: object) -> object:
|
||||
effort: Final[object] = cast(Mapping[str, object], value).get("effort") if isinstance(value, Mapping) else value
|
||||
if effort is True:
|
||||
return "medium"
|
||||
if effort is False:
|
||||
return "none"
|
||||
if effort == "auto":
|
||||
return None
|
||||
return effort
|
||||
|
||||
|
||||
def _extract_fireworks_hidden_params(payload: dict) -> dict:
|
||||
"""
|
||||
Collect Fireworks-specific response fields (perf_metrics, prompt_token_ids,
|
||||
|
|
@ -327,12 +338,9 @@ class FireworksAIConfig(FireworksAIMixin, OpenAIGPTConfig):
|
|||
elif param == "max_completion_tokens":
|
||||
optional_params["max_tokens"] = value
|
||||
elif param == "reasoning_effort":
|
||||
if value is True:
|
||||
optional_params["reasoning_effort"] = "medium"
|
||||
elif value is False:
|
||||
optional_params["reasoning_effort"] = "none"
|
||||
elif value != "auto":
|
||||
optional_params["reasoning_effort"] = value
|
||||
effort = _map_reasoning_effort(value)
|
||||
if effort is not None:
|
||||
optional_params["reasoning_effort"] = effort
|
||||
elif param in supported_openai_params:
|
||||
if value is not None:
|
||||
optional_params[param] = value
|
||||
|
|
|
|||
|
|
@ -1189,6 +1189,28 @@ def test_reasoning_effort_integer_passthrough():
|
|||
assert isinstance(result["reasoning_effort"], int)
|
||||
|
||||
|
||||
def test_reasoning_effort_dict_from_anthropic_adapter_flattened_to_effort_string():
|
||||
config = FireworksAIConfig()
|
||||
result = config.map_openai_params(
|
||||
{"reasoning_effort": {"effort": "medium", "summary": "detailed"}},
|
||||
{},
|
||||
_REASONING_MODEL,
|
||||
drop_params=False,
|
||||
)
|
||||
assert result["reasoning_effort"] == "medium"
|
||||
|
||||
|
||||
def test_reasoning_effort_dict_without_effort_key_dropped():
|
||||
config = FireworksAIConfig()
|
||||
result = config.map_openai_params(
|
||||
{"reasoning_effort": {"summary": "detailed"}},
|
||||
{},
|
||||
_REASONING_MODEL,
|
||||
drop_params=False,
|
||||
)
|
||||
assert "reasoning_effort" not in result
|
||||
|
||||
|
||||
def test_reasoning_effort_auto_dropped_to_model_default():
|
||||
config = FireworksAIConfig()
|
||||
result = config.map_openai_params(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue