A Python-based news summarization application that uses OpenAI's GPT models and the News API to fetch and summarize news articles on any given topic.
- Fetches latest news articles using News API
- Uses OpenAI's Assistant API to summarize news content
- Interactive Streamlit web interface
- Supports any news topic or keyword
- Clone this repository:
git clone <repository-url>
cd news-summarizer- Install required dependencies:
pip install -r requirements.txt- Create a
.envfile in the root directory with your API keys:
NEWS_API_KEY=your_news_api_key_here
OPENAI_API_KEY=your_openai_api_key_here
- News API: Get your free API key from NewsAPI.org
- OpenAI API: Get your API key from OpenAI Platform
streamlit run main.pyThis will start a web interface where you can:
- Enter a topic of interest
- Click "Run Assistant" to fetch and summarize news
- View the AI-generated summary of recent articles
python test.pymain.py: Main application with Streamlit interface and OpenAI Assistant integrationtest.py: Test script for the news summarization functionalityrequirements.txt: Python dependencies.env: Environment variables for API keys (not included in repository).gitignore: Git ignore file to exclude sensitive files and directories
- News Fetching: Uses News API to retrieve the latest 5 articles for a given topic
- AI Processing: Utilizes OpenAI's Assistant API with function calling to process news data
- Summarization: The AI assistant analyzes articles and provides concise summaries
- Web Interface: Streamlit provides an easy-to-use web interface for interaction
python-dotenv: For environment variable managementopenai: OpenAI API clientrequests: HTTP requests for News APIstreamlit: Web interface framework
Here is an example of how the News Summarizer works:
- Input: Enter the topic "Artificial Intelligence" in the Streamlit app.
- Processing: The app fetches the latest news articles on "Artificial Intelligence" using the News API and summarizes them using OpenAI's GPT model.
- Output: A concise summary of the top articles is displayed in the app.
The image above shows a sample output for the topic "Artificial Intelligence."
Make sure to keep your API keys secure and never commit them to version control. The .env file is already included in .gitignore for this purpose.