Skip to content

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.

Notifications You must be signed in to change notification settings

armanjscript/Article-Summary-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Article Summary Generator for Telegram

License: MIT Python 3.8+

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.

Features

  • 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.

Technologies Used

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.

Prerequisites

Installation

  1. 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
  2. Clone the Repository:

    git clone https://github.com/armanjscript/Article-Summary-Generator.git
    cd Article-Summary-Generator
  3. Install Python Libraries:

    pip install streamlit langchain langchain-ollama langgraph python-telegram-bot python-dotenv nest_asyncio
  4. 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.

Running the Application

  1. Ensure the Ollama server is running in the background:
    ollama serve
  2. Start the Streamlit app:
    streamlit run main.py
  3. Open your browser and navigate to http://localhost:8501 to access the application.

How It Works

The application uses LangGraph to orchestrate a workflow with the following steps:

  1. Keyword Suggestion:
    • The user’s query is processed by the Ollama model ("qwen2.5:latest") to generate up to 3 relevant keywords.
  2. Article Search:
    • The Serper API searches for articles on Wikipedia and Medium using the keywords, selecting up to 3 URLs per source.
  3. Article Loading:
    • LangChain’s WebBaseLoader fetches the content of selected articles, adding metadata like source and title.
  4. 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.
  5. Telegram Posting:
    • The summary is sent to the specified Telegram channel via the Telegram Bot API.
  6. Result Display:
    • The Streamlit interface shows the keywords, article URLs, summary, and a confirmation of the Telegram post.

Example Usage

  1. Run the app:
    streamlit run main.py
  2. In the web interface at http://localhost:8501:
    • Enter a query, e.g., "Machine learning."
    • Click "Generate Summary."
  3. 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.
  4. Check your Telegram channel for the posted summary.

Dependencies

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

Environment Variables

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.

Limitations

  • 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.

Contributing

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.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

For questions or feedback, please contact [armanjscript] at [[email protected]].

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages