mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
* test: add new test image embedding to base llm unit tests Addresses https://github.com/BerriAI/litellm/issues/6515 * fix(bedrock/embed/multimodal-embeddings): strip data prefix from image urls for bedrock multimodal embeddings Fix https://github.com/BerriAI/litellm/issues/6515 * feat: initial commit for fireworks ai audio transcription support Relevant issue: https://github.com/BerriAI/litellm/issues/7134 * test: initial fireworks ai test * feat(fireworks_ai/): implemented fireworks ai audio transcription config * fix(utils.py): register fireworks ai audio transcription config, in config manager * fix(utils.py): add fireworks ai param translation to 'get_optional_params_transcription' * refactor(fireworks_ai/): define text completion route with model name handling moves model name handling to specific fireworks routes, as required by their api * refactor(fireworks_ai/chat): define transform_Request - allows fixing model if accounts/ is missing * fix: fix linting errors * fix: fix linting errors * fix: fix linting errors * fix: fix linting errors * fix(handler.py): fix linting errors * fix(main.py): fix tgai text completion route * refactor(together_ai/completion): refactors together ai text completion route to just use provider transform request * refactor: move test_fine_tuning_api out of local_testing reduces local testing ci/cd time
50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
from typing import List, Optional, Union
|
|
|
|
from httpx import Headers
|
|
|
|
from litellm.secret_managers.main import get_secret_str
|
|
from litellm.types.llms.openai import AllMessageValues
|
|
|
|
from ..base_llm.chat.transformation import BaseLLMException
|
|
|
|
|
|
class FireworksAIException(BaseLLMException):
|
|
pass
|
|
|
|
|
|
class FireworksAIMixin:
|
|
"""
|
|
Common Base Config functions across Fireworks AI Endpoints
|
|
"""
|
|
|
|
def get_error_class(
|
|
self, error_message: str, status_code: int, headers: Union[dict, Headers]
|
|
) -> BaseLLMException:
|
|
return FireworksAIException(
|
|
status_code=status_code,
|
|
message=error_message,
|
|
headers=headers,
|
|
)
|
|
|
|
def _get_api_key(self, api_key: Optional[str]) -> Optional[str]:
|
|
dynamic_api_key = api_key or (
|
|
get_secret_str("FIREWORKS_API_KEY")
|
|
or get_secret_str("FIREWORKS_AI_API_KEY")
|
|
or get_secret_str("FIREWORKSAI_API_KEY")
|
|
or get_secret_str("FIREWORKS_AI_TOKEN")
|
|
)
|
|
return dynamic_api_key
|
|
|
|
def validate_environment(
|
|
self,
|
|
headers: dict,
|
|
model: str,
|
|
messages: List[AllMessageValues],
|
|
optional_params: dict,
|
|
api_key: Optional[str] = None,
|
|
) -> dict:
|
|
api_key = self._get_api_key(api_key)
|
|
if api_key is None:
|
|
raise ValueError("FIREWORKS_API_KEY is not set")
|
|
|
|
return {"Authorization": "Bearer {}".format(api_key), **headers}
|