Spaces:
Sleeping
Sleeping
replaced currency_converter tool with web_search
Browse files
app.py
CHANGED
|
@@ -4,7 +4,6 @@ import requests
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
| 7 |
-
from forex_python.converter import CurrencyRates
|
| 8 |
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
|
@@ -20,30 +19,13 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
| 20 |
return "What magic will you build ?"
|
| 21 |
|
| 22 |
@tool
|
| 23 |
-
def
|
| 24 |
-
""" A tool that
|
| 25 |
Args:
|
| 26 |
-
|
| 27 |
-
from_currency (str): The currency code of the source currency (e.g., 'USD').
|
| 28 |
-
to_currency (str): The currency code of the target currency (e.g., 'EUR').
|
| 29 |
"""
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
c = CurrencyRates()
|
| 33 |
-
|
| 34 |
-
try:
|
| 35 |
-
# Fetch the conversion rate
|
| 36 |
-
rate = c.get_rate(from_currency.upper(), to_currency.upper())
|
| 37 |
-
# Perform the conversion
|
| 38 |
-
converted_amount = amount * rate
|
| 39 |
-
return converted_amount
|
| 40 |
-
|
| 41 |
-
except RatesNotAvailableError:
|
| 42 |
-
return f"Error: Conversionrate not available for {from_currency} to {to_currency}."
|
| 43 |
-
except ValueError:
|
| 44 |
-
return f"Error: Invalid amount entered."
|
| 45 |
-
except Exception as e:
|
| 46 |
-
return f"An unexpected error occurred: {e}"
|
| 47 |
|
| 48 |
@tool
|
| 49 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -83,7 +65,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 83 |
|
| 84 |
agent = CodeAgent(
|
| 85 |
model=model,
|
| 86 |
-
tools=[final_answer, get_current_time_in_timezone,
|
| 87 |
max_steps=6,
|
| 88 |
verbosity_level=1,
|
| 89 |
grammar=None,
|
|
|
|
| 4 |
import pytz
|
| 5 |
import yaml
|
| 6 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
|
|
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
| 21 |
@tool
|
| 22 |
+
def web_search(prompt: str) -> str:
|
| 23 |
+
""" A tool that searches a given prompt from the internet and returns best 5 results
|
| 24 |
Args:
|
| 25 |
+
prompt (str): the query the user inputs
|
|
|
|
|
|
|
| 26 |
"""
|
| 27 |
+
search_tool = DuckDuckGoSearchTool(max_results=5)
|
| 28 |
+
return search_tool(prompt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
@tool
|
| 31 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 65 |
|
| 66 |
agent = CodeAgent(
|
| 67 |
model=model,
|
| 68 |
+
tools=[final_answer, get_current_time_in_timezone, web_search, image_generation_tool], ## add your tools here (don't remove final answer)
|
| 69 |
max_steps=6,
|
| 70 |
verbosity_level=1,
|
| 71 |
grammar=None,
|