This repository was archived by the owner on Jun 5, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
src/codegate/providers/anthropic Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change
1
+ from typing import Optional
1
2
from litellm .adapters .anthropic_adapter import (
2
3
AnthropicAdapter as LitellmAnthropicAdapter ,
3
4
)
6
7
LiteLLMAdapterInputNormalizer ,
7
8
LiteLLMAdapterOutputNormalizer ,
8
9
)
10
+ import litellm
11
+ from litellm import ChatCompletionRequest
12
+ from litellm .types .llms .anthropic import (
13
+ AnthropicMessagesRequest ,
14
+ )
15
+
16
+
17
+ class AnthropicAdapter (LitellmAnthropicAdapter ):
18
+ def __init__ (self ) -> None :
19
+ super ().__init__ ()
20
+
21
+ def translate_completion_input_params (self , kwargs ) -> Optional [ChatCompletionRequest ]:
22
+ request_body = AnthropicMessagesRequest (** kwargs ) # type: ignore
23
+ translated_body = litellm .AnthropicExperimentalPassThroughConfig ().translate_anthropic_to_openai (
24
+ anthropic_message_request = request_body
25
+ )
26
+ return translated_body
9
27
10
28
11
29
class AnthropicInputNormalizer (LiteLLMAdapterInputNormalizer ):
@@ -16,7 +34,8 @@ class AnthropicInputNormalizer(LiteLLMAdapterInputNormalizer):
16
34
"""
17
35
18
36
def __init__ (self ):
19
- super ().__init__ (LitellmAnthropicAdapter ())
37
+ self .adapter = AnthropicAdapter ()
38
+ super ().__init__ (self .adapter )
20
39
21
40
22
41
class AnthropicOutputNormalizer (LiteLLMAdapterOutputNormalizer ):
You can’t perform that action at this time.
0 commit comments