BaoKhuong commited on
Commit
faa18d1
·
verified ·
1 Parent(s): 05412f4

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -300,9 +300,11 @@ Two tabs: Price Prediction (Finnhub with Alpha Vantage fallback) and Equity Rese
300
  try:
301
  candles = fetch_alpha_vantage_series_daily(sym, outputsize="compact")
302
  except Exception as e2:
303
- return f"Error fetching candles: {e2}"
 
304
  prompt = build_price_prediction_prompt(sym, candles)
305
- return generate_response_stream(prompt, temperature=temperature, max_new_tokens=int(max_tokens))
 
306
 
307
  btn.click(on_predict, inputs=[symbol, resolution, count, temp, max_new], outputs=out, show_progress=True)
308
 
@@ -316,10 +318,12 @@ Two tabs: Price Prediction (Finnhub with Alpha Vantage fallback) and Equity Rese
316
  def on_report(sym, temperature, max_tokens):
317
  try:
318
  overview = fetch_alpha_vantage_overview(sym)
319
- prompt = build_equity_research_prompt(sym, overview)
320
- return generate_response_stream(prompt, temperature=temperature, max_new_tokens=int(max_tokens))
321
  except Exception as e:
322
- return f"Error generating report: {e}"
 
 
 
 
323
 
324
  btn2.click(on_report, inputs=[symbol2, temp2, max_new2], outputs=out2, show_progress=True)
325
 
 
300
  try:
301
  candles = fetch_alpha_vantage_series_daily(sym, outputsize="compact")
302
  except Exception as e2:
303
+ yield f"Error fetching candles: {e2}"
304
+ return
305
  prompt = build_price_prediction_prompt(sym, candles)
306
+ for text in generate_response_stream(prompt, temperature=temperature, max_new_tokens=int(max_tokens)):
307
+ yield text
308
 
309
  btn.click(on_predict, inputs=[symbol, resolution, count, temp, max_new], outputs=out, show_progress=True)
310
 
 
318
  def on_report(sym, temperature, max_tokens):
319
  try:
320
  overview = fetch_alpha_vantage_overview(sym)
 
 
321
  except Exception as e:
322
+ yield f"Error fetching fundamentals: {e}"
323
+ return
324
+ prompt = build_equity_research_prompt(sym, overview)
325
+ for text in generate_response_stream(prompt, temperature=temperature, max_new_tokens=int(max_tokens)):
326
+ yield text
327
 
328
  btn2.click(on_report, inputs=[symbol2, temp2, max_new2], outputs=out2, show_progress=True)
329