mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-16 09:22:22 +00:00
fix: preserve explicit native endpoint opt-in
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
debf90e568
commit
5d41295c2a
4 changed files with 11 additions and 49 deletions
|
|
@ -31,7 +31,7 @@ from litellm.types.llms.anthropic_messages.anthropic_response import (
|
|||
AnthropicMessagesResponse,
|
||||
)
|
||||
from litellm.types.router import GenericLiteLLMParams
|
||||
from litellm.types.utils import CallTypes, LlmProviders
|
||||
from litellm.types.utils import CallTypes
|
||||
from litellm.utils import ProviderConfigManager, client
|
||||
|
||||
from ..adapters.handler import LiteLLMMessagesToCompletionTransformationHandler
|
||||
|
|
@ -567,7 +567,7 @@ def anthropic_messages_handler(
|
|||
provider=litellm.LlmProviders(custom_llm_provider),
|
||||
)
|
||||
if anthropic_messages_provider_config is None and _deployment_supports_native_anthropic_messages(
|
||||
kwargs.get("model_info"), model=model, custom_llm_provider=custom_llm_provider
|
||||
kwargs.get("model_info")
|
||||
):
|
||||
from litellm.llms.openai_like.messages.transformation import (
|
||||
OpenAILikeAnthropicMessagesConfig,
|
||||
|
|
@ -666,13 +666,5 @@ def anthropic_messages_handler(
|
|||
)
|
||||
|
||||
|
||||
def _deployment_supports_native_anthropic_messages(
|
||||
model_info: object, model: str | None, custom_llm_provider: str | None
|
||||
) -> bool:
|
||||
if _deployment_passes_through_anthropic_messages(model_info):
|
||||
return True
|
||||
if model is None or custom_llm_provider not in tuple(provider.value for provider in LlmProviders):
|
||||
return False
|
||||
from litellm.utils import model_supports_native_endpoint
|
||||
|
||||
return model_supports_native_endpoint("/v1/messages", model, LlmProviders(custom_llm_provider))
|
||||
def _deployment_supports_native_anthropic_messages(model_info: object) -> bool:
|
||||
return _deployment_passes_through_anthropic_messages(model_info)
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ from litellm.llms.openai.data_residency import infer_openai_data_residency
|
|||
from litellm.secret_managers.main import get_secret_str
|
||||
from litellm.types.responses.main import *
|
||||
from litellm.types.router import GenericLiteLLMParams
|
||||
from litellm.types.utils import LlmProviders
|
||||
from litellm.utils import (
|
||||
ProviderConfigManager,
|
||||
client,
|
||||
|
|
@ -467,9 +466,7 @@ def _resolve_responses_api_provider_config(
|
|||
provider_config: Final = ProviderConfigManager.get_provider_responses_api_config(
|
||||
model=model, provider=custom_llm_provider
|
||||
)
|
||||
if provider_config is not None or not _deployment_supports_native_responses(
|
||||
model_info, model=model, custom_llm_provider=custom_llm_provider
|
||||
):
|
||||
if provider_config is not None or not _deployment_supports_native_responses(model_info):
|
||||
return provider_config
|
||||
return OpenAILikeResponsesConfig()
|
||||
|
||||
|
|
@ -2296,13 +2293,5 @@ async def _aresponses_websocket(
|
|||
)
|
||||
|
||||
|
||||
def _deployment_supports_native_responses(
|
||||
model_info: object, model: str | None, custom_llm_provider: str | None
|
||||
) -> bool:
|
||||
if _deployment_passes_through_responses(model_info):
|
||||
return True
|
||||
if model is None or custom_llm_provider not in tuple(provider.value for provider in LlmProviders):
|
||||
return False
|
||||
from litellm.utils import model_supports_native_endpoint
|
||||
|
||||
return model_supports_native_endpoint("/v1/responses", model, LlmProviders(custom_llm_provider))
|
||||
def _deployment_supports_native_responses(model_info: object) -> bool:
|
||||
return _deployment_passes_through_responses(model_info)
|
||||
|
|
|
|||
|
|
@ -5,9 +5,6 @@ import httpx
|
|||
import pytest
|
||||
|
||||
import litellm
|
||||
from litellm.llms.anthropic.experimental_pass_through.messages.handler import (
|
||||
_deployment_supports_native_anthropic_messages,
|
||||
)
|
||||
from litellm.llms.bedrock.chat.openai_chat_completions_transformation import (
|
||||
AmazonBedrockOpenAIChatCompletionsConfig,
|
||||
)
|
||||
|
|
@ -17,7 +14,6 @@ from litellm.llms.bedrock.messages.native_transformation import (
|
|||
mantle_native_messages_config,
|
||||
)
|
||||
from litellm.llms.bedrock.responses.transformation import AmazonBedrockResponsesAPIConfig
|
||||
from litellm.responses.main import _deployment_supports_native_responses
|
||||
from litellm.types.utils import LlmProviders
|
||||
from litellm.utils import ProviderConfigManager, model_supports_native_endpoint
|
||||
|
||||
|
|
@ -265,21 +261,6 @@ def test_native_responses_selection_and_url(monkeypatch):
|
|||
) is None
|
||||
|
||||
|
||||
def test_generic_endpoint_helpers_read_cost_map(monkeypatch):
|
||||
monkeypatch.setitem(
|
||||
litellm.model_cost,
|
||||
"hosted_vllm/native-model",
|
||||
{"supported_endpoints": ["/v1/messages", "/v1/responses"]}, # mutable-ok: provider interface
|
||||
)
|
||||
|
||||
assert _deployment_supports_native_anthropic_messages(
|
||||
None, model="native-model", custom_llm_provider="hosted_vllm"
|
||||
)
|
||||
assert _deployment_supports_native_responses(
|
||||
None, model="native-model", custom_llm_provider="hosted_vllm"
|
||||
)
|
||||
|
||||
|
||||
def test_completion_forwards_native_chat_body(monkeypatch):
|
||||
monkeypatch.setitem(
|
||||
litellm.model_cost,
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@ class TestResponsesAPIPromptManagement:
|
|||
def test_cache_control_hook_preserves_reasoning_items(self):
|
||||
original_input, merged_messages, reasoning_item = _make_cache_control_case()
|
||||
logging_obj = _make_logging_obj(
|
||||
merged_model="azure/prompt-management-test-model",
|
||||
merged_model="azure/gpt-5-codex",
|
||||
merged_messages=merged_messages,
|
||||
)
|
||||
|
||||
|
|
@ -330,7 +330,7 @@ class TestResponsesAPIPromptManagement:
|
|||
|
||||
litellm.responses(
|
||||
input=original_input,
|
||||
model="azure/prompt-management-test-model",
|
||||
model="azure/gpt-5-codex",
|
||||
litellm_logging_obj=logging_obj,
|
||||
cache_control_injection_points=[{"location": "message", "role": "system"}],
|
||||
)
|
||||
|
|
@ -516,7 +516,7 @@ class TestAsyncResponsesAPIPromptManagement:
|
|||
async def test_async_cache_control_hook_preserves_reasoning_items(self):
|
||||
original_input, merged_messages, reasoning_item = _make_cache_control_case()
|
||||
logging_obj = _make_logging_obj(
|
||||
merged_model="azure/prompt-management-test-model",
|
||||
merged_model="azure/gpt-5-codex",
|
||||
merged_messages=merged_messages,
|
||||
)
|
||||
|
||||
|
|
@ -526,7 +526,7 @@ class TestAsyncResponsesAPIPromptManagement:
|
|||
|
||||
await litellm.aresponses(
|
||||
input=original_input,
|
||||
model="azure/prompt-management-test-model",
|
||||
model="azure/gpt-5-codex",
|
||||
litellm_logging_obj=logging_obj,
|
||||
cache_control_injection_points=[{"location": "message", "role": "system"}],
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue