swarm_nutritionist

Agent

swarm_nutritionist

Creator:

About this agent

๐ŸŽ Nutritionist Swarm App

A hierarchical swarm-based nutritionist application that analyzes lab results and provides dietary recommendations using the Swarms AI framework.

๐Ÿš€ Features

  • Hierarchical Swarm Architecture: Uses orchestrator and medical expert agents
  • Lab Results Analysis: Processes PDF, JPEG, PNG, and text lab results
  • Intelligent Routing: Automatically routes requests to appropriate agents
  • Interactive Analysis: Provides follow-up questions and recommendations
  • Multi-format Support: Handles various lab result file formats

๐Ÿ—๏ธ Architecture

Agents

  • Orchestrator Agent: Routes user requests to appropriate specialized agents
  • Medical Expert Agent: Analyzes lab results and provides health recommendations

Components

  • Lab Results Analyzer: Extracts and processes lab data from files
  • Sequential Workflow: Coordinates multi-step analysis processes
  • Configuration Management: Secure API key and settings management

๐Ÿ“‹ Prerequisites

  • Python 3.12+
  • Swarms API key
  • OpenAI API key (for GPT models)

๐Ÿ› ๏ธ Installation

  1. Clone and navigate to the project:

    BASH
    cd swarm_nutritionist  
    
  2. Activate virtual environment:

    BASH
    source venv/bin/activate  
    
  3. Install dependencies:

    BASH
    pip install -r requirements.txt  
    
  4. Configure API keys:

    • Your Swarms API key is already configured in config.py
    • OpenAI API key is set in .env file

๐ŸŽฏ Usage

Running the Main Application

BASH
python nutritionist_app.py  

Testing the Implementation

BASH
python test_app.py  

Programmatic Usage

PYTHON
from nutritionist_app import NutritionistApp

# Initialize the app  
app = NutritionistApp()

# Analyze lab results from a file  
result = app.analyze_lab_file("path/to/lab_results.pdf", "User context")

# Ask medical questions  
response = app.ask_medical_question("What should I eat for better cholesterol?")

# Interactive analysis  
conversation = app.interactive_analysis("path/to/lab_results.pdf")  

๐Ÿ“ Project Structure

swarm_nutritionist/  
โ”œโ”€โ”€ agents.py              # Swarm agents (orchestrator, medical expert)  
โ”œโ”€โ”€ lab_analyzer.py        # Lab results processing and OCR  
โ”œโ”€โ”€ nutritionist_app.py    # Main application interface  
โ”œโ”€โ”€ config.py             # Configuration and API keys  
โ”œโ”€โ”€ test_app.py           # Test suite  
โ”œโ”€โ”€ requirements.txt      # Python dependencies  
โ”œโ”€โ”€ .env                  # Environment variables  
โ”œโ”€โ”€ .gitignore           # Git ignore rules  
โ””โ”€โ”€ README.md            # This file  

๐Ÿ”ง Configuration

API Keys

  • Swarms API Key: Configured in config.py
  • OpenAI API Key: Set in .env file

Supported File Formats

  • PDF: Lab results in PDF format
  • Images: JPEG, PNG lab result images
  • Text: Plain text lab results

๐Ÿค– Agent Capabilities

Orchestrator Agent

  • Routes user requests to appropriate agents
  • Analyzes request types (lab analysis, dietary questions, etc.)
  • Coordinates multi-agent workflows

Medical Expert Agent

  • Interprets laboratory test results
  • Provides evidence-based dietary recommendations
  • Asks clarifying questions about patient history
  • Suggests lifestyle modifications
  • Explains medical concepts in understandable terms

๐Ÿ“Š Lab Analysis Features

  • OCR Processing: Extracts text from lab result images
  • Value Extraction: Identifies key lab values and ranges
  • Comprehensive Analysis: Provides detailed interpretations
  • Follow-up Questions: Asks relevant medical history questions
  • Actionable Recommendations: Suggests specific dietary and lifestyle changes

๐Ÿ”’ Security

  • API keys stored securely in environment variables
  • .env file excluded from version control
  • Sensitive data protection through .gitignore

๐Ÿงช Testing

The application includes a comprehensive test suite that demonstrates:

  • Agent routing functionality
  • Lab result analysis capabilities
  • Swarm processing workflows

๐Ÿ“š Dependencies

  • swarms: Multi-agent framework
  • Pillow: Image processing
  • pytesseract: OCR for lab result images
  • PyMuPDF: PDF text extraction
  • python-dotenv: Environment variable management

๐Ÿš€ Getting Started

  1. Ensure your virtual environment is activated
  2. Run the test suite to verify everything works
  3. Use the main application for lab analysis
  4. Extend with additional agents as needed

๐Ÿ”ฎ Future Enhancements

  • Additional specialized agents (diet planner, lifestyle coach)
  • Integration with electronic health records
  • Real-time lab value monitoring
  • Personalized meal planning
  • Exercise recommendation system

Built with โค๏ธ using the Swarms AI Framework

Source: https://github.com/ailucia/swarm_nutritionist

Comments & Discussion

Scroll to load comments...

Tags

healthcare

Share

Tokenization

This item is not available for tokenization.

Loading recommendations...

Yuki

Your Marketplace Companion

Agent

Hey, I'm Yuki ๐Ÿ‘‹

Ask me about specific products, customer support, or anything about the Swarms Marketplace.