tournas commited on
Commit
621c6f6
·
verified ·
1 Parent(s): 6c6ee80

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -13,7 +13,7 @@ api_key = os.getenv("ALPHAVANTAGE")
13
  if not api_key:
14
  raise ValueError("\u26a0\ufe0f Key is missing! Add it as a Secret in Hugging Face Spaces.")
15
 
16
- @spaces.GPU
17
  # Helper functions for DCF calculation using Alpha Vantage API
18
  def get_company_ticker(api_key: str, company_name: str) -> str:
19
  """
@@ -26,7 +26,7 @@ def get_company_ticker(api_key: str, company_name: str) -> str:
26
  return data['bestMatches'][0]['1. symbol']
27
  else:
28
  return None
29
-
30
  def get_company_overview(api_key: str, symbol: str) -> dict:
31
  """
32
  Retrieves the company overview (financial fundamentals) for a given ticker using Alpha Vantage.
@@ -34,7 +34,7 @@ def get_company_overview(api_key: str, symbol: str) -> dict:
34
  overview_url = f'https://www.alphavantage.co/query?function=OVERVIEW&symbol={symbol}&apikey={api_key}'
35
  response = requests.get(overview_url)
36
  return response.json()
37
-
38
  def calculate_dcf(free_cash_flow: float, wacc: float, growth_rate: float, years: int = 5) -> float:
39
  """
40
  Calculates the Discounted Cash Flow (DCF) given the free cash flow, WACC and growth rate.
@@ -46,6 +46,7 @@ def calculate_dcf(free_cash_flow: float, wacc: float, growth_rate: float, years:
46
  dcf_value += discounted_cash_flow
47
  return dcf_value
48
 
 
49
  @tool
50
  def get_company_dcf(company_name: str) -> str:
51
  """A tool that calculates the Discounted Cash Flow (DCF) of a company's stock.
@@ -103,7 +104,7 @@ with open("prompts.yaml", 'r') as stream:
103
 
104
  agent = CodeAgent(
105
  model=model,
106
- tools=[final_answer, get_company_dcf], ## add your tools here (don't remove final answer)
107
  max_steps=6,
108
  verbosity_level=1,
109
  grammar=None,
 
13
  if not api_key:
14
  raise ValueError("\u26a0\ufe0f Key is missing! Add it as a Secret in Hugging Face Spaces.")
15
 
16
+ @tool
17
  # Helper functions for DCF calculation using Alpha Vantage API
18
  def get_company_ticker(api_key: str, company_name: str) -> str:
19
  """
 
26
  return data['bestMatches'][0]['1. symbol']
27
  else:
28
  return None
29
+ @tool
30
  def get_company_overview(api_key: str, symbol: str) -> dict:
31
  """
32
  Retrieves the company overview (financial fundamentals) for a given ticker using Alpha Vantage.
 
34
  overview_url = f'https://www.alphavantage.co/query?function=OVERVIEW&symbol={symbol}&apikey={api_key}'
35
  response = requests.get(overview_url)
36
  return response.json()
37
+ @tool
38
  def calculate_dcf(free_cash_flow: float, wacc: float, growth_rate: float, years: int = 5) -> float:
39
  """
40
  Calculates the Discounted Cash Flow (DCF) given the free cash flow, WACC and growth rate.
 
46
  dcf_value += discounted_cash_flow
47
  return dcf_value
48
 
49
+ @spaces.GPU
50
  @tool
51
  def get_company_dcf(company_name: str) -> str:
52
  """A tool that calculates the Discounted Cash Flow (DCF) of a company's stock.
 
104
 
105
  agent = CodeAgent(
106
  model=model,
107
+ tools=[final_answer,get_company_ticker, get_company_overview, calculate_dcf, get_company_dcf], ## add your tools here (don't remove final answer)
108
  max_steps=6,
109
  verbosity_level=1,
110
  grammar=None,