diff --git a/.env b/.env deleted file mode 100644 index 149dd4d..0000000 --- a/.env +++ /dev/null @@ -1,18 +0,0 @@ -# Application settings -Application settings -APP_HOST=0.0.0.0 -APP_PORT=8000 -RELOAD=true - -WEAVIATE_URL= -WEAVIATE_API_KEY= -OPENAI_API_KEY=your-openai-key-here -OPENROUTER_API_KEY= - - -# Cache settings -CACHE_DEFAULT_TTL=300 - -# Rate limiting -RATE_LIMIT=60 -RATE_LIMIT_WINDOW=60 diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..569bdf3 --- /dev/null +++ b/.env.example @@ -0,0 +1,45 @@ +# Multi-Modal AI Platform - Environment Variables Example +# Copy this file to .env and fill in your actual values. +# NEVER commit your .env file to version control. + +# ── Application Settings ────────────────────────────────────────────────────── +APP_HOST=0.0.0.0 +APP_PORT=8000 +# Set to "true" to enable uvicorn auto-reload (development only) +RELOAD=false +# Runtime environment label (development | staging | production) +ENVIRONMENT=development + +# ── Security ────────────────────────────────────────────────────────────────── +# A long random string used as an application secret (e.g. `openssl rand -hex 32`) +SECRET_KEY=your-secret-key-here +# Static API key for the student/demo auth path +STUDENT_API_KEY=student-api-key-123 + +# ── Weaviate Vector Database ────────────────────────────────────────────────── +# Cluster URL from https://cloud.weaviate.io/ +WEAVIATE_URL=https://your-cluster.weaviate.network +WEAVIATE_API_KEY=your-weaviate-api-key + +# ── OpenAI ──────────────────────────────────────────────────────────────────── +OPENAI_API_KEY=your-openai-api-key-here + +# ── OpenRouter (optional alternative LLM gateway) ──────────────────────────── +OPENROUTER_API_KEY=your-openrouter-api-key-here +# Override the RAG model (must be a valid OpenRouter model key, e.g. meta-llama/llama-3.1-8b-instruct:free) +# RAG_MODEL= + +# ── Embeddings ──────────────────────────────────────────────────────────────── +# Set to "true" to use local sentence-transformers instead of the OpenAI API +USE_LOCAL_EMBEDDINGS=true + +# ── Filebase / S3-compatible Storage ───────────────────────────────────────── +# Credentials from https://filebase.com/dashboard/access-keys +FILEBASE_ACCESS_KEY=your-filebase-access-key +FILEBASE_SECRET_KEY=your-filebase-secret-key +BUCKET_NAME=multimodal-student-bucket + +# ── Cache & Rate Limiting ───────────────────────────────────────────────────── +CACHE_DEFAULT_TTL=300 +RATE_LIMIT=60 +RATE_LIMIT_WINDOW=60 diff --git a/.gitignore b/.gitignore index aba7e18..07ba2ed 100644 Binary files a/.gitignore and b/.gitignore differ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bac416c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM python:3.11-slim + +# Set working directory +WORKDIR /app + +# Install system dependencies needed by some Python packages +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc \ + libsndfile1 \ + ffmpeg \ + && rm -rf /var/lib/apt/lists/* + +# Install Python dependencies first (layer-cache friendly) +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +# Copy application source +COPY . . + +# Expose the application port (default 8000) +EXPOSE 8000 + +# Default command – can be overridden in docker-compose +CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000"] diff --git a/README.md b/README.md index 712763a..42344ac 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,17 @@ A comprehensive multi-modal AI platform that processes text, images, audio, and source venv/bin/activate # On Windows: venv\Scripts\activate ``` +3. **Install dependencies** + ```bash + pip install -r requirements.txt + ``` + +4. **Set up environment variables** + ```bash + cp .env.example .env + # Open .env and fill in your actual credentials (see Configuration section below) + ``` + ### Phase 2: Cloud Services Setup 1. **Google Cloud Storage Setup** @@ -50,6 +61,7 @@ A comprehensive multi-modal AI platform that processes text, images, audio, and - Note your cluster URL and API key 3. **Update environment variables** + Edit the `.env` file (created in Phase 1 step 4) with your cloud service credentials: ```env # API Configuration API_HOST=localhost @@ -72,6 +84,22 @@ A comprehensive multi-modal AI platform that processes text, images, audio, and MODEL_CONFIG_PATH=config/models.json ``` +## 🐳 Docker Setup + +```bash +# 1. Copy and configure environment +cp .env.example .env +# Edit .env with your credentials + +# 2. Build and start all services +docker compose up --build + +# 3. Access the API +# Swagger UI: http://localhost:8000/docs +``` + +To enable auto-reload during development, set `RELOAD=true` in your `.env`. + ## 🏃‍♂️ Quick Start 1. **Initialize the database** @@ -129,8 +157,10 @@ multi Model AI/ ├── config/ │ └── models.json # AI model configurations ├── requirements.txt # Python dependencies +├── Dockerfile # Container image build file +├── docker-compose.yml # Multi-service container orchestration ├── README.md # This file -├── .env.example # Environment variables template +├── .env.example # Environment variables template (copy to .env) └── .gitignore # Git ignore rules ``` @@ -138,34 +168,41 @@ multi Model AI/ ### Environment Variables -Create a `.env` file with the following variables: +Copy `.env.example` to `.env` and fill in your values. **Never commit the `.env` file** — it is excluded by `.gitignore`. -```env -# API Configuration -API_HOST=localhost -API_PORT=8000 -DEBUG=True +```bash +cp .env.example .env +``` -# Database -DATABASE_URL=sqlite:///./app.db +Key variables: -# Cloud Storage -GCS_BUCKET_NAME=multimodal-student-storage -GCS_KEY_PATH=./gcs-key.json +```env +# Application +APP_HOST=0.0.0.0 +APP_PORT=8000 +RELOAD=false +ENVIRONMENT=development + +# Security +SECRET_KEY=your-secret-key-here +STUDENT_API_KEY=student-api-key-123 # Weaviate Vector Database WEAVIATE_URL=https://your-cluster.weaviate.network WEAVIATE_API_KEY=your-api-key -# AI Model Configuration +# AI Model APIs OPENAI_API_KEY=your_openai_api_key -MODEL_CONFIG_PATH=config/models.json +OPENROUTER_API_KEY=your_openrouter_api_key # optional -# Security -SECRET_KEY=your-secret-key-here -API_KEY=student-api-key-123 +# Filebase / S3 Storage +FILEBASE_ACCESS_KEY=your-access-key +FILEBASE_SECRET_KEY=your-secret-key +BUCKET_NAME=multimodal-student-bucket ``` +See `.env.example` for a complete list of all supported variables with descriptions. + ### Model Configuration Create `config/models.json` to configure AI models: diff --git a/backend/storage.py b/backend/storage.py index a2ac962..e2588c8 100644 --- a/backend/storage.py +++ b/backend/storage.py @@ -17,9 +17,9 @@ def __init__(self, bucket_name: str): bucket_name: Name for your storage bucket (must be globally unique) """ # Get credentials from environment variables - access_key = os.getenv('068004E9D0BE3AECE1E7') - secret_key = os.getenv('dMvlaq4pdisOwZqs37kKTldybXZGpQr15ky1x29V') - + access_key = os.getenv('FILEBASE_ACCESS_KEY') + secret_key = os.getenv('FILEBASE_SECRET_KEY') + if not access_key or not secret_key: raise ValueError( "FILEBASE_ACCESS_KEY and FILEBASE_SECRET_KEY must be set in environment variables. " diff --git a/docker-compose.yml b/docker-compose.yml index 52092af..c109fee 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,23 +1,35 @@ -version: '3.8' - services: app: build: . ports: - - "${APP_PORT}:${APP_PORT}" + - "${APP_PORT:-8000}:${APP_PORT:-8000}" environment: + - APP_HOST=${APP_HOST:-0.0.0.0} + - APP_PORT=${APP_PORT:-8000} + - RELOAD=${RELOAD:-false} + - ENVIRONMENT=${ENVIRONMENT:-development} - WEAVIATE_URL=${WEAVIATE_URL} - WEAVIATE_API_KEY=${WEAVIATE_API_KEY} - OPENAI_API_KEY=${OPENAI_API_KEY} + - OPENROUTER_API_KEY=${OPENROUTER_API_KEY} + - STUDENT_API_KEY=${STUDENT_API_KEY} + - FILEBASE_ACCESS_KEY=${FILEBASE_ACCESS_KEY} + - FILEBASE_SECRET_KEY=${FILEBASE_SECRET_KEY} + - BUCKET_NAME=${BUCKET_NAME:-multimodal-student-bucket} + env_file: + - .env volumes: - .:/app command: > - sh -c "uvicorn backend.main:app --host ${APP_HOST} --port ${APP_PORT} --reload ${RELOAD:+--reload}" + sh -c "if [ \"${RELOAD:-false}\" = 'true' ]; + then uvicorn backend.main:app --host ${APP_HOST:-0.0.0.0} --port ${APP_PORT:-8000} --reload; + else uvicorn backend.main:app --host ${APP_HOST:-0.0.0.0} --port ${APP_PORT:-8000}; + fi" depends_on: - weaviate weaviate: - image: semitechnologies/weaviate:1.19.0 + image: semitechnologies/weaviate:1.24.0 ports: - "8080:8080" environment: @@ -28,4 +40,4 @@ services: - weaviate_data:/var/lib/weaviate volumes: - weaviate_data: \ No newline at end of file + weaviate_data: diff --git a/requirements.txt b/requirements.txt index 9ded0d7..7ee70d7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,19 +1,19 @@ # Multi-Modal AI Platform Dependencies (Student Edition) # Core AI/ML Libraries -torch>=2.0.0 -transformers>=4.30.0 -sentencepiece>=0.1.99 -accelerate>=0.20.0 -openai>=1.0.0 -langchain>=0.1.0 -langchain-openai>=0.1.0 -langchain-community>=0.0.10 +torch>=2.4.0 +transformers>=4.48.0 +sentencepiece>=0.2.0 +accelerate>=1.2.0 +openai>=1.68.0 +langchain>=0.3.0 +langchain-openai>=0.3.0 +langchain-community>=0.3.0 # Computer Vision -opencv-python>=4.8.0 -pillow>=10.0.0 -imageio>=2.31.0 +opencv-python>=4.10.0 +pillow>=11.0.0 +imageio>=2.36.0 # Audio Processing librosa>=0.10.0 @@ -22,42 +22,44 @@ pydub>=0.25.0 moviepy>=1.0.3 # Data Processing -pandas>=2.0.0 -numpy>=1.24.0 -scikit-learn>=1.3.0 +pandas>=2.2.0 +numpy>=1.26.0 +scikit-learn>=1.5.0 # Web Framework -fastapi>=0.100.0 -uvicorn>=0.23.0 -python-multipart>=0.0.6 +fastapi>=0.115.0 +uvicorn>=0.34.0 +python-multipart>=0.0.20 # Database & Vector Storage sqlalchemy>=2.0.0 -alembic>=1.11.0 -weaviate-client>=3.25.0 +alembic>=1.14.0 +weaviate-client>=3.26.0 # Cloud Storage -google-cloud-storage>=2.10.0 +google-cloud-storage>=2.19.0 +boto3>=1.37.0 # Environment and Configuration python-dotenv>=1.0.0 -pydantic>=2.0.0 +pydantic>=2.10.0 # Security & Authentication python-jose[cryptography]>=3.3.0 passlib[bcrypt]>=1.7.4 # Testing -pytest>=7.4.0 -pytest-asyncio>=0.21.0 -pytest-cov>=4.1.0 +pytest>=8.3.0 +pytest-asyncio>=0.25.0 +pytest-cov>=6.0.0 # Development & Code Quality -black>=23.0.0 -flake8>=6.0.0 -mypy>=1.5.0 -pre-commit>=3.3.0 +black>=24.0.0 +flake8>=7.0.0 +mypy>=1.13.0 +pre-commit>=4.0.0 # Monitoring & Logging -structlog>=23.1.0 -prometheus-client>=0.17.0 \ No newline at end of file +structlog>=24.0.0 +prometheus-client>=0.21.0 +psutil>=6.1.0