Checkpoint: Phase 10: LLM Provider Configuration — Ollama Cloud как дефолт, локальный Ollama закомментирован (GPU only), docker-compose/stack обновлены, .env.example с 4 провайдерами

This commit is contained in:
Manus
2026-03-20 19:16:44 -04:00
parent 02742f836c
commit dda99d7056
6 changed files with 259 additions and 71 deletions

View File

@@ -1,7 +1,23 @@
##############################################################################
# GoClaw Control Center — Docker Stack (Docker Swarm Production)
#
# LLM Provider:
# By default the gateway uses Ollama Cloud (https://ollama.com/v1).
# Set LLM_BASE_URL and LLM_API_KEY via Docker secrets or environment.
#
# To use a local Ollama instance on a GPU-equipped Swarm node:
# 1. Uncomment the "ollama" service below.
# 2. Add the label gpu=true to the GPU node:
# docker node update --label-add gpu=true <node-id>
# 3. Change LLM_BASE_URL in the gateway service to: http://ollama:11434
#
# Deploy:
# # Create required secrets first:
# echo "rootpass" | docker secret create mysql-root-password -
# echo "pass" | docker secret create mysql-password -
# echo "jwtsecret"| docker secret create jwt-secret -
# echo "ollamakey"| docker secret create llm-api-key -
#
# docker stack deploy -c docker/docker-stack.yml goclaw
#
# Remove:
@@ -19,14 +35,10 @@ networks:
attachable: true
volumes:
ollama-data:
driver: local
mysql-data:
driver: local
configs:
gateway-env:
external: true
# ollama-data: # Uncomment when using local Ollama service below
# driver: local
secrets:
mysql-root-password:
@@ -35,6 +47,8 @@ secrets:
external: true
jwt-secret:
external: true
llm-api-key:
external: true
services:
@@ -73,45 +87,59 @@ services:
retries: 5
start_period: 30s
# ── Ollama LLM Server ─────────────────────────────────────────────────────
ollama:
image: ollama/ollama:latest
volumes:
- ollama-data:/root/.ollama
networks:
- goclaw-net
deploy:
replicas: 1
placement:
constraints:
# Pin to GPU node if available
- node.labels.gpu == true
restart_policy:
condition: on-failure
delay: 15s
resources:
limits:
memory: 16G
reservations:
memory: 4G
# GPU support via nvidia-container-runtime
# Uncomment on GPU-enabled nodes:
# runtime: nvidia
# environment:
# - NVIDIA_VISIBLE_DEVICES=all
# ── Local Ollama LLM Server (GPU ONLY — disabled by default) ─────────────
# Uncomment this entire block only on Swarm nodes with a compatible GPU.
# After uncommenting, also change gateway LLM_BASE_URL to http://ollama:11434
# and remove the llm-api-key secret from gateway (not needed for local Ollama).
#
# ollama:
# image: ollama/ollama:latest
# volumes:
# - ollama-data:/root/.ollama
# networks:
# - goclaw-net
# deploy:
# replicas: 1
# placement:
# constraints:
# # Pin to GPU-labelled node: docker node update --label-add gpu=true <id>
# - node.labels.gpu == true
# restart_policy:
# condition: on-failure
# delay: 15s
# resources:
# limits:
# memory: 16G
# reservations:
# memory: 4G
# # NVIDIA GPU support — uncomment on GPU-enabled nodes:
# # runtime: nvidia
# # environment:
# # - NVIDIA_VISIBLE_DEVICES=all
# ── Go Gateway (Orchestrator + Tool Executor) ─────────────────────────────
gateway:
image: git.softuniq.eu/uniqai/goclaw/gateway:latest
environment:
PORT: "18789"
OLLAMA_BASE_URL: "http://ollama:11434"
# ── LLM Provider ─────────────────────────────────────────────────────
# Default: Ollama Cloud (requires llm-api-key secret below)
LLM_BASE_URL: "${LLM_BASE_URL:-https://ollama.com/v1}"
DEFAULT_MODEL: "${DEFAULT_MODEL:-qwen2.5:7b}"
# LLM_API_KEY is injected via /run/secrets/llm-api-key (see below)
# ── To switch to local GPU Ollama, set: ──────────────────────────────
# LLM_BASE_URL: "http://ollama:11434"
# (and uncomment the ollama service above)
# ─────────────────────────────────────────────────────────────────────
DATABASE_URL: "goclaw:{{MYSQL_PASSWORD}}@tcp(db:3306)/goclaw?parseTime=true"
PROJECT_ROOT: "/app"
REQUEST_TIMEOUT_SECS: "120"
GATEWAY_REQUEST_TIMEOUT_SECS: "120"
GATEWAY_MAX_TOOL_ITERATIONS: "10"
LOG_LEVEL: "info"
secrets:
- mysql-password
- source: llm-api-key
target: /run/secrets/llm-api-key
networks:
- goclaw-net
ports:
@@ -119,6 +147,9 @@ services:
published: 18789
protocol: tcp
mode: ingress
volumes:
# Docker socket for docker_exec tool
- /var/run/docker.sock:/var/run/docker.sock
deploy:
replicas: 2
update_config: