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.")