errchh
commited on
Commit
·
26557f2
1
Parent(s):
c0f603c
tool
Browse files
agent.py
CHANGED
@@ -21,7 +21,6 @@ from langchain_community.retrievers import BM25Retriever
|
|
21 |
|
22 |
from langgraph.prebuilt import ToolNode, tools_condition
|
23 |
|
24 |
-
# load system prompt
|
25 |
from prompts import system_prompt
|
26 |
|
27 |
|
@@ -29,63 +28,6 @@ from prompts import system_prompt
|
|
29 |
load_dotenv()
|
30 |
|
31 |
|
32 |
-
# maths tool
|
33 |
-
@tool
|
34 |
-
def add(a:int, b:int) -> int:
|
35 |
-
"""add two numbers.
|
36 |
-
args:
|
37 |
-
a: first int
|
38 |
-
b: second int
|
39 |
-
"""
|
40 |
-
return a + b
|
41 |
-
|
42 |
-
|
43 |
-
@tool
|
44 |
-
def subtract(a:int, b:int) -> int:
|
45 |
-
"""subtract two numbers.
|
46 |
-
args:
|
47 |
-
a: first int
|
48 |
-
b: second int
|
49 |
-
"""
|
50 |
-
return a - b
|
51 |
-
|
52 |
-
|
53 |
-
@tool
|
54 |
-
def multiply(a:int, b:int) -> int:
|
55 |
-
"""multiply two numbers.
|
56 |
-
args:
|
57 |
-
a: first int
|
58 |
-
b: second int
|
59 |
-
"""
|
60 |
-
return a * b
|
61 |
-
|
62 |
-
|
63 |
-
@tool
|
64 |
-
def divide(a:int, b:int) -> float:
|
65 |
-
"""divide two numbers.
|
66 |
-
args:
|
67 |
-
a: first int
|
68 |
-
b: second int
|
69 |
-
"""
|
70 |
-
try:
|
71 |
-
# Attempt the division
|
72 |
-
result = a / b
|
73 |
-
return result
|
74 |
-
except ZeroDivisionError:
|
75 |
-
# Handle the case where b is zero
|
76 |
-
raise ValueError("Cannot divide by zero.")
|
77 |
-
|
78 |
-
|
79 |
-
@tool
|
80 |
-
def modulus(a:int, b:int) -> int:
|
81 |
-
"""modulus remainder of two numbers.
|
82 |
-
args:
|
83 |
-
a: first int
|
84 |
-
b: second int
|
85 |
-
"""
|
86 |
-
return a % b
|
87 |
-
|
88 |
-
|
89 |
# wikipedia search tool
|
90 |
@tool
|
91 |
def search_wiki(query: str) -> str:
|
@@ -143,11 +85,6 @@ sys_msg = SystemMessage(content=system_prompt)
|
|
143 |
|
144 |
|
145 |
tools = [
|
146 |
-
add,
|
147 |
-
subtract,
|
148 |
-
multiply,
|
149 |
-
divide,
|
150 |
-
modulus,
|
151 |
search_web,
|
152 |
search_wiki,
|
153 |
search_arxiv
|
|
|
21 |
|
22 |
from langgraph.prebuilt import ToolNode, tools_condition
|
23 |
|
|
|
24 |
from prompts import system_prompt
|
25 |
|
26 |
|
|
|
28 |
load_dotenv()
|
29 |
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
# wikipedia search tool
|
32 |
@tool
|
33 |
def search_wiki(query: str) -> str:
|
|
|
85 |
|
86 |
|
87 |
tools = [
|
|
|
|
|
|
|
|
|
|
|
88 |
search_web,
|
89 |
search_wiki,
|
90 |
search_arxiv
|