ahudock commited on
Commit
cd230b1
·
1 Parent(s): f906687

Add tool yf_get_ticker_price

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -34,6 +34,11 @@ def get_current_time_in_timezone(timezone: str) -> str:
34
  except Exception as e:
35
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
36
 
 
 
 
 
 
37
 
38
  ddgs = DuckDuckGoSearchTool();
39
 
@@ -58,7 +63,7 @@ with open("prompts.yaml", 'r') as stream:
58
 
59
  agent = CodeAgent(
60
  model=model,
61
- tools=[final_answer, ddgs], ## add your tools here (don't remove final answer)
62
  max_steps=6,
63
  verbosity_level=1,
64
  grammar=None,
 
34
  except Exception as e:
35
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
36
 
37
+ @tool
38
+ def yf_get_ticker_price(ticker: str):
39
+ """Return the latest closing price for a stock ticker."""
40
+ data = yf.Ticker(ticker).history(period="1d")
41
+ return float(data["Close"].iloc[-1])
42
 
43
  ddgs = DuckDuckGoSearchTool();
44
 
 
63
 
64
  agent = CodeAgent(
65
  model=model,
66
+ tools=[final_answer, ddgs, yf_get_ticker_price], ## add your tools here (don't remove final answer)
67
  max_steps=6,
68
  verbosity_level=1,
69
  grammar=None,