Discord bot inbound adapter (adapters/inbound/discord_bot.py): - ChatService injected directly — no HTTP roundtrip to FastAPI API - No module-level singleton: create_bot() factory for construction - Pure functions extracted for testing: build_answer_embed, build_error_embed, parse_conversation_id - Uses message.reference.resolved cache before fetch_message - Error embeds never leak exception details - 19 new tests covering embed building, footer parsing, error safety Removed old app/ directory (9 files): - All functionality preserved in hexagonal domain/, adapters/, config/ - Old test_basic.py removed (superseded by 120 adapter/domain tests) Other changes: - docker-compose: api uses main:app, discord-bot uses run_discord.py with direct ChatService injection (no API dependency) - Removed unused openai dependency from pyproject.toml - Removed app/ from hatch build targets Test suite: 120 passed, 1 skipped Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
77 lines
2.3 KiB
YAML
77 lines
2.3 KiB
YAML
services:
|
|
chroma:
|
|
image: chromadb/chroma:latest
|
|
volumes:
|
|
- ./data/chroma:/chroma/chroma_storage
|
|
ports:
|
|
- "127.0.0.1:8001:8000"
|
|
environment:
|
|
- CHROMA_SERVER_HOST=0.0.0.0
|
|
- CHROMA_SERVER_PORT=8000
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8000/api/v1/heartbeat"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
api:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
volumes:
|
|
- ./data:/app/data
|
|
ports:
|
|
- "127.0.0.1:8000:8000"
|
|
environment:
|
|
- OPENROUTER_API_KEY=${OPENROUTER_API_KEY:-}
|
|
- OPENROUTER_MODEL=${OPENROUTER_MODEL:-stepfun/step-3.5-flash:free}
|
|
- GITEA_TOKEN=${GITEA_TOKEN:-}
|
|
- GITEA_OWNER=${GITEA_OWNER:-cal}
|
|
- GITEA_REPO=${GITEA_REPO:-strat-chatbot}
|
|
- DATA_DIR=/app/data
|
|
- RULES_DIR=/app/data/rules
|
|
- CHROMA_DIR=/app/data/chroma
|
|
- DB_URL=sqlite+aiosqlite:///./data/conversations.db
|
|
- API_SECRET=${API_SECRET:-}
|
|
- CONVERSATION_TTL=1800
|
|
- TOP_K_RULES=10
|
|
- EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v2
|
|
depends_on:
|
|
chroma:
|
|
condition: service_healthy
|
|
command: uvicorn main:app --host 0.0.0.0 --port 8000
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
|
|
interval: 15s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 30s
|
|
|
|
discord-bot:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
volumes:
|
|
- ./data:/app/data
|
|
environment:
|
|
# The bot now calls ChatService directly — needs its own adapter config
|
|
- OPENROUTER_API_KEY=${OPENROUTER_API_KEY:-}
|
|
- OPENROUTER_MODEL=${OPENROUTER_MODEL:-stepfun/step-3.5-flash:free}
|
|
- DISCORD_BOT_TOKEN=${DISCORD_BOT_TOKEN:-}
|
|
- DISCORD_GUILD_ID=${DISCORD_GUILD_ID:-}
|
|
- GITEA_TOKEN=${GITEA_TOKEN:-}
|
|
- GITEA_OWNER=${GITEA_OWNER:-cal}
|
|
- GITEA_REPO=${GITEA_REPO:-strat-chatbot}
|
|
- DATA_DIR=/app/data
|
|
- RULES_DIR=/app/data/rules
|
|
- CHROMA_DIR=/app/data/chroma
|
|
- DB_URL=sqlite+aiosqlite:///./data/conversations.db
|
|
- CONVERSATION_TTL=1800
|
|
- TOP_K_RULES=10
|
|
- EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v2
|
|
depends_on:
|
|
chroma:
|
|
condition: service_healthy
|
|
command: python -m run_discord
|
|
restart: unless-stopped
|