mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-12 19:49:04 +08:00
fix: cohere tool call does not support single tool (#3373)
This commit is contained in:
parent
02e483c99b
commit
36b7dbb8d0
@ -323,6 +323,9 @@ class CohereLargeLanguageModel(LargeLanguageModel):
|
|||||||
model_parameters['stop_sequences'] = stop
|
model_parameters['stop_sequences'] = stop
|
||||||
|
|
||||||
if tools:
|
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)
|
model_parameters['tools'] = self._convert_tools(tools)
|
||||||
|
|
||||||
message, chat_histories, tool_results \
|
message, chat_histories, tool_results \
|
||||||
@ -476,8 +479,6 @@ class CohereLargeLanguageModel(LargeLanguageModel):
|
|||||||
index += 1
|
index += 1
|
||||||
elif isinstance(chunk, StreamedChatResponse_ToolCallsGeneration):
|
elif isinstance(chunk, StreamedChatResponse_ToolCallsGeneration):
|
||||||
chunk = cast(StreamedChatResponse_ToolCallsGeneration, chunk)
|
chunk = cast(StreamedChatResponse_ToolCallsGeneration, chunk)
|
||||||
|
|
||||||
tool_calls = []
|
|
||||||
if chunk.tool_calls:
|
if chunk.tool_calls:
|
||||||
for cohere_tool_call in chunk.tool_calls:
|
for cohere_tool_call in chunk.tool_calls:
|
||||||
tool_call = AssistantPromptMessage.ToolCall(
|
tool_call = AssistantPromptMessage.ToolCall(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user