API: Default tool call ID and type

Doing this helps reduce the model's burden of generating the tool
call ID and type (which is always "function"). Follow mistral's spec
for tool call IDs by using a 9 character alphanumeric string.

Signed-off-by: kingbri <8082010+kingbri1@users.noreply.github.com>
This commit is contained in:
kingbri
2025-07-11 01:11:09 -04:00
parent 5b1db3ad83
commit 707d005aad
3 changed files with 8 additions and 11 deletions

View File

@@ -1,5 +1,6 @@
from pydantic import BaseModel
from pydantic import BaseModel, Field
from typing import Dict, Literal
from uuid import uuid4
class Function(BaseModel):
@@ -29,6 +30,6 @@ class Tool(BaseModel):
class ToolCall(BaseModel):
"""Represents an OAI tool description."""
id: str
id: str = Field(default_factory=lambda: str(uuid4()).replace("-", "")[:9])
function: Tool
type: Literal["function"]
type: Literal["function"] = "function"