An intelligent conversational AI application designed to provide evidence-based guidance on longevity, healthspan optimization, and wellness. Built with advanced RAG (Retrieval Augmented Generation) technology and powered by expert knowledge from leading longevity researchers.
- Context-Aware Chat: Maintains conversation history for natural, flowing discussions
- Expert Knowledge: Trained on content from Dr. Peter Attia, Dr. Gabrielle Lyon, and other longevity experts
- Personalized Responses: Adapts answers based on conversation context and user needs
- Book Summaries: Key insights from "Outlive", "Forever Strong", and other longevity books
- Web Articles: Curated content from trusted health and longevity websites
- Semantic Chunking: Intelligent document splitting that preserves logical structure
- Rich Metadata: Detailed source tracking and content categorization
- Exercise & Training: VO2 max, Zone 2 training, strength protocols, stability work
- Nutrition Science: Evidence-based dietary strategies for metabolic health
- Sleep Optimization: Protocols for improving sleep quality and duration
- Stress Management: Techniques for mental health and resilience
- Disease Prevention: Focus on the "Four Horsemen" of chronic disease
- Biomarkers: Understanding key health metrics and their significance
- Medical Disclaimers: Clear boundaries on medical advice
- Evidence-Based: Only recommendations supported by research
- European Units: Metric system for all measurements
- Professional Standards: Balanced, realistic health guidance
- Python: Core application development
- LangChain: RAG pipeline and document processing
- OpenAI GPT-4: Advanced language model for responses
- Gradio: Interactive web interface
- Supabase + pgvector: Vector database for semantic search
- Markdown Processing: Intelligent content parsing and chunking
longevity-ai/
โโโ config/
โ โโโ system_message.txt # AI personality and guidelines
โ โโโ web_sources.json # Curated web content sources
โโโ downloads/
โ โโโ books/ # Book summaries in markdown format
โโโ src/
โ โโโ document_loaders.py # Content loading utilities
โ โโโ vector_store_setup.py # Database initialization
โโโ app.py # Main Gradio application
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
- Docker and Docker Compose installed
- Git
- OpenAI API key
- Supabase account (for vector database)
1. Clone and Start (2 commands!)
# Clone and enter the project
git clone https://github.com/ruthiel/longevity-ai.git
cd longevity-ai
# Start the application
docker-compose up --build2. Configure environment variables
Create a .env file in the root directory:
OPENAI_API_KEY=your_openai_api_key
SUPABASE_URL_API=your_supabase_url
SUPABASE_KEY=your_supabase_anon_key3. Set up Supabase database
In your Supabase SQL Editor, run:
-- Enable vector extension
create extension vector;
-- Create documents table
create table longevity_knowledge (
id bigserial primary key,
content text,
embedding vector(1536),
source text,
metadata jsonb
);
-- Create index for faster similarity search
create index on longevity_knowledge
using ivfflat (embedding vector_cosine_ops)
with (lists = 100);4. Access the application
Open your browser and go to: http://localhost:8888
Our knowledge base includes carefully curated content from:
- "Outlive" by Dr. Peter Attia - Comprehensive longevity framework
- "Forever Strong" by Dr. Gabrielle Lyon - Muscle-centric health approach
- Additional longevity and health optimization books
- Expert websites and research institutions
- Peer-reviewed articles and studies
- Trusted health and longevity publications
User: "How can I improve my sleep quality?"
AI: "Great question! Sleep is one of the fundamental pillars of longevity ๐ด
Quality sleep optimization involves several key strategies:
โข Sleep hygiene protocols ๐
โข Temperature regulation (16-19ยฐC optimal)
โข Light exposure management
โข Stress reduction techniques
[Detailed evidence-based recommendations follow...]"
User: "What supplements help with that?"
AI: "For sleep optimization specifically, here are evidence-backed supplements:
โข Magnesium glycinate (200-400mg before bed)
โข Melatonin (0.5-3mg, 30-60 minutes before sleep)
โข L-theanine (100-200mg for relaxation)
[Context-aware response continues...]"
- Semantic Chunking: Preserves logical document structure
- Metadata Enrichment: Tracks source, author, section, and processing details
- Context-Aware Retrieval: Uses conversation history for better search results
- Memory Limitation: Configurable history length to manage token usage
- Context Continuity: References previous topics naturally
- Source Attribution: Transparent about information sources
- Enhanced source citation display
- User preference customization
- Mobile-responsive interface improvements
- Additional expert content integration
- Personal health data integration
- Custom protocol generation
- Multi-language support
- API endpoints for third-party integration
- Advanced analytics and insights
We welcome contributions to improve Longevity AI! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- High-quality, evidence-based health content
- Expert interviews and summaries
- Research paper summaries
- Protocol documentation
docker-compose downImportant: This application provides educational information only and is not intended as medical advice. Always consult with qualified healthcare professionals before making any health-related decisions or changes to your lifestyle.
Special thanks to:
- Dr. Peter Attia - For groundbreaking longevity research and protocols
- Dr. Gabrielle Lyon - For muscle-centric health insights
- LangChain Community - For excellent RAG framework tools
- OpenAI - For advanced language model capabilities
- Supabase Team - For vector database infrastructure
This project is licensed under the MIT License - see the LICENSE file for details.
Ruthiel Trevisan - @ruthiel
Project Link: https://github.com/ruthiel/longevity-ai
๐ Star this repository if you find it helpful! ๐
Building the future of personalized longevity guidance, one conversation at a time.