From 5af2df0cd593aee525e61a3c0921c887061a8c90 Mon Sep 17 00:00:00 2001 From: dufei <33253618+Dofine-dufei@users.noreply.github.com> Date: Wed, 24 Jul 2024 16:56:06 +0800 Subject: [PATCH] fix: qwen fc error (#6620) Co-authored-by: dufei --- api/core/model_runtime/model_providers/tongyi/llm/llm.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 410dcf7a9a..1f018c4078 100644 --- a/api/core/model_runtime/model_providers/tongyi/llm/llm.py +++ b/api/core/model_runtime/model_providers/tongyi/llm/llm.py @@ -425,7 +425,7 @@ You should also complete the text started with ``` but not tell ``` directly. raise ValueError(f"Got unknown type {message}") return message_text - + def _convert_messages_to_prompt(self, messages: list[PromptMessage]) -> str: """ Format a list of messages into a full prompt for the Anthropic model @@ -500,6 +500,9 @@ You should also complete the text started with ``` but not tell ``` directly. tongyi_messages.append({ '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 [] + }) elif isinstance(prompt_message, ToolPromptMessage): tongyi_messages.append({