mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-18 09:45:23 +00:00
Merge 3719ac89ff into f96200bcea
This commit is contained in:
commit
3eca2c9363
2 changed files with 22 additions and 1 deletions
|
|
@ -401,6 +401,7 @@ class LiteLLMMessagesToCompletionTransformationHandler:
|
|||
completion_kwargs: _CompletionKwargs,
|
||||
*,
|
||||
thinking: Mapping[str, object] | None,
|
||||
use_chat_completions_url: bool = False,
|
||||
) -> None:
|
||||
"""
|
||||
When users call `litellm.anthropic.messages.*` with a non-Anthropic model and
|
||||
|
|
@ -423,7 +424,7 @@ class LiteLLMMessagesToCompletionTransformationHandler:
|
|||
except Exception:
|
||||
custom_llm_provider = None
|
||||
|
||||
if custom_llm_provider != "openai":
|
||||
if custom_llm_provider != "openai" or use_chat_completions_url:
|
||||
return
|
||||
|
||||
if not isinstance(thinking, dict) or thinking.get("type") != "enabled":
|
||||
|
|
@ -705,6 +706,7 @@ class LiteLLMMessagesToCompletionTransformationHandler:
|
|||
LiteLLMMessagesToCompletionTransformationHandler._route_openai_thinking_to_responses_api_if_needed(
|
||||
completion_kwargs,
|
||||
thinking=thinking,
|
||||
use_chat_completions_url=litellm.use_chat_completions_url_for_anthropic_messages,
|
||||
)
|
||||
|
||||
chat_reasoning: Final = LiteLLMMessagesToCompletionTransformationHandler._chat_target_reasoning(
|
||||
|
|
|
|||
|
|
@ -427,6 +427,25 @@ class TestThinkingParameterTransformation:
|
|||
class TestThinkingSummaryPreservation:
|
||||
"""Tests for thinking.summary preservation and reasoning_auto_summary flag."""
|
||||
|
||||
@pytest.mark.parametrize("use_chat_completions_url", [True, False])
|
||||
def test_thinking_respects_chat_completions_url_override(
|
||||
self, monkeypatch: pytest.MonkeyPatch, use_chat_completions_url: bool
|
||||
) -> None:
|
||||
from litellm.llms.anthropic.pass_through.adapters.handler import (
|
||||
LiteLLMMessagesToCompletionTransformationHandler,
|
||||
)
|
||||
|
||||
monkeypatch.setattr(litellm, "use_chat_completions_url_for_anthropic_messages", use_chat_completions_url)
|
||||
completion_kwargs, _ = LiteLLMMessagesToCompletionTransformationHandler._prepare_completion_kwargs(
|
||||
model="openai/gpt-5.6",
|
||||
max_tokens=1024,
|
||||
messages=[{"role": "user", "content": "Reply with OK"}],
|
||||
thinking={"type": "enabled", "budget_tokens": 5000},
|
||||
)
|
||||
|
||||
expected_model: Final = "openai/gpt-5.6" if use_chat_completions_url else "openai/responses/gpt-5.6"
|
||||
assert completion_kwargs["model"] == expected_model
|
||||
|
||||
def test_thinking_summary_concise_preserved_for_openai(self):
|
||||
"""User-provided summary='concise' should not be replaced with 'detailed'."""
|
||||
from litellm.llms.anthropic.pass_through.adapters.handler import (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue