-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagent.py
More file actions
47 lines (30 loc) · 779 Bytes
/
Copy pathagent.py
File metadata and controls
47 lines (30 loc) · 779 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
36
37
38
39
40
41
42
43
44
45
46
47
"""
"""
import asyncio
import os
from typing import Any
from llmkit import Tool
from llmkit.builders import anthropic
def _add(args: dict[str, Any]) -> str:
return str(args["a"] + args["b"])
add_tool = Tool(
name="add",
description="Add two numbers",
schema={
"type": "object",
"properties": {"a": {"type": "number"}, "b": {"type": "number"}},
},
run=_add,
)
async def main() -> None:
c = anthropic(os.environ.get("ANTHROPIC_API_KEY", "sk-test"))
bot = (
c.agent
.system("You are a calculator. Use the add tool.")
.add_tool(add_tool)
.max_tool_iterations(5)
)
resp = await bot.prompt("What is 2 + 3?")
print(resp.text)
if __name__ == "__main__":
asyncio.run(main())