replace web search tool, add system prompt
Browse files- agent.py +21 -4
- prompt.txt +1 -0
agent.py
CHANGED
|
@@ -1,13 +1,30 @@
|
|
| 1 |
-
from smolagents import CodeAgent, InferenceClientModel, WikipediaSearchTool
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
|
| 4 |
class GAIAAgent:
|
| 5 |
def __init__(self):
|
| 6 |
self.agent = CodeAgent(
|
| 7 |
-
tools=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
model=InferenceClientModel(),
|
| 9 |
-
add_base_tools=
|
| 10 |
)
|
|
|
|
| 11 |
|
| 12 |
def __call__(self, question: str) -> str:
|
| 13 |
-
return self.agent.run(question)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from smolagents import CodeAgent, InferenceClientModel, WikipediaSearchTool, GoogleSearchTool, VisitWebpageTool, \
|
| 2 |
+
PythonInterpreterTool
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def get_prompt():
|
| 6 |
+
with open("prompt.txt", "r") as f:
|
| 7 |
+
return f.read()
|
| 8 |
|
| 9 |
|
| 10 |
class GAIAAgent:
|
| 11 |
def __init__(self):
|
| 12 |
self.agent = CodeAgent(
|
| 13 |
+
tools=[
|
| 14 |
+
GoogleSearchTool(provider="serper"),
|
| 15 |
+
VisitWebpageTool(),
|
| 16 |
+
WikipediaSearchTool(),
|
| 17 |
+
PythonInterpreterTool(),
|
| 18 |
+
],
|
| 19 |
model=InferenceClientModel(),
|
| 20 |
+
add_base_tools=False
|
| 21 |
)
|
| 22 |
+
self.prompt = get_prompt()
|
| 23 |
|
| 24 |
def __call__(self, question: str) -> str:
|
| 25 |
+
return self.agent.run(self.prompt, additional_args={"question": question})
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
if __name__ == '__main__':
|
| 29 |
+
agent = GAIAAgent()
|
| 30 |
+
agent("What is the meaning of life?")
|
prompt.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
You are a general AI assistant. I will ask you a question. Report your thoughts and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma-separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ nor percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g., for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma-separated list, apply the above rules depending on whether the element to be put in the list is a number or a string.
|