CCockrum commited on
Commit
8eb4d8c
·
verified ·
1 Parent(s): 9a0bbc7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -7,7 +7,6 @@ import datetime
7
  import tempfile
8
  from transformers import pipeline
9
 
10
-
11
  # Your Hugging Face API Token (set this safely)
12
  HF_TOKEN = os.getenv("HUGGINGFACE_TOKEN") # Recommended: use environment variable
13
 
@@ -19,6 +18,9 @@ headers = {
19
  "Authorization": f"Bearer {HF_TOKEN}"
20
  }
21
 
 
 
 
22
  # Function to query Mistral API
23
  def query_mistral(question):
24
  payload = {
@@ -29,7 +31,6 @@ def query_mistral(question):
29
  output = response.json()
30
  return output[0]["generated_text"]
31
 
32
-
33
  # API Key
34
  POLYGON_API_KEY = os.getenv("POLYGON_API_KEY")
35
 
@@ -164,7 +165,6 @@ def generate_summary(info, ratios):
164
  )
165
  return summarizer(report, max_length=250, min_length=100, do_sample=False)[0]['summary_text']
166
 
167
-
168
  def stock_research(symbol, eps=5.0, growth=0.1, book=500000000):
169
  info = get_company_info(symbol)
170
  price = get_current_price(symbol)
@@ -209,7 +209,7 @@ with gr.Blocks(theme="soft") as iface:
209
  output_sector = gr.Dataframe()
210
  with gr.Tab("Historical Price Chart"):
211
  output_chart = gr.Plot()
212
- with gr.Tab("Ask About Investing"): # <-- ✅ Correct (no extra Blocks)
213
  user_question = gr.Textbox(label="Ask about investing...")
214
  answer_box = gr.Textbox(label="Answer")
215
  ask_button = gr.Button("Get Answer")
@@ -222,6 +222,5 @@ with gr.Blocks(theme="soft") as iface:
222
  submit_btn.click(fn=stock_research, inputs=[symbol, eps, growth, book],
223
  outputs=[output_summary, output_info, output_ratios, output_sector, output_chart])
224
 
225
-
226
  if __name__ == "__main__":
227
- iface.launch()
 
7
  import tempfile
8
  from transformers import pipeline
9
 
 
10
  # Your Hugging Face API Token (set this safely)
11
  HF_TOKEN = os.getenv("HUGGINGFACE_TOKEN") # Recommended: use environment variable
12
 
 
18
  "Authorization": f"Bearer {HF_TOKEN}"
19
  }
20
 
21
+ # Load summarizer model
22
+ summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
23
+
24
  # Function to query Mistral API
25
  def query_mistral(question):
26
  payload = {
 
31
  output = response.json()
32
  return output[0]["generated_text"]
33
 
 
34
  # API Key
35
  POLYGON_API_KEY = os.getenv("POLYGON_API_KEY")
36
 
 
165
  )
166
  return summarizer(report, max_length=250, min_length=100, do_sample=False)[0]['summary_text']
167
 
 
168
  def stock_research(symbol, eps=5.0, growth=0.1, book=500000000):
169
  info = get_company_info(symbol)
170
  price = get_current_price(symbol)
 
209
  output_sector = gr.Dataframe()
210
  with gr.Tab("Historical Price Chart"):
211
  output_chart = gr.Plot()
212
+ with gr.Tab("Ask About Investing"):
213
  user_question = gr.Textbox(label="Ask about investing...")
214
  answer_box = gr.Textbox(label="Answer")
215
  ask_button = gr.Button("Get Answer")
 
222
  submit_btn.click(fn=stock_research, inputs=[symbol, eps, growth, book],
223
  outputs=[output_summary, output_info, output_ratios, output_sector, output_chart])
224
 
 
225
  if __name__ == "__main__":
226
+ iface.launch()