WilliamGazeley commited on
Commit
7aab4a8
1 Parent(s): 7c1188c

Enable price and ratios

Browse files
Files changed (4) hide show
  1. src/app.py +3 -1
  2. src/config.py +3 -0
  3. src/functioncall.py +2 -0
  4. src/functions.py +4 -2
src/app.py CHANGED
@@ -46,9 +46,11 @@ def main():
46
 
47
  if st.button("Generate"):
48
  if input_text:
49
- with st.spinner('Generating response...'):
 
50
  agent_resp = get_response(input_text)
51
  st.write(get_output(agent_resp, input_text))
 
52
  else:
53
  st.warning("Please enter some text to generate a response.")
54
 
 
46
 
47
  if st.button("Generate"):
48
  if input_text:
49
+ with st.status('Generating response...') as status:
50
+ config.status = status
51
  agent_resp = get_response(input_text)
52
  st.write(get_output(agent_resp, input_text))
53
+ config.status.update(label="Finished!", state="complete", expanded=True)
54
  else:
55
  st.warning("Please enter some text to generate a response.")
56
 
src/config.py CHANGED
@@ -1,11 +1,14 @@
1
  from pydantic import Field
2
  from pydantic_settings import BaseSettings
 
3
 
4
  class Config(BaseSettings):
5
  hf_token: str = Field(...)
6
  hf_model: str = Field("InvestmentResearchAI/LLM-ADE-dev")
7
  headless: bool = Field(False, description="Run in headless mode.")
8
 
 
 
9
  az_search_endpoint: str = Field("https://analysis-bank.search.windows.net")
10
  az_search_api_key: str = Field(...)
11
  az_search_idx_name: str = Field("analysis-index")
 
1
  from pydantic import Field
2
  from pydantic_settings import BaseSettings
3
+ from typing import Dict, Any
4
 
5
  class Config(BaseSettings):
6
  hf_token: str = Field(...)
7
  hf_model: str = Field("InvestmentResearchAI/LLM-ADE-dev")
8
  headless: bool = Field(False, description="Run in headless mode.")
9
 
10
+ status: Any = None # Hold the status
11
+
12
  az_search_endpoint: str = Field("https://analysis-bank.search.windows.net")
13
  az_search_api_key: str = Field(...)
14
  az_search_idx_name: str = Field("analysis-index")
src/functioncall.py CHANGED
@@ -72,6 +72,7 @@ class ModelInference:
72
  raise ValueError("Assistant message is None")
73
 
74
  def execute_function_call(self, tool_call):
 
75
  function_name = tool_call.get("name")
76
  function_to_call = getattr(functions, function_name, None)
77
  function_args = tool_call.get("arguments", {})
@@ -82,6 +83,7 @@ class ModelInference:
82
  return results_dict
83
 
84
  def run_inference(self, prompt: List[Dict[str, str]]):
 
85
  inputs = self.tokenizer.apply_chat_template(
86
  prompt,
87
  add_generation_prompt=True,
 
72
  raise ValueError("Assistant message is None")
73
 
74
  def execute_function_call(self, tool_call):
75
+ config.status.update(label=":mag: Gathering information..")
76
  function_name = tool_call.get("name")
77
  function_to_call = getattr(functions, function_name, None)
78
  function_args = tool_call.get("arguments", {})
 
83
  return results_dict
84
 
85
  def run_inference(self, prompt: List[Dict[str, str]]):
86
+ config.status.update(label=":brain: Thinking..")
87
  inputs = self.tokenizer.apply_chat_template(
88
  prompt,
89
  add_generation_prompt=True,
src/functions.py CHANGED
@@ -102,6 +102,7 @@ def get_current_stock_price(symbol: str) -> float:
102
  float: The current stock price, or None if an error occurs.
103
  """
104
  try:
 
105
  stock = yf.Ticker(symbol)
106
  # Use "regularMarketPrice" for regular market hours, or "currentPrice" for pre/post market
107
  current_price = stock.info.get("regularMarketPrice", stock.info.get("currentPrice"))
@@ -187,6 +188,7 @@ def get_key_financial_ratios(symbol: str) -> dict:
187
  dict: Dictionary containing key financial ratios.
188
  """
189
  try:
 
190
  stock = yf.Ticker(symbol)
191
  key_ratios = stock.info
192
  return key_ratios
@@ -290,12 +292,12 @@ def get_openai_tools() -> List[dict]:
290
  functions = [
291
  get_analysis,
292
  # google_search_and_scrape,
293
- # get_current_stock_price,
294
  # get_company_news,
295
  # get_company_profile,
296
  # get_stock_fundamentals,
297
  # get_financial_statements,
298
- # get_key_financial_ratios,
299
  # get_analyst_recommendations,
300
  # get_dividend_data,
301
  # get_technical_indicators
 
102
  float: The current stock price, or None if an error occurs.
103
  """
104
  try:
105
+ config.status.update(label=":chart_with_upwards_trend: Getting price")
106
  stock = yf.Ticker(symbol)
107
  # Use "regularMarketPrice" for regular market hours, or "currentPrice" for pre/post market
108
  current_price = stock.info.get("regularMarketPrice", stock.info.get("currentPrice"))
 
188
  dict: Dictionary containing key financial ratios.
189
  """
190
  try:
191
+ config.status.update(label=":chart_with_upwards_trend: Gathering financial data")
192
  stock = yf.Ticker(symbol)
193
  key_ratios = stock.info
194
  return key_ratios
 
292
  functions = [
293
  get_analysis,
294
  # google_search_and_scrape,
295
+ get_current_stock_price,
296
  # get_company_news,
297
  # get_company_profile,
298
  # get_stock_fundamentals,
299
  # get_financial_statements,
300
+ get_key_financial_ratios,
301
  # get_analyst_recommendations,
302
  # get_dividend_data,
303
  # get_technical_indicators