mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 19:24:27 +00:00
* test(test_utils.py): initial test for valid models Addresses https://github.com/BerriAI/litellm/issues/7525 * fix: test * feat(fireworks_ai/transformation.py): support retrieving valid models from fireworks ai endpoint * refactor(fireworks_ai/): support checking model info on `/v1/models` route * docs(set_keys.md): update docs to clarify check llm provider api usage * fix(watsonx/common_utils.py): support 'WATSONX_ZENAPIKEY' for iam auth * fix(watsonx): read in watsonx token from env var * fix: fix linting errors * fix(utils.py): fix provider config check * style: cleanup unused imports
29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
"""
|
|
Translate from OpenAI's `/v1/chat/completions` to VLLM's `/v1/chat/completions`
|
|
"""
|
|
|
|
from typing import List, Optional, Tuple
|
|
|
|
from litellm.secret_managers.main import get_secret_str
|
|
|
|
from ...openai.chat.gpt_transformation import OpenAIGPTConfig
|
|
|
|
|
|
class LiteLLMProxyChatConfig(OpenAIGPTConfig):
|
|
def _get_openai_compatible_provider_info(
|
|
self, api_base: Optional[str], api_key: Optional[str]
|
|
) -> Tuple[Optional[str], Optional[str]]:
|
|
api_base = api_base or get_secret_str("LITELLM_PROXY_API_BASE") # type: ignore
|
|
dynamic_api_key = api_key or get_secret_str("LITELLM_PROXY_API_KEY")
|
|
return api_base, dynamic_api_key
|
|
|
|
def get_models(
|
|
self, api_key: Optional[str] = None, api_base: Optional[str] = None
|
|
) -> List[str]:
|
|
api_base, api_key = self._get_openai_compatible_provider_info(api_base, api_key)
|
|
if api_base is None:
|
|
raise ValueError(
|
|
"api_base not set for LiteLLM Proxy route. Set in env via `LITELLM_PROXY_API_BASE`"
|
|
)
|
|
models = super().get_models(api_key=api_key, api_base=api_base)
|
|
return [f"litellm_proxy/{model}" for model in models]
|