Spaces:
Sleeping
Sleeping
added formula_one_search tool
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
|
@@ -33,6 +34,16 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
final_answer = FinalAnswerTool()
|
| 38 |
|
|
@@ -55,7 +66,10 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[
|
|
|
|
|
|
|
|
|
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
|
@@ -66,4 +80,4 @@ agent = CodeAgent(
|
|
| 66 |
)
|
| 67 |
|
| 68 |
|
| 69 |
-
GradioUI(agent).launch()
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
+
from duckduckgo_search import DuckDuckGoSearchTool
|
| 8 |
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
|
|
|
| 34 |
except Exception as e:
|
| 35 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 36 |
|
| 37 |
+
@tool
|
| 38 |
+
def formula_one_search(query: str) -> str:
|
| 39 |
+
"""A tool that searches for information related to Formula One using DuckDuckGo.
|
| 40 |
+
Args:
|
| 41 |
+
query: A string representing the search query related to Formula One.
|
| 42 |
+
"""
|
| 43 |
+
search = DuckDuckGoSearchTool()
|
| 44 |
+
results = search.search(query)
|
| 45 |
+
return "\n".join([f"{result['title']}: {result['href']}" for result in results])
|
| 46 |
+
|
| 47 |
|
| 48 |
final_answer = FinalAnswerTool()
|
| 49 |
|
|
|
|
| 66 |
|
| 67 |
agent = CodeAgent(
|
| 68 |
model=model,
|
| 69 |
+
tools=[
|
| 70 |
+
final_answer,
|
| 71 |
+
formula_one_search,
|
| 72 |
+
], ## add your tools here (don't remove final answer)
|
| 73 |
max_steps=6,
|
| 74 |
verbosity_level=1,
|
| 75 |
grammar=None,
|
|
|
|
| 80 |
)
|
| 81 |
|
| 82 |
|
| 83 |
+
GradioUI(agent).launch()
|