Gab-Chung commited on
Commit
0e5070f
·
verified ·
1 Parent(s): 7ae9b0c

updated the import for currency converter

Browse files
Files changed (1) hide show
  1. app.py +4 -5
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
 
@@ -29,13 +28,15 @@ def web_search(prompt: str) -> str:
29
  return search_tool(prompt)
30
 
31
  @tool
32
- def convert_currency(amount:float, from_currency:str, to_currency:str) -> float:
33
  """ A tool that converts a specified amount from one currency to another.
34
  Args:
35
  amount: The amount of money to convert (e.g. 10.5).
36
  from_currency: The currency code of the source currency (e.g., 'USD').
37
  to_currency: The currency code of the target currency (e.g., 'EUR').
38
  """
 
 
39
 
40
  # Initialize the CurrencyRates object
41
  c = CurrencyRates()
@@ -104,6 +105,4 @@ agent = CodeAgent(
104
  )
105
 
106
 
107
- GradioUI(agent).launch()
108
-
109
- agent.run("How much is $1000 to rubles?")
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
 
7
 
8
  from Gradio_UI import GradioUI
9
 
 
28
  return search_tool(prompt)
29
 
30
  @tool
31
+ def convert_currency(amount:float, from_currency:str, to_currency:str) -> str:
32
  """ A tool that converts a specified amount from one currency to another.
33
  Args:
34
  amount: The amount of money to convert (e.g. 10.5).
35
  from_currency: The currency code of the source currency (e.g., 'USD').
36
  to_currency: The currency code of the target currency (e.g., 'EUR').
37
  """
38
+ # Import module within function
39
+ from forex_python.converter import CurrencyRates, RatesNotAvailableError
40
 
41
  # Initialize the CurrencyRates object
42
  c = CurrencyRates()
 
105
  )
106
 
107
 
108
+ GradioUI(agent).launch()