sidmanale643 commited on
Commit
943e3a5
Β·
verified Β·
1 Parent(s): fa4ac2d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -38
app.py CHANGED
@@ -401,53 +401,53 @@ company_name = st.text_input("Enter Company Name", "Tesla")
401
  model_provider = st.selectbox("Model Provider", options=["Ollama", "Groq"])
402
 
403
  if st.button("Fetch Sentiment Data"):
404
- web_results = fetch_from_web(company_name)
405
-
406
- if "sources" not in web_results:
407
- return {"error": "No sources found."}
408
 
409
- sentiment_output = [
410
- analyze_sentiment(article, model_provider)
411
- for article in web_results["sources"][:5]
412
- ]
 
 
 
413
 
414
- comparative_sentiment = generate_comparative_sentiment(sentiment_output)
415
 
416
- positive_summary, negative_summary, neutral_summary = get_summaries_by_sentiment(
417
- sentiment_output
418
- )
419
 
420
- final_report = generate_final_report(
421
- positive_summary,
422
- negative_summary,
423
- neutral_summary,
424
- comparative_sentiment,
425
- model_provider,
426
- )
427
 
428
- hindi_translation = translate(final_report, model_provider)
429
- audio_path = text_to_speech(hindi_translation)
430
 
431
- output_dict = {
432
- "company_name": company_name,
433
- "articles": sentiment_output,
434
- "comparative_sentiment": comparative_sentiment,
435
- "final_report": final_report,
436
- "hindi_translation": hindi_translation,
437
- "audio_url": audio_path,
438
- }
439
 
440
- st.subheader("Company Name")
441
- st.write(output_dict.get("company_name"))
442
 
443
- st.subheader("Final Report")
444
- st.write(output_dict.get("final_report"))
445
 
446
- st.subheader("πŸ”Š Audio Output")
447
- audio_file = "output.mp3"
448
- if audio_file:
449
- st.audio(audio_file)
450
 
451
  except requests.exceptions.RequestException as e:
452
  st.error(f"Error fetching data: {e}")
453
-
 
401
  model_provider = st.selectbox("Model Provider", options=["Ollama", "Groq"])
402
 
403
  if st.button("Fetch Sentiment Data"):
404
+ try:
405
+ web_results = fetch_from_web(company_name)
 
 
406
 
407
+ if "sources" not in web_results:
408
+ st.error("No sources found.")
409
+ else:
410
+ sentiment_output = [
411
+ analyze_sentiment(article, model_provider)
412
+ for article in web_results["sources"][:5]
413
+ ]
414
 
415
+ comparative_sentiment = generate_comparative_sentiment(sentiment_output)
416
 
417
+ positive_summary, negative_summary, neutral_summary = get_summaries_by_sentiment(
418
+ sentiment_output
419
+ )
420
 
421
+ final_report = generate_final_report(
422
+ positive_summary,
423
+ negative_summary,
424
+ neutral_summary,
425
+ comparative_sentiment,
426
+ model_provider,
427
+ )
428
 
429
+ hindi_translation = translate(final_report, model_provider)
430
+ audio_path = text_to_speech(hindi_translation)
431
 
432
+ output_dict = {
433
+ "company_name": company_name,
434
+ "articles": sentiment_output,
435
+ "comparative_sentiment": comparative_sentiment,
436
+ "final_report": final_report,
437
+ "hindi_translation": hindi_translation,
438
+ "audio_url": audio_path,
439
+ }
440
 
441
+ st.subheader("Company Name")
442
+ st.write(output_dict.get("company_name"))
443
 
444
+ st.subheader("Final Report")
445
+ st.write(output_dict.get("final_report"))
446
 
447
+ st.subheader("πŸ”Š Audio Output")
448
+ audio_file = "output.mp3"
449
+ if audio_file:
450
+ st.audio(audio_file)
451
 
452
  except requests.exceptions.RequestException as e:
453
  st.error(f"Error fetching data: {e}")