File tree 1 file changed +21
-0
lines changed
litellm/llms/bedrock/chat/invoke_transformations
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 3
3
import httpx
4
4
5
5
import litellm
6
+ from litellm .llms .anthropic .chat .handler import (
7
+ ModelResponseIterator as AnthropicModelResponseIterator ,
8
+ )
6
9
from litellm .llms .anthropic .chat .transformation import AnthropicConfig
10
+ from litellm .llms .bedrock .chat .invoke_handler import AWSEventStreamDecoder
7
11
from litellm .llms .bedrock .chat .invoke_transformations .base_invoke_transformation import (
8
12
AmazonInvokeConfig ,
9
13
)
10
14
from litellm .types .llms .openai import AllMessageValues
15
+ from litellm .types .utils import GenericStreamingChunk as GChunk
11
16
from litellm .types .utils import ModelResponse
12
17
13
18
if TYPE_CHECKING :
@@ -78,3 +83,19 @@ def transform_response(
78
83
api_key = api_key ,
79
84
json_mode = json_mode ,
80
85
)
86
+
87
+
88
+ class AmazonAnthropicClaudeStreamDecoder (AWSEventStreamDecoder ):
89
+ def __init__ (
90
+ self ,
91
+ model : str ,
92
+ sync_stream : bool ,
93
+ ) -> None :
94
+ super ().__init__ (model = model )
95
+ self .anthropic_model_response_iterator = AnthropicModelResponseIterator (
96
+ streaming_response = None ,
97
+ sync_stream = sync_stream ,
98
+ )
99
+
100
+ def _chunk_parser (self , chunk_data : dict ) -> GChunk :
101
+ return self .anthropic_model_response_iterator .chunk_parser (chunk = chunk_data )
You can’t perform that action at this time.
0 commit comments