"apps/vscode:/vscode.git/clone" did not exist on "7f65199a867fef67d0d747344beaa809fabea7f3"
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): ...@@ -127,12 +127,12 @@ class OpenAIServingChat(OpenAIServingBase):
request.skip_special_tokens = False request.skip_special_tokens = False
if not isinstance(request.tool_choice, str): if not isinstance(request.tool_choice, str):
tools = [ tools = [
item.model_dump() item.function.model_dump()
for item in request.tools for item in request.tools
if item.function.name == request.tool_choice.function.name if item.function.name == request.tool_choice.function.name
] ]
else: 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 tool_call_parser = self.tokenizer_manager.server_args.tool_call_parser
parser = FunctionCallParser(request.tools, tool_call_parser) parser = FunctionCallParser(request.tools, tool_call_parser)
...@@ -178,25 +178,6 @@ class OpenAIServingChat(OpenAIServingBase): ...@@ -178,25 +178,6 @@ class OpenAIServingChat(OpenAIServingBase):
audio_data, audio_data,
modalities, 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) openai_compatible_messages.append(processed_msg)
# Handle assistant prefix for continue_final_message # 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