Enhance function tool schemas with Annotated types (#1777)

Co-authored-by: Kazuhiro Sera <seratch@openai.com>
This commit is contained in:
Hassaan Arain
2025-09-22 11:17:15 +05:00
committed by GitHub
parent 7a4a22f0a9
commit 566b188fb5
+8 -4
View File
@@ -1,5 +1,5 @@
import asyncio
from typing import Any
from typing import Annotated, Any, Optional
from openai.types.responses import ResponseFunctionCallArgumentsDeltaEvent
@@ -7,14 +7,18 @@ from agents import Agent, Runner, function_tool
@function_tool
def write_file(filename: str, content: str) -> str:
def write_file(filename: Annotated[str, "Name of the file"], content: str) -> str:
"""Write content to a file."""
return f"File {filename} written successfully"
@function_tool
def create_config(project_name: str, version: str, dependencies: list[str]) -> str:
"""Create a configuration file for a project."""
def create_config(
project_name: Annotated[str, "Project name"],
version: Annotated[str, "Project version"],
dependencies: Annotated[Optional[list[str]], "Dependencies (list of packages)"],
) -> str:
"""Generate a project configuration file."""
return f"Config for {project_name} v{version} created"