
Agent
swarm_nutritionist
Creator:%22%2F%3E%3Cg%20fill%3D%22hsl(268%2090%25%2062%25)%22%3E%3Crect%20x%3D%222%22%20y%3D%220%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%228%22%20y%3D%220%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%223%22%20y%3D%221%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%227%22%20y%3D%221%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%222%22%20y%3D%222%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%228%22%20y%3D%222%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%223%22%20y%3D%222%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%227%22%20y%3D%222%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%224%22%20y%3D%222%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%226%22%20y%3D%222%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%225%22%20y%3D%222%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%221%22%20y%3D%223%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%229%22%20y%3D%223%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%223%22%20y%3D%223%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%227%22%20y%3D%223%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%224%22%20y%3D%223%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%226%22%20y%3D%223%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%225%22%20y%3D%223%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%220%22%20y%3D%224%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%2210%22%20y%3D%224%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%221%22%20y%3D%224%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%229%22%20y%3D%224%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%222%22%20y%3D%224%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%228%22%20y%3D%224%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%223%22%20y%3D%224%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%227%22%20y%3D%224%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%224%22%20y%3D%224%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%226%22%20y%3D%224%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%225%22%20y%3D%224%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%221%22%20y%3D%225%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%229%22%20y%3D%225%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%222%22%20y%3D%225%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%228%22%20y%3D%225%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%223%22%20y%3D%225%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%227%22%20y%3D%225%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%225%22%20y%3D%225%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%221%22%20y%3D%226%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%229%22%20y%3D%226%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%223%22%20y%3D%226%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%227%22%20y%3D%226%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%221%22%20y%3D%227%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%229%22%20y%3D%227%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%224%22%20y%3D%227%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3Crect%20x%3D%226%22%20y%3D%227%22%20width%3D%221%22%20height%3D%221%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E)
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
-
Clone and navigate to the project:
BASHcd swarm_nutritionist -
Activate virtual environment:
BASHsource venv/bin/activate -
Install dependencies:
BASHpip install -r requirements.txt -
Configure API keys:
- Your Swarms API key is already configured in
config.py - OpenAI API key is set in
.envfile
- Your Swarms API key is already configured in
๐ฏ Usage
Running the Main Application
BASHpython nutritionist_app.py
Testing the Implementation
BASHpython test_app.py
Programmatic Usage
PYTHONfrom 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
.envfile
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
.envfile 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
- Ensure your virtual environment is activated
- Run the test suite to verify everything works
- Use the main application for lab analysis
- 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
Comments & Discussion
Scroll to load comments...
Tags
healthcare
Share
Tokenization
This item is not available for tokenization.
Loading recommendations...