Skip to content

Commit e86e5e2

Browse files
authored
Merge pull request #99 from openai/update_docs
use @function_tool decorator in docs
2 parents c8f3cdd + a373162 commit e86e5e2

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Diff for: docs/agents.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ The most common properties of an agent you'll configure are:
1313
```python
1414
from agents import Agent, ModelSettings, function_tool
1515

16+
@function_tool
1617
def get_weather(city: str) -> str:
1718
return f"The weather in {city} is sunny"
1819

1920
agent = Agent(
2021
name="Haiku agent",
2122
instructions="Always respond in haiku form",
2223
model="o3-mini",
23-
tools=[function_tool(get_weather)],
24+
tools=[get_weather],
2425
)
2526
```
2627

Diff for: docs/context.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class UserInfo: # (1)!
3636
name: str
3737
uid: int
3838

39+
@function_tool
3940
async def fetch_user_age(wrapper: RunContextWrapper[UserInfo]) -> str: # (2)!
4041
return f"User {wrapper.context.name} is 47 years old"
4142

@@ -44,7 +45,7 @@ async def main():
4445

4546
agent = Agent[UserInfo]( # (4)!
4647
name="Assistant",
47-
tools=[function_tool(fetch_user_age)],
48+
tools=[fetch_user_age],
4849
)
4950

5051
result = await Runner.run(

0 commit comments

Comments
 (0)