A powerful Streamlit application that generates concise summaries of articles from Wikipedia and Medium based on user queries and automatically posts them to a Telegram channel. Perfect for researchers, students, and knowledge enthusiasts looking to quickly digest information from trusted sources.
- Intuitive Web Interface: Built with Streamlit for seamless user interaction.
- Smart Article Search: Uses the Serper API to find relevant articles on Wikipedia and Medium.
- AI-Powered Summarization: Leverages LangChain and Ollama to create concise, high-quality summaries.
- Telegram Integration: Automatically posts summaries to a specified Telegram channel.
- Structured Workflow: Managed by LangGraph for efficient and reliable processing.
Technology | Description |
---|---|
Python | Core programming language for the application. |
Streamlit | Creates the interactive web-based user interface. |
LangChain | Framework for building applications with language models. |
LangChain-Ollama | Integrates Ollama for advanced summarization tasks. |
LangGraph | Manages the workflow of keyword suggestion, search, and more. |
Serper API | Enables web searches for relevant articles. |
Telegram API | Sends summaries to a Telegram channel. |
- Python 3.8 or later: Ensure you have Python installed (Python Downloads).
- Ollama: A local AI server for running the "qwen2.5:latest" model. Install it from the Ollama GitHub repository.
-
Install Ollama:
- Follow the instructions at the Ollama GitHub repository.
- Pull the required model:
ollama pull qwen2.5:latest
- Start the Ollama server:
ollama serve
-
Clone the Repository:
git clone https://github.com/armanjscript/Article-Summary-Generator.git cd Article-Summary-Generator
-
Install Python Libraries:
pip install streamlit langchain langchain-ollama langgraph python-telegram-bot python-dotenv nest_asyncio
-
Set Up Environment Variables:
- Create a
.env
file in the project root with the following:SERPER_API_KEY=your_serper_api_key TELEGRAM_BOT_TOKEN=your_telegram_bot_token TELEGRAM_CHANNEL_ID=your_telegram_channel_id
- Obtain the keys:
- SERPER_API_KEY: Sign up at Serper API to get your API key.
- TELEGRAM_BOT_TOKEN: Create a bot via @BotFather on Telegram.
- TELEGRAM_CHANNEL_ID: Find your channel ID using @RawDataBot by sending
/start
and/id
in your channel.
- Create a
- Ensure the Ollama server is running in the background:
ollama serve
- Start the Streamlit app:
streamlit run main.py
- Open your browser and navigate to
http://localhost:8501
to access the application.
The application uses LangGraph to orchestrate a workflow with the following steps:
- Keyword Suggestion:
- The user’s query is processed by the Ollama model ("qwen2.5:latest") to generate up to 3 relevant keywords.
- Article Search:
- The Serper API searches for articles on Wikipedia and Medium using the keywords, selecting up to 3 URLs per source.
- Article Loading:
- LangChain’s WebBaseLoader fetches the content of selected articles, adding metadata like source and title.
- Summarization:
- The Ollama model generates concise summaries (under 350 characters each) for each article, combining them into a final output with the query, keywords, and sources.
- Telegram Posting:
- The summary is sent to the specified Telegram channel via the Telegram Bot API.
- Result Display:
- The Streamlit interface shows the keywords, article URLs, summary, and a confirmation of the Telegram post.
- Run the app:
streamlit run main.py
- In the web interface at
http://localhost:8501
:- Enter a query, e.g., "Machine learning."
- Click "Generate Summary."
- View the results:
- Keywords: e.g., "machine learning, artificial intelligence, deep learning."
- Article URLs: Links to Wikipedia and Medium articles.
- Summary: A concise summary of the articles.
- Check your Telegram channel for the posted summary.
Library | Purpose |
---|---|
streamlit |
Web interface creation |
langchain |
Language model framework |
langchain-ollama |
Ollama integration for summarization |
langgraph |
Workflow management |
python-telegram-bot |
Telegram API interaction |
python-dotenv |
Environment variable management |
nest_asyncio |
Asynchronous operation support |
Variable | Description |
---|---|
SERPER_API_KEY |
API key for Serper (Serper API). |
TELEGRAM_BOT_TOKEN |
Telegram bot token from @BotFather. |
TELEGRAM_CHANNEL_ID |
Channel ID from @RawDataBot. |
- Searches are limited to Wikipedia and Medium, with up to 3 articles per source.
- Summaries are capped at 350 characters to fit Telegram’s limits.
- Requires a running Ollama server with the "qwen2.5:latest" model.
- Ensure API keys and Telegram credentials are correctly configured to avoid errors.
Contributions are welcome! Fork the repository, make your changes, and submit a pull request. Please ensure your code follows the project’s style and includes appropriate tests.
This project is licensed under the MIT License - see the LICENSE file for details.
For questions or feedback, please contact [armanjscript] at [armannew73@gmail.com].