-
Notifications
You must be signed in to change notification settings - Fork 402
Expand file tree
/
Copy pathbasic.py
More file actions
35 lines (22 loc) · 793 Bytes
/
basic.py
File metadata and controls
35 lines (22 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
Basic @fast.tool example.
Register Python functions as tools using the @fast.tool decorator.
Tools are automatically available to all agents.
Run with: uv run examples/function-tools/basic.py
"""
import asyncio
from fast_agent import FastAgent
fast = FastAgent("Function Tools Example")
@fast.tool
def get_weather(city: str) -> str:
"""Return the current weather for a city."""
return f"Currently sunny and 22°C in {city}"
@fast.tool(name="add", description="Add two numbers together")
def add_numbers(a: int, b: int) -> int:
return a + b
@fast.agent(instruction="You are a helpful assistant with access to tools.")
async def main() -> None:
async with fast.run() as agent:
await agent.interactive()
if __name__ == "__main__":
asyncio.run(main())