From a373162bb01dd0651da026d2e973ceeedc4df4da Mon Sep 17 00:00:00 2001 From: jhills20 Date: Wed, 12 Mar 2025 11:15:42 -0700 Subject: [PATCH] use @function_tool decorator in docs --- docs/agents.md | 3 ++- docs/context.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/agents.md b/docs/agents.md index 9b6264b5..17589b3d 100644 --- a/docs/agents.md +++ b/docs/agents.md @@ -13,6 +13,7 @@ The most common properties of an agent you'll configure are: ```python from agents import Agent, ModelSettings, function_tool +@function_tool def get_weather(city: str) -> str: return f"The weather in {city} is sunny" @@ -20,7 +21,7 @@ agent = Agent( name="Haiku agent", instructions="Always respond in haiku form", model="o3-mini", - tools=[function_tool(get_weather)], + tools=[get_weather], ) ``` diff --git a/docs/context.md b/docs/context.md index 5dcacebe..69c43fbb 100644 --- a/docs/context.md +++ b/docs/context.md @@ -36,6 +36,7 @@ class UserInfo: # (1)! name: str uid: int +@function_tool async def fetch_user_age(wrapper: RunContextWrapper[UserInfo]) -> str: # (2)! return f"User {wrapper.context.name} is 47 years old" @@ -44,7 +45,7 @@ async def main(): agent = Agent[UserInfo]( # (4)! name="Assistant", - tools=[function_tool(fetch_user_age)], + tools=[fetch_user_age], ) result = await Runner.run(