API: Add tool_call_id for role = tool

If a message with role = tool is present, the tool_call_id should
also be given to the template.

Signed-off-by: kingbri <8082010+kingbri1@users.noreply.github.com>
This commit is contained in:
kingbri 2025-07-05 21:52:26 -04:00
parent 1c3f84151f
commit 3dfa965019
2 changed files with 1 additions and 5 deletions

View file

@ -1,5 +1,4 @@
from pydantic import AliasChoices, BaseModel, Field, field_validator
from pydantic.json_schema import SkipJsonSchema
from time import time
from typing import Literal, Union, List, Optional, Dict
from uuid import uuid4
@ -32,7 +31,7 @@ class ChatCompletionMessage(BaseModel):
role: str = "user"
content: Optional[Union[str, List[ChatCompletionMessagePart]]] = None
tool_calls: Optional[List[ToolCall]] = None
tool_calls_json: SkipJsonSchema[Optional[str]] = None
tool_call_id: Optional[str] = None
class ChatCompletionRespChoice(BaseModel):

View file

@ -237,9 +237,6 @@ async def format_messages_with_template(
# Convert the message content into a concatenated string
message.content = concatenated_content
if message.tool_calls:
message.tool_calls_json = ToolCallProcessor.to_json(message.tool_calls)
message_dicts.append(message.model_dump(exclude_none=True))
# Get all special tokens