Cover image
Try Now
2025-04-14

3 years

Works with Finder

0

Github Watches

0

Github Forks

0

Github Stars

AI Health Article Summarizer & Explainer

A FastAPI-based multi-agent system for processing and analyzing medical articles. The system fetches articles from URLs, generates summaries, explains medical terminology, and assesses study quality.

Features

  • Article Fetching: Extracts content from medical articles and research papers
  • Smart Summarization: Generates concise, accurate summaries of medical content
  • Terminology Explanation: Identifies and explains medical terms in layperson-friendly language
  • Quality Assessment: Evaluates study quality based on methodology, sample size, statistical rigor, and more
  • Multi-Agent Architecture: Coordinated processing through specialized agents
  • Error Handling & Retry Logic: Robust error handling with exponential backoff retry mechanism
  • Rate Limiting: Prevents API abuse with configurable rate limits
  • Response Caching: Improves performance by caching responses
  • URL Validation: Ensures only valid medical/academic URLs are processed

Requirements

  • Python 3.9+
  • Redis server (for rate limiting and caching)
  • OpenAI API key

Installation

  1. Clone the repository:
git clone https://github.com/lyudmylan/health-article-mcp.git
cd health-article-mcp
  1. Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Install and start Redis server:
# On macOS using Homebrew
brew install redis
brew services start redis

# On Ubuntu/Debian
sudo apt-get install redis-server
sudo systemctl start redis-server
  1. Set up environment variables:
export OPENAI_API_KEY='your-api-key-here'
export REDIS_URL='redis://localhost'  # Optional: default is localhost
export RATE_LIMIT_MAX_REQUESTS='60'   # Optional: requests per window
export RATE_LIMIT_WINDOW='60'         # Optional: window in seconds
export CACHE_TTL='3600'              # Optional: cache TTL in seconds

Redis Configuration

The application uses Redis for rate limiting and caching. Make sure you have Redis installed and running locally, or set the REDIS_URL environment variable to point to your Redis instance.

Local Redis Setup

  1. Install Redis:

    • macOS: brew install redis
    • Linux: sudo apt-get install redis-server
    • Windows: Download from Redis Windows
  2. Start Redis:

    • macOS/Linux: redis-server
    • Windows: Start the Redis service

Environment Variables

  • REDIS_URL: Redis connection URL (default: "redis://localhost:6379")
  • RATE_LIMIT_MAX_REQUESTS: Maximum requests per minute (default: 60)
  • RATE_LIMIT_WINDOW: Time window in seconds (default: 60)
  • CACHE_TTL: Cache time-to-live in seconds (default: 3600)

Usage

  1. Start the server:
python main.py
  1. Send a POST request to process an article:
curl -X POST http://localhost:8000/workflow/process \
  -H "Content-Type: application/json" \
  -d '{
    "message_id": "123e4567-e89b-12d3-a456-426614174000",
    "conversation_id": "123e4567-e89b-12d3-a456-426614174001",
    "sender_agent": "UserAgent",
    "recipient_agent": "ArticleFetcherAgent",
    "payload_type": "url",
    "payload": {
      "url": "https://example.com/medical-article"
    }
  }'

API Response

The API returns a JSON response with:

  • Article summary
  • Explained medical terminology
  • Quality assessment metrics including:
    • Study design evaluation
    • Sample quality analysis
    • Statistical rigor assessment
    • Bias evaluation
    • Evidence level classification
    • Overall quality score
    • Key limitations and recommendations

Example response:

{
  "success": true,
  "message": "Article processed successfully",
  "data": {
    "message_id": "123e4567-e89b-12d3-a456-426614174002",
    "summary": "Comprehensive summary of the article...",
    "terminology": {
      "Term 1": "Definition in simple language",
      "Term 2": "Another explanation..."
    },
    "quality_assessment": {
      "study_design": {
        "rating": "4",
        "explanation": "Well-designed cohort study"
      },
      "overall_score": {
        "rating": "4.2",
        "explanation": "High-quality study with minor limitations"
      },
      "key_limitations": [
        "Limited follow-up period",
        "Potential selection bias"
      ],
      "recommendations": [
        "Consider longer follow-up study",
        "Expand demographic diversity"
      ]
    }
  }
}

Error Handling

The API includes comprehensive error handling:

  • Input validation errors (400)
  • Rate limiting errors (429)
  • Network errors (503)
  • Server errors (500)

Each error response includes a descriptive message and appropriate HTTP status code.

Rate Limiting

The API implements rate limiting to prevent abuse:

  • Default: 60 requests per minute per IP
  • Configurable via environment variables
  • Uses Redis for distributed rate limiting
  • Returns 429 status code when limit exceeded

Caching

Response caching improves performance:

  • Default TTL: 1 hour
  • Configurable via environment variables
  • Uses Redis for distributed caching
  • Automatic cache invalidation
  • Cache keys based on request parameters

URL Validation

The API validates URLs before processing:

  • Ensures HTTPS/HTTP protocol
  • Validates against whitelist of medical/academic domains
  • Checks for malicious patterns
  • Returns detailed validation errors

Testing

Run the test suite:

TESTING=1 PYTHONPATH=. pytest tests/ -v

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Notes

Redis Connection Handling

The application uses aclose() for Redis connection cleanup (supported in redis-py >= 5.0.0). For backward compatibility, the close() method is still available but will be removed in future versions.

License

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

相关推荐

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • 1Panel-dev
  • 🔥1Panel提供了直观的Web接口和MCP服务器,用于在Linux服务器上管理网站,文件,容器,数据库和LLMS。

  • WangRongsheng
  • 🧑‍🚀 llm 资料总结(数据处理、模型训练、模型部署、 o1 模型、mcp 、小语言模型、视觉语言模型)|摘要世界上最好的LLM资源。

  • sigoden
  • 使用普通的bash/javascript/python函数轻松创建LLM工具和代理。

  • hkr04
  • 轻巧的C ++ MCP(模型上下文协议)SDK

  • rulego
  • ⛓️Rulego是一种轻巧,高性能,嵌入式,下一代组件编排规则引擎框架。

  • RockChinQ
  • 😎简单易用、🧩丰富生态 -大模型原生即时通信机器人平台| 适配QQ / 微信(企业微信、个人微信) /飞书 /钉钉 / discord / telegram / slack等平台| 支持chatgpt,deepseek,dify,claude,基于LLM的即时消息机器人平台,支持Discord,Telegram,微信,Lark,Dingtalk,QQ,Slack

  • dmayboroda
  • 带有可配置容器的本地对话抹布

  • paulwing
  • 使用MCP服务创建的测试存储库

  • modelscope
  • 开始以更轻松的方式开始构建具有LLM授权的多代理应用程序。

  • evilsocket
  • 简单的代理开发套件。

    Reviews

    2.7 (11)
    Avatar
    user_jR2lP8UH
    2025-04-23

    As a dedicated user of the health-article-mcp by lyudmylan, I find it incredibly valuable for staying informed about health topics. The articles are well-researched and presented in a clear, accessible manner. It's a reliable resource for anyone looking to improve their understanding of health and wellness. Highly recommended!

    Avatar
    user_hJrkYuEn
    2025-04-23

    I recently started using health-article-mcp by lyudmylan and it has significantly enhanced my knowledge about health topics. The articles are well-written, informative, and easy to understand. The user interface is intuitive, making it simple to navigate through various articles. Overall, it's a fantastic resource for anyone looking to stay informed about health and wellness.

    Avatar
    user_4yPsXDwQ
    2025-04-23

    I've been using health-article-mcp by lyudmylan, and it's been a game-changer for my health information needs. The articles are well-researched and provide reliable insights. Highly recommend for anyone serious about their health.

    Avatar
    user_OggJqIgE
    2025-04-23

    I've been using health-article-mcp by lyudmylan and it has significantly enhanced my understanding of health topics. The content is well-curated and it delivers valuable information in an easily digestible format. Highly recommended for anyone looking to improve their health knowledge!

    Avatar
    user_hD8F0KSb
    2025-04-23

    I've been using the health-article-mcp and I'm thoroughly impressed. Created by lyudmylan, this tool is remarkably informative and user-friendly. It offers invaluable health insights and the welcome information is inviting. Highly recommend for anyone keen on health topics!

    Avatar
    user_Rx1VOD8m
    2025-04-23

    I've been using the health-article-mcp application and I'm thoroughly impressed. Created by lyudmylan, it provides well-researched and insightful health articles that are easy to read and understand. The user-friendly interface and comprehensive content have made it my go-to resource for health information. I highly recommend checking it out!

    Avatar
    user_uTeAHUsN
    2025-04-23

    I've been using the Health-Article-MCP by lyudmylan, and it's fantastic! It's a superb resource for in-depth and well-researched health articles. The seamless interface and easy navigation make it a pleasure to use. Highly recommended for anyone looking to stay informed about health topics!

    Avatar
    user_XQpyIQi2
    2025-04-23

    As a dedicated user of health-article-mcp by lyudmylan, I find it incredibly insightful and resourceful. This product consistently provides well-researched and up-to-date health information. The user-friendly interface makes navigation a breeze, enhancing my reading experience. I highly recommend it to anyone looking to stay informed about health topics.

    Avatar
    user_ZUw1jHMg
    2025-04-23

    As an avid user of the health-article-mcp by lyudmylan, I find this product to be incredibly informative and well-written. The articles are comprehensive and provide valuable insights into various health topics. The user interface is seamless, making it easy to navigate and find relevant information. Highly recommend for anyone looking to stay informed about health and wellness!

    Avatar
    user_LSbPnWpX
    2025-04-23

    I've been using health-article-mcp by lyudmylan for a while now, and it's simply fantastic! The articles are well-researched and provide valuable health insights. The easy-to-navigate interface and the welcome information make it a pleasure to use. It's a must-have for anyone interested in health topics. Highly recommended!

    Avatar
    user_odbs3h3u
    2025-04-23

    I've been using the health-article-mcp application created by lyudmylan and I'm incredibly impressed. The articles are insightful and well-researched, covering a wide range of health topics. The user interface is intuitive and the start URL makes navigation easy. This application has become my go-to source for reliable health information. Highly recommended!