Adiii143 commited on
Commit
b34b655
·
verified ·
1 Parent(s): 954ed6f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -9,18 +9,24 @@ import yfinance as yf
9
  from Gradio_UI import GradioUI
10
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
 
12
  @tool
13
- def fetch_stock_data(stock_ticker)-> str: #it's import to specify the return type
14
- #Keep this format for the description / args / args description but feel free to modify the tool
15
  """A tool that fetches the stock data
16
  Args:
17
- stock_ticker:The name of stock you want to fetch data
18
  """
19
- data = yf.download(stock_sticker,period = "6mo", interval = 'id')
20
- return f"Latest price for {stock_ticker}: ${data['Close'].iloc[-1]}"
 
21
 
 
22
  @tool
23
- def risk_analysis(stock_ticker):
 
 
 
 
24
  return f"Risk assessment for {stock_ticker}: Market is volatile, consider stop-loss adjustments."
25
 
26
 
@@ -42,7 +48,7 @@ with open("prompts.yaml", 'r') as stream:
42
 
43
  agent = CodeAgent(
44
  model=model,
45
- tools=[final_answer], ## add your tools here (don't remove final answer)
46
  max_steps=6,
47
  verbosity_level=1,
48
  grammar=None,
 
9
  from Gradio_UI import GradioUI
10
 
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
12
+ # Tool to fetch stock data
13
  @tool
14
+ def fetch_stock_data(stock_ticker: str) -> str:
 
15
  """A tool that fetches the stock data
16
  Args:
17
+ stock_ticker: The name of the stock you want to fetch data for
18
  """
19
+ data = yf.download(stock_ticker, period="6mo", interval="1d")
20
+ return f"Latest price for {stock_ticker}: ${data['Close'].iloc[-1]:.2f}"
21
+
22
 
23
+ # Tool to perform risk analysis on a stock
24
  @tool
25
+ def risk_analysis(stock_ticker: str) -> str:
26
+ """A tool that provides a risk analysis based on market conditions
27
+ Args:
28
+ stock_ticker: The stock symbol to analyze
29
+ """
30
  return f"Risk assessment for {stock_ticker}: Market is volatile, consider stop-loss adjustments."
31
 
32
 
 
48
 
49
  agent = CodeAgent(
50
  model=model,
51
+ tools=[final_answer,fetch_stock_data,risk_analysis], ## add your tools here (don't remove final answer)
52
  max_steps=6,
53
  verbosity_level=1,
54
  grammar=None,