-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support checking provider-specific
/models
endpoints for available …
…models based on key (#7538) * test(test_utils.py): initial test for valid models Addresses #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
- Loading branch information
1 parent
cac06a3
commit f770dd0
Showing
12 changed files
with
352 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
from abc import ABC, abstractmethod | ||
from typing import List, Optional | ||
|
||
from litellm.types.utils import ModelInfoBase | ||
|
||
|
||
class BaseLLMModelInfo(ABC): | ||
@abstractmethod | ||
def get_model_info(self, model: str) -> ModelInfoBase: | ||
def get_model_info( | ||
self, | ||
model: str, | ||
existing_model_info: Optional[ModelInfoBase] = None, | ||
) -> Optional[ModelInfoBase]: | ||
pass | ||
|
||
@abstractmethod | ||
def get_models(self) -> List[str]: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.