fix: Turn off parallel tool calling for Claude (#2736)
This commit is contained in:
@@ -91,7 +91,14 @@ class AnthropicStreamingInterface:
|
||||
def get_tool_call_object(self) -> ToolCall:
|
||||
"""Useful for agent loop"""
|
||||
# hack for tool rules
|
||||
tool_input = json.loads(self.accumulated_tool_call_args)
|
||||
try:
|
||||
tool_input = json.loads(self.accumulated_tool_call_args)
|
||||
except json.JSONDecodeError as e:
|
||||
logger.warning(
|
||||
f"Failed to decode tool call arguments for tool_call_id={self.tool_call_id}, "
|
||||
f"name={self.tool_call_name}. Raw input: {self.accumulated_tool_call_args!r}. Error: {e}"
|
||||
)
|
||||
raise
|
||||
if "id" in tool_input and tool_input["id"].startswith("toolu_") and "function" in tool_input:
|
||||
arguments = str(json.dumps(tool_input["function"]["arguments"], indent=2))
|
||||
else:
|
||||
|
||||
@@ -202,7 +202,7 @@ class AnthropicClient(LLMClientBase):
|
||||
tool_choice = {"type": "auto", "disable_parallel_tool_use": True}
|
||||
tools_for_request = [OpenAITool(function=f) for f in tools]
|
||||
elif force_tool_call is not None:
|
||||
tool_choice = {"type": "tool", "name": force_tool_call}
|
||||
tool_choice = {"type": "tool", "name": force_tool_call, "disable_parallel_tool_use": True}
|
||||
tools_for_request = [OpenAITool(function=f) for f in tools if f["name"] == force_tool_call]
|
||||
|
||||
# need to have this setting to be able to put inner thoughts in kwargs
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import re
|
||||
import time
|
||||
from typing import List, Optional
|
||||
from typing import List
|
||||
|
||||
from fastapi import Depends, FastAPI, Request
|
||||
from fastapi import FastAPI, Request
|
||||
from opentelemetry import metrics
|
||||
from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import OTLPMetricExporter
|
||||
from opentelemetry.metrics import NoOpMeter
|
||||
|
||||
Reference in New Issue
Block a user