Skip to content

Commit 566b188

Browse files
Enhance function tool schemas with Annotated types (#1777)
Co-authored-by: Kazuhiro Sera <seratch@openai.com>
1 parent 7a4a22f commit 566b188

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

examples/basic/stream_function_call_args.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
import asyncio
2-
from typing import Any
2+
from typing import Annotated, Any, Optional
33

44
from openai.types.responses import ResponseFunctionCallArgumentsDeltaEvent
55

66
from agents import Agent, Runner, function_tool
77

88

99
@function_tool
10-
def write_file(filename: str, content: str) -> str:
10+
def write_file(filename: Annotated[str, "Name of the file"], content: str) -> str:
1111
"""Write content to a file."""
1212
return f"File {filename} written successfully"
1313

1414

1515
@function_tool
16-
def create_config(project_name: str, version: str, dependencies: list[str]) -> str:
17-
"""Create a configuration file for a project."""
16+
def create_config(
17+
project_name: Annotated[str, "Project name"],
18+
version: Annotated[str, "Project version"],
19+
dependencies: Annotated[Optional[list[str]], "Dependencies (list of packages)"],
20+
) -> str:
21+
"""Generate a project configuration file."""
1822
return f"Config for {project_name} v{version} created"
1923

2024

0 commit comments

Comments
 (0)