Phase completion and enhancement updates: ## Documentation Added - Phase 2 completion: Memory system implementation details - Phase 3 completion: Research capabilities and tool integration - Session documentation: Model testing, VRAM optimization analysis - Test results: Comprehensive prompt testing (v1_verbose: 87/100) - Tool logging implementation guide ## System Prompts - Added prompts.py with 7 tested variants for A/B testing - v1_verbose, v2_concise, v3_imperative, v4_minimal, etc. - Comprehensive testing results for each variant - Production-ready prompt selection guidance ## Memory System Enhancements - Multi-tenancy support: Added user_id parameter throughout - System message filtering: Don't store system messages in history - Improved conversation turn tracking with user isolation - Enhanced memory manager for better multi-user support ## AI Controller Improvements - Better memory integration with user_id support - Enhanced error handling for memory operations - Improved token tracking for usage monitoring - Skip system message storage (part of agent state) ## Portainer Client - Comprehensive API client (148 lines) - Stack management and service monitoring - Container operations with full error handling - Async support for all operations ## Architecture Documentation - Updated agent flow diagrams for ADK architecture - Enhanced core-api README with current setup - Updated Docker compose stack configuration - Complete testing and validation documentation
129 lines
3.5 KiB
YAML
129 lines
3.5 KiB
YAML
version: '3.8'
|
|
|
|
# Core API - OpenAPI-compatible functions and AI orchestration for Open WebUI
|
|
# Purpose: Provides OpenAI-compatible API (/v1/chat/completions) and tool functions (web scraping)
|
|
# Port: 8083 (HTTP API)
|
|
# Network: docker-dataplane (shared infrastructure network)
|
|
#
|
|
# Setup: Create venv before first deployment:
|
|
# cd /home/jpmschweitzer/Projects/portainer-core/services/core-api
|
|
# python3 -m venv .venv
|
|
# source .venv/bin/activate
|
|
# pip install -r requirements.txt
|
|
|
|
services:
|
|
core-api:
|
|
image: python:3.12
|
|
container_name: core-api
|
|
restart: unless-stopped
|
|
|
|
# Production mode with workers
|
|
# Always sync dependencies on startup to catch requirements.txt changes
|
|
command: >
|
|
sh -c "
|
|
echo 'Setting up Python environment...' &&
|
|
if [ ! -d /venv ]; then
|
|
echo 'Creating new venv...' &&
|
|
python3 -m venv /venv;
|
|
fi &&
|
|
echo 'Upgrading pip...' &&
|
|
/venv/bin/pip install --upgrade pip &&
|
|
echo 'Installing/updating dependencies from requirements.txt...' &&
|
|
/venv/bin/pip install -r /app/requirements.txt &&
|
|
echo 'Starting uvicorn server...' &&
|
|
/venv/bin/uvicorn src.main:app
|
|
--host 0.0.0.0
|
|
--port 8083
|
|
--workers 1
|
|
"
|
|
|
|
ports:
|
|
- "8083:8083"
|
|
|
|
environment:
|
|
# Application
|
|
- APP_NAME=Core API
|
|
- APP_VERSION=1.0.0-phase1
|
|
- DEBUG=true
|
|
|
|
# Server
|
|
- HOST=0.0.0.0
|
|
- PORT=8083
|
|
|
|
# Logging
|
|
- LOG_LEVEL=INFO
|
|
|
|
# Ollama Configuration (AI Orchestration)
|
|
- OLLAMA_BASE_URL=http://ollama:11434
|
|
- OLLAMA_TIMEOUT=300
|
|
|
|
# Model Configuration
|
|
- DEFAULT_MODEL=gemma:7b
|
|
- LIGHTWEIGHT_MODELS=gemma:2b,gemma:7b
|
|
- HEAVY_MODELS=mistral:7b,gemma2:9b,mixtral:8x7b
|
|
- CODE_MODELS=codestral:latest,codegemma:latest
|
|
|
|
# Model Aliases (OpenAI → Local)
|
|
- ALIAS_GPT35=gemma:7b
|
|
- ALIAS_GPT4=mistral:7b
|
|
- ALIAS_GPT4_TURBO=mixtral:8x7b
|
|
- ALIAS_GPT4_CODE=codestral:latest
|
|
|
|
# Agent Configuration
|
|
# Set to "false" to make agent errors explicit (500 errors) instead of silent fallback.
|
|
- AGENT_FALLBACK_ENABLED=false
|
|
|
|
# Web Scraper settings
|
|
- WEB_SCRAPER_REQUEST_TIMEOUT=30
|
|
- WEB_SCRAPER_MAX_REDIRECTS=5
|
|
- WEB_SCRAPER_USER_AGENT=Mozilla/5.0 (compatible; CoreAPI/1.0)
|
|
- WEB_SCRAPER_DEFAULT_MAX_LENGTH=10000
|
|
- WEB_SCRAPER_MAX_LINKS_TO_EXTRACT=50
|
|
|
|
# Uptime Kuma Configuration
|
|
- KUMA_URL=http://uptime-kuma:3001
|
|
- KUMA_USERNAME=${KUMA_USERNAME}
|
|
- KUMA_PASSWORD=${KUMA_PASSWORD}
|
|
|
|
# Python path
|
|
- PYTHONPATH=/app
|
|
|
|
volumes:
|
|
# Mount source code for live editing (not .venv - that's container-specific)
|
|
- /home/jpmschweitzer/Projects/portainer-core/services/core-api:/app
|
|
|
|
# Persist container's venv for fast restarts
|
|
- /home/jpmschweitzer/docker-data/core-api/venv:/venv
|
|
|
|
# Persist logs
|
|
- /home/jpmschweitzer/docker-data/core-api/logs:/app/logs
|
|
|
|
# Docker socket for direct container access (fallback when Portainer API incomplete)
|
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
|
|
|
networks:
|
|
- docker-dataplane
|
|
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
cpus: '2.0'
|
|
memory: 6G
|
|
reservations:
|
|
memory: 1G
|
|
|
|
labels:
|
|
- "com.centurylinklabs.watchtower.enable=true"
|
|
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8083/health/full"]
|
|
interval: 30s
|
|
timeout: 20s
|
|
retries: 3
|
|
start_period: 60s
|
|
|
|
networks:
|
|
docker-dataplane:
|
|
external: true
|
|
name: docker-dataplane
|