Skip to content

Commit

Permalink
fix tongyi tool calls (#6896)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dofine-dufei authored Aug 2, 2024
1 parent 2ab9af3 commit f8617db
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions api/core/model_runtime/model_providers/tongyi/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,12 +497,13 @@ def _convert_prompt_messages_to_tongyi_messages(self, prompt_messages: list[Prom
content = prompt_message.content
if not content:
content = ' '
tongyi_messages.append({
message = {
'role': 'assistant',
'content': content if not rich_content else [{"text": content}],
'tool_calls': [tool_call.model_dump() for tool_call in
prompt_message.tool_calls] if prompt_message.tool_calls else None
})
'content': content if not rich_content else [{"text": content}]
}
if prompt_message.tool_calls:
message['tool_calls'] = [tool_call.model_dump() for tool_call in prompt_message.tool_calls]
tongyi_messages.append(message)
elif isinstance(prompt_message, ToolPromptMessage):
tongyi_messages.append({
"role": "tool",
Expand Down

0 comments on commit f8617db

Please sign in to comment.