Skip to content

Commit a4eaff2

Browse files
Enhance function tool schemas with Annotated types
- Replaced plain type hints with Annotated to provide parameter descriptions - Marked dependencies as Optional[list[str]] for flexibility - Improved function docstrings for consistency and clarity - No changes to streaming logic, only schema/metadata enhancements
1 parent 7a4a22f commit a4eaff2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

examples/basic/stream_function_call_args.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import asyncio
2-
from typing import Any
2+
from typing import Any, Annotated,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(project_name:Annotated[str,"Project name"], version:Annotated[str,"Project version"], dependencies: Annotated[Optional[list[str]],"Dependencies (list of packages)"]) -> str:
17+
"""Generate a project configuration file."""
1818
return f"Config for {project_name} v{version} created"
1919

2020

0 commit comments

Comments
 (0)