forked from phoenix/litellm-mirror
fix(anthropic.py): fix translation
This commit is contained in:
parent
1f43368110
commit
9839a7858c
2 changed files with 4 additions and 4 deletions
|
@ -223,6 +223,9 @@ class AnthropicConfig:
|
|||
for m in messages:
|
||||
user_message: Optional[ChatCompletionUserMessage] = None
|
||||
tool_message_list: List[ChatCompletionToolMessage] = []
|
||||
new_user_content_list: List[
|
||||
Union[ChatCompletionTextObject, ChatCompletionImageObject]
|
||||
] = []
|
||||
## USER MESSAGE ##
|
||||
if m["role"] == "user":
|
||||
## translate user message
|
||||
|
@ -231,9 +234,6 @@ class AnthropicConfig:
|
|||
role="user", content=m["content"]
|
||||
)
|
||||
elif isinstance(m["content"], list):
|
||||
new_user_content_list: List[
|
||||
Union[ChatCompletionTextObject, ChatCompletionImageObject]
|
||||
] = []
|
||||
for content in m["content"]:
|
||||
if content["type"] == "text":
|
||||
text_obj = ChatCompletionTextObject(
|
||||
|
|
|
@ -275,4 +275,4 @@ def test_anthropic_tool_calling_translation():
|
|||
print(translated_params["messages"])
|
||||
|
||||
assert len(translated_params["messages"]) > 0
|
||||
assert translated_params["messages"][1]["role"] == "user"
|
||||
assert translated_params["messages"][0]["role"] == "user"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue