From a4eaff27dda922b669f9805ef92c98de7d0ce80e Mon Sep 17 00:00:00 2001 From: Muhammad Hassaan Date: Sat, 20 Sep 2025 22:19:05 +0500 Subject: [PATCH 1/3] 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 --- examples/basic/stream_function_call_args.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/basic/stream_function_call_args.py b/examples/basic/stream_function_call_args.py index 3c3538772..7d12d8824 100644 --- a/examples/basic/stream_function_call_args.py +++ b/examples/basic/stream_function_call_args.py @@ -1,5 +1,5 @@ import asyncio -from typing import Any +from typing import Any, Annotated,Optional from openai.types.responses import ResponseFunctionCallArgumentsDeltaEvent @@ -7,14 +7,14 @@ @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" From e663ee326488f5871d1cd9cb7ca92cb60d0df984 Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Mon, 22 Sep 2025 15:11:52 +0900 Subject: [PATCH 2/3] Apply suggestions from code review --- examples/basic/stream_function_call_args.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/basic/stream_function_call_args.py b/examples/basic/stream_function_call_args.py index 7d12d8824..e6de7f85c 100644 --- a/examples/basic/stream_function_call_args.py +++ b/examples/basic/stream_function_call_args.py @@ -7,13 +7,17 @@ @function_tool -def write_file(filename:Annotated[str,"Name of the file"], 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:Annotated[str,"Project name"], version:Annotated[str,"Project version"], dependencies: Annotated[Optional[list[str]],"Dependencies (list of packages)"]) -> str: +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" From d479f6450e2c385cac78093215aeed1fdec20acc Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Mon, 22 Sep 2025 15:14:09 +0900 Subject: [PATCH 3/3] Apply suggestions from code review --- examples/basic/stream_function_call_args.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/basic/stream_function_call_args.py b/examples/basic/stream_function_call_args.py index e6de7f85c..e04806169 100644 --- a/examples/basic/stream_function_call_args.py +++ b/examples/basic/stream_function_call_args.py @@ -1,5 +1,5 @@ import asyncio -from typing import Any, Annotated,Optional +from typing import Annotated, Any, Optional from openai.types.responses import ResponseFunctionCallArgumentsDeltaEvent