From 0e096d7883e117b5a21a73683e2cabfa2a4e95bd Mon Sep 17 00:00:00 2001 From: Tim Elfrink Date: Thu, 18 Sep 2025 20:17:23 +0200 Subject: [PATCH] Update Bedrock Titan V2 type definitions for encoding format support - Add embeddingTypes parameter to AmazonTitanV2EmbeddingRequest - Add embeddingsByType response field for binary format support - Update type hints for enhanced embedding response handling --- litellm/types/llms/bedrock.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/litellm/types/llms/bedrock.py b/litellm/types/llms/bedrock.py index a829a6b94b9..352e7f7eef0 100644 --- a/litellm/types/llms/bedrock.py +++ b/litellm/types/llms/bedrock.py @@ -324,15 +324,22 @@ class CohereEmbeddingResponse(TypedDict): texts: List[str] -class AmazonTitanV2EmbeddingRequest(TypedDict): - inputText: str +class AmazonTitanV2EmbeddingRequest(TypedDict, total=False): + inputText: Required[str] dimensions: int normalize: bool + embeddingTypes: List[Literal["float", "binary"]] -class AmazonTitanV2EmbeddingResponse(TypedDict): - embedding: List[float] - inputTextTokenCount: int +class AmazonTitanV2EmbeddingsByType(TypedDict, total=False): + binary: List[int] # Array of integers for binary format + float: List[float] # Array of floats for float format + + +class AmazonTitanV2EmbeddingResponse(TypedDict, total=False): + embedding: List[float] # Legacy field - array of floats (backward compatibility) + embeddingsByType: AmazonTitanV2EmbeddingsByType # New format per AWS schema + inputTextTokenCount: Required[int] # Always present in AWS response class AmazonTitanG1EmbeddingRequest(TypedDict):