-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
41 lines (28 loc) · 914 Bytes
/
Copy pathmain.py
File metadata and controls
41 lines (28 loc) · 914 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
from message import Message
from react_agent import ReactAgent
from tool import tool
@tool
def add(a: int, b: int) -> int:
"""Returns the sum of a and b"""
return a + b
@tool
def substract(a: int, b: int) -> int:
"""Returns the difference of a and b"""
return a - b
@tool
def multiply(a: int, b: int) -> int:
"""Multiplies a with b and returns the value"""
return a * b
@tool
def divide(a: int, b: int) -> float:
"""Divides a with b and returns the value"""
return a / b
@tool
def exponent(a: int, b: int) -> int:
"""returns the exponent of a with b"""
return a ** b
tools = [add, substract, multiply, divide, exponent]
agent = ReactAgent(tools=tools, include_internal_logs=True)
message = Message("user",
"What is 2 plus 4 and then divided by 3 and multiplied by 4? and what if we also raise it to power of 3?")
print(agent.execute(message))