Unverified Commit a79a5d70 authored by Chang Su's avatar Chang Su Committed by GitHub
Browse files

Revert "Fix the input tools format and history tool_calls in OpenAI API (#6556)" (#8584)

parent ec5f9442
......@@ -127,12 +127,12 @@ class OpenAIServingChat(OpenAIServingBase):
request.skip_special_tokens = False
if not isinstance(request.tool_choice, str):
tools = [
item.model_dump()
item.function.model_dump()
for item in request.tools
if item.function.name == request.tool_choice.function.name
]
else:
tools = [item.model_dump() for item in request.tools]
tools = [item.function.model_dump() for item in request.tools]
tool_call_parser = self.tokenizer_manager.server_args.tool_call_parser
parser = FunctionCallParser(request.tools, tool_call_parser)
......@@ -178,25 +178,6 @@ class OpenAIServingChat(OpenAIServingBase):
audio_data,
modalities,
)
if "tool_calls" in processed_msg and isinstance(
processed_msg.get("tool_calls"), list
):
for call in processed_msg["tool_calls"]:
try:
if "arguments" in call["function"] and isinstance(
call["function"]["arguments"], str
):
call["function"]["arguments"] = json.loads(
call["function"]["arguments"]
)
except json.JSONDecodeError as e:
# Log a warning or error if JSON parsing fails for arguments
logger.warning(
f"Failed to parse tool call arguments as JSON: {e}"
)
# Decide whether to continue or raise the exception based on desired behavior
continue # Or raise e if strict parsing is required
openai_compatible_messages.append(processed_msg)
# Handle assistant prefix for continue_final_message
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment