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: cohere tool call does not support single tool (#3373)

takatost36b7dbb8d0cb
diff --git a/api/core/model_runtime/model_providers/cohere/llm/llm.py b/api/core/model_runtime/model_providers/cohere/llm/llm.py
index 186afddafc4..cc8e5b0eae7 100644
--- a/api/core/model_runtime/model_providers/cohere/llm/llm.py
+++ b/api/core/model_runtime/model_providers/cohere/llm/llm.py
@@ -323,6 +323,9 @@ class CohereLargeLanguageModel(LargeLanguageModel):
model_parameters['stop_sequences'] = stop
if tools:
+ if len(tools) == 1:
+ raise ValueError("Cohere tool call requires at least two tools to be specified.")
+
model_parameters['tools'] = self._convert_tools(tools)
message, chat_histories, tool_results \
@@ -476,8 +479,6 @@ class CohereLargeLanguageModel(LargeLanguageModel):
index += 1
elif isinstance(chunk, StreamedChatResponse_ToolCallsGeneration):
chunk = cast(StreamedChatResponse_ToolCallsGeneration, chunk)
-
- tool_calls = []
if chunk.tool_calls:
for cohere_tool_call in chunk.tool_calls:
tool_call = AssistantPromptMessage.ToolCall(