feat: Add GitHub Actions workflow for Docker builds

- Add docker-publish.yml workflow for ghcr.io
- Add production-ready Dockerfile (if missing)
- Enable automated builds on push to main
- Support for semantic versioning tags
This commit is contained in:
Hanzo Dev
2025-07-23 23:06:15 -05:00
parent 4aee55defe
commit cb1bf0e258
40 changed files with 779 additions and 3103 deletions
+56
View File
@@ -0,0 +1,56 @@
name: Build and Push Docker Image
on:
push:
branches: [ main ]
tags: [ 'v*' ]
pull_request:
branches: [ main ]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
+41 -1
View File
@@ -108,4 +108,44 @@ backend.log
frontend.log
mongod.log
logs/
*.log
*.log
# Build artifacts
dist/
build/
coverage/
*.orig
client/dist/
packages/*/dist/
packages/*/coverage/
client/coverage/
api/logs/
# Temporary files
uploads/temp/
images/
.nyc_output/
junit.xml
test-results/
# IDE and editor files
.idea/
.vscode/
*.swp
*.swo
*~
# Environment files
.env.*
!.env.example
!.env.hanzo-cloud
# OS files
.DS_Store
Thumbs.db
# Test artifacts
tests/**/*.wav
tests/**/*.mp3
tests/**/*.png
tests/**/*.jpg
-144
View File
@@ -1,144 +0,0 @@
# INSTRUCTIONS FOR LITELLM
This document provides comprehensive instructions for AI agents working in the LiteLLM repository.
## OVERVIEW
LiteLLM is a unified interface for 100+ LLMs that:
- Translates inputs to provider-specific completion, embedding, and image generation endpoints
- Provides consistent OpenAI-format output across all providers
- Includes retry/fallback logic across multiple deployments (Router)
- Offers a proxy server (LLM Gateway) with budgets, rate limits, and authentication
- Supports advanced features like function calling, streaming, caching, and observability
## REPOSITORY STRUCTURE
### Core Components
- `litellm/` - Main library code
- `llms/` - Provider-specific implementations (OpenAI, Anthropic, Azure, etc.)
- `proxy/` - Proxy server implementation (LLM Gateway)
- `router_utils/` - Load balancing and fallback logic
- `types/` - Type definitions and schemas
- `integrations/` - Third-party integrations (observability, caching, etc.)
### Key Directories
- `tests/` - Comprehensive test suites
- `docs/my-website/` - Documentation website
- `ui/litellm-dashboard/` - Admin dashboard UI
- `enterprise/` - Enterprise-specific features
## DEVELOPMENT GUIDELINES
### MAKING CODE CHANGES
1. **Provider Implementations**: When adding/modifying LLM providers:
- Follow existing patterns in `litellm/llms/{provider}/`
- Implement proper transformation classes that inherit from `BaseConfig`
- Support both sync and async operations
- Handle streaming responses appropriately
- Include proper error handling with provider-specific exceptions
2. **Type Safety**:
- Use proper type hints throughout
- Update type definitions in `litellm/types/`
- Ensure compatibility with both Pydantic v1 and v2
3. **Testing**:
- Add tests in appropriate `tests/` subdirectories
- Include both unit tests and integration tests
- Test provider-specific functionality thoroughly
- Consider adding load tests for performance-critical changes
### IMPORTANT PATTERNS
1. **Function/Tool Calling**:
- LiteLLM standardizes tool calling across providers
- OpenAI format is the standard, with transformations for other providers
- See `litellm/llms/anthropic/chat/transformation.py` for complex tool handling
2. **Streaming**:
- All providers should support streaming where possible
- Use consistent chunk formatting across providers
- Handle both sync and async streaming
3. **Error Handling**:
- Use provider-specific exception classes
- Maintain consistent error formats across providers
- Include proper retry logic and fallback mechanisms
4. **Configuration**:
- Support both environment variables and programmatic configuration
- Use `BaseConfig` classes for provider configurations
- Allow dynamic parameter passing
## PROXY SERVER (LLM GATEWAY)
The proxy server is a critical component that provides:
- Authentication and authorization
- Rate limiting and budget management
- Load balancing across multiple models/deployments
- Observability and logging
- Admin dashboard UI
- Enterprise features
Key files:
- `litellm/proxy/proxy_server.py` - Main server implementation
- `litellm/proxy/auth/` - Authentication logic
- `litellm/proxy/management_endpoints/` - Admin API endpoints
## MCP (MODEL CONTEXT PROTOCOL) SUPPORT
LiteLLM supports MCP for agent workflows:
- MCP server integration for tool calling
- Transformation between OpenAI and MCP tool formats
- Support for external MCP servers (Zapier, Jira, Linear, etc.)
- See `litellm/experimental_mcp_client/` and `litellm/proxy/_experimental/mcp_server/`
## TESTING CONSIDERATIONS
1. **Provider Tests**: Test against real provider APIs when possible
2. **Proxy Tests**: Include authentication, rate limiting, and routing tests
3. **Performance Tests**: Load testing for high-throughput scenarios
4. **Integration Tests**: End-to-end workflows including tool calling
## DOCUMENTATION
- Keep documentation in sync with code changes
- Update provider documentation when adding new providers
- Include code examples for new features
- Update changelog and release notes
## SECURITY CONSIDERATIONS
- Handle API keys securely
- Validate all inputs, especially for proxy endpoints
- Consider rate limiting and abuse prevention
- Follow security best practices for authentication
## ENTERPRISE FEATURES
- Some features are enterprise-only
- Check `enterprise/` directory for enterprise-specific code
- Maintain compatibility between open-source and enterprise versions
## COMMON PITFALLS TO AVOID
1. **Breaking Changes**: LiteLLM has many users - avoid breaking existing APIs
2. **Provider Specifics**: Each provider has unique quirks - handle them properly
3. **Rate Limits**: Respect provider rate limits in tests
4. **Memory Usage**: Be mindful of memory usage in streaming scenarios
5. **Dependencies**: Keep dependencies minimal and well-justified
## HELPFUL RESOURCES
- Main documentation: https://docs.litellm.ai/
- Provider-specific docs in `docs/my-website/docs/providers/`
- Admin UI for testing proxy features
## WHEN IN DOUBT
- Follow existing patterns in the codebase
- Check similar provider implementations
- Ensure comprehensive test coverage
- Update documentation appropriately
- Consider backward compatibility impact
-25
View File
@@ -1,25 +0,0 @@
# Changelog
All notable changes to this project will be documented in this file.
## [Unreleased]
### ✨ New Features
<<<<<<< HEAD
- 🪄 feat: Agent Artifacts by **@hanzoai** in [#5804](https://github.com/hanzoai/chat/pull/5804)
### ⚙️ Other Changes
- 🔄 chore: Enforce 18next Language Keys by **@rubentalstra** in [#5803](https://github.com/hanzoai/chat/pull/5803)
- 🔃 refactor: Parent Message ID Handling on Error, Update Translations, Bump Agents by **@hanzoai** in [#5833](https://github.com/hanzoai/chat/pull/5833)
=======
- 🪄 feat: Agent Artifacts by **@hanzoai** in [#5804](https://github.com/hanzoai/chat/pull/5804)
### ⚙️ Other Changes
- 🔄 chore: Enforce 18next Language Keys by **@rubentalstra** in [#5803](https://github.com/hanzoai/chat/pull/5803)
- 🔃 refactor: Parent Message ID Handling on Error, Update Translations, Bump Agents by **@hanzoai** in [#5833](https://github.com/hanzoai/chat/pull/5833)
>>>>>>> feature/hanzo-mcp-integration
---
-43
View File
@@ -1,43 +0,0 @@
# Development Dockerfile for Hanzo Router
FROM python:3.11-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
build-essential \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install uv for faster Python package management
RUN pip install uv
# Copy requirements
COPY pyproject.toml ./
COPY poetry.lock* ./
COPY requirements.txt* ./
# Install Python dependencies
RUN uv pip install --system -r requirements.txt || \
pip install poetry && poetry export -f requirements.txt | pip install -r /dev/stdin || \
pip install litellm[proxy]
# Copy source code (will be overridden by volume mount)
COPY . .
# Create necessary directories
RUN mkdir -p /app/logs /app/.cache
# Expose port
EXPOSE 4000
# Install watchdog for Python hot reloading
RUN pip install watchdog[watchmedo]
# Environment for development
ENV PYTHONUNBUFFERED=1
ENV LITELLM_MODE=development
# Development command with auto-reload using watchmedo
CMD ["watchmedo", "auto-restart", "--directory=/app/litellm", "--pattern=*.py", "--recursive", "--", "python", "-m", "litellm", "--config", "/app/config.yaml", "--port", "4000", "--detailed_debug"]
View File
+235 -182
View File
@@ -1,207 +1,260 @@
# LiteLLM Makefile
# Simple Makefile for running tests and basic development tasks
# Hanzo AI Chat - Unified Makefile
# Simple, clean commands for development and production
.PHONY: help test test-unit test-integration test-unit-helm lint format install-dev install-proxy-dev install-test-deps install-helm-unittest check-circular-imports check-import-safety up down logs restart status clean test-platform
# Default compose file for platform
COMPOSE_FILE := compose-simple.yml
.PHONY: help
# Colors for output
GREEN := \033[0;32m
YELLOW := \033[0;33m
RED := \033[0;31m
BLUE := \033[0;34m
NC := \033[0m # No Color
# Default compose file
COMPOSE_FILE ?= compose.yml
# Default target
help:
@echo "$(GREEN)=== Hanzo AI Platform ===$(NC)"
@echo "$(GREEN)╔══════════════════════════════════════════════════════════════╗$(NC)"
@echo "$(GREEN)║ Hanzo AI Chat Platform ║$(NC)"
@echo "$(GREEN)╚══════════════════════════════════════════════════════════════╝$(NC)"
@echo ""
@echo "$(YELLOW)Platform Management:$(NC)"
@echo " $(GREEN)make up$(NC) - Start all services"
@echo " $(GREEN)make down$(NC) - Stop all services"
@echo " $(GREEN)make logs$(NC) - View logs (all services)"
@echo " $(GREEN)make restart$(NC) - Restart all services"
@echo " $(GREEN)make status$(NC) - Check service status"
@echo " $(GREEN)make clean$(NC) - Stop services and remove volumes"
@echo "$(BLUE)Quick Start:$(NC)"
@echo " $(GREEN)make up$(NC) - Start chat with cloud API"
@echo " $(GREEN)make dev$(NC) - Start in dev mode (hot reload)"
@echo " $(GREEN)make dev-full$(NC) - Dev mode with local router"
@echo ""
@echo "$(YELLOW)Development Commands:$(NC)"
@echo " make install-dev - Install development dependencies"
@echo " make install-proxy-dev - Install proxy development dependencies"
@echo " make install-dev-ci - Install dev dependencies (CI-compatible, pins OpenAI)"
@echo " make install-proxy-dev-ci - Install proxy dev dependencies (CI-compatible)"
@echo " make install-test-deps - Install test dependencies"
@echo " make install-helm-unittest - Install helm unittest plugin"
@echo " make format - Apply Black code formatting"
@echo " make format-check - Check Black code formatting (matches CI)"
@echo " make lint - Run all linting (Ruff, MyPy, Black check, circular imports, import safety)"
@echo " make lint-ruff - Run Ruff linting only"
@echo " make lint-mypy - Run MyPy type checking only"
@echo " make lint-black - Check Black formatting (matches CI)"
@echo " make check-circular-imports - Check for circular imports"
@echo " make check-import-safety - Check import safety"
@echo " make test - Run all tests"
@echo " make test-platform - Test platform services (health & API)"
@echo " make test-unit - Run unit tests (tests/test_litellm)"
@echo " make test-integration - Run integration tests"
@echo " make test-unit-helm - Run helm unit tests"
@echo "$(BLUE)Core Commands:$(NC)"
@echo " $(GREEN)make down$(NC) - Stop all services"
@echo " $(GREEN)make restart$(NC) - Restart services"
@echo " $(GREEN)make logs$(NC) - View logs"
@echo " $(GREEN)make status$(NC) - Check service status"
@echo " $(GREEN)make clean$(NC) - Stop and remove data"
@echo ""
@echo "$(BLUE)Development:$(NC)"
@echo " $(GREEN)make build$(NC) - Build containers"
@echo " $(GREEN)make test$(NC) - Run tests"
@echo " $(GREEN)make lint$(NC) - Run linting"
@echo " $(GREEN)make format$(NC) - Format code"
@echo ""
@echo "$(BLUE)Production:$(NC)"
@echo " $(GREEN)make prod$(NC) - Deploy production"
@echo " $(GREEN)make backup$(NC) - Backup data"
@echo ""
@echo "Run 'make help-all' for advanced usage"
# Installation targets
install-dev:
poetry install --with dev
help-all:
@echo "$(GREEN)══════════════════════════════════════════════════════════════$(NC)"
@echo "$(GREEN) Advanced Usage $(NC)"
@echo "$(GREEN)══════════════════════════════════════════════════════════════$(NC)"
@echo ""
@echo "$(BLUE)Deployment Modes:$(NC)"
@echo " make up - Basic: Chat + Cloud API"
@echo " make dev - Development: Hot reload"
@echo " make dev-full - Dev + Local router"
@echo " make prod - Production with Traefik"
@echo ""
@echo "$(BLUE)Service Control:$(NC)"
@echo " make logs-chat - View chat logs"
@echo " make logs-mongo - View MongoDB logs"
@echo " make logs-router - View router logs (dev-full)"
@echo " make shell-chat - Shell into chat container"
@echo " make shell-mongo - MongoDB shell"
@echo ""
@echo "$(BLUE)Development Tools:$(NC)"
@echo " make install - Install dependencies"
@echo " make dev-frontend - Run frontend only"
@echo " make dev-backend - Run backend only"
@echo " make test-unit - Unit tests"
@echo " make test-e2e - E2E tests"
@echo " make lint-fix - Auto-fix linting"
@echo ""
@echo "$(BLUE)Database:$(NC)"
@echo " make db-seed - Seed demo data"
@echo " make db-reset - Reset database"
@echo " make db-export - Export data"
@echo " make db-import FILE= - Import data"
@echo ""
@echo "$(BLUE)Docker Compose Files:$(NC)"
@echo " compose.yml - Base configuration"
@echo " compose.dev.yml - Development overrides"
@echo " compose.prod.yml - Production overrides"
install-proxy-dev:
poetry install --with dev,proxy-dev --extras proxy
# ============================================================================
# CORE COMMANDS
# ============================================================================
# CI-compatible installations (matches GitHub workflows exactly)
install-dev-ci:
pip install openai==1.81.0
poetry install --with dev
pip install openai==1.81.0
install-proxy-dev-ci:
poetry install --with dev,proxy-dev --extras proxy
pip install openai==1.81.0
install-test-deps: install-proxy-dev
poetry run pip install "pytest-retry==1.6.3"
poetry run pip install pytest-xdist
cd enterprise && python -m pip install -e . && cd ..
install-helm-unittest:
helm plugin install https://github.com/helm-unittest/helm-unittest --version v0.4.4
# Formatting
format: install-dev
cd litellm && poetry run black . && cd ..
format-check: install-dev
cd litellm && poetry run black --check . && cd ..
# Linting targets
lint-ruff: install-dev
cd litellm && poetry run ruff check . && cd ..
lint-mypy: install-dev
poetry run pip install types-requests types-setuptools types-redis types-PyYAML
cd litellm && poetry run mypy . --ignore-missing-imports && cd ..
lint-black: format-check
check-circular-imports: install-dev
cd litellm && poetry run python ../tests/documentation_tests/test_circular_imports.py && cd ..
check-import-safety: install-dev
poetry run python -c "from litellm import *" || (echo '🚨 import failed, this means you introduced unprotected imports! 🚨'; exit 1)
# Combined linting (matches test-linting.yml workflow)
lint: format-check lint-ruff lint-mypy check-circular-imports check-import-safety
# Testing targets
test:
poetry run pytest tests/
test-unit: install-test-deps
poetry run pytest tests/test_litellm -x -vv -n 4
test-integration:
poetry run pytest tests/ -k "not test_litellm"
test-unit-helm: install-helm-unittest
helm unittest -f 'tests/*.yaml' deploy/charts/litellm-helm
# LLM Translation testing targets
test-llm-translation: install-test-deps
@echo "Running LLM translation tests..."
@python .github/workflows/run_llm_translation_tests.py
test-llm-translation-single: install-test-deps
@echo "Running single LLM translation test file..."
@if [ -z "$(FILE)" ]; then echo "Usage: make test-llm-translation-single FILE=test_filename.py"; exit 1; fi
@mkdir -p test-results
poetry run pytest tests/llm_translation/$(FILE) \
--junitxml=test-results/junit.xml \
-v --tb=short --maxfail=100 --timeout=300
# =================================
# Platform Management Commands
# =================================
# Start all services
up:
@echo "$(GREEN)🚀 Starting Hanzo AI Platform...$(NC)"
@docker compose -f $(COMPOSE_FILE) up -d --remove-orphans
@echo "$(YELLOW)⏳ Waiting for services to be ready...$(NC)"
@sleep 5
@docker start hanzo-chat 2>/dev/null || true
@echo ""
@echo "$(GREEN)✅ Platform is starting!$(NC)"
@echo ""
@echo "$(YELLOW)📋 Access Points:$(NC)"
@echo " • Chat Interface: http://localhost:3081"
@echo " • Router API: http://localhost:4000"
@echo " • Runtime API: http://localhost:3003"
@echo " • Meilisearch: http://localhost:7700"
@echo ""
@echo "$(YELLOW)🔑 Router API Key:$(NC) sk-hanzo-master-key"
@echo ""
@echo "Run '$(GREEN)make test$(NC)' to verify everything is working"
@echo "$(GREEN)Starting Hanzo Chat...$(NC)"
@docker compose up -d
@echo "$(GREEN)Chat available at http://localhost:3081$(NC)"
# Stop all services
down:
@echo "$(RED)⏹️ Stopping Hanzo AI Platform...$(NC)"
@docker compose -f $(COMPOSE_FILE) down
@echo "$(GREEN)✅ All services stopped$(NC)"
@echo "$(YELLOW)Stopping services...$(NC)"
@docker compose down
restart: down up
# View logs
logs:
@docker compose -f $(COMPOSE_FILE) logs -f
@docker compose logs -f
# View chat logs specifically
logs-chat:
@docker compose -f $(COMPOSE_FILE) logs -f chat
# View router logs specifically
logs-router:
@docker compose -f $(COMPOSE_FILE) logs -f router
# Restart all services
restart:
@echo "$(YELLOW)🔄 Restarting services...$(NC)"
@$(MAKE) down
@$(MAKE) up
# Check status
status:
@echo "$(YELLOW)📊 Service Status:$(NC)"
@docker compose -f $(COMPOSE_FILE) ps
@echo "$(GREEN)Service Status:$(NC)"
@docker compose ps
@echo ""
@echo "$(GREEN)Health Checks:$(NC)"
@curl -s http://localhost:3081/api/health > /dev/null 2>&1 && echo " ✓ Chat API" || echo " ✗ Chat API"
@curl -s http://localhost:3081 > /dev/null 2>&1 && echo " ✓ Chat UI" || echo " ✗ Chat UI"
# Clean everything (including volumes)
clean:
@echo "$(RED)🧹 Cleaning up everything...$(NC)"
@docker compose -f $(COMPOSE_FILE) down -v --remove-orphans
@echo "$(GREEN)✅ Cleanup complete$(NC)"
@echo "$(RED)Removing all data...$(NC)"
@docker compose down -v
# Test platform services
test-platform:
@echo "$(YELLOW)🧪 Testing Hanzo AI Platform...$(NC)"
@echo ""
@echo -n "$(YELLOW)Router Health:$(NC) "
@curl -s http://localhost:4000/health >/dev/null 2>&1 && echo "$(GREEN)✅ OK$(NC)" || echo "$(RED)❌ Failed$(NC)"
@echo -n "$(YELLOW)Chat Health:$(NC) "
@curl -s http://localhost:3081/health >/dev/null 2>&1 && echo "$(GREEN)✅ OK$(NC)" || echo "$(RED)❌ Failed$(NC)"
@echo -n "$(YELLOW)Search Health:$(NC) "
@curl -s http://localhost:7700/health >/dev/null 2>&1 && echo "$(GREEN)✅ OK$(NC)" || echo "$(RED)❌ Failed$(NC)"
@echo -n "$(YELLOW)Runtime Health:$(NC) "
@curl -s http://localhost:3003/api/health >/dev/null 2>&1 && echo "$(GREEN)✅ OK$(NC)" || echo "$(RED)❌ Failed$(NC)"
@echo ""
@echo -n "$(YELLOW)Router API Test (Anthropic):$(NC) "
@curl -s -X POST http://localhost:4000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-hanzo-master-key" \
-d '{"model": "hanzo-zen-1", "messages": [{"role": "user", "content": "Say OK"}], "max_tokens": 5}' \
2>/dev/null | grep -q "OK" && echo "$(GREEN)✅ Working$(NC)" || echo "$(RED)❌ Failed$(NC)"
@echo ""
@echo "$(YELLOW)Available Models:$(NC)"
@curl -s http://localhost:4000/v1/models -H "Authorization: Bearer sk-hanzo-master-key" 2>/dev/null | jq -r '.data[].id' | head -5 | sed 's/^/ • /'
@echo ""
@docker compose -f $(COMPOSE_FILE) ps --format "table {{.Name}}\t{{.Status}}"
# ============================================================================
# DEVELOPMENT
# ============================================================================
dev:
@echo "$(GREEN)Starting in development mode...$(NC)"
@docker compose -f compose.yml -f compose.dev.yml up
dev-full:
@echo "$(GREEN)Starting full dev stack with local router...$(NC)"
@docker compose -f compose.yml -f compose.dev.yml --profile with-router up
build:
@echo "$(GREEN)Building containers...$(NC)"
@docker compose build
build-prod:
@echo "$(GREEN)Building production image...$(NC)"
@docker build -f docker/Dockerfile -t hanzoai/chat:latest .
# ============================================================================
# PRODUCTION
# ============================================================================
prod:
@echo "$(GREEN)Deploying production...$(NC)"
@test -n "$${JWT_SECRET}" || (echo "$(RED)JWT_SECRET required$(NC)" && exit 1)
@test -n "$${OPENAI_API_KEY}" || (echo "$(RED)OPENAI_API_KEY required$(NC)" && exit 1)
@docker compose -f compose.yml -f compose.prod.yml up -d
backup:
@echo "$(GREEN)Creating backup...$(NC)"
@mkdir -p backups
@docker compose exec -T mongodb mongodump --out /backup
@docker cp $$(docker compose ps -q mongodb):/backup backups/mongodb-$$(date +%Y%m%d-%H%M%S)
@echo "$(GREEN)Backup complete$(NC)"
# ============================================================================
# LOGS
# ============================================================================
logs-chat:
@docker compose logs -f chat
logs-mongo:
@docker compose logs -f mongodb
logs-meili:
@docker compose logs -f meilisearch
logs-router:
@docker compose -f compose.yml -f compose.dev.yml logs -f router
# ============================================================================
# SHELL ACCESS
# ============================================================================
shell-chat:
@docker compose exec chat sh
shell-mongo:
@docker compose exec mongodb mongosh -u hanzo -p hanzo123 HanzoChat
# ============================================================================
# TESTING
# ============================================================================
test:
@echo "$(GREEN)Running tests...$(NC)"
@npm test
test-unit:
@echo "$(GREEN)Running unit tests...$(NC)"
@npm run test:unit
test-e2e:
@echo "$(GREEN)Running E2E tests...$(NC)"
@npm run test:e2e
# ============================================================================
# CODE QUALITY
# ============================================================================
lint:
@echo "$(GREEN)Running linters...$(NC)"
@npm run lint
lint-fix:
@echo "$(GREEN)Auto-fixing lint issues...$(NC)"
@npm run lint:fix
format:
@echo "$(GREEN)Formatting code...$(NC)"
@npm run format
# ============================================================================
# INSTALLATION
# ============================================================================
install:
@echo "$(GREEN)Installing dependencies...$(NC)"
@npm install
@cd api && npm install
@cd client && npm install
# ============================================================================
# DATABASE
# ============================================================================
db-seed:
@echo "$(GREEN)Seeding database...$(NC)"
@docker compose exec chat npm run seed
db-reset:
@echo "$(RED)Resetting database...$(NC)"
@docker compose exec mongodb mongosh -u hanzo -p hanzo123 HanzoChat --eval "db.dropDatabase()"
@make db-seed
db-export:
@echo "$(GREEN)Exporting database...$(NC)"
@mkdir -p exports
@docker compose exec -T mongodb mongoexport -u hanzo -p hanzo123 -d HanzoChat -c conversations > exports/conversations-$$(date +%Y%m%d).json
db-import:
@test -n "$(FILE)" || (echo "$(RED)Please specify FILE=path/to/export.json$(NC)" && exit 1)
@echo "$(GREEN)Importing $(FILE)...$(NC)"
@docker compose exec -T mongodb mongoimport -u hanzo -p hanzo123 -d HanzoChat -c conversations < $(FILE)
# ============================================================================
# UTILITIES
# ============================================================================
env-example:
@echo "$(GREEN)Creating example .env file...$(NC)"
@cp .env.example .env
@echo "$(YELLOW)Edit .env and add your API keys$(NC)"
check-env:
@echo "$(GREEN)Environment Check:$(NC)"
@test -f .env && echo "✓ .env file exists" || echo "✗ .env file missing"
@which docker > /dev/null && echo "✓ Docker installed" || echo "✗ Docker not found"
@docker compose version > /dev/null 2>&1 && echo "✓ Docker Compose v2" || echo "✗ Docker Compose v2 not found"
version:
@echo "$(GREEN)Hanzo AI Chat$(NC)"
@echo "Version: $$(cat package.json | grep version | head -1 | awk -F: '{ print $$2 }' | sed 's/[",]//g')"
.DEFAULT_GOAL := help
-85
View File
@@ -1,85 +0,0 @@
# Hanzo Chat - Clean LibreChat Makefile
# Uses external Hanzo API at api.hanzo.ai
.PHONY: help up down restart logs status clean setup
# Default target
help:
@echo "Hanzo Chat - Clean LibreChat Commands"
@echo ""
@echo "Setup & Configuration:"
@echo " make setup - Initial setup (copy env file)"
@echo " make config - Edit configuration"
@echo ""
@echo "Service Management:"
@echo " make up - Start all services"
@echo " make down - Stop all services"
@echo " make restart - Restart all services"
@echo " make logs - View logs (all services)"
@echo " make status - Check service status"
@echo " make clean - Stop services and remove volumes"
@echo ""
@echo "Development:"
@echo " make dev - Start in development mode"
@echo " make build - Build containers"
@echo ""
# Setup environment
setup:
@if [ ! -f .env ]; then \
echo "Creating .env from .env.hanzo-cloud..."; \
cp .env.hanzo-cloud .env; \
echo "✅ Created .env file"; \
echo "⚠️ Please edit .env and add your Hanzo API key"; \
else \
echo "⚠️ .env already exists. Skipping..."; \
fi
# Edit configuration
config:
@${EDITOR:-nano} .env
# Start all services
up:
@echo "🚀 Starting Hanzo Chat..."
@docker compose -f docker-compose.hanzo-clean.yml up -d
@echo ""
@echo "✅ Hanzo Chat is running!"
@echo ""
@echo "🌐 Access at: http://localhost:3081"
@echo "📝 Register your first account to get started"
@echo ""
# Stop all services
down:
@echo "⏹️ Stopping Hanzo Chat..."
@docker compose -f docker-compose.hanzo-clean.yml down
@echo "✅ All services stopped"
# Restart services
restart: down up
# View logs
logs:
@docker compose -f docker-compose.hanzo-clean.yml logs -f
# Check status
status:
@echo "📊 Service Status:"
@docker compose -f docker-compose.hanzo-clean.yml ps
# Clean everything
clean:
@echo "🧹 Cleaning up..."
@docker compose -f docker-compose.hanzo-clean.yml down -v
@echo "✅ Removed all containers and volumes"
# Development mode
dev:
@echo "🔧 Starting in development mode..."
@docker compose -f docker-compose.hanzo-clean.yml up
# Build containers
build:
@echo "🔨 Building containers..."
@docker compose -f docker-compose.hanzo-clean.yml build
-251
View File
@@ -1,251 +0,0 @@
# Hanzo AI Chat Stack Makefile
# One-command deployment and management
.PHONY: help up down restart logs build push deploy clean test status backup restore
# Color definitions
YELLOW := \033[1;33m
GREEN := \033[1;32m
RED := \033[1;31m
BLUE := \033[1;34m
NC := \033[0m # No Color
# Configuration
DOCKER_REGISTRY ?= ghcr.io/hanzoai
ROUTER_IMAGE := $(DOCKER_REGISTRY)/router
CHAT_IMAGE := $(DOCKER_REGISTRY)/chat
VERSION ?= latest
COMPOSE_FILE := docker-compose.hanzo.yml
# Default target
help:
@echo "$(BLUE)Hanzo AI Platform - Complete Stack Management$(NC)"
@echo ""
@echo "$(YELLOW)🚀 Quick Start:$(NC)"
@echo " $(GREEN)make platform$(NC) - Start the COMPLETE Hanzo AI Platform"
@echo " $(GREEN)make deploy$(NC) - Build and start the entire stack"
@echo ""
@echo "$(YELLOW)📋 Platform Services:$(NC)"
@echo " • Cloud Dashboard: http://localhost:3000 (AI platform management)"
@echo " • Chat Interface: http://localhost:3081 (AI chat)"
@echo " • IAM Dashboard: http://localhost:8000 (identity management)"
@echo " • Router API: http://localhost:4000 (LLM gateway)"
@echo ""
@echo "$(YELLOW)Development:$(NC)"
@echo " $(GREEN)make up$(NC) - Start all services"
@echo " $(GREEN)make down$(NC) - Stop all services"
@echo " $(GREEN)make restart$(NC) - Restart all services"
@echo " $(GREEN)make logs$(NC) - View logs (all services)"
@echo " $(GREEN)make logs-cloud$(NC) - View cloud service logs"
@echo " $(GREEN)make logs-iam$(NC) - View IAM service logs"
@echo " $(GREEN)make logs-chat$(NC) - View chat service logs"
@echo " $(GREEN)make logs-router$(NC) - View router logs"
@echo " $(GREEN)make status$(NC) - Check service health"
@echo ""
@echo "$(YELLOW)Building:$(NC)"
@echo " $(GREEN)make build$(NC) - Build Docker images"
@echo " $(GREEN)make push$(NC) - Push images to registry"
@echo " $(GREEN)make clean$(NC) - Clean up volumes and images"
@echo ""
@echo "$(YELLOW)Testing:$(NC)"
@echo " $(GREEN)make test$(NC) - Run all tests"
@echo " $(GREEN)make test-api$(NC) - Test API endpoints"
@echo ""
@echo "$(YELLOW)Data Management:$(NC)"
@echo " $(GREEN)make backup$(NC) - Backup all data"
@echo " $(GREEN)make restore$(NC) - Restore from backup"
# Start complete platform with all services
platform:
@echo "$(BLUE)🚀 Starting Complete Hanzo AI Platform...$(NC)"
@./start-hanzo.sh
# Quick deploy - builds and starts everything
deploy: check-env build
@echo "$(BLUE)🚀 Deploying Hanzo AI Platform...$(NC)"
@docker compose up -d
@echo "$(GREEN)✅ Deployment complete!$(NC)"
@echo ""
@echo "$(YELLOW)Access points:$(NC)"
@echo " Cloud Dashboard: http://localhost:3000"
@echo " Chat Interface: http://localhost:3081"
@echo " IAM Dashboard: http://localhost:8000"
@echo " Router API: http://localhost:4000"
@echo ""
@echo "$(YELLOW)Default credentials:$(NC)"
@echo " Email: admin@hanzo.ai"
@echo " Password: demo1234"
@echo " Router Key: sk-hanzo-master-key"
@echo ""
@$(MAKE) wait-healthy
# Check required environment variables
check-env:
@echo "$(BLUE)🔍 Checking environment...$(NC)"
@if [ -z "$$OPENAI_API_KEY" ] && [ -z "$$ANTHROPIC_API_KEY" ] && [ -z "$$TOGETHER_API_KEY" ]; then \
echo "$(RED)❌ Error: At least one LLM API key must be set$(NC)"; \
echo "$(YELLOW)Please set one of: OPENAI_API_KEY, ANTHROPIC_API_KEY, or TOGETHER_API_KEY$(NC)"; \
exit 1; \
fi
@if [ ! -f .env ]; then \
echo "$(YELLOW)📝 Creating .env file from template...$(NC)"; \
cp .env.example .env; \
fi
@echo "$(GREEN)✅ Environment check passed$(NC)"
# Build Docker images
build:
@echo "$(BLUE)🔨 Building Docker images...$(NC)"
@docker compose -f $(COMPOSE_FILE) build
@echo "$(GREEN)✅ Build complete$(NC)"
# Push images to registry
push:
@echo "$(BLUE)📤 Pushing images to registry...$(NC)"
@docker tag hanzo/router:latest $(ROUTER_IMAGE):$(VERSION)
@docker tag hanzo/chat:latest $(CHAT_IMAGE):$(VERSION)
@docker push $(ROUTER_IMAGE):$(VERSION)
@docker push $(CHAT_IMAGE):$(VERSION)
@echo "$(GREEN)✅ Images pushed successfully$(NC)"
# Start services
up:
@echo "$(BLUE)▶️ Starting services...$(NC)"
@docker compose -f $(COMPOSE_FILE) up -d
@$(MAKE) wait-healthy
# Stop services
down:
@echo "$(BLUE)⏹️ Stopping services...$(NC)"
@docker compose -f $(COMPOSE_FILE) down
@echo "$(GREEN)✅ Services stopped$(NC)"
# Restart services
restart:
@echo "$(BLUE)🔄 Restarting services...$(NC)"
@docker compose -f $(COMPOSE_FILE) restart
@$(MAKE) wait-healthy
# View logs
logs:
@docker compose -f $(COMPOSE_FILE) logs -f
logs-chat:
@docker compose -f $(COMPOSE_FILE) logs -f chat
logs-router:
@docker compose -f $(COMPOSE_FILE) logs -f router
logs-cloud:
@docker compose -f $(COMPOSE_FILE) logs -f cloud
logs-iam:
@docker compose -f $(COMPOSE_FILE) logs -f iam
logs-services:
@docker compose -f $(COMPOSE_FILE) logs -f services
# Check service health
status:
@echo "$(BLUE)📊 Service Status:$(NC)"
@echo ""
@docker compose -f $(COMPOSE_FILE) ps
@echo ""
@echo "$(BLUE)🏥 Health Checks:$(NC)"
@for service in postgres redis mongodb meilisearch router chat nginx; do \
if docker compose -f $(COMPOSE_FILE) exec -T $$service echo "OK" >/dev/null 2>&1; then \
echo " $$service: $(GREEN)✅ Healthy$(NC)"; \
else \
echo " $$service: $(RED)❌ Unhealthy$(NC)"; \
fi; \
done
# Wait for services to be healthy
wait-healthy:
@echo "$(BLUE)⏳ Waiting for services to be healthy...$(NC)"
@for i in 1 2 3 4 5 6 7 8 9 10; do \
if docker compose -f $(COMPOSE_FILE) exec -T router curl -f http://localhost:4000/health >/dev/null 2>&1 && \
docker compose -f $(COMPOSE_FILE) exec -T chat curl -f http://localhost:3080/health >/dev/null 2>&1; then \
echo "$(GREEN)✅ All services are healthy!$(NC)"; \
break; \
fi; \
echo " Waiting... ($$i/10)"; \
sleep 5; \
done
# Run tests
test: test-api test-chat
test-api:
@echo "$(BLUE)🧪 Testing API endpoints...$(NC)"
@curl -s -X GET http://localhost:4000/health | grep -q "healthy" && \
echo "$(GREEN)✅ Hanzo Router: OK$(NC)" || \
echo "$(RED)❌ Hanzo Router: Failed$(NC)"
@curl -s -X GET http://localhost:3081/health | grep -q "OK" && \
echo "$(GREEN)✅ Chat UI: OK$(NC)" || \
echo "$(RED)❌ Chat UI: Failed$(NC)"
test-chat:
@echo "$(BLUE)🧪 Testing chat functionality...$(NC)"
@curl -s -X POST http://localhost:4000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-hanzo-master-key" \
-d '{"model": "hanzo-zen-1", "messages": [{"role": "user", "content": "Hello"}]}' | \
grep -q "content" && \
echo "$(GREEN)✅ Chat completion: OK$(NC)" || \
echo "$(RED)❌ Chat completion: Failed$(NC)"
# Clean up
clean:
@echo "$(BLUE)🧹 Cleaning up...$(NC)"
@docker compose -f $(COMPOSE_FILE) down -v
@docker rmi hanzo/router:latest hanzo/chat:latest || true
@echo "$(GREEN)✅ Cleanup complete$(NC)"
# Backup data
backup:
@echo "$(BLUE)💾 Backing up data...$(NC)"
@mkdir -p backups
@BACKUP_NAME="hanzo-backup-$$(date +%Y%m%d-%H%M%S)"; \
docker compose -f $(COMPOSE_FILE) exec -T postgres pg_dump -U hanzo hanzo_chat > backups/$$BACKUP_NAME-postgres.sql; \
docker compose -f $(COMPOSE_FILE) exec -T mongodb mongodump --archive > backups/$$BACKUP_NAME-mongodb.archive; \
echo "$(GREEN)✅ Backup saved to backups/$$BACKUP_NAME-*$(NC)"
# Restore from backup
restore:
@if [ -z "$(BACKUP)" ]; then \
echo "$(RED)❌ Please specify BACKUP=<backup-name>$(NC)"; \
exit 1; \
fi
@echo "$(BLUE)📥 Restoring from backup...$(NC)"
@docker compose -f $(COMPOSE_FILE) exec -T postgres psql -U hanzo hanzo_chat < backups/$(BACKUP)-postgres.sql
@docker compose -f $(COMPOSE_FILE) exec -T mongodb mongorestore --archive < backups/$(BACKUP)-mongodb.archive
@echo "$(GREEN)✅ Restore complete$(NC)"
# Initialize demo user
init-demo:
@echo "$(BLUE)👤 Initializing demo user...$(NC)"
@./init-demo-user.sh
# Development helpers
dev-setup:
@echo "$(BLUE)🛠️ Setting up development environment...$(NC)"
@poetry install --with dev,proxy-dev --extras proxy
@cd client && npm install
@echo "$(GREEN)✅ Development setup complete$(NC)"
dev-frontend:
@echo "$(BLUE)🎨 Starting frontend development server...$(NC)"
@cd client && npm run dev
dev-backend:
@echo "$(BLUE)⚙️ Starting Hanzo Router development server...$(NC)"
@poetry run litellm --config hanzo-config.yaml --port 4000
# Production deployment
prod-deploy:
@echo "$(BLUE)🚀 Deploying to production...$(NC)"
@$(MAKE) build VERSION=$(shell git rev-parse --short HEAD)
@$(MAKE) push VERSION=$(shell git rev-parse --short HEAD)
@echo "$(GREEN)✅ Production deployment complete$(NC)"
@echo "$(YELLOW)Images tagged with version: $(shell git rev-parse --short HEAD)$(NC)"
-145
View File
@@ -1,145 +0,0 @@
# Hanzo AI Chat
A clean deployment of LibreChat configured to use Hanzo AI's cloud services.
## Architecture
```
┌─────────────────────────┐ ┌─────────────────────────┐
│ Hanzo Chat UI │────▶│ api.hanzo.ai │
│ (LibreChat Fork) │ │ │
│ localhost:3081 │ │ • AI Models (100+) │
└─────────────────────────┘ │ • Runtime Execution │
│ │ • MCP Tools │
│ └─────────────────────────┘
┌─────────────────────────┐
│ Local Data Storage │
│ • MongoDB (chat history)│
│ • Meilisearch (search) │
└─────────────────────────┘
```
## Features
- 🤖 **Unified AI Access**: All models through api.hanzo.ai
- 💬 **Clean LibreChat UI**: Familiar ChatGPT-like interface
- 🔍 **Full-Text Search**: Local Meilisearch integration
- 📝 **Chat History**: Local MongoDB storage
- 🛠️ **MCP Tools**: Model Context Protocol support
- 🚀 **Code Execution**: Via Hanzo's cloud runtime
## Quick Start
### 1. Setup
```bash
# Copy environment template
cp .env.hanzo-cloud .env
# Edit .env and add your Hanzo API key
# Get your key at: https://hanzo.ai/dashboard
nano .env
```
### 2. Start Services
```bash
# Using the clean Makefile
make -f Makefile.clean up
# Or using docker-compose directly
docker compose -f docker-compose.hanzo-clean.yml up -d
```
### 3. Access Chat
1. Open http://localhost:3081
2. Click "Sign up" to create your first account
3. Start chatting with AI models!
## Configuration
### Required Settings
```env
# Your Hanzo API key
OPENAI_API_KEY=sk-hanzo-your-key-here
# Hanzo API endpoint (default)
OPENAI_BASE_URL=https://api.hanzo.ai/v1
```
### Optional Settings
```env
# Enable/disable features
MCP_ENABLED=true
ALLOW_REGISTRATION=true
# Customize branding
APP_TITLE=Hanzo AI Chat
CUSTOM_FOOTER=Powered by Hanzo AI
```
## Available Models
Through api.hanzo.ai, you have access to:
- OpenAI (GPT-4, GPT-3.5)
- Anthropic (Claude 3.5, Claude 3)
- Google (Gemini Pro, Gemini Ultra)
- Meta (Llama 3.1)
- Mistral
- And 100+ more models
## Commands
```bash
# Service management
make -f Makefile.clean up # Start services
make -f Makefile.clean down # Stop services
make -f Makefile.clean restart # Restart services
make -f Makefile.clean logs # View logs
make -f Makefile.clean status # Check status
make -f Makefile.clean clean # Remove everything
# Development
make -f Makefile.clean dev # Run in foreground
make -f Makefile.clean build # Build containers
```
## Project Structure
```
hanzo/chat/
├── api/ # LibreChat API backend
├── client/ # LibreChat React frontend
├── packages/ # Shared packages
├── docker-compose.hanzo-clean.yml # Clean deployment
├── .env.hanzo-cloud # Environment template
└── Makefile.clean # Simplified commands
```
## Troubleshooting
### Chat not loading?
- Check services: `make -f Makefile.clean status`
- View logs: `make -f Makefile.clean logs`
- Ensure MongoDB and Meilisearch are healthy
### Authentication issues?
- Registration is enabled by default
- First user should be given admin access
- Check `ALLOW_REGISTRATION=true` in .env
### API errors?
- Verify your Hanzo API key is correct
- Check api.hanzo.ai is accessible
- View chat container logs for details
## Support
- Hanzo AI Dashboard: https://hanzo.ai/dashboard
- API Documentation: https://docs.hanzo.ai
- Support: support@hanzo.ai
-225
View File
@@ -1,225 +0,0 @@
# Hanzo AI Platform - Complete Local Stack
This is the complete Hanzo AI platform running locally, mirroring our production architecture.
## 🏗️ Architecture Overview
```
┌─────────────────────────────────────────────────────────────────────────────┐
│ Hanzo AI Platform Stack │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Hanzo Chat │ │ Hanzo Cloud │ │ Hanzo IAM │ │Hanzo Router │ │
│ │ :3081 │ │ :3000 │ │ :8000 │ │ :4000 │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │ │ │ │ │
│ └──────────────────┴──────────────────┴────────────────────┘ │
│ │ │
├───────────────────────────────────────┴───────────────────────────────────────┤
│ Data Layer │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ PostgreSQL │ │ MySQL │ │ MongoDB │ │ ClickHouse │ │
│ │ :5432 │ │ :3306 │ │ :27017 │ │ :8123 │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Redis │ │ Meilisearch │ │ MinIO │ │
│ │ :6379 │ │ :7700 │ │ :9001 │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
```
## 🚀 Services
### Core Applications
1. **Hanzo IAM** (Port 8000)
- Identity & Access Management (like Clerk)
- User authentication & authorization
- Social login providers (Google, GitHub)
- OAuth2/OpenID Connect server
- Multi-tenant support
2. **Hanzo Cloud** (Port 3000)
- AI Platform management dashboard
- Model configuration & pricing
- Usage analytics & monitoring
- Project & organization management
- API key management
3. **Hanzo Router** (Port 4000)
- Unified LLM gateway (100+ providers)
- Cost tracking & rate limiting
- Model routing & fallbacks
- OpenAI-compatible API
- MCP (Model Context Protocol) support
4. **Hanzo Chat** (Port 3081)
- AI chat interface
- Multi-model support via Router
- SSO via IAM
- Document handling & search
- Conversation management
### Data Stores
- **PostgreSQL**: Router config, Cloud data
- **MySQL**: IAM users & auth
- **MongoDB**: Chat conversations
- **ClickHouse**: Analytics & metrics
- **Redis**: Caching & sessions
- **Meilisearch**: Full-text search
- **MinIO**: S3-compatible object storage
## 📋 Access Points
| Service | URL | Description |
|---------|-----|-------------|
| Hanzo IAM | http://localhost:8000 | Identity management |
| Hanzo Cloud | http://localhost:3000 | Platform dashboard |
| Hanzo Router | http://localhost:4000 | LLM gateway API |
| Hanzo Chat | http://localhost:3081 | Chat interface |
| MinIO Console | http://localhost:9001 | Storage management |
## 🔑 Default Credentials
### IAM Users
- **Registration Required**: The system starts with no users. Please register your first account.
- **Demo Setup**: See [DEMO_SETUP.md](./DEMO_SETUP.md) for creating demo accounts
- **Quick Start**: Visit http://localhost:3081 and click "Sign up" to create your first account
### Service Keys
- **Router Master Key**: sk-hanzo-master-key
- **MinIO**: minio / miniosecret
## 🛠️ Configuration
### Model Configuration (via Cloud UI)
1. Access Cloud dashboard: http://localhost:3000
2. Navigate to Models section
3. Add/configure LLM providers:
- OpenAI models
- Anthropic models
- Custom endpoints
- Pricing & limits
### Authentication Flow
```
User → Chat → IAM (OAuth) → Authorized → Router → LLM Provider
Cloud (for config)
```
## 🚀 Quick Start
```bash
# Start the complete stack
docker compose up -d
# Wait for all services to be healthy
docker compose ps
# Access services:
# - IAM: http://localhost:8000
# - Cloud: http://localhost:3000
# - Chat: http://localhost:3081
```
## 🔧 Environment Variables
Create `.env` file:
```bash
# LLM Providers (at least one required)
OPENAI_API_KEY=your-key
ANTHROPIC_API_KEY=your-key
TOGETHER_API_KEY=your-key
# Optional: Social Login
GOOGLE_CLIENT_ID=your-client-id
GOOGLE_CLIENT_SECRET=your-client-secret
GITHUB_CLIENT_ID=your-client-id
GITHUB_CLIENT_SECRET=your-client-secret
```
## 📊 Using the Platform
### 1. Configure Models (Cloud)
- Login to Cloud with admin@hanzo.ai
- Add API keys for providers
- Configure model pricing
- Set rate limits
### 2. Manage Users (IAM)
- Create users/organizations
- Configure OAuth applications
- Set up social providers
- Manage permissions
### 3. Chat with AI (Chat)
- Login via IAM SSO
- Select models configured in Cloud
- Chat with automatic routing via Router
- Track usage in Cloud dashboard
## 🔄 Production Parity
This local setup mirrors production:
- Same service architecture
- Same authentication flow
- Same data storage patterns
- Same API interfaces
Migration to production requires:
1. Update database credentials
2. Configure proper domains
3. Set production API keys
4. Enable SSL/TLS
5. Configure cloud storage
## 🛟 Troubleshooting
### Service Health Checks
```bash
# Check all services
docker compose ps
# View logs
docker compose logs [service-name]
# Restart a service
docker compose restart [service-name]
```
### Common Issues
1. **IAM not accessible**
- Check MySQL is running
- Verify init data loaded
2. **Cloud build fails**
- Ensure Node.js dependencies installed
- Check PostgreSQL connection
3. **Router unhealthy**
- Verify PostgreSQL is running
- Check config file mounted
4. **Chat can't authenticate**
- Ensure IAM is healthy
- Check OAuth redirect URLs
## 🏗️ Development
For development with hot-reload:
```bash
docker compose -f compose.dev.yml up
```
This mounts source code for:
- Live editing
- Hot module replacement
- Instant updates
-188
View File
@@ -1,188 +0,0 @@
# Hanzo AI Chat Stack
A fully integrated AI chat platform powered by Hanzo AI infrastructure, featuring a customized chat interface with Hanzo Router as the unified LLM gateway.
## Quick Start
### Prerequisites
- Docker and Docker Compose installed
- At least one LLM API key (OpenAI, Anthropic, or Together AI)
### One-Command Deployment
```bash
# Set your API keys
export ANTHROPIC_API_KEY=your-api-key-here
# Optional: export OPENAI_API_KEY=...
# Optional: export TOGETHER_API_KEY=...
# Deploy the entire stack
make -f Makefile.hanzo deploy
```
This will:
1. Build all Docker images with Hanzo branding
2. Start all required services (PostgreSQL, Redis, MongoDB, Meilisearch)
3. Launch the Hanzo Router on port 4000
4. Start the Hanzo Chat UI on port 3081
5. Configure Nginx reverse proxy
## Access Points
- **Chat UI**: http://localhost:3081
- **Hanzo Router API**: http://localhost:4000/v1
- **Router Admin**: http://localhost:4000/ui
- **API Documentation**: http://localhost:4000/docs
## Architecture
```
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Hanzo Chat │────▶│ Hanzo Router │────▶│ LLM Providers │
│ (Custom UI) │ │ (Port 4000) │ │ (Anthropic, │
│ Port 3081 │ │ │ │ OpenAI, etc) │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │
▼ ▼
┌─────────────────┐ ┌──────────────────┐
│ MongoDB │ │ PostgreSQL │
│ (Chat History) │ │ (Router Data) │
└─────────────────┘ └──────────────────┘
│ │
▼ ▼
┌─────────────────┐ ┌──────────────────┐
│ Meilisearch │ │ Redis │
│ (Search) │ │ (Caching) │
└─────────────────┘ └──────────────────┘
```
## Available Models
### Hanzo AI Models
- **hanzo-zen-1**: Fast, efficient AI for most tasks (Claude 3.5 Sonnet)
- **hanzo-zen-1-pro**: Advanced reasoning for complex tasks (Claude 3 Opus)
### Additional Models
- GPT-4, GPT-3.5 Turbo (via OpenAI)
- Mixtral 8x7B (via Together AI)
- Any model supported by Hanzo Router
## Management Commands
```bash
# View all available commands
make -f Makefile.hanzo help
# Start/stop services
make -f Makefile.hanzo up
make -f Makefile.hanzo down
make -f Makefile.hanzo restart
# View logs
make -f Makefile.hanzo logs
make -f Makefile.hanzo logs-chat
make -f Makefile.hanzo logs-router
# Check service health
make -f Makefile.hanzo status
# Run tests
make -f Makefile.hanzo test
# Backup/restore data
make -f Makefile.hanzo backup
make -f Makefile.hanzo restore BACKUP=hanzo-backup-20240714-120000
```
## Configuration
### Environment Variables
Copy `.env.hanzo.example` to `.env` and configure:
```bash
# Required: At least one LLM API key
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
TOGETHER_API_KEY=...
# Optional: Customize passwords (recommended for production)
POSTGRES_PASSWORD=your-secure-password
MONGO_PASSWORD=your-secure-password
REDIS_PASSWORD=your-secure-password
LITELLM_MASTER_KEY=your-master-key
```
### Model Configuration
Edit `hanzo-config.yaml` to add or modify available models.
## MCP Integration
The Hanzo Chat stack includes Model Context Protocol (MCP) support for enhanced AI capabilities:
1. File operations and code analysis
2. Web search and browsing
3. Agent delegation
4. Tool execution
MCP servers are configured in `mcp_servers.json`.
## Development
### Local Development Setup
```bash
# Install dependencies
make -f Makefile.hanzo dev-setup
# Run frontend dev server
make -f Makefile.hanzo dev-frontend
# Run backend dev server
make -f Makefile.hanzo dev-backend
```
### Building Images
```bash
# Build locally
make -f Makefile.hanzo build
# Push to registry
make -f Makefile.hanzo push
```
## Production Deployment
For production deployment:
1. Update all passwords and keys in `.env`
2. Configure SSL certificates in `nginx.hanzo.conf`
3. Set proper domain names
4. Enable authentication providers
5. Configure monitoring and logging
```bash
# Deploy with production settings
make -f Makefile.hanzo prod-deploy
```
## Troubleshooting
### Services not starting
- Check Docker is running
- Verify API keys are set correctly
- Check port availability (3081, 4000, 5432, 6379, 27017, 7700)
### Chat not connecting to Router
- Verify Hanzo Router is healthy: `curl http://localhost:4000/health`
- Check API keys in environment
- Review logs: `make -f Makefile.hanzo logs-router`
### Database issues
- Ensure volumes have proper permissions
- Check disk space availability
- Review database logs
## Support
For issues and questions:
- GitHub: https://github.com/hanzoai
- Documentation: https://docs.hanzo.ai
+135 -418
View File
@@ -1,449 +1,166 @@
<h1 align="center">
🚅 LiteLLM
</h1>
<p align="center">
<p align="center">
<a href="https://render.com/deploy?repo=https://github.com/BerriAI/litellm" target="_blank" rel="nofollow"><img src="https://render.com/images/deploy-to-render-button.svg" alt="Deploy to Render"></a>
<a href="https://railway.app/template/HLP0Ub?referralCode=jch2ME">
<img src="https://railway.app/button.svg" alt="Deploy on Railway">
</a>
</p>
<p align="center">Call all LLM APIs using the OpenAI format [Bedrock, Huggingface, VertexAI, TogetherAI, Azure, OpenAI, Groq etc.]
<br>
</p>
<h4 align="center"><a href="https://docs.litellm.ai/docs/simple_proxy" target="_blank">LiteLLM Proxy Server (LLM Gateway)</a> | <a href="https://docs.litellm.ai/docs/hosted" target="_blank"> Hosted Proxy (Preview)</a> | <a href="https://docs.litellm.ai/docs/enterprise"target="_blank">Enterprise Tier</a></h4>
<h4 align="center">
<a href="https://pypi.org/project/litellm/" target="_blank">
<img src="https://img.shields.io/pypi/v/litellm.svg" alt="PyPI Version">
</a>
<a href="https://www.ycombinator.com/companies/berriai">
<img src="https://img.shields.io/badge/Y%20Combinator-W23-orange?style=flat-square" alt="Y Combinator W23">
</a>
<a href="https://wa.link/huol9n">
<img src="https://img.shields.io/static/v1?label=Chat%20on&message=WhatsApp&color=success&logo=WhatsApp&style=flat-square" alt="Whatsapp">
</a>
<a href="https://discord.gg/wuPM9dRgDw">
<img src="https://img.shields.io/static/v1?label=Chat%20on&message=Discord&color=blue&logo=Discord&style=flat-square" alt="Discord">
</a>
<a href="https://join.slack.com/share/enQtOTE0ODczMzk2Nzk4NC01YjUxNjY2YjBlYTFmNDRiZTM3NDFiYTM3MzVkODFiMDVjOGRjMmNmZTZkZTMzOWQzZGQyZWIwYjQ0MWExYmE3">
<img src="https://img.shields.io/static/v1?label=Chat%20on&message=Slack&color=black&logo=Slack&style=flat-square" alt="Slack">
</a>
</h4>
# Hanzo AI Chat
LiteLLM manages:
AI-powered chat platform with enterprise features, using Hanzo's cloud API or local deployment.
- Translate inputs to provider's `completion`, `embedding`, and `image_generation` endpoints
- [Consistent output](https://docs.litellm.ai/docs/completion/output), text responses will always be available at `['choices'][0]['message']['content']`
- Retry/fallback logic across multiple deployments (e.g. Azure/OpenAI) - [Router](https://docs.litellm.ai/docs/routing)
- Set Budgets & Rate limits per project, api key, model [LiteLLM Proxy Server (LLM Gateway)](https://docs.litellm.ai/docs/simple_proxy)
[**Jump to LiteLLM Proxy (LLM Gateway) Docs**](https://github.com/BerriAI/litellm?tab=readme-ov-file#openai-proxy---docs) <br>
[**Jump to Supported LLM Providers**](https://github.com/BerriAI/litellm?tab=readme-ov-file#supported-providers-docs)
🚨 **Stable Release:** Use docker images with the `-stable` tag. These have undergone 12 hour load tests, before being published. [More information about the release cycle here](https://docs.litellm.ai/docs/proxy/release_cycle)
Support for more providers. Missing a provider or LLM Platform, raise a [feature request](https://github.com/BerriAI/litellm/issues/new?assignees=&labels=enhancement&projects=&template=feature_request.yml&title=%5BFeature%5D%3A+).
# Usage ([**Docs**](https://docs.litellm.ai/docs/))
> [!IMPORTANT]
> LiteLLM v1.0.0 now requires `openai>=1.0.0`. Migration guide [here](https://docs.litellm.ai/docs/migration)
> LiteLLM v1.40.14+ now requires `pydantic>=2.0.0`. No changes required.
<a target="_blank" href="https://colab.research.google.com/github/BerriAI/litellm/blob/main/cookbook/liteLLM_Getting_Started.ipynb">
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
</a>
```shell
pip install litellm
```
```python
from litellm import completion
import os
## set ENV variables
os.environ["OPENAI_API_KEY"] = "your-openai-key"
os.environ["ANTHROPIC_API_KEY"] = "your-anthropic-key"
messages = [{ "content": "Hello, how are you?","role": "user"}]
# openai call
response = completion(model="openai/gpt-4o", messages=messages)
# anthropic call
response = completion(model="anthropic/claude-sonnet-4-20250514", messages=messages)
print(response)
```
### Response (OpenAI Format)
```json
{
"id": "chatcmpl-1214900a-6cdd-4148-b663-b5e2f642b4de",
"created": 1751494488,
"model": "claude-sonnet-4-20250514",
"object": "chat.completion",
"system_fingerprint": null,
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Hello! I'm doing well, thank you for asking. I'm here and ready to help with whatever you'd like to discuss or work on. How are you doing today?",
"role": "assistant",
"tool_calls": null,
"function_call": null
}
}
],
"usage": {
"completion_tokens": 39,
"prompt_tokens": 13,
"total_tokens": 52,
"completion_tokens_details": null,
"prompt_tokens_details": {
"audio_tokens": null,
"cached_tokens": 0
},
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0
}
}
```
Call any model supported by a provider, with `model=<provider_name>/<model_name>`. There might be provider-specific details here, so refer to [provider docs for more information](https://docs.litellm.ai/docs/providers)
## Async ([Docs](https://docs.litellm.ai/docs/completion/stream#async-completion))
```python
from litellm import acompletion
import asyncio
async def test_get_response():
user_message = "Hello, how are you?"
messages = [{"content": user_message, "role": "user"}]
response = await acompletion(model="openai/gpt-4o", messages=messages)
return response
response = asyncio.run(test_get_response())
print(response)
```
## Streaming ([Docs](https://docs.litellm.ai/docs/completion/stream))
liteLLM supports streaming the model response back, pass `stream=True` to get a streaming iterator in response.
Streaming is supported for all models (Bedrock, Huggingface, TogetherAI, Azure, OpenAI, etc.)
```python
from litellm import completion
response = completion(model="openai/gpt-4o", messages=messages, stream=True)
for part in response:
print(part.choices[0].delta.content or "")
# claude sonnet 4
response = completion('anthropic/claude-sonnet-4-20250514', messages, stream=True)
for part in response:
print(part)
```
### Response chunk (OpenAI Format)
```json
{
"id": "chatcmpl-fe575c37-5004-4926-ae5e-bfbc31f356ca",
"created": 1751494808,
"model": "claude-sonnet-4-20250514",
"object": "chat.completion.chunk",
"system_fingerprint": null,
"choices": [
{
"finish_reason": null,
"index": 0,
"delta": {
"provider_specific_fields": null,
"content": "Hello",
"role": "assistant",
"function_call": null,
"tool_calls": null,
"audio": null
},
"logprobs": null
}
],
"provider_specific_fields": null,
"stream_options": null,
"citations": null
}
```
## Logging Observability ([Docs](https://docs.litellm.ai/docs/observability/callbacks))
LiteLLM exposes pre defined callbacks to send data to Lunary, MLflow, Langfuse, DynamoDB, s3 Buckets, Helicone, Promptlayer, Traceloop, Athina, Slack
```python
from litellm import completion
## set env variables for logging tools (when using MLflow, no API key set up is required)
os.environ["LUNARY_PUBLIC_KEY"] = "your-lunary-public-key"
os.environ["HELICONE_API_KEY"] = "your-helicone-auth-key"
os.environ["LANGFUSE_PUBLIC_KEY"] = ""
os.environ["LANGFUSE_SECRET_KEY"] = ""
os.environ["ATHINA_API_KEY"] = "your-athina-api-key"
os.environ["OPENAI_API_KEY"] = "your-openai-key"
# set callbacks
litellm.success_callback = ["lunary", "mlflow", "langfuse", "athina", "helicone"] # log input/output to lunary, langfuse, supabase, athina, helicone etc
#openai call
response = completion(model="openai/gpt-4o", messages=[{"role": "user", "content": "Hi 👋 - i'm openai"}])
```
# LiteLLM Proxy Server (LLM Gateway) - ([Docs](https://docs.litellm.ai/docs/simple_proxy))
Track spend + Load Balance across multiple projects
[Hosted Proxy (Preview)](https://docs.litellm.ai/docs/hosted)
The proxy provides:
1. [Hooks for auth](https://docs.litellm.ai/docs/proxy/virtual_keys#custom-auth)
2. [Hooks for logging](https://docs.litellm.ai/docs/proxy/logging#step-1---create-your-custom-litellm-callback-class)
3. [Cost tracking](https://docs.litellm.ai/docs/proxy/virtual_keys#tracking-spend)
4. [Rate Limiting](https://docs.litellm.ai/docs/proxy/users#set-rate-limits)
## 📖 Proxy Endpoints - [Swagger Docs](https://litellm-api.up.railway.app/)
## Quick Start Proxy - CLI
```shell
pip install 'litellm[proxy]'
```
### Step 1: Start litellm proxy
```shell
$ litellm --model huggingface/bigcode/starcoder
#INFO: Proxy running on http://0.0.0.0:4000
```
### Step 2: Make ChatCompletions Request to Proxy
> [!IMPORTANT]
> 💡 [Use LiteLLM Proxy with Langchain (Python, JS), OpenAI SDK (Python, JS) Anthropic SDK, Mistral SDK, LlamaIndex, Instructor, Curl](https://docs.litellm.ai/docs/proxy/user_keys)
```python
import openai # openai v1.0.0+
client = openai.OpenAI(api_key="anything",base_url="http://0.0.0.0:4000") # set proxy to base_url
# request sent to model set on litellm proxy, `litellm --model`
response = client.chat.completions.create(model="gpt-3.5-turbo", messages = [
{
"role": "user",
"content": "this is a test request, write a short poem"
}
])
print(response)
```
## Proxy Key Management ([Docs](https://docs.litellm.ai/docs/proxy/virtual_keys))
Connect the proxy with a Postgres DB to create proxy keys
## Quick Start
```bash
# Get the code
git clone https://github.com/BerriAI/litellm
# Clone and setup
git clone https://github.com/hanzoai/chat.git
cd chat
# Go to folder
cd litellm
# Copy environment template
cp .env.example .env
# Add the master key - you can change this after setup
echo 'LITELLM_MASTER_KEY="sk-1234"' > .env
# Edit .env and add your Hanzo API key
# Get your key at: https://hanzo.ai/dashboard
nano .env
# Add the litellm salt key - you cannot change this after adding a model
# It is used to encrypt / decrypt your LLM API Key credentials
# We recommend - https://1password.com/password-generator/
# password generator to get a random hash for litellm salt key
echo 'LITELLM_SALT_KEY="sk-1234"' >> .env
source .env
# Start
docker-compose up
# Start the platform
make up
```
Access the chat at http://localhost:3081
UI on `/ui` on your proxy server
![ui_3](https://github.com/BerriAI/litellm/assets/29436595/47c97d5e-b9be-4839-b28c-43d7f4f10033)
Set budgets and rate limits across multiple projects
`POST /key/generate`
### Request
```shell
curl 'http://0.0.0.0:4000/key/generate' \
--header 'Authorization: Bearer sk-1234' \
--header 'Content-Type: application/json' \
--data-raw '{"models": ["gpt-3.5-turbo", "gpt-4", "claude-2"], "duration": "20m","metadata": {"user": "ishaan@berri.ai", "team": "core-infra"}}'
```
### Expected Response
```shell
{
"key": "sk-kdEXbIqZRwEeEiHwdg7sFA", # Bearer token
"expires": "2023-11-19T01:38:25.838000+00:00" # datetime object
}
```
## Supported Providers ([Docs](https://docs.litellm.ai/docs/providers))
| Provider | [Completion](https://docs.litellm.ai/docs/#basic-usage) | [Streaming](https://docs.litellm.ai/docs/completion/stream#streaming-responses) | [Async Completion](https://docs.litellm.ai/docs/completion/stream#async-completion) | [Async Streaming](https://docs.litellm.ai/docs/completion/stream#async-streaming) | [Async Embedding](https://docs.litellm.ai/docs/embedding/supported_embedding) | [Async Image Generation](https://docs.litellm.ai/docs/image_generation) |
|-------------------------------------------------------------------------------------|---------------------------------------------------------|---------------------------------------------------------------------------------|-------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------|-------------------------------------------------------------------------------|-------------------------------------------------------------------------|
| [openai](https://docs.litellm.ai/docs/providers/openai) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [Meta - Llama API](https://docs.litellm.ai/docs/providers/meta_llama) | ✅ | ✅ | ✅ | ✅ | | |
| [azure](https://docs.litellm.ai/docs/providers/azure) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [AI/ML API](https://docs.litellm.ai/docs/providers/aiml) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [aws - sagemaker](https://docs.litellm.ai/docs/providers/aws_sagemaker) | ✅ | ✅ | ✅ | ✅ | ✅ | |
| [aws - bedrock](https://docs.litellm.ai/docs/providers/bedrock) | ✅ | ✅ | ✅ | ✅ | ✅ | |
| [google - vertex_ai](https://docs.litellm.ai/docs/providers/vertex) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [google - palm](https://docs.litellm.ai/docs/providers/palm) | ✅ | ✅ | ✅ | ✅ | | |
| [google AI Studio - gemini](https://docs.litellm.ai/docs/providers/gemini) | ✅ | ✅ | ✅ | ✅ | | |
| [mistral ai api](https://docs.litellm.ai/docs/providers/mistral) | ✅ | ✅ | ✅ | ✅ | ✅ | |
| [cloudflare AI Workers](https://docs.litellm.ai/docs/providers/cloudflare_workers) | ✅ | ✅ | ✅ | ✅ | | |
| [cohere](https://docs.litellm.ai/docs/providers/cohere) | ✅ | ✅ | ✅ | ✅ | ✅ | |
| [anthropic](https://docs.litellm.ai/docs/providers/anthropic) | ✅ | ✅ | ✅ | ✅ | | |
| [empower](https://docs.litellm.ai/docs/providers/empower) | ✅ | ✅ | ✅ | ✅ |
| [huggingface](https://docs.litellm.ai/docs/providers/huggingface) | ✅ | ✅ | ✅ | ✅ | ✅ | |
| [replicate](https://docs.litellm.ai/docs/providers/replicate) | ✅ | ✅ | ✅ | ✅ | | |
| [together_ai](https://docs.litellm.ai/docs/providers/togetherai) | ✅ | ✅ | ✅ | ✅ | | |
| [openrouter](https://docs.litellm.ai/docs/providers/openrouter) | ✅ | ✅ | ✅ | ✅ | | |
| [ai21](https://docs.litellm.ai/docs/providers/ai21) | ✅ | ✅ | ✅ | ✅ | | |
| [baseten](https://docs.litellm.ai/docs/providers/baseten) | ✅ | ✅ | ✅ | ✅ | | |
| [vllm](https://docs.litellm.ai/docs/providers/vllm) | ✅ | ✅ | ✅ | ✅ | | |
| [nlp_cloud](https://docs.litellm.ai/docs/providers/nlp_cloud) | ✅ | ✅ | ✅ | ✅ | | |
| [aleph alpha](https://docs.litellm.ai/docs/providers/aleph_alpha) | ✅ | ✅ | ✅ | ✅ | | |
| [petals](https://docs.litellm.ai/docs/providers/petals) | ✅ | ✅ | ✅ | ✅ | | |
| [ollama](https://docs.litellm.ai/docs/providers/ollama) | ✅ | ✅ | ✅ | ✅ | ✅ | |
| [deepinfra](https://docs.litellm.ai/docs/providers/deepinfra) | ✅ | ✅ | ✅ | ✅ | | |
| [perplexity-ai](https://docs.litellm.ai/docs/providers/perplexity) | ✅ | ✅ | ✅ | ✅ | | |
| [Groq AI](https://docs.litellm.ai/docs/providers/groq) | ✅ | ✅ | ✅ | ✅ | | |
| [Deepseek](https://docs.litellm.ai/docs/providers/deepseek) | ✅ | ✅ | ✅ | ✅ | | |
| [anyscale](https://docs.litellm.ai/docs/providers/anyscale) | ✅ | ✅ | ✅ | ✅ | | |
| [IBM - watsonx.ai](https://docs.litellm.ai/docs/providers/watsonx) | ✅ | ✅ | ✅ | ✅ | ✅ | |
| [voyage ai](https://docs.litellm.ai/docs/providers/voyage) | | | | | ✅ | |
| [xinference [Xorbits Inference]](https://docs.litellm.ai/docs/providers/xinference) | | | | | ✅ | |
| [FriendliAI](https://docs.litellm.ai/docs/providers/friendliai) | ✅ | ✅ | ✅ | ✅ | | |
| [Galadriel](https://docs.litellm.ai/docs/providers/galadriel) | ✅ | ✅ | ✅ | ✅ | | |
| [Novita AI](https://novita.ai/models/llm?utm_source=github_litellm&utm_medium=github_readme&utm_campaign=github_link) | ✅ | ✅ | ✅ | ✅ | | |
| [Featherless AI](https://docs.litellm.ai/docs/providers/featherless_ai) | ✅ | ✅ | ✅ | ✅ | | |
| [Nebius AI Studio](https://docs.litellm.ai/docs/providers/nebius) | ✅ | ✅ | ✅ | ✅ | ✅ | |
[**Read the Docs**](https://docs.litellm.ai/docs/)
## Contributing
Interested in contributing? Contributions to LiteLLM Python SDK, Proxy Server, and LLM integrations are both accepted and highly encouraged!
**Quick start:** `git clone``make install-dev``make format``make lint``make test-unit`
See our comprehensive [Contributing Guide (CONTRIBUTING.md)](CONTRIBUTING.md) for detailed instructions.
# Enterprise
For companies that need better security, user management and professional support
[Talk to founders](https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat)
This covers:
-**Features under the [LiteLLM Commercial License](https://docs.litellm.ai/docs/proxy/enterprise):**
-**Feature Prioritization**
-**Custom Integrations**
-**Professional Support - Dedicated discord + slack**
-**Custom SLAs**
-**Secure access with Single Sign-On**
# Contributing
We welcome contributions to LiteLLM! Whether you're fixing bugs, adding features, or improving documentation, we appreciate your help.
## Quick Start for Contributors
## Development
### Basic Development (with hot reload)
```bash
git clone https://github.com/BerriAI/litellm.git
cd litellm
make install-dev # Install development dependencies
make format # Format your code
make lint # Run all linting checks
make test-unit # Run unit tests
make dev
```
For detailed contributing guidelines, see [CONTRIBUTING.md](CONTRIBUTING.md).
## Code Quality / Linting
LiteLLM follows the [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html).
Our automated checks include:
- **Black** for code formatting
- **Ruff** for linting and code quality
- **MyPy** for type checking
- **Circular import detection**
- **Import safety checks**
Run all checks locally:
### Full Development (with local router)
```bash
make lint # Run all linting (matches CI)
make format-check # Check formatting only
# Set your LLM API keys
export ANTHROPIC_API_KEY=your-key
export OPENAI_API_KEY=your-key
# Start full dev stack
make dev-full
```
All these checks must pass before your PR can be merged.
## Architecture
```
┌─────────────────────────┐ ┌─────────────────────────┐
│ Hanzo Chat UI │────▶│ api.hanzo.ai │
│ (LibreChat Fork) │ │ (or local router) │
│ localhost:3081 │ │ │
└─────────────────────────┘ │ • 100+ AI Models │
│ │ • MCP Tools │
│ │ • Code Execution │
▼ └─────────────────────────┘
┌─────────────────────────┐
│ Local Data Storage │
│ • MongoDB (chat history)│
│ • Meilisearch (search) │
└─────────────────────────┘
```
# Support / talk with founders
## Configuration
- [Schedule Demo 👋](https://calendly.com/d/4mp-gd3-k5k/berriai-1-1-onboarding-litellm-hosted-version)
- [Community Discord 💭](https://discord.gg/wuPM9dRgDw)
- [Community Slack 💭](https://join.slack.com/share/enQtOTE0ODczMzk2Nzk4NC01YjUxNjY2YjBlYTFmNDRiZTM3NDFiYTM3MzVkODFiMDVjOGRjMmNmZTZkZTMzOWQzZGQyZWIwYjQ0MWExYmE3)
- Our numbers 📞 +1 (770) 8783-106 / +1 (412) 618-6238
- Our emails ✉️ ishaan@berri.ai / krrish@berri.ai
### Required Environment Variables
# Why did we build this
```env
# Your Hanzo API key (required)
OPENAI_API_KEY=sk-hanzo-your-key-here
- **Need for simplicity**: Our code started to get extremely complicated managing & translating calls between Azure, OpenAI and Cohere.
# API endpoint (default: Hanzo cloud)
OPENAI_BASE_URL=https://api.hanzo.ai/v1
# Contributors
# Features
MCP_ENABLED=true
ALLOW_REGISTRATION=true
```
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
### Optional Customization
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
```env
# Branding
APP_TITLE=My AI Assistant
CUSTOM_FOOTER=Powered by Hanzo AI
<!-- ALL-CONTRIBUTORS-LIST:END -->
# Security
JWT_SECRET=your-secret-key
```
<a href="https://github.com/BerriAI/litellm/graphs/contributors">
<img src="https://contrib.rocks/image?repo=BerriAI/litellm" />
</a>
## Commands
### Basic Usage
```bash
make up # Start services
make down # Stop services
make logs # View logs
make status # Check health
make clean # Remove all data
```
## Run in Developer mode
### Services
1. Setup .env file in root
2. Run dependant services `docker-compose up db prometheus`
### Development
```bash
make dev # Dev mode with hot reload
make build # Build containers
make test # Run tests
make lint # Check code quality
make format # Format code
```
### Backend
1. (In root) create virtual environment `python -m venv .venv`
2. Activate virtual environment `source .venv/bin/activate`
3. Install dependencies `pip install -e ".[all]"`
4. Start proxy backend `uvicorn litellm.proxy.proxy_server:app --host localhost --port 4000 --reload`
### Production
```bash
make prod # Deploy with Traefik
make backup # Backup database
```
### Frontend
1. Navigate to `ui/litellm-dashboard`
2. Install dependencies `npm install`
3. Run `npm run dev` to start the dashboard
## Docker Compose Structure
- `compose.yml` - Base configuration for local development
- `compose.dev.yml` - Development overrides (hot reload, local router)
- `compose.prod.yml` - Production overrides (Traefik, security)
## Features
- 🤖 **100+ AI Models** via Hanzo Router
- 💬 **Clean UI** based on LibreChat
- 🔍 **Full-Text Search** with Meilisearch
- 📝 **Persistent Chat History**
- 🛠️ **MCP Tools** for enhanced capabilities
- 🚀 **Code Execution** via secure runtime
- 🔐 **Enterprise Security** with JWT auth
## Troubleshooting
### Chat not loading
```bash
# Check service status
make status
# View logs
make logs-chat
# Verify API key
echo $OPENAI_API_KEY
```
### Database issues
```bash
# Reset database
make db-reset
# Export data
make db-export
# Import data
make db-import FILE=backup.json
```
## Additional Documentation
- [Production Deployment](./docs/production-domains.md)
- [IAM Integration](./docs/iam-integration.md)
- [Platform Overview](./docs/platform-overview.md)
- [Demo User Guide](./docs/demo-user.md)
## Support
- Documentation: https://docs.hanzo.ai
- Issues: https://github.com/hanzoai/chat/issues
- Discord: https://discord.gg/hanzoai
-218
View File
@@ -1,218 +0,0 @@
# Simplified Hanzo Chat Stack for testing favicon
# This runs without IAM/Cloud/Services for quick testing
services:
# PostgreSQL Database (for Router)
postgres:
image: postgres:16-alpine
container_name: hanzo-postgres
environment:
POSTGRES_USER: hanzo
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-hanzo123}
POSTGRES_DB: hanzo_chat
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U hanzo"]
interval: 10s
timeout: 5s
retries: 5
networks:
- hanzo-network
# Redis Cache
redis:
image: redis:7-alpine
container_name: hanzo-redis
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD:-hanzosecret}
ports:
- "6379:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD:-hanzosecret}", "ping"]
interval: 10s
timeout: 5s
retries: 5
networks:
- hanzo-network
# MongoDB for Chat History
mongodb:
image: mongo:7-jammy
container_name: hanzo-mongodb
environment:
MONGO_INITDB_ROOT_USERNAME: hanzo
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD:-hanzo123}
MONGO_INITDB_DATABASE: HanzoChat
ports:
- "27017:27017"
volumes:
- mongodb_data:/data/db
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 5s
retries: 5
networks:
- hanzo-network
# Meilisearch for Full-Text Search
meilisearch:
image: getmeili/meilisearch:v1.9
container_name: hanzo-meilisearch
environment:
MEILI_MASTER_KEY: ${MEILI_MASTER_KEY:-HanzoMeiliMasterKey}
MEILI_ENV: production
ports:
- "7700:7700"
volumes:
- meilisearch_data:/meili_data
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:7700/health"]
interval: 10s
timeout: 5s
retries: 5
networks:
- hanzo-network
# Hanzo Router (LiteLLM Gateway)
router:
image: hanzo/router:latest
container_name: hanzo-router
ports:
- "4000:4000"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
environment:
# Database
DATABASE_URL: postgresql://hanzo:${POSTGRES_PASSWORD:-hanzo123}@postgres:5432/hanzo_chat
REDIS_URL: redis://:${REDIS_PASSWORD:-hanzosecret}@redis:6379
# Router Configuration
ROUTER_MASTER_KEY: ${ROUTER_MASTER_KEY:-sk-hanzo-master-key}
LITELLM_MASTER_KEY: ${ROUTER_MASTER_KEY:-sk-hanzo-master-key} # For compatibility
# LLM API Keys
OPENAI_API_KEY: ${OPENAI_API_KEY}
ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY}
TOGETHER_API_KEY: ${TOGETHER_API_KEY}
# Logging
ROUTER_LOG_LEVEL: INFO
DEBUG: ${DEBUG:-false}
volumes:
- ./config.yaml:/app/config.yaml:ro
command: ["--config", "/app/config.yaml", "--port", "4000", "--num_workers", "${ROUTER_WORKERS:-4}"]
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:4000/health"]
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
networks:
- hanzo-network
# Hanzo Chat Frontend
chat:
image: ghcr.io/hanzoai/chat:latest
container_name: hanzo-chat
ports:
- "3081:3080"
depends_on:
mongodb:
condition: service_healthy
meilisearch:
condition: service_healthy
router:
condition: service_healthy
environment:
# Server Configuration
HOST: 0.0.0.0
PORT: 3080
# Database
MONGO_URI: mongodb://hanzo:${MONGO_PASSWORD:-hanzo123}@mongodb:27017/HanzoChat?authSource=admin
# Domain
DOMAIN_CLIENT: ${DOMAIN_CLIENT:-http://localhost:3081}
DOMAIN_SERVER: ${DOMAIN_SERVER:-http://localhost:3081}
# Branding
APP_TITLE: "Hanzo AI Chat"
CUSTOM_FOOTER: "Powered by Hanzo AI"
# Router Gateway
OPENAI_API_KEY: proxy
OPENAI_BASE_URL: http://router:4000/v1
# Auth & Security
JWT_SECRET: ${JWT_SECRET:-hanzo-jwt-secret-change-in-production}
JWT_REFRESH_SECRET: ${JWT_REFRESH_SECRET:-hanzo-refresh-secret-change-in-production}
CREDS_KEY: ${CREDS_KEY:-hanzo-creds-key-change-in-production}
CREDS_IV: ${CREDS_IV:-hanzo-creds-iv-change}
# Search
MEILI_HOST: http://meilisearch:7700
MEILI_MASTER_KEY: ${MEILI_MASTER_KEY:-HanzoMeiliMasterKey}
# MCP Integration
MCP_ENABLED: true
# Logging
DEBUG_LOGGING: ${DEBUG:-false}
# Allow local registration for testing
ALLOW_REGISTRATION: true
ALLOW_UNVERIFIED_EMAIL_LOGIN: true
volumes:
- ./scripts:/app/scripts:ro
- ./client/dist/assets:/app/client/dist/assets:ro
- ./client/dist/favicon.ico:/app/client/dist/favicon.ico:ro
- chat_uploads:/app/uploads
- chat_logs:/app/logs
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3080/health"]
interval: 10s
timeout: 5s
retries: 5
networks:
- hanzo-network
# Hanzo Runtime API (Mock for testing)
runtime:
image: node:20-alpine
container_name: hanzo-runtime
ports:
- "3003:3000"
environment:
NODE_ENV: development
PORT: 3000
volumes:
- ./runtime-mock.js:/app/server.js:ro
command: ["node", "/app/server.js"]
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:3000/api/health"]
interval: 10s
timeout: 5s
retries: 5
networks:
- hanzo-network
volumes:
postgres_data:
redis_data:
mongodb_data:
meilisearch_data:
chat_uploads:
chat_logs:
networks:
hanzo-network:
driver: bridge
+85 -195
View File
@@ -1,215 +1,105 @@
# Hanzo AI Chat Stack - Development Environment
# This mounts source code for live editing
# Use with: docker compose -f compose.dev.yml up
# Hanzo AI Chat - Development Override
# Use with: docker compose -f compose.yml -f compose.dev.yml up
# This mounts source code for live development
services:
# PostgreSQL Database
postgres:
image: postgres:16-alpine
container_name: hanzo-postgres-dev
environment:
POSTGRES_USER: hanzo
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-hanzo123}
POSTGRES_DB: hanzo_chat
ports:
- "5432:5432"
volumes:
- postgres_data_dev:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U hanzo"]
interval: 10s
timeout: 5s
retries: 5
networks:
- hanzo-network-dev
# Redis Cache
redis:
image: redis:7-alpine
container_name: hanzo-redis-dev
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD:-hanzosecret}
ports:
- "6379:6379"
volumes:
- redis_data_dev:/data
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD:-hanzosecret}", "ping"]
interval: 10s
timeout: 5s
retries: 5
networks:
- hanzo-network-dev
# MongoDB for Chat History
mongodb:
image: mongo:7-jammy
container_name: hanzo-mongodb-dev
environment:
MONGO_INITDB_ROOT_USERNAME: hanzo
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD:-hanzo123}
MONGO_INITDB_DATABASE: HanzoChat
ports:
- "27017:27017"
volumes:
- mongodb_data_dev:/data/db
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 5s
retries: 5
networks:
- hanzo-network-dev
# Meilisearch for Full-Text Search
meilisearch:
image: getmeili/meilisearch:v1.9
container_name: hanzo-meilisearch-dev
environment:
MEILI_MASTER_KEY: ${MEILI_MASTER_KEY:-HanzoMeiliMasterKey}
MEILI_ENV: development
ports:
- "7700:7700"
volumes:
- meilisearch_data_dev:/meili_data
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:7700/health"]
interval: 10s
timeout: 5s
retries: 5
networks:
- hanzo-network-dev
# Hanzo Router (Development Mode with Hot Reload)
router:
# Override chat service for development
chat:
build:
context: ../router
dockerfile: Dockerfile.dev
target: development
container_name: hanzo-router-dev
context: .
dockerfile: docker/Dockerfile.dev
volumes:
# Mount source code for hot reloading
- ./api:/app/api:cached
- ./client:/app/client:cached
- ./packages:/app/packages:cached
- ./config:/app/config:cached
# Exclude node_modules
- /app/node_modules
- /app/api/node_modules
- /app/client/node_modules
environment:
# Development settings
NODE_ENV: development
DEBUG: ${DEBUG:-true}
# Hot reload
CHOKIDAR_USEPOLLING: true
WATCHPACK_POLLING: true
command: npm run dev
# Optional: Local Hanzo Router for development
router:
image: hanzoai/llm:latest
container_name: hanzo-router
ports:
- "4000:4000"
environment:
# Database
DATABASE_URL: postgresql://hanzo:${POSTGRES_PASSWORD:-hanzo123}@postgres:5432/hanzo_router
# Redis
REDIS_URL: redis://:${REDIS_PASSWORD:-hanzosecret}@redis:6379
# LLM Keys (at least one required)
ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-}
OPENAI_API_KEY: ${OPENAI_REALKEY:-}
TOGETHER_API_KEY: ${TOGETHER_API_KEY:-}
# Router Settings
LITELLM_MASTER_KEY: ${LITELLM_MASTER_KEY:-sk-hanzo-local-dev}
UI_USERNAME: ${UI_USERNAME:-admin}
UI_PASSWORD: ${UI_PASSWORD:-admin}
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
environment:
# Database
DATABASE_URL: postgresql://hanzo:${POSTGRES_PASSWORD:-hanzo123}@postgres:5432/hanzo_chat
REDIS_URL: redis://:${REDIS_PASSWORD:-hanzosecret}@redis:6379
# Router Configuration
ROUTER_MASTER_KEY: ${ROUTER_MASTER_KEY:-sk-hanzo-master-key}
LITELLM_MASTER_KEY: ${ROUTER_MASTER_KEY:-sk-hanzo-master-key}
# LLM API Keys
OPENAI_API_KEY: ${OPENAI_API_KEY}
ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY}
TOGETHER_API_KEY: ${TOGETHER_API_KEY}
# Development
LITELLM_LOG: DEBUG
DEBUG: true
PYTHONUNBUFFERED: 1
volumes:
# Mount source code for development
- ../router/litellm:/app/litellm:ro
- ../router/pyproject.toml:/app/pyproject.toml:ro
- ./hanzo-config.yaml:/app/config.yaml:ro
command: ["--config", "/app/config.yaml", "--port", "4000", "--num_workers", "1", "--detailed_debug"]
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:4000/health/readiness"]
interval: 10s
timeout: 5s
retries: 10
networks:
- hanzo-network-dev
- hanzo-network
profiles:
- with-router
# Hanzo Chat Frontend (Development Mode)
chat:
build:
context: .
dockerfile: Dockerfile.dev
target: development
container_name: hanzo-chat-dev
ports:
- "3081:3080"
depends_on:
mongodb:
condition: service_healthy
meilisearch:
condition: service_healthy
router:
condition: service_healthy
# PostgreSQL for Router (only if using local router)
postgres:
image: postgres:16-alpine
container_name: hanzo-postgres
environment:
# Server Configuration
HOST: 0.0.0.0
PORT: 3080
NODE_ENV: development
# Database
MONGO_URI: mongodb://hanzo:${MONGO_PASSWORD:-hanzo123}@mongodb:27017/HanzoChat?authSource=admin
# Domain
DOMAIN_CLIENT: ${DOMAIN_CLIENT:-http://localhost:3081}
DOMAIN_SERVER: ${DOMAIN_SERVER:-http://localhost:3081}
# Branding
APP_TITLE: "Hanzo AI Chat (Dev)"
CUSTOM_FOOTER: "Development Environment"
# Router Gateway
OPENAI_API_KEY: proxy
OPENAI_BASE_URL: http://router:4000/v1
# Auth & Security
JWT_SECRET: ${JWT_SECRET:-dev-jwt-secret}
JWT_REFRESH_SECRET: ${JWT_REFRESH_SECRET:-dev-refresh-secret}
CREDS_KEY: ${CREDS_KEY:-dev-creds-key}
CREDS_IV: ${CREDS_IV:-dev-creds-iv}
# Features
ALLOW_REGISTRATION: true
ALLOW_UNVERIFIED_EMAIL_LOGIN: true
# Search
MEILI_HOST: http://meilisearch:7700
MEILI_MASTER_KEY: ${MEILI_MASTER_KEY:-HanzoMeiliMasterKey}
# MCP Integration
MCP_ENABLED: true
# Logging
DEBUG_LOGGING: true
POSTGRES_USER: hanzo
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-hanzo123}
POSTGRES_DB: hanzo_router
volumes:
# Mount source for development
- ./api:/app/api:ro
- ./client:/app/client:ro
- ./packages:/app/packages:ro
- ./package.json:/app/package.json:ro
- ./client/dist/assets:/app/client/dist/assets:ro
- chat_uploads_dev:/app/uploads
- chat_logs_dev:/app/logs
# Node modules volume for faster rebuilds
- node_modules:/app/node_modules
command: ["npm", "run", "dev"]
- postgres_data:/var/lib/postgresql/data
networks:
- hanzo-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3080/health"]
test: ["CMD-SHELL", "pg_isready -U hanzo"]
interval: 10s
timeout: 5s
retries: 10
retries: 5
profiles:
- with-router
# Redis for Router (only if using local router)
redis:
image: redis:7-alpine
container_name: hanzo-redis
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD:-hanzosecret}
volumes:
- redis_data:/data
networks:
- hanzo-network-dev
- hanzo-network
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD:-hanzosecret}", "ping"]
interval: 10s
timeout: 5s
retries: 5
profiles:
- with-router
volumes:
postgres_data_dev:
redis_data_dev:
mongodb_data_dev:
meilisearch_data_dev:
chat_uploads_dev:
chat_logs_dev:
node_modules:
networks:
hanzo-network-dev:
driver: bridge
postgres_data:
redis_data:
+113
View File
@@ -0,0 +1,113 @@
# Hanzo AI Chat - Production Override
# Use with: docker compose -f compose.yml -f compose.prod.yml up -d
# Requires Traefik reverse proxy running
services:
# Production chat configuration
chat:
image: hanzoai/chat:${VERSION:-latest}
container_name: hanzo-chat-prod
restart: unless-stopped
ports: [] # No direct port exposure in production
environment:
# Production settings
NODE_ENV: production
ALLOW_REGISTRATION: ${ALLOW_REGISTRATION:-false}
# Use production API
OPENAI_BASE_URL: https://api.hanzo.ai/v1
# Production secrets (use real values)
JWT_SECRET: ${JWT_SECRET:?JWT_SECRET is required}
OPENAI_API_KEY: ${OPENAI_API_KEY:?OPENAI_API_KEY is required}
labels:
# Traefik routing
- "traefik.enable=true"
- "traefik.docker.network=traefik"
# HTTPS router
- "traefik.http.routers.hanzo-chat.rule=Host(`chat.hanzo.ai`)"
- "traefik.http.routers.hanzo-chat.entrypoints=websecure"
- "traefik.http.routers.hanzo-chat.tls=true"
- "traefik.http.routers.hanzo-chat.tls.certresolver=letsencrypt"
# Service
- "traefik.http.services.hanzo-chat.loadbalancer.server.port=3080"
# Security headers
- "traefik.http.middlewares.hanzo-chat-headers.headers.stsSeconds=31536000"
- "traefik.http.middlewares.hanzo-chat-headers.headers.stsIncludeSubdomains=true"
- "traefik.http.middlewares.hanzo-chat-headers.headers.stsPreload=true"
- "traefik.http.middlewares.hanzo-chat-headers.headers.contentTypeNosniff=true"
- "traefik.http.middlewares.hanzo-chat-headers.headers.browserXssFilter=true"
- "traefik.http.middlewares.hanzo-chat-headers.headers.referrerPolicy=strict-origin-when-cross-origin"
- "traefik.http.middlewares.hanzo-chat-headers.headers.customFrameOptionsValue=SAMEORIGIN"
# Apply middlewares
- "traefik.http.routers.hanzo-chat.middlewares=hanzo-chat-headers"
networks:
- hanzo-network
- traefik
deploy:
resources:
limits:
cpus: '2'
memory: 2G
reservations:
cpus: '0.5'
memory: 512M
# MongoDB production settings
mongodb:
restart: unless-stopped
volumes:
- mongodb_data:/data/db
- mongodb_backup:/backup
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_USERNAME:?MONGO_USERNAME is required}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD:?MONGO_PASSWORD is required}
deploy:
resources:
limits:
cpus: '1'
memory: 1G
# Meilisearch production settings
meilisearch:
restart: unless-stopped
environment:
MEILI_ENV: production
MEILI_MASTER_KEY: ${MEILI_MASTER_KEY:?MEILI_MASTER_KEY is required}
deploy:
resources:
limits:
cpus: '1'
memory: 1G
# Optional: MongoDB backup service
mongodb-backup:
image: hanzoai/mongodb-backup:latest
container_name: hanzo-mongodb-backup
restart: unless-stopped
environment:
MONGO_URI: mongodb://${MONGO_USERNAME}:${MONGO_PASSWORD}@mongodb:27017/HanzoChat?authSource=admin
BACKUP_SCHEDULE: "0 2 * * *" # Daily at 2 AM
BACKUP_RETENTION_DAYS: 7
S3_BUCKET: ${BACKUP_S3_BUCKET:-}
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID:-}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY:-}
volumes:
- mongodb_backup:/backup
depends_on:
- mongodb
networks:
- hanzo-network
profiles:
- with-backup
volumes:
mongodb_backup:
networks:
traefik:
external: true
+43 -519
View File
@@ -1,567 +1,91 @@
# Hanzo AI Chat Stack - Local Production Environment
# This runs pre-built images suitable for local testing
# For development with mounted volumes, use compose.dev.yml
# Hanzo AI Chat - Base Configuration
# Use directly for local development with pre-built images
# Override with compose.dev.yml for mounted volumes
# Override with compose.prod.yml for production deployment
services:
# PostgreSQL Database (for Router)
postgres:
image: postgres:16-alpine
container_name: hanzo-postgres
environment:
POSTGRES_USER: hanzo
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-hanzo123}
POSTGRES_DB: hanzo_chat
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U hanzo"]
interval: 10s
timeout: 5s
retries: 5
networks:
- hanzo-network
# MySQL Database (for IAM)
mysql:
image: mysql:8.0.25
container_name: hanzo-mysql
platform: linux/amd64
environment:
MYSQL_DATABASE: iam
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-hanzo123}
ports:
- "3306:3306"
volumes:
- mysql_data:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${MYSQL_ROOT_PASSWORD:-hanzo123}"]
interval: 10s
timeout: 5s
retries: 5
networks:
- hanzo-network
# Redis Cache
redis:
image: redis:7-alpine
container_name: hanzo-redis
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD:-hanzosecret}
ports:
- "6379:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD:-hanzosecret}", "ping"]
interval: 10s
timeout: 5s
retries: 5
networks:
- hanzo-network
# MongoDB for Chat History
mongodb:
image: mongo:7-jammy
container_name: hanzo-mongodb
environment:
MONGO_INITDB_ROOT_USERNAME: hanzo
MONGO_INITDB_ROOT_USERNAME: ${MONGO_USERNAME:-hanzo}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD:-hanzo123}
MONGO_INITDB_DATABASE: HanzoChat
ports:
- "27017:27017"
volumes:
- mongodb_data:/data/db
networks:
- hanzo-network
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 5s
retries: 5
networks:
- hanzo-network
# Meilisearch for Full-Text Search
meilisearch:
image: getmeili/meilisearch:v1.9
image: getmeili/meilisearch:v1.8
container_name: hanzo-meilisearch
environment:
MEILI_MASTER_KEY: ${MEILI_MASTER_KEY:-HanzoMeiliMasterKey}
MEILI_ENV: production
ports:
- "7700:7700"
MEILI_MASTER_KEY: ${MEILI_MASTER_KEY:-hanzo-search-key}
MEILI_ENV: ${MEILI_ENV:-development}
volumes:
- meilisearch_data:/meili_data
networks:
- hanzo-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:7700/health"]
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:7700/health"]
interval: 10s
timeout: 5s
retries: 5
networks:
- hanzo-network
# Hanzo Router (LiteLLM Gateway)
router:
image: hanzo/router:latest
container_name: hanzo-router
ports:
- "4000:4000"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
environment:
# Database
DATABASE_URL: postgresql://hanzo:${POSTGRES_PASSWORD:-hanzo123}@postgres:5432/hanzo_chat
REDIS_URL: redis://:${REDIS_PASSWORD:-hanzosecret}@redis:6379
# Router Configuration
ROUTER_MASTER_KEY: ${ROUTER_MASTER_KEY:-sk-hanzo-master-key}
LITELLM_MASTER_KEY: ${ROUTER_MASTER_KEY:-sk-hanzo-master-key} # For compatibility
# LLM API Keys
OPENAI_API_KEY: ${OPENAI_API_KEY}
ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY}
TOGETHER_API_KEY: ${TOGETHER_API_KEY}
# Runtime Integration
RUNTIME_API_URL: http://runtime:3000/api
RUNTIME_API_KEY: runtime-secret-key
# Logging
ROUTER_LOG_LEVEL: INFO
DEBUG: ${DEBUG:-false}
volumes:
- ./config.yaml:/app/config.yaml:ro
- ./mcp:/app/mcp:ro
command: ["--config", "/app/config.yaml", "--port", "4000", "--num_workers", "${ROUTER_WORKERS:-4}"]
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:4000/health/readiness"]
interval: 10s
timeout: 5s
retries: 5
networks:
- hanzo-network
# Hanzo IAM (Identity & Access Management)
iam:
build:
context: ../iam
dockerfile: Dockerfile
target: STANDARD
image: hanzo/iam:latest
container_name: hanzo-iam
ports:
- "8000:8000"
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
environment:
RUNNING_IN_DOCKER: "true"
# Local dev mode - bypass orgs/teams
LOCAL_DEV_MODE: "true"
SKIP_ORG_CHECK: "true"
# Production domains (for reference)
PRODUCTION_URL: "https://hanzo.id"
PRODUCTION_API: "https://api.hanzo.id"
volumes:
- ../iam/conf/app_local.conf:/conf/app.conf:ro
- ../iam/init_data_local.json:/init_data.json:ro
- ../iam/web/build:/web/build:ro
command: ["./server", "--createDatabase=true"]
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/api/get-account"]
interval: 10s
timeout: 5s
retries: 5
networks:
- hanzo-network
# Hanzo Services Bridge
services:
build:
context: ../services/services
dockerfile: Dockerfile.dev
image: hanzo/services:dev
container_name: hanzo-services
ports:
- "3333:3000"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
iam:
condition: service_healthy
environment:
NODE_ENV: development
LOCAL_DEV_MODE: "true"
# Database connections
DATABASE_URL: postgresql://hanzo:hanzo123@postgres:5432/services
REDIS_URL: redis://redis:6379
# Service URLs
IAM_URL: http://iam:8000
CLOUD_URL: http://cloud:3000
ROUTER_URL: http://router:4000
CHAT_URL: http://chat:3080
# Production domains (for reference)
PRODUCTION_URL: "https://hanzo.services"
PRODUCTION_IAM: "https://hanzo.id"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 10s
timeout: 5s
retries: 5
networks:
- hanzo-network
# ClickHouse Database (for Cloud Analytics)
clickhouse:
image: clickhouse/clickhouse-server
container_name: hanzo-clickhouse
user: "101:101"
environment:
CLICKHOUSE_DB: default
CLICKHOUSE_USER: clickhouse
CLICKHOUSE_PASSWORD: ${CLICKHOUSE_PASSWORD:-clickhouse123}
CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT: 1
ports:
- "8123:8123"
- "9000:9000"
volumes:
- clickhouse_data:/var/lib/clickhouse
- clickhouse_logs:/var/log/clickhouse-server
healthcheck:
test: ["CMD", "clickhouse-client", "--query", "SELECT 1"]
interval: 10s
timeout: 5s
retries: 5
networks:
- hanzo-network
# MinIO (S3-compatible storage for Cloud)
minio:
image: minio/minio
container_name: hanzo-minio
environment:
MINIO_ROOT_USER: ${MINIO_ROOT_USER:-minio}
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-miniosecret}
ports:
- "9001:9001" # Console
- "9002:9000" # API (changed from 9000 to avoid conflict with router)
volumes:
- minio_data:/data
command: server /data --console-address ":9001"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 10s
timeout: 5s
retries: 5
networks:
- hanzo-network
# Hanzo Cloud Frontend (AI Platform Management)
cloud:
build:
context: ../cloud
dockerfile: web/Dockerfile
args:
NEXT_PUBLIC_HANZO_CLOUD_REGION: "LOCAL"
image: hanzo/cloud:latest
container_name: hanzo-cloud
ports:
- "3000:3000"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
clickhouse:
condition: service_healthy
minio:
condition: service_healthy
iam:
condition: service_healthy
environment:
# Database
DATABASE_URL: postgresql://hanzo:${POSTGRES_PASSWORD:-hanzo123}@postgres:5432/cloud
CLICKHOUSE_URL: http://clickhouse:8123
CLICKHOUSE_USER: clickhouse
CLICKHOUSE_PASSWORD: ${CLICKHOUSE_PASSWORD:-clickhouse123}
# Redis
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_AUTH: ${REDIS_PASSWORD:-hanzosecret}
# S3 Storage
HANZO_S3_EVENT_UPLOAD_BUCKET: hanzo
HANZO_S3_EVENT_UPLOAD_ENDPOINT: http://minio:9000
HANZO_S3_EVENT_UPLOAD_ACCESS_KEY_ID: ${MINIO_ROOT_USER:-minio}
HANZO_S3_EVENT_UPLOAD_SECRET_ACCESS_KEY: ${MINIO_ROOT_PASSWORD:-miniosecret}
HANZO_S3_EVENT_UPLOAD_FORCE_PATH_STYLE: true
HANZO_S3_MEDIA_UPLOAD_BUCKET: hanzo
HANZO_S3_MEDIA_UPLOAD_ENDPOINT: http://minio:9000
HANZO_S3_MEDIA_UPLOAD_ACCESS_KEY_ID: ${MINIO_ROOT_USER:-minio}
HANZO_S3_MEDIA_UPLOAD_SECRET_ACCESS_KEY: ${MINIO_ROOT_PASSWORD:-miniosecret}
HANZO_S3_MEDIA_UPLOAD_FORCE_PATH_STYLE: true
# Security
SALT: ${CLOUD_SALT:-mysalt}
ENCRYPTION_KEY: ${CLOUD_ENCRYPTION_KEY:-0000000000000000000000000000000000000000000000000000000000000000}
# Auth (using IAM)
NEXTAUTH_URL: http://localhost:3000
NEXTAUTH_SECRET: ${NEXTAUTH_SECRET:-mysecret}
# Router Integration
HANZO_ROUTER_URL: http://router:4000
HANZO_ROUTER_API_KEY: ${ROUTER_MASTER_KEY:-sk-hanzo-master-key}
# Initial Setup
HANZO_INIT_ORG_NAME: "Hanzo AI"
HANZO_INIT_PROJECT_NAME: "Default Project"
HANZO_INIT_USER_EMAIL: admin@hanzo.ai
HANZO_INIT_USER_NAME: "Admin"
HANZO_INIT_USER_PASSWORD: demo1234
# Features
HANZO_ENABLE_EXPERIMENTAL_FEATURES: true
TELEMETRY_ENABLED: false
NEXT_PUBLIC_HANZO_CLOUD_REGION: LOCAL
# Local Dev Mode
LOCAL_DEV_MODE: true
SKIP_ORG_CHECK: true
SINGLE_TENANT_MODE: true
# Services Integration
SERVICES_URL: http://services:3000
# Production domains (for reference)
PRODUCTION_URL: "https://cloud.hanzo.ai"
PRODUCTION_SERVICES: "https://hanzo.services"
networks:
- hanzo-network
# Hanzo Chat Frontend
# Hanzo Chat UI (LibreChat Fork)
chat:
image: ghcr.io/hanzoai/chat:latest
image: hanzoai/chat:latest
container_name: hanzo-chat
build:
context: .
dockerfile: docker/Dockerfile
ports:
- "3081:3080"
environment:
# Database
MONGO_URI: mongodb://${MONGO_USERNAME:-hanzo}:${MONGO_PASSWORD:-hanzo123}@mongodb:27017/HanzoChat?authSource=admin
# Search
MEILI_HOST: http://meilisearch:7700
MEILI_MASTER_KEY: ${MEILI_MASTER_KEY:-hanzo-search-key}
# Auth
ALLOW_REGISTRATION: ${ALLOW_REGISTRATION:-true}
JWT_SECRET: ${JWT_SECRET:-your-super-secret-jwt}
# AI Provider - Point to Hanzo Router or external API
OPENAI_API_KEY: ${OPENAI_API_KEY:-sk-hanzo-your-key}
OPENAI_BASE_URL: ${OPENAI_BASE_URL:-https://api.hanzo.ai/v1}
# Features
MCP_ENABLED: ${MCP_ENABLED:-true}
# Branding
APP_TITLE: ${APP_TITLE:-Hanzo AI Chat}
CUSTOM_FOOTER: ${CUSTOM_FOOTER:-Powered by Hanzo AI}
depends_on:
mongodb:
condition: service_healthy
meilisearch:
condition: service_healthy
router:
condition: service_healthy
iam:
condition: service_healthy
environment:
# Server Configuration
HOST: 0.0.0.0
PORT: 3080
# Database
MONGO_URI: mongodb://hanzo:${MONGO_PASSWORD:-hanzo123}@mongodb:27017/HanzoChat?authSource=admin
# Domain
DOMAIN_CLIENT: ${DOMAIN_CLIENT:-http://localhost:3081}
DOMAIN_SERVER: ${DOMAIN_SERVER:-http://localhost:3081}
# Branding
APP_TITLE: "Hanzo AI Chat"
CUSTOM_FOOTER: "Powered by Hanzo AI"
# Router Gateway
OPENAI_API_KEY: proxy
OPENAI_BASE_URL: http://router:4000/v1
# Auth & Security
JWT_SECRET: ${JWT_SECRET:-hanzo-jwt-secret-change-in-production}
JWT_REFRESH_SECRET: ${JWT_REFRESH_SECRET:-hanzo-refresh-secret-change-in-production}
CREDS_KEY: ${CREDS_KEY:-hanzo-creds-key-change-in-production}
CREDS_IV: ${CREDS_IV:-hanzo-creds-iv-change}
# SSO Configuration (Hanzo IAM)
OPENID_CLIENT_ID: hanzo-chat-client
OPENID_CLIENT_SECRET: hanzo-chat-secret-change-in-production
OPENID_ISSUER: http://iam:8000
OPENID_SESSION_SECRET: ${OPENID_SESSION_SECRET:-hanzo-session-secret}
OPENID_SCOPE: "openid profile email"
OPENID_CALLBACK_URL: http://localhost:3081/api/auth/callback/openid
# Social Login
ALLOW_SOCIAL_LOGIN: true
ALLOW_SOCIAL_REGISTRATION: true
# Features
ALLOW_REGISTRATION: false # Users register via IAM
ALLOW_UNVERIFIED_EMAIL_LOGIN: false
# Search
MEILI_HOST: http://meilisearch:7700
MEILI_MASTER_KEY: ${MEILI_MASTER_KEY:-HanzoMeiliMasterKey}
# MCP Integration
MCP_ENABLED: true
# Tool/Function Calling
TOOLS_ENABLED: true
FUNCTIONS_ENABLED: true
# Logging
DEBUG_LOGGING: ${DEBUG:-false}
volumes:
- ./scripts:/app/scripts:ro
- ./client/dist/assets:/app/client/dist/assets:ro
- ./client/dist/favicon.ico:/app/client/dist/favicon.ico:ro
- chat_uploads:/app/uploads
- chat_logs:/app/logs
networks:
- hanzo-network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3080/health"]
test: ["CMD", "curl", "-f", "http://localhost:3080/api/health"]
interval: 10s
timeout: 5s
retries: 5
networks:
- hanzo-network
# Hanzo Runtime API (Code Execution)
# NOTE: Using mock runtime for now, replace with full build when ready
runtime:
# build:
# context: ../runtime
# dockerfile: ../chat/runtime/Dockerfile
# args:
# - --build-context=runtime=../runtime
image: node:20-alpine
container_name: hanzo-runtime
ports:
- "3003:3000"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
environment:
NODE_ENV: development
PORT: 3000
APP_URL: http://localhost:3003
# Database
DB_HOST: postgres
DB_PORT: 5432
DB_USERNAME: hanzo
DB_PASSWORD: ${POSTGRES_PASSWORD:-hanzo123}
DB_DATABASE: hanzo_runtime
# Redis
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_AUTH: ${REDIS_PASSWORD:-hanzosecret}
# Auth (using local dev mode)
OIDC_CLIENT_ID: runtime-client
OIDC_ISSUER_BASE_URL: http://iam:8000
OIDC_AUDIENCE: runtime-api
# S3 Storage
S3_ENDPOINT: http://minio:9000
S3_ACCESS_KEY: ${MINIO_ROOT_USER:-minio}
S3_SECRET_KEY: ${MINIO_ROOT_PASSWORD:-miniosecret}
S3_DEFAULT_BUCKET: runtime-storage
# Docker Registry (for sandbox images)
INTERNAL_REGISTRY_URL: registry:5000
# Skip external connections in local dev
SKIP_CONNECTIONS: true
# Local runner will be auto-created
RUNNER_DOMAIN: localtest.me:3003
RUNNER_API_KEY: secret_api_token
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
command: |
sh -c "
cat > /tmp/server.js << 'EOF'
const http = require('http');
const server = http.createServer((req, res) => {
console.log(req.method, req.url);
// CORS headers
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
if (req.method === 'OPTIONS') {
res.writeHead(200);
res.end();
return;
}
if (req.url === '/api/health' || req.url === '/health') {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ status: 'ok', service: 'hanzo-runtime' }));
} else if (req.url === '/api/sandboxes' && req.method === 'POST') {
// Mock sandbox creation
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({
id: 'sandbox-' + Date.now(),
state: 'started',
language: 'python',
createdAt: new Date().toISOString()
}));
} else if (req.url.startsWith('/api/sandboxes/') && req.method === 'DELETE') {
// Mock sandbox deletion
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ success: true }));
} else if (req.url.includes('/execute') && req.method === 'POST') {
// Mock code execution
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({
output: 'Hello from Hanzo Runtime!\\nCode execution successful.',
exitCode: 0,
executionTime: 100
}));
} else {
res.writeHead(404, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ error: 'Not found' }));
}
});
server.listen(3000, '0.0.0.0', () => {
console.log('Mock Hanzo Runtime API running on port 3000');
});
EOF
node /tmp/server.js
"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/api/health"]
interval: 10s
timeout: 5s
retries: 5
networks:
- hanzo-network
volumes:
postgres_data:
mysql_data:
redis_data:
mongodb_data:
meilisearch_data:
clickhouse_data:
clickhouse_logs:
minio_data:
chat_uploads:
chat_logs:
networks:
hanzo-network:
-57
View File
@@ -1,57 +0,0 @@
# Hanzo Router (LiteLLM) - Local Development
# Usage: docker compose up -d
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: hanzo
POSTGRES_PASSWORD: hanzo123
POSTGRES_DB: router
ports:
- "5433:5432" # Different port to avoid conflicts
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U hanzo"]
interval: 10s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
command: redis-server --appendonly yes --requirepass routersecret
ports:
- "6380:6379" # Different port to avoid conflicts
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "-a", "routersecret", "ping"]
interval: 10s
timeout: 5s
retries: 5
router:
image: ghcr.io/berriai/litellm:main-latest
ports:
- "4000:4000"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
environment:
DATABASE_URL: postgresql://hanzo:hanzo123@postgres:5432/router
REDIS_URL: redis://:routersecret@redis:6379
LITELLM_MASTER_KEY: ${LITELLM_MASTER_KEY:-sk-router-master-dev}
# LLM Keys
OPENAI_API_KEY: ${OPENAI_API_KEY}
ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY}
TOGETHER_API_KEY: ${TOGETHER_API_KEY}
volumes:
- ./config.yaml:/app/config.yaml
command: ["--config", "/app/config.yaml", "--port", "4000", "--num_workers", "1"]
volumes:
postgres_data:
redis_data:
-17
View File
@@ -1,17 +0,0 @@
services:
api:
volumes:
- type: bind
source: ./.env
target: /app/.env
- type: bind
source: ./chat.yaml
target: /app/chat.yaml
- ./images:/app/client/public/images
- ./uploads:/app/uploads
- ./logs:/app/api/logs
# Add volume mount for client dist assets
- ./client/dist/assets:/app/client/dist/assets
meilisearch:
ports:
- "7700:7700"
View File
+32 -76
View File
@@ -1,87 +1,43 @@
# Base image for building
ARG LITELLM_BUILD_IMAGE=python:3.11-slim
# Development Dockerfile for Hanzo Router
FROM python:3.11-slim
# Runtime image
ARG LITELLM_RUNTIME_IMAGE=python:3.11-slim
# Builder stage
FROM $LITELLM_BUILD_IMAGE AS builder
# Set the working directory to /app
WORKDIR /app
USER root
# Install build dependencies in one layer
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
python3-dev \
libssl-dev \
pkg-config \
&& rm -rf /var/lib/apt/lists/* \
&& pip install --upgrade pip build
# Copy requirements first for better layer caching
COPY requirements.txt .
# Install Python dependencies with cache mount for faster rebuilds
RUN --mount=type=cache,target=/root/.cache/pip \
pip wheel --no-cache-dir --wheel-dir=/wheels/ -r requirements.txt
# Fix JWT dependency conflicts early
RUN pip uninstall jwt -y || true && \
pip uninstall PyJWT -y || true && \
pip install PyJWT==2.9.0 --no-cache-dir
# Copy only necessary files for build
COPY pyproject.toml README.md schema.prisma poetry.lock ./
COPY litellm/ ./litellm/
COPY enterprise/ ./enterprise/
COPY docker/ ./docker/
# Build Admin UI once
RUN chmod +x docker/build_admin_ui.sh && ./docker/build_admin_ui.sh
# Build the package
RUN rm -rf dist/* && python -m build
# Install the built package
RUN pip install dist/*.whl
# Runtime stage
FROM $LITELLM_RUNTIME_IMAGE AS runtime
# Ensure runtime stage runs as root
USER root
# Install only runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
libssl3 \
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
build-essential \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy only necessary runtime files
COPY docker/entrypoint.sh docker/prod_entrypoint.sh ./docker/
COPY litellm/ ./litellm/
COPY pyproject.toml README.md schema.prisma poetry.lock ./
# Install uv for faster Python package management
RUN pip install uv
# Copy pre-built wheels and install everything at once
COPY --from=builder /wheels/ /wheels/
COPY --from=builder /app/dist/*.whl .
# Copy requirements
COPY pyproject.toml ./
COPY poetry.lock* ./
COPY requirements.txt* ./
# Install all dependencies in one step with no-cache for smaller image
RUN pip install --no-cache-dir *.whl /wheels/* --no-index --find-links=/wheels/ && \
rm -f *.whl && \
rm -rf /wheels
# Install Python dependencies
RUN uv pip install --system -r requirements.txt || \
pip install poetry && poetry export -f requirements.txt | pip install -r /dev/stdin || \
pip install litellm[proxy]
# Generate prisma client and set permissions
RUN prisma generate && \
chmod +x docker/entrypoint.sh docker/prod_entrypoint.sh
# Copy source code (will be overridden by volume mount)
COPY . .
EXPOSE 4000/tcp
# Create necessary directories
RUN mkdir -p /app/logs /app/.cache
ENTRYPOINT ["docker/prod_entrypoint.sh"]
# Expose port
EXPOSE 4000
# Append "--detailed_debug" to the end of CMD to view detailed debug logs
CMD ["--port", "4000"]
# Install watchdog for Python hot reloading
RUN pip install watchdog[watchmedo]
# Environment for development
ENV PYTHONUNBUFFERED=1
ENV LITELLM_MODE=development
# Development command with auto-reload using watchmedo
CMD ["watchmedo", "auto-restart", "--directory=/app/litellm", "--pattern=*.py", "--recursive", "--", "python", "-m", "litellm", "--config", "/app/config.yaml", "--port", "4000", "--detailed_debug"]
+17
View File
@@ -0,0 +1,17 @@
# Hanzo Chat - Alpine version
FROM ghcr.io/danny-avila/librechat:latest
# Set environment defaults
ENV HOST=0.0.0.0
ENV PORT=3080
ENV APP_TITLE="Hanzo AI Chat"
ENV CUSTOM_FOOTER="Powered by Hanzo AI"
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3080/health || exit 1
EXPOSE 3080
# Start the application
CMD ["npm", "run", "backend:prod"]
-108
View File
@@ -1,108 +0,0 @@
apiVersion: v1
entries:
litellm-helm:
- apiVersion: v2
appVersion: v1.43.18
created: "2024-08-19T23:58:25.331689+08:00"
dependencies:
- condition: db.deployStandalone
name: postgresql
repository: oci://registry-1.docker.io/bitnamicharts
version: '>=13.3.0'
- condition: redis.enabled
name: redis
repository: oci://registry-1.docker.io/bitnamicharts
version: '>=18.0.0'
description: Call all LLM APIs using the OpenAI format
digest: 0411df3dc42868be8af3ad3e00cb252790e6bd7ad15f5b77f1ca5214573a8531
name: litellm-helm
type: application
urls:
- https://berriai.github.io/litellm/litellm-helm-0.2.3.tgz
version: 0.2.3
postgresql:
- annotations:
category: Database
images: |
- name: os-shell
image: docker.io/bitnami/os-shell:12-debian-12-r16
- name: postgres-exporter
image: docker.io/bitnami/postgres-exporter:0.15.0-debian-12-r14
- name: postgresql
image: docker.io/bitnami/postgresql:16.2.0-debian-12-r6
licenses: Apache-2.0
apiVersion: v2
appVersion: 16.2.0
created: "2024-08-19T23:58:25.335716+08:00"
dependencies:
- name: common
repository: oci://registry-1.docker.io/bitnamicharts
tags:
- bitnami-common
version: 2.x.x
description: PostgreSQL (Postgres) is an open source object-relational database
known for reliability and data integrity. ACID-compliant, it supports foreign
keys, joins, views, triggers and stored procedures.
digest: 3c8125526b06833df32e2f626db34aeaedb29d38f03d15349db6604027d4a167
home: https://bitnami.com
icon: https://bitnami.com/assets/stacks/postgresql/img/postgresql-stack-220x234.png
keywords:
- postgresql
- postgres
- database
- sql
- replication
- cluster
maintainers:
- name: VMware, Inc.
url: https://github.com/bitnami/charts
name: postgresql
sources:
- https://github.com/bitnami/charts/tree/main/bitnami/postgresql
urls:
- https://berriai.github.io/litellm/charts/postgresql-14.3.1.tgz
version: 14.3.1
redis:
- annotations:
category: Database
images: |
- name: kubectl
image: docker.io/bitnami/kubectl:1.29.2-debian-12-r3
- name: os-shell
image: docker.io/bitnami/os-shell:12-debian-12-r16
- name: redis
image: docker.io/bitnami/redis:7.2.4-debian-12-r9
- name: redis-exporter
image: docker.io/bitnami/redis-exporter:1.58.0-debian-12-r4
- name: redis-sentinel
image: docker.io/bitnami/redis-sentinel:7.2.4-debian-12-r7
licenses: Apache-2.0
apiVersion: v2
appVersion: 7.2.4
created: "2024-08-19T23:58:25.339392+08:00"
dependencies:
- name: common
repository: oci://registry-1.docker.io/bitnamicharts
tags:
- bitnami-common
version: 2.x.x
description: Redis(R) is an open source, advanced key-value store. It is often
referred to as a data structure server since keys can contain strings, hashes,
lists, sets and sorted sets.
digest: b2fa1835f673a18002ca864c54fadac3c33789b26f6c5e58e2851b0b14a8f984
home: https://bitnami.com
icon: https://bitnami.com/assets/stacks/redis/img/redis-stack-220x234.png
keywords:
- redis
- keyvalue
- database
maintainers:
- name: VMware, Inc.
url: https://github.com/bitnami/charts
name: redis
sources:
- https://github.com/bitnami/charts/tree/main/bitnami/redis
urls:
- https://berriai.github.io/litellm/charts/redis-18.19.1.tgz
version: 18.19.1
generated: "2024-08-19T23:58:25.322532+08:00"
-28
View File
@@ -1,28 +0,0 @@
#!/bin/bash
# Initialize demo user for Hanzo Chat
# Run this after docker compose up
echo "🚀 Initializing Hanzo Chat demo user..."
echo "📧 Email: hattori@hanzo.ai"
echo "🔑 Password: demo1234"
echo ""
# Wait for services to be ready
echo "⏳ Waiting for services to be ready..."
sleep 5
# Run the seed script inside a temporary container
docker run --rm \
--network chat_hanzo-network \
-e MONGO_URI="mongodb://hanzo:hanzo123@hanzo-mongodb:27017/HanzoChat?authSource=admin" \
-v "$PWD/scripts:/scripts" \
-w /scripts \
node:18-alpine sh -c "
npm install mongoose bcryptjs
node seed_demo_user.js
"
echo ""
echo "✅ Demo user initialization complete!"
echo "🌐 Access Hanzo Chat at: http://localhost:3081"
echo "📧 Login with: hattori@hanzo.ai / demo1234"
-82
View File
@@ -1,82 +0,0 @@
{
"name": "@chat/data-schemas",
<<<<<<< HEAD
"version": "0.0.6",
"description": "Mongoose schemas and models for Chat",
=======
"version": "0.0.5",
"description": "Mongoose schemas and models for Hanzo",
>>>>>>> e65a8a45 (Update brand)
"type": "module",
"main": "dist/index.cjs",
"module": "dist/index.es.js",
"types": "./dist/types/index.d.ts",
"exports": {
".": {
"import": "./dist/index.es.js",
"require": "./dist/index.cjs",
"types": "./dist/types/index.d.ts"
}
},
"files": [
"dist"
],
"scripts": {
"clean": "rimraf dist",
"build": "npm run clean && rollup -c --silent --bundleConfigAsCjs",
"build:watch": "rollup -c -w",
"test": "jest --coverage --watch",
"test:ci": "jest --coverage --ci",
"verify": "npm run test:ci",
"b:clean": "bun run rimraf dist",
"b:build": "bun run b:clean && bun run rollup -c --silent --bundleConfigAsCjs"
},
"repository": {
"type": "git",
"url": "git+https://github.com/hanzoai/chat.git"
},
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/hanzoai/chat/issues"
},
"homepage": "https://hanzo.ai",
"devDependencies": {
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-commonjs": "^25.0.2",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.1.0",
"@rollup/plugin-replace": "^5.0.5",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^12.1.2",
"@types/diff": "^6.0.0",
"@types/express": "^5.0.0",
"@types/jest": "^29.5.2",
"@types/node": "^20.3.0",
"jest": "^29.5.0",
"jest-junit": "^16.0.0",
"rimraf": "^5.0.1",
"rollup": "^4.22.4",
"rollup-plugin-generate-package-json": "^3.2.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-typescript2": "^0.35.0",
"ts-node": "^10.9.2",
"typescript": "^5.0.4"
},
"dependencies": {
"mongoose": "^8.12.1"
},
"peerDependencies": {
"keyv": "^4.5.4"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"keywords": [
"mongoose",
"schema",
"typescript",
"chat"
]
}
-84
View File
@@ -1,84 +0,0 @@
{
"name": "chat-mcp",
<<<<<<< HEAD
"version": "1.2.0",
"type": "commonjs",
"description": "MCP services for Chat",
=======
"version": "1.1.0",
"type": "module",
"description": "MCP services for Hanzo",
>>>>>>> e65a8a45 (Update brand)
"main": "dist/index.js",
"module": "dist/index.es.js",
"types": "./dist/types/index.d.ts",
"exports": {
".": {
"require": "./dist/index.js",
"types": "./dist/types/index.d.ts"
}
},
"scripts": {
"clean": "rimraf dist",
"build": "npm run clean && rollup -c --bundleConfigAsCjs",
"build:watch": "rollup -c -w --bundleConfigAsCjs",
"test": "jest --coverage --watch",
"test:ci": "jest --coverage --ci",
"verify": "npm run test:ci",
"b:clean": "bun run rimraf dist",
"b:build": "bun run b:clean && bun run rollup -c --silent --bundleConfigAsCjs",
"start:everything-sse": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/examples/everything/sse.ts",
"start:everything": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/demo/everything.ts",
"start:filesystem": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/demo/filesystem.ts",
"start:servers": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/demo/servers.ts"
},
"repository": {
"type": "git",
"url": "git+https://github.com/hanzoai/chat.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/hanzoai/chat/issues"
},
"homepage": "https://hanzo.ai",
"devDependencies": {
"@babel/preset-env": "^7.21.5",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.21.0",
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-commonjs": "^25.0.2",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.1.0",
"@rollup/plugin-replace": "^5.0.5",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^12.1.2",
"@types/diff": "^6.0.0",
"@types/express": "^5.0.0",
"@types/jest": "^29.5.2",
"@types/node": "^20.3.0",
"@types/react": "^18.2.18",
"@types/winston": "^2.4.4",
"jest": "^29.5.0",
"jest-junit": "^16.0.0",
"chat-data-provider": "*",
"rimraf": "^5.0.1",
"rollup": "^4.22.4",
"rollup-plugin-generate-package-json": "^3.2.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"ts-node": "^10.9.2",
"typescript": "^5.0.4"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/"
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.9.0",
"diff": "^7.0.0",
"eventsource": "^3.0.2",
"express": "^4.21.2"
},
"peerDependencies": {
"keyv": "^4.5.4"
}
}
+22 -12
View File
@@ -1,18 +1,28 @@
#!/bin/bash
# Initialize demo user for Hanzo Chat
# This script runs when the chat container starts
# Run this after docker compose up
echo "🚀 Checking for demo user initialization..."
echo "🚀 Initializing Hanzo Chat demo user..."
echo "📧 Email: hattori@hanzo.ai"
echo "🔑 Password: demo1234"
echo ""
# Wait for MongoDB to be ready
until mongosh --host mongodb:27017 --username hanzo --password ${MONGO_PASSWORD:-hanzo123} --authenticationDatabase admin --eval "db.adminCommand('ping')" > /dev/null 2>&1; do
echo "⏳ Waiting for MongoDB to be ready..."
sleep 2
done
# Wait for services to be ready
echo "⏳ Waiting for services to be ready..."
sleep 5
echo "✅ MongoDB is ready"
# Run the seed script inside a temporary container
docker run --rm \
--network chat_hanzo-network \
-e MONGO_URI="mongodb://hanzo:hanzo123@hanzo-mongodb:27017/HanzoChat?authSource=admin" \
-v "$PWD/scripts:/scripts" \
-w /scripts \
node:18-alpine sh -c "
npm install mongoose bcryptjs
node seed_demo_user.js
"
# Run the seed script
node /app/scripts/seed_demo_user.js
echo "✅ Demo user initialization complete"
echo ""
echo "✅ Demo user initialization complete!"
echo "🌐 Access Hanzo Chat at: http://localhost:3081"
echo "📧 Login with: hattori@hanzo.ai / demo1234"