Merge pull request #99 from openai/update_docs
use @function_tool decorator in docs
This commit is contained in:
commit
e86e5e2e6d
2 changed files with 4 additions and 2 deletions
|
|
@ -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],
|
||||
)
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in a new issue