This commit is contained in:
Achuth Reddy Bangaru 2026-09-13 00:01:05 -07:00 committed by GitHub
commit cd15ede305
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 59 additions and 1 deletions

View file

@ -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/", "")

View file

@ -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

View file

@ -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.