News Summarizer AI is a Python-based application designed to fetch and summarize news articles on a specific topic using the OpenAI GPT model and the NewsAPI. The application leverages Streamlit for its user interface, making it easy to interact with.
- Fetch News Articles: Retrieve news articles from NewsAPI based on a topic.
- Summarize News: Use OpenAI's GPT model to create concise summaries of the retrieved news articles.
- Streamlit Integration: An interactive user interface for input and displaying results.
Before you can run the project, ensure you have the following installed:
-
Clone the repository:
git clone https://github.com/your-username/news-summarizer-AI.git cd news-summarizer-AI
-
Set up a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
- Create a
.env
file in the root directory. - Add your API keys:
NEWS_API_KEY=your_newsapi_key OPENAI_API_KEY=your_openai_api_key
- Create a
-
Run the application:
streamlit run main.py
-
Open the application in your browser at
http://localhost:8501
. -
Enter a topic in the input field and click Run Assistant to generate summaries for the latest news on that topic.
.
├── main.py # Main application file
├── requirements.txt # Project dependencies
├── .env # Environment variables (not included in the repo)
├── README.md # Project documentation
-
Fetching News:
- The
get_news
function queries the NewsAPI for articles based on the user's topic. - Retrieves up to 5 articles and their metadata.
- The
-
Summarizing News:
- The
AssistantManager
class interacts with OpenAI's GPT API. - A personal assistant is created to process and summarize the news articles.
- The
-
Interactive Interface:
- Users can interact with the app via a Streamlit-powered UI.
openai
streamlit
python-dotenv
requests
Install all dependencies using:
pip install -r requirements.txt
Contributions are welcome! Please open an issue or submit a pull request for any feature requests or bug fixes.
This project is licensed under the MIT License.