mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-16 09:22:22 +00:00
refactor(requesty): expose provider info resolution as a public method
The type check gate counts reportPrivateUsage across the litellm package and get_llm_provider_logic calling RequestyConfig()._get_openai_compatible_provider_info pushed the count one over the ratcheted budget. RequestyConfig now exposes get_openai_compatible_provider_info instead, and the new tests go through get_llm_provider and get_supported_openai_params rather than private helpers
This commit is contained in:
parent
2cb0beb9d6
commit
48cfeae0ec
3 changed files with 8 additions and 7 deletions
|
|
@ -846,7 +846,7 @@ def _get_openai_compatible_provider_info(
|
|||
(
|
||||
api_base, # rebind-ok: provider resolution
|
||||
dynamic_api_key, # rebind-ok: provider resolution
|
||||
) = litellm.RequestyConfig()._get_openai_compatible_provider_info(api_base, api_key)
|
||||
) = litellm.RequestyConfig().get_openai_compatible_provider_info(api_base, api_key)
|
||||
elif custom_llm_provider == "vercel_ai_gateway":
|
||||
(
|
||||
api_base,
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class RequestyConfig(OpenrouterConfig):
|
|||
def custom_llm_provider(self) -> str | None:
|
||||
return "requesty"
|
||||
|
||||
def _get_openai_compatible_provider_info(
|
||||
def get_openai_compatible_provider_info(
|
||||
self, api_base: str | None, api_key: str | None
|
||||
) -> tuple[str | None, str | None]:
|
||||
resolved_api_base: Final = api_base or get_secret_str("REQUESTY_API_BASE") or "https://router.requesty.ai/v1"
|
||||
|
|
|
|||
|
|
@ -29,9 +29,7 @@ def test_requesty_in_provider_registries():
|
|||
|
||||
def test_requesty_config_default_base_url():
|
||||
"""RequestyConfig exposes the fixed Requesty router base URL."""
|
||||
api_base, _dynamic_api_key = RequestyConfig()._get_openai_compatible_provider_info(
|
||||
api_base=None, api_key="test-key"
|
||||
)
|
||||
api_base, _dynamic_api_key = RequestyConfig().get_openai_compatible_provider_info(api_base=None, api_key="test-key")
|
||||
assert api_base == "https://router.requesty.ai/v1"
|
||||
|
||||
|
||||
|
|
@ -158,7 +156,7 @@ def test_requesty_config_reads_base_url_and_key_from_env(monkeypatch):
|
|||
monkeypatch.setenv("REQUESTY_API_BASE", "https://router.eu.requesty.ai/v1")
|
||||
monkeypatch.setenv("REQUESTY_API_KEY", "env-test-key")
|
||||
|
||||
api_base, dynamic_api_key = RequestyConfig()._get_openai_compatible_provider_info(api_base=None, api_key=None)
|
||||
_model, _custom_llm_provider, dynamic_api_key, api_base = get_llm_provider(model="requesty/openai/gpt-4o-mini")
|
||||
|
||||
assert api_base == "https://router.eu.requesty.ai/v1"
|
||||
assert dynamic_api_key == "env-test-key"
|
||||
|
|
@ -172,7 +170,10 @@ def test_supports_reasoning_swallows_lookup_errors(monkeypatch):
|
|||
|
||||
monkeypatch.setattr(litellm, "supports_reasoning", _boom)
|
||||
|
||||
assert RequestyConfig()._supports_reasoning("acme/unknown-1") is False
|
||||
supported_params = RequestyConfig().get_supported_openai_params("acme/unknown-1")
|
||||
|
||||
assert "reasoning_effort" not in supported_params
|
||||
assert "thinking" not in supported_params
|
||||
|
||||
|
||||
def test_map_openai_params_translates_max_reasoning_effort_to_xhigh():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue