Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix tongyi tool calls (#6896)

dufeif8617db01246
diff --git a/api/core/model_runtime/model_providers/tongyi/llm/llm.py b/api/core/model_runtime/model_providers/tongyi/llm/llm.py
index 6f768131fb5..a75db78d8ce 100644
--- a/api/core/model_runtime/model_providers/tongyi/llm/llm.py
+++ b/api/core/model_runtime/model_providers/tongyi/llm/llm.py
@@ -497,12 +497,13 @@ You should also complete the text started with ``` but not tell ``` directly.
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",