Enhance function tool schemas with Annotated types (#1777)
Co-authored-by: Kazuhiro Sera <seratch@openai.com>
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user