Sharpaxis commited on
Commit
117303e
·
verified ·
1 Parent(s): e59e860

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -13
app.py CHANGED
@@ -16,18 +16,21 @@ def daily_stock_data(symbol: str)-> str: #it's import to specify the return type
16
  Args:
17
  symbol:for which symbol the data is to be fetched
18
  """
19
- start_date = (datetime.now() - timedelta(days=1)).strftime("%Y-%m-%d")
20
- end_date = datetime.now().strftime("%Y-%m-%d")
21
- ticker = yf.Ticker(symbol)
22
- df = ticker.history(start=start_date, end=end_date, auto_adjust=True)
23
- return f"""
24
- Today's Stock data for {symbol}:
25
- Open : {df['Open'].iloc[0]}
26
- High : {df['High'].iloc[0]}
27
- Low : {df['Low'].iloc[0]}
28
- Close : {df['Open'].iloc[0]}
29
- Volume : {df['Volume'].iloc[0]}
30
- """
 
 
 
31
 
32
  @tool
33
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -66,7 +69,7 @@ with open("prompts.yaml", 'r') as stream:
66
 
67
  agent = CodeAgent(
68
  model=model,
69
- tools=[final_answer], ## add your tools here (don't remove final answer)
70
  max_steps=6,
71
  verbosity_level=1,
72
  grammar=None,
 
16
  Args:
17
  symbol:for which symbol the data is to be fetched
18
  """
19
+ try :
20
+ start_date = (datetime.now() - timedelta(days=1)).strftime("%Y-%m-%d")
21
+ end_date = datetime.now().strftime("%Y-%m-%d")
22
+ ticker = yf.Ticker(symbol)
23
+ df = ticker.history(start=start_date, end=end_date, auto_adjust=True)
24
+ return f"""
25
+ Today's Stock data for {symbol}:
26
+ Open : {df['Open'].iloc[0]}
27
+ High : {df['High'].iloc[0]}
28
+ Low : {df['Low'].iloc[0]}
29
+ Close : {df['Open'].iloc[0]}
30
+ Volume : {df['Volume'].iloc[0]}
31
+ """
32
+ except Exception as e:
33
+ return f"Error fetching stock data for {symbol}: {str(e)}"
34
 
35
  @tool
36
  def get_current_time_in_timezone(timezone: str) -> str:
 
69
 
70
  agent = CodeAgent(
71
  model=model,
72
+ tools=[final_answer, daily_stock_data, get_current_time_in_timezone, image_generation_tool] ## add your tools here (don't remove final answer)
73
  max_steps=6,
74
  verbosity_level=1,
75
  grammar=None,