[Frontend] Add defer_loading and tool_reference support for Anthropic and OpenAI APIs (#40190)

Signed-off-by: JaredforReal <w13431838023@gmail.com>
Signed-off-by: sfeng33 <4florafeng@gmail.com>
Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Co-authored-by: sfeng33 <4florafeng@gmail.com>
Co-authored-by: Chauncey <chaunceyjiang@gmail.com>
This commit is contained in:
Jared Wen
2026-04-29 04:35:50 -07:00
committed by GitHub
co-authored by sfeng33 Chauncey
parent 33f36d4260
commit 11b69129e2
5 changed files with 97 additions and 6 deletions
@@ -12,6 +12,7 @@ from pydantic import (
BaseModel,
ConfigDict,
Field,
model_serializer,
model_validator,
)
@@ -166,6 +167,14 @@ class FunctionDefinition(OpenAIBaseModel):
name: str
description: str | None = None
parameters: dict[str, Any] | None = None
defer_loading: bool | None = None
@model_serializer(mode="wrap")
def _serialize(self, handler):
data = handler(self)
if self.defer_loading is None:
data.pop("defer_loading", None)
return data
# extra="forbid" is a workaround to have kwargs as a field,