Spaces:
Sleeping
Sleeping
Added custom google search tool using googlesearch-python.
Browse files- functions/agent.py +4 -3
- functions/tools.py +19 -0
- requirements.txt +1 -0
functions/agent.py
CHANGED
@@ -1,13 +1,14 @@
|
|
1 |
'''Agent definition for GAIA question answering system.'''
|
2 |
|
3 |
# Imports for agent creation
|
4 |
-
from smolagents import CodeAgent,
|
5 |
from langchain_community.agent_toolkits.load_tools import load_tools
|
|
|
6 |
|
7 |
def create_agent():
|
8 |
'''Creates agent for GAIA question answering system.'''
|
9 |
|
10 |
-
|
11 |
load_tools(["wikipedia"])[0]
|
12 |
)
|
13 |
|
@@ -16,7 +17,7 @@ def create_agent():
|
|
16 |
)
|
17 |
|
18 |
agent = CodeAgent(
|
19 |
-
tools=[
|
20 |
model=model
|
21 |
)
|
22 |
|
|
|
1 |
'''Agent definition for GAIA question answering system.'''
|
2 |
|
3 |
# Imports for agent creation
|
4 |
+
from smolagents import CodeAgent, InferenceClientModel, VisitWebpageTool, Tool
|
5 |
from langchain_community.agent_toolkits.load_tools import load_tools
|
6 |
+
from functions.tools import google_search
|
7 |
|
8 |
def create_agent():
|
9 |
'''Creates agent for GAIA question answering system.'''
|
10 |
|
11 |
+
wikipedia = Tool.from_langchain(
|
12 |
load_tools(["wikipedia"])[0]
|
13 |
)
|
14 |
|
|
|
17 |
)
|
18 |
|
19 |
agent = CodeAgent(
|
20 |
+
tools=[wikipedia, google_search, VisitWebpageTool()],
|
21 |
model=model
|
22 |
)
|
23 |
|
functions/tools.py
CHANGED
@@ -1 +1,20 @@
|
|
1 |
'''Tools for GAIA question answering agent.'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
'''Tools for GAIA question answering agent.'''
|
2 |
+
|
3 |
+
from smolagents import tool
|
4 |
+
from googlesearch import search
|
5 |
+
|
6 |
+
@tool
|
7 |
+
def google_search(query: str) -> str:
|
8 |
+
"""
|
9 |
+
Perform a Google search and return the top 10 results.
|
10 |
+
|
11 |
+
Args:
|
12 |
+
query (str): The search query.
|
13 |
+
|
14 |
+
Returns:
|
15 |
+
str: The URLs of the top search results, separated by newlines.
|
16 |
+
"""
|
17 |
+
|
18 |
+
results = list(search(query, num_results=10, advanced=True))
|
19 |
+
|
20 |
+
return results
|
requirements.txt
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
duckduckgo-search
|
|
|
2 |
gradio[oauth]
|
3 |
markdownify
|
4 |
requests
|
|
|
1 |
duckduckgo-search
|
2 |
+
googlesearch-python
|
3 |
gradio[oauth]
|
4 |
markdownify
|
5 |
requests
|