mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 19:24:27 +00:00
* test: fix import for test
* fix: fix bad error string
* docs: cleanup files docs
* fix(files/main.py): cleanup error string
* style: initial commit with a provider/config pattern for files api
google ai studio files api onboarding
* fix: test
* feat(gemini/files/transformation.py): support gemini files api response transformation
* fix(gemini/files/transformation.py): return file id as gemini uri
allows id to be passed in to chat completion request, just like openai
* feat(llm_http_handler.py): support async route for files api on llm_http_handler
* fix: fix linting errors
* fix: fix model info check
* fix: fix ruff errors
* fix: fix linting errors
* Revert "fix: fix linting errors"
This reverts commit 926a5a527f
.
* fix: fix linting errors
* test: fix test
* test: fix tests
86 lines
2.4 KiB
Python
86 lines
2.4 KiB
Python
from abc import ABC, abstractmethod
|
|
from typing import TYPE_CHECKING, Any, List, Optional, Union
|
|
|
|
import httpx
|
|
|
|
from litellm.llms.base_llm.chat.transformation import BaseConfig
|
|
from litellm.types.llms.openai import (
|
|
AllMessageValues,
|
|
OpenAIAudioTranscriptionOptionalParams,
|
|
)
|
|
from litellm.types.utils import FileTypes, ModelResponse
|
|
|
|
if TYPE_CHECKING:
|
|
from litellm.litellm_core_utils.litellm_logging import Logging as _LiteLLMLoggingObj
|
|
|
|
LiteLLMLoggingObj = _LiteLLMLoggingObj
|
|
else:
|
|
LiteLLMLoggingObj = Any
|
|
|
|
|
|
class BaseAudioTranscriptionConfig(BaseConfig, ABC):
|
|
@abstractmethod
|
|
def get_supported_openai_params(
|
|
self, model: str
|
|
) -> List[OpenAIAudioTranscriptionOptionalParams]:
|
|
pass
|
|
|
|
def get_complete_url(
|
|
self,
|
|
api_base: Optional[str],
|
|
api_key: Optional[str],
|
|
model: str,
|
|
optional_params: dict,
|
|
litellm_params: dict,
|
|
stream: Optional[bool] = None,
|
|
) -> str:
|
|
"""
|
|
OPTIONAL
|
|
|
|
Get the complete url for the request
|
|
|
|
Some providers need `model` in `api_base`
|
|
"""
|
|
return api_base or ""
|
|
|
|
@abstractmethod
|
|
def transform_audio_transcription_request(
|
|
self,
|
|
model: str,
|
|
audio_file: FileTypes,
|
|
optional_params: dict,
|
|
litellm_params: dict,
|
|
) -> Union[dict, bytes]:
|
|
raise NotImplementedError(
|
|
"AudioTranscriptionConfig needs a request transformation for audio transcription models"
|
|
)
|
|
|
|
def transform_request(
|
|
self,
|
|
model: str,
|
|
messages: List[AllMessageValues],
|
|
optional_params: dict,
|
|
litellm_params: dict,
|
|
headers: dict,
|
|
) -> dict:
|
|
raise NotImplementedError(
|
|
"AudioTranscriptionConfig does not need a request transformation for audio transcription models"
|
|
)
|
|
|
|
def transform_response(
|
|
self,
|
|
model: str,
|
|
raw_response: httpx.Response,
|
|
model_response: ModelResponse,
|
|
logging_obj: LiteLLMLoggingObj,
|
|
request_data: dict,
|
|
messages: List[AllMessageValues],
|
|
optional_params: dict,
|
|
litellm_params: dict,
|
|
encoding: Any,
|
|
api_key: Optional[str] = None,
|
|
json_mode: Optional[bool] = None,
|
|
) -> ModelResponse:
|
|
raise NotImplementedError(
|
|
"AudioTranscriptionConfig does not need a response transformation for audio transcription models"
|
|
)
|