CCockrum commited on
Commit
20d6bb4
·
verified ·
1 Parent(s): d277616

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -5,10 +5,10 @@ import requests
5
  import os
6
  import datetime
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
 
13
  # Mistral Inference API URL
14
  API_URL = "https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instruct-v0.3"
@@ -39,6 +39,7 @@ sector_averages = {
39
  "Energy": {"P/E Ratio": 12, "P/S Ratio": 1.2, "P/B Ratio": 1.3},
40
  }
41
 
 
42
  # Safe Request Function
43
  def safe_request(url):
44
  try:
@@ -215,7 +216,7 @@ with gr.Blocks(theme=theme) as iface:
215
  growth = gr.Number(label="Assumed Growth Rate", value=0.1)
216
  book = gr.Number(label="Assumed Book Value", value=500000000)
217
 
218
- with gr.Tabs():
219
  with gr.Tab("AI Research Summary"):
220
  output_summary = gr.Textbox()
221
  with gr.Tab("Company Snapshot"):
@@ -240,13 +241,20 @@ with gr.Blocks(theme=theme) as iface:
240
  outputs=[user_question]
241
  )
242
 
243
- submit_btn = gr.Button("Run Analysis")
244
- download_btn = gr.Button("Download Report")
245
- file_output = gr.File()
 
 
246
 
247
  submit_btn.click(fn=stock_research, inputs=[symbol, eps, growth, book],
248
  outputs=[output_summary, output_info, output_ratios, output_sector, output_chart])
249
 
 
 
 
 
 
250
 
251
 
252
  if __name__ == "__main__":
 
5
  import os
6
  import datetime
7
  import tempfile
8
+ import numpy as np # Added for smoothing historical prices
9
 
10
  # Your Hugging Face API Token (set this safely)
11
+ HF_TOKEN = os.getenv("HUGGINGFACE_TOKEN")
12
 
13
  # Mistral Inference API URL
14
  API_URL = "https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instruct-v0.3"
 
39
  "Energy": {"P/E Ratio": 12, "P/S Ratio": 1.2, "P/B Ratio": 1.3},
40
  }
41
 
42
+
43
  # Safe Request Function
44
  def safe_request(url):
45
  try:
 
216
  growth = gr.Number(label="Assumed Growth Rate", value=0.1)
217
  book = gr.Number(label="Assumed Book Value", value=500000000)
218
 
219
+ with gr.Tabs() as tabs:
220
  with gr.Tab("AI Research Summary"):
221
  output_summary = gr.Textbox()
222
  with gr.Tab("Company Snapshot"):
 
241
  outputs=[user_question]
242
  )
243
 
244
+ with gr.Row():
245
+ submit_btn = gr.Button("Run Analysis")
246
+ reset_btn = gr.Button("Reset All Fields")
247
+ download_btn = gr.Button("Download Report")
248
+ file_output = gr.File()
249
 
250
  submit_btn.click(fn=stock_research, inputs=[symbol, eps, growth, book],
251
  outputs=[output_summary, output_info, output_ratios, output_sector, output_chart])
252
 
253
+ def reset_fields():
254
+ return "", 5.0, 0.1, 500000000, "", "", "", "", None
255
+
256
+ reset_btn.click(fn=reset_fields, inputs=[], outputs=[symbol, eps, growth, book, output_summary, output_info, output_ratios, output_sector, output_chart])
257
+
258
 
259
 
260
  if __name__ == "__main__":