Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
|
@@ -11,15 +11,15 @@ pip install googlesearch-python
|
|
| 11 |
from googlesearch import search
|
| 12 |
|
| 13 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 14 |
-
@tool
|
| 15 |
-
def web_search(search_query:str)-> str: #it's import to specify the return type
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
|
| 24 |
@tool
|
| 25 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -52,13 +52,14 @@ custom_role_conversions=None,
|
|
| 52 |
|
| 53 |
# Import tool from Hub
|
| 54 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
|
|
|
| 55 |
|
| 56 |
with open("prompts.yaml", 'r') as stream:
|
| 57 |
prompt_templates = yaml.safe_load(stream)
|
| 58 |
|
| 59 |
agent = CodeAgent(
|
| 60 |
model=model,
|
| 61 |
-
tools=[final_answer, image_generation_tool], ## add your tools here (don't remove final answer)
|
| 62 |
max_steps=6,
|
| 63 |
verbosity_level=1,
|
| 64 |
grammar=None,
|
|
|
|
| 1 |
+
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool, GoogleSearchTool
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
|
|
|
| 11 |
from googlesearch import search
|
| 12 |
|
| 13 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 14 |
+
# @tool
|
| 15 |
+
# def web_search(search_query:str)-> str: #it's import to specify the return type
|
| 16 |
+
# #Keep this format for the description / args / args description but feel free to modify the tool
|
| 17 |
+
# """A tool that does a web search
|
| 18 |
+
# Args:
|
| 19 |
+
# search_query: the text that contains the search query
|
| 20 |
+
# """
|
| 21 |
+
# search_results = search(search_query, num_results=1)
|
| 22 |
+
# return search_results
|
| 23 |
|
| 24 |
@tool
|
| 25 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 52 |
|
| 53 |
# Import tool from Hub
|
| 54 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 55 |
+
websearch_tool = GoogleSearchTool()
|
| 56 |
|
| 57 |
with open("prompts.yaml", 'r') as stream:
|
| 58 |
prompt_templates = yaml.safe_load(stream)
|
| 59 |
|
| 60 |
agent = CodeAgent(
|
| 61 |
model=model,
|
| 62 |
+
tools=[final_answer, image_generation_tool, websearch_tool], ## add your tools here (don't remove final answer)
|
| 63 |
max_steps=6,
|
| 64 |
verbosity_level=1,
|
| 65 |
grammar=None,
|