Skip to content

Commit 0e096d7

Browse files
committed
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
1 parent 8296bfb commit 0e096d7

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

litellm/types/llms/bedrock.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,15 +324,22 @@ class CohereEmbeddingResponse(TypedDict):
324324
texts: List[str]
325325

326326

327-
class AmazonTitanV2EmbeddingRequest(TypedDict):
328-
inputText: str
327+
class AmazonTitanV2EmbeddingRequest(TypedDict, total=False):
328+
inputText: Required[str]
329329
dimensions: int
330330
normalize: bool
331+
embeddingTypes: List[Literal["float", "binary"]]
331332

332333

333-
class AmazonTitanV2EmbeddingResponse(TypedDict):
334-
embedding: List[float]
335-
inputTextTokenCount: int
334+
class AmazonTitanV2EmbeddingsByType(TypedDict, total=False):
335+
binary: List[int] # Array of integers for binary format
336+
float: List[float] # Array of floats for float format
337+
338+
339+
class AmazonTitanV2EmbeddingResponse(TypedDict, total=False):
340+
embedding: List[float] # Legacy field - array of floats (backward compatibility)
341+
embeddingsByType: AmazonTitanV2EmbeddingsByType # New format per AWS schema
342+
inputTextTokenCount: Required[int] # Always present in AWS response
336343

337344

338345
class AmazonTitanG1EmbeddingRequest(TypedDict):

0 commit comments

Comments
 (0)