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 +21
-1
lines changed
src/codegate/providers/anthropic Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 1+ from typing import Optional
12from litellm .adapters .anthropic_adapter import (
23 AnthropicAdapter as LitellmAnthropicAdapter ,
34)
67 LiteLLMAdapterInputNormalizer ,
78 LiteLLMAdapterOutputNormalizer ,
89)
10+ import litellm
11+ from litellm import ChatCompletionRequest
12+ from litellm .types .llms .anthropic import (
13+ AnthropicMessagesRequest ,
14+ )
15+
916
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+ if not request_body .get ("system" ):
24+ request_body ["system" ] = "System prompt"
25+ translated_body = litellm .AnthropicExperimentalPassThroughConfig ()\
26+ .translate_anthropic_to_openai (anthropic_message_request = request_body )
27+ return translated_body
28+
1029
1130class AnthropicInputNormalizer (LiteLLMAdapterInputNormalizer ):
1231 """
@@ -16,7 +35,8 @@ class AnthropicInputNormalizer(LiteLLMAdapterInputNormalizer):
1635 """
1736
1837 def __init__ (self ):
19- super ().__init__ (LitellmAnthropicAdapter ())
38+ self .adapter = AnthropicAdapter ()
39+ super ().__init__ (self .adapter )
2040
2141
2242class AnthropicOutputNormalizer (LiteLLMAdapterOutputNormalizer ):
You can’t perform that action at this time.
0 commit comments