mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
* refactor(bedrock): initial commit to refactor bedrock to a folder Improve code readability + maintainability * refactor: more refactor work * fix: fix imports * feat(bedrock/embeddings.py): support translating embedding into amazon embedding formats * fix: fix linting errors * test: skip test on end of life model * fix(cohere/embed.py): fix linting error * fix(cohere/embed.py): fix typing * fix(cohere/embed.py): fix post-call logging for cohere embedding call * test(test_embeddings.py): fix error message assertion in test
25 lines
735 B
Python
25 lines
735 B
Python
"""
|
|
Transformation logic from OpenAI /v1/embeddings format to Bedrock Cohere /invoke format.
|
|
|
|
Why separate file? Make it easy to see how transformation works
|
|
"""
|
|
|
|
from typing import List
|
|
|
|
import litellm
|
|
from litellm.types.llms.bedrock import CohereEmbeddingRequest, CohereEmbeddingResponse
|
|
from litellm.types.utils import Embedding, EmbeddingResponse
|
|
|
|
|
|
def _transform_request(
|
|
input: List[str], inference_params: dict
|
|
) -> CohereEmbeddingRequest:
|
|
transformed_request = CohereEmbeddingRequest(
|
|
texts=input,
|
|
input_type=litellm.COHERE_DEFAULT_EMBEDDING_INPUT_TYPE, # type: ignore
|
|
)
|
|
|
|
for k, v in inference_params.items():
|
|
transformed_request[k] = v # type: ignore
|
|
|
|
return transformed_request
|