umarigan commited on
Commit
2f4bb21
·
verified ·
1 Parent(s): fe09f62

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -1,4 +1,4 @@
1
- from smolagents import CodeAgent, tool, OpenAIServerModel, FinalAnswerTool
2
  import datetime
3
  import pytz
4
  import yfinance as yf
@@ -19,7 +19,7 @@ def get_currency_rate(currency_pair: str) -> str:
19
  # Use yfinance to get the exchange rate
20
  ticker = f"{base}{target}=X" # Format for yfinance (e.g., "USDEUR=X")
21
  data = yf.Ticker(ticker)
22
- rate = data.history(period="1d")["Close"].iloc[-1]
23
  return f"Current {currency_pair} rate: {rate}"
24
  except Exception as e:
25
  return f"Error fetching rate: {str(e)}"
@@ -52,7 +52,7 @@ currency_tool = get_currency_rate
52
  time_tool = get_current_time_in_timezone
53
 
54
  # Create the agent
55
- agent = CodeAgent(
56
  model=model,
57
  tools=[currency_tool, final_answer],
58
  max_steps=3,
 
1
+ from smolagents import CodeAgent, tool, OpenAIServerModel, FinalAnswerTool,ToolCallingAgent
2
  import datetime
3
  import pytz
4
  import yfinance as yf
 
19
  # Use yfinance to get the exchange rate
20
  ticker = f"{base}{target}=X" # Format for yfinance (e.g., "USDEUR=X")
21
  data = yf.Ticker(ticker)
22
+ rate = data.history(period="1d")["Close"].iloc[-1].astype(str)
23
  return f"Current {currency_pair} rate: {rate}"
24
  except Exception as e:
25
  return f"Error fetching rate: {str(e)}"
 
52
  time_tool = get_current_time_in_timezone
53
 
54
  # Create the agent
55
+ agent = ToolCallingAgent(
56
  model=model,
57
  tools=[currency_tool, final_answer],
58
  max_steps=3,