renwei2024 commited on
Commit
93c7665
·
verified ·
1 Parent(s): f2c1c06

Add the missing `try` syntax in tool `get_stock_price`

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -19,8 +19,9 @@ def get_stock_price(stock_symbol: str)-> str:
19
  Returns:
20
  current stock price in dollars.
21
  """
22
- ticker = yf.Ticker(stock_symbol.upper())
23
- price = ticker.info["regularMarketPrice"]
 
24
  return f"The current stock price of {symbol.upper()} is ${price:.2f}."
25
  except Exception as e:
26
  return f"Failed to retrieve stock price for {symbol}: {str(e)}"
 
19
  Returns:
20
  current stock price in dollars.
21
  """
22
+ try:
23
+ ticker = yf.Ticker(stock_symbol.upper())
24
+ price = ticker.info["regularMarketPrice"]
25
  return f"The current stock price of {symbol.upper()} is ${price:.2f}."
26
  except Exception as e:
27
  return f"Failed to retrieve stock price for {symbol}: {str(e)}"