Skip to content

hicsail/PREAA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

47 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PREAA - Providing Reusable Equitable AI Access in Academia

PREAA (Providing Reusable Equitable AI Access in Academia) is a comprehensive open-source platform designed to democratize AI access within academic institutions. Our carefully curated stack of open-source technologies has been researched and selected to provide the most effective, scalable, and equitable AI solutions for educational environments.

🎯 Mission

Academic institutions face significant barriers when implementing AI technologies - from cost constraints to technical complexity. PREAA addresses these challenges by providing a battle-tested, open-source technology stack that enables institutions to deploy enterprise-grade AI capabilities without the typical financial and technical overhead.

πŸ—οΈ System Architecture

PREAA integrates several best-in-class open-source technologies to create a comprehensive AI platform:

Core Components

  • LibreChat: A ChatGPT-like all-in-one interface providing authentication, conversation history, and multi-model support
  • LiteLLM: Unified proxy for LLM requests with rate limiting and standardized OpenAI-compatible interface
  • LangFlow: Visual LLM workflow builder supporting multiple AI providers, agentic tools, RAG components, and custom integrations
  • LangFuse: Comprehensive LLM analytics platform for token usage tracking, completion costs, and performance metrics

Frontend Components

  • Embedded Chat Widget: Lightweight, embeddable chat interface for seamless integration into existing web applications
  • Standalone Chat Client: Full-featured React-based chat application with modern UI/UX
  • Admin Dashboard: Next.js-based administrative interface for system management and configuration

Backend Services

  • Helper Backend: NestJS-based service providing request proxying capabilities and administrative functions
  • Custom Integrations:
    • LangFlow custom components for enhanced chat completion interfaces
    • LiteLLM custom providers for workflow integration

Supporting Infrastructure

  • PostgreSQL: Primary database for user data, conversation history, and analytics
  • MongoDB: Document storage for LibreChat data
  • Redis: Caching and session management
  • ClickHouse: High-performance analytics database for LangFuse metrics
  • MinIO: S3-compatible object storage
  • Prometheus & Grafana: Monitoring and visualization stack

πŸš€ Getting Started

Prerequisites

  • Docker and Docker Compose
  • Git
  • OpenSSL (for key generation)

Quick Start

  1. Clone the repository:

    git clone <repository-url>
    cd PREAA
  2. Navigate to the deployment directory:

    cd deploy/local
  3. Set up environment variables:

    Copy the sample environment files and configure them:

    # Copy all sample environment files
    cp config/.env.clickhouse.sample config/.env.clickhouse
    cp config/.env.minio.sample config/.env.minio
    cp config/.env.redis.sample config/.env.redis
    cp config/.env.psql.sample config/.env.psql
    cp config/.env.langfuse.sample config/.env.langfuse
    cp config/.env.librechat.sample config/.env.librechat
    cp config/.env.litellm.sample config/.env.litellm
    cp config/.env.librechat-metrics.sample config/.env.librechat-metrics
    cp config/.env.langflow.sample config/.env.langflow
  4. Configure required secrets:

    Database passwords (generate secure passwords for each):

    • config/.env.clickhouse: Set CLICKHOUSE_PASSWORD
    • config/.env.minio: Set MINIO_ROOT_PASSWORD
    • config/.env.redis: Set REDIS_PASSWORD
    • config/.env.psql: Set POSTGRES_PASSWORD

    LangFuse configuration (config/.env.langfuse):

    # Generate encryption key
    ENCRYPTION_KEY=$(openssl rand -hex 32)
    
    # Set the following variables:
    # SALT=<any secure string>
    # CLICKHOUSE_PASSWORD=<matching value from .env.clickhouse>
    # LANGFUSE_S3_EVENT_UPLOAD_SECRET_ACCESS_KEY=<matching MINIO_ROOT_PASSWORD>
    # LANGFUSE_S3_MEDIA_UPLOAD_SECRET_ACCESS_KEY=<matching MINIO_ROOT_PASSWORD>
    # REDIS_AUTH=<matching REDIS_PASSWORD>
    # DATABASE_URL=postgresql://postgres:<POSTGRES_PASSWORD>@postgres:5432/postgres

    LibreChat configuration (config/.env.librechat):

    # Generate LibreChat secrets using their generator: https://www.librechat.ai/toolkit/creds_generator
    # Set: CREDS_KEY, CREDS_IV, JWT_SECRET, JWT_REFRESH_SECRET
    # Set: LITELLM_API_KEY=<matching LITELLM_MASTER_KEY from .env.litellm>

    LiteLLM configuration (config/.env.litellm):

    # Set: LITELLM_MASTER_KEY=<any secure string>
    # Set: DATABASE_URL=postgresql://postgres:<POSTGRES_PASSWORD>@postgres:5432/postgres
  5. Start the platform:

    docker-compose up -d
  6. Access the services:

Post-Installation Configuration

LangFuse + LiteLLM Integration

  1. Create a LangFuse account at http://localhost:3000
  2. Set up a new organization and project
  3. Generate API keys (public and private)
  4. Access LiteLLM at http://localhost:4000/ui
  5. Login with username admin and your LITELLM_MASTER_KEY as password
  6. Under "Logging & Alerts", add a LangFuse callback
  7. Enter your LangFuse API keys and set host to http://langfuse-web:3000
  8. Test the integration

πŸ”§ Development

Frontend Development

Each frontend package can be developed independently:

# Embedded Chat Widget
cd packages/embedded-chat
npm install
npm run dev

# Admin Dashboard
cd packages/admin
npm install
npm run dev:https  # Note: Uses HTTPS for functionality

# Chat Client
cd packages/chat-client
npm install
npm run dev

Backend Development

# Helper Backend (NestJS)
cd packages/helper-backend
npm install
npm run start:dev

Custom Components

LangFlow Components:

cd packages/langflow
pip install -r requirements.txt
# Restart LangFlow container to see changes

LiteLLM Custom Providers:

cd packages/litellm
pip install -r requirements.txt
# Restart LiteLLM container to see changes

πŸ“Š Monitoring and Analytics

The platform includes comprehensive monitoring capabilities:

  • LangFuse: Track LLM usage, costs, and performance metrics
  • Prometheus: System metrics collection
  • Grafana: Visualization and dashboards
  • LibreChat Metrics: Specialized metrics exporter for LibreChat

πŸ” Security Considerations

  • All services run in isolated Docker containers
  • Environment variables store sensitive configuration
  • Database connections use authentication
  • API keys provide service-to-service authentication
  • HTTPS support available for production deployments

🀝 Contributing

We welcome contributions from the academic community! Please see our contribution guidelines and feel free to:

  • Report issues or bugs
  • Suggest new features
  • Submit pull requests
  • Share your deployment experiences

πŸ“„ License

This project is licensed under the LICENSE file in the repository.

πŸ†˜ Support

For support, please:

  1. Check the individual component documentation in each package
  2. Review the deployment configuration files
  3. Open an issue in the repository
  4. Consult the upstream documentation for each integrated technology

PREAA - Empowering academic institutions with accessible, equitable AI technology.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •