mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-16 23:41:43 +00:00
Merge 49894b2b63 into c2c2a623c0
This commit is contained in:
commit
cd15ede305
3 changed files with 59 additions and 1 deletions
|
|
@ -1065,7 +1065,11 @@ def responses_api_bridge_check(
|
|||
try:
|
||||
model_info = cast(
|
||||
dict,
|
||||
_get_model_info_helper(model=model, custom_llm_provider=custom_llm_provider),
|
||||
_get_model_info_helper(
|
||||
model=model,
|
||||
custom_llm_provider=custom_llm_provider,
|
||||
api_base=api_base,
|
||||
),
|
||||
)
|
||||
if model_info.get("mode") is None and model.startswith("responses/"):
|
||||
model = model.replace("responses/", "")
|
||||
|
|
|
|||
|
|
@ -227,6 +227,36 @@ class TestOllamaModelInfo:
|
|||
class TestOllamaGetModelInfo:
|
||||
"""Tests for OllamaConfig.get_model_info() api_base threading and graceful fallback."""
|
||||
|
||||
def test_responses_api_bridge_check_uses_provided_api_base_for_ollama(
|
||||
self, monkeypatch
|
||||
):
|
||||
"""Bridge lookup must hit the completion api_base, not localhost:11434.
|
||||
|
||||
Regression for https://github.com/BerriAI/litellm/issues/37041
|
||||
"""
|
||||
from litellm.main import responses_api_bridge_check
|
||||
|
||||
captured_urls = []
|
||||
|
||||
def mock_post(url, json, headers=None):
|
||||
captured_urls.append(url)
|
||||
return DummyResponse({"template": "", "model_info": {}}, status_code=200)
|
||||
|
||||
monkeypatch.setattr("litellm.module_level_client.post", mock_post)
|
||||
monkeypatch.delenv("OLLAMA_API_BASE", raising=False)
|
||||
|
||||
responses_api_bridge_check(
|
||||
model="unknown-custom-model",
|
||||
custom_llm_provider="ollama",
|
||||
api_base="http://my-remote-server:30000",
|
||||
)
|
||||
|
||||
assert captured_urls
|
||||
assert all(
|
||||
url.startswith("http://my-remote-server:30000") for url in captured_urls
|
||||
)
|
||||
assert not any("localhost:11434" in url for url in captured_urls)
|
||||
|
||||
def test_get_model_info_uses_provided_api_base(self, monkeypatch):
|
||||
"""When api_base is passed, get_model_info should use it instead of env var or default."""
|
||||
from litellm.llms.ollama.completion.transformation import OllamaConfig
|
||||
|
|
|
|||
|
|
@ -750,6 +750,30 @@ def test_responses_api_bridge_check_strips_responses_prefix():
|
|||
assert model_info["mode"] == "responses"
|
||||
|
||||
|
||||
def test_responses_api_bridge_check_forwards_api_base_to_model_info_helper():
|
||||
"""completion() api_base must reach Ollama /api/show, not localhost:11434.
|
||||
|
||||
Regression for https://github.com/BerriAI/litellm/issues/37041
|
||||
"""
|
||||
from litellm.main import responses_api_bridge_check
|
||||
|
||||
with patch("litellm.main._get_model_info_helper") as mock_get_model_info:
|
||||
mock_get_model_info.return_value = {"mode": "chat"}
|
||||
api_base = "http://my-host:30000"
|
||||
|
||||
responses_api_bridge_check(
|
||||
model="my-custom-model",
|
||||
custom_llm_provider="ollama",
|
||||
api_base=api_base,
|
||||
)
|
||||
|
||||
mock_get_model_info.assert_called_once_with(
|
||||
model="my-custom-model",
|
||||
custom_llm_provider="ollama",
|
||||
api_base=api_base,
|
||||
)
|
||||
|
||||
|
||||
def test_responses_api_bridge_check_gpt_5_4_pro():
|
||||
"""Test that gpt-5.4-pro routes through responses API bridge, not chat completions.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue