mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 02:34:29 +00:00
* test: add initial e2e test * fix(vertex_ai/files): initial commit adding sync file create support * refactor: initial commit of vertex ai non-jsonl files reaching gcp endpoint * fix(vertex_ai/files/transformation.py): initial working commit of non-jsonl file call reaching backend endpoint * fix(vertex_ai/files/transformation.py): working e2e non-jsonl file upload * test: working e2e jsonl call * test: unit testing for jsonl file creation * fix(vertex_ai/transformation.py): reset file pointer after read allow multiple reads on same file object * fix: fix linting errors * fix: fix ruff linting errors * fix: fix import * fix: fix linting error * fix: fix linting error * fix(vertex_ai/files/transformation.py): fix linting error * test: update test * test: update tests * fix: fix linting errors * fix: fix test * fix: fix linting error
101 lines
2.7 KiB
Python
101 lines
2.7 KiB
Python
from abc import abstractmethod
|
|
from typing import TYPE_CHECKING, Any, List, Optional, Union
|
|
|
|
import httpx
|
|
|
|
from litellm.types.llms.openai import (
|
|
AllMessageValues,
|
|
CreateFileRequest,
|
|
OpenAICreateFileRequestOptionalParams,
|
|
OpenAIFileObject,
|
|
)
|
|
from litellm.types.utils import LlmProviders, ModelResponse
|
|
|
|
from ..chat.transformation import BaseConfig
|
|
|
|
if TYPE_CHECKING:
|
|
from litellm.litellm_core_utils.litellm_logging import Logging as _LiteLLMLoggingObj
|
|
|
|
LiteLLMLoggingObj = _LiteLLMLoggingObj
|
|
else:
|
|
LiteLLMLoggingObj = Any
|
|
|
|
|
|
class BaseFilesConfig(BaseConfig):
|
|
@property
|
|
@abstractmethod
|
|
def custom_llm_provider(self) -> LlmProviders:
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_supported_openai_params(
|
|
self, model: str
|
|
) -> List[OpenAICreateFileRequestOptionalParams]:
|
|
pass
|
|
|
|
def get_complete_file_url(
|
|
self,
|
|
api_base: Optional[str],
|
|
api_key: Optional[str],
|
|
model: str,
|
|
optional_params: dict,
|
|
litellm_params: dict,
|
|
data: CreateFileRequest,
|
|
):
|
|
return self.get_complete_url(
|
|
api_base=api_base,
|
|
api_key=api_key,
|
|
model=model,
|
|
optional_params=optional_params,
|
|
litellm_params=litellm_params,
|
|
)
|
|
|
|
@abstractmethod
|
|
def transform_create_file_request(
|
|
self,
|
|
model: str,
|
|
create_file_data: CreateFileRequest,
|
|
optional_params: dict,
|
|
litellm_params: dict,
|
|
) -> Union[dict, str, bytes]:
|
|
pass
|
|
|
|
@abstractmethod
|
|
def transform_create_file_response(
|
|
self,
|
|
model: Optional[str],
|
|
raw_response: httpx.Response,
|
|
logging_obj: LiteLLMLoggingObj,
|
|
litellm_params: dict,
|
|
) -> OpenAIFileObject:
|
|
pass
|
|
|
|
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"
|
|
)
|