File size: 1,280 Bytes
71074e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import streamlit as st
import requests

# API URL for the Hugging Face Space
API_URL = "https://company-news-analyzer.hf.space/get_news_and_sentiment"

# Streamlit UI
st.title("Company News Analyzer")

company_name = st.text_input("Enter company name:")

if st.button("Analyze"):
    if company_name:
        # Send a POST request to the FastAPI backend
        response = requests.post(API_URL, json={"company_name": company_name})
        
        if response.status_code == 200:
            data = response.json()
            
            # Display results
            st.write(f"Company: {data['Company']}")
            st.write("Articles:")
            for article in data['Articles']:
                st.write(f"Title: {article['Title']}")
                st.write(f"Summary: {article['Summary']}")
                st.write(f"Sentiment: {article['Sentiment']}")
                
            # Display comparative sentiment analysis
            st.write("Comparative Sentiment Analysis:")
            st.write(data['Comparative Sentiment Score'])

            # Play the audio file
            st.audio(data['Audio'], format='audio/mp3')
        else:
            st.error("Failed to fetch data. Please try again.")
    else:
        st.error("Please enter a company name.")