Browse Source

fix/moonshot-function-call (#3339)

tags/0.6.2
Yeuoly 1 year ago
parent
commit
18b855140d
No account linked to committer's email address
1 changed files with 1 additions and 8 deletions
  1. 1
    8
      api/core/model_runtime/model_providers/moonshot/llm/llm.py

+ 1
- 8
api/core/model_runtime/model_providers/moonshot/llm/llm.py View File

"id": function_call.id, "id": function_call.id,
"type": function_call.type, "type": function_call.type,
"function": { "function": {
"name": f"functions.{function_call.function.name}",
"name": function_call.function.name,
"arguments": function_call.function.arguments "arguments": function_call.function.arguments
} }
}) })
elif isinstance(message, ToolPromptMessage): elif isinstance(message, ToolPromptMessage):
message = cast(ToolPromptMessage, message) message = cast(ToolPromptMessage, message)
message_dict = {"role": "tool", "content": message.content, "tool_call_id": message.tool_call_id} message_dict = {"role": "tool", "content": message.content, "tool_call_id": message.tool_call_id}
if not message.name.startswith("functions."):
message.name = f"functions.{message.name}"
elif isinstance(message, SystemPromptMessage): elif isinstance(message, SystemPromptMessage):
message = cast(SystemPromptMessage, message) message = cast(SystemPromptMessage, message)
message_dict = {"role": "system", "content": message.content} message_dict = {"role": "system", "content": message.content}
if new_tool_call.type: if new_tool_call.type:
tool_call.type = new_tool_call.type tool_call.type = new_tool_call.type
if new_tool_call.function.name: if new_tool_call.function.name:
# remove the functions. prefix
if new_tool_call.function.name.startswith('functions.'):
parts = new_tool_call.function.name.split('functions.')
if len(parts) > 1:
new_tool_call.function.name = parts[1]
tool_call.function.name = new_tool_call.function.name tool_call.function.name = new_tool_call.function.name
if new_tool_call.function.arguments: if new_tool_call.function.arguments:
tool_call.function.arguments += new_tool_call.function.arguments tool_call.function.arguments += new_tool_call.function.arguments

Loading…
Cancel
Save