WS Gateway:
- WebSocket lifecycle handler with RS256 JWT auth
- Redis bridge: device registry, frame publishing, tool_result routing
- Inbound routing: tool_result→LPUSH, home/floating→chat pub/sub
- Outbound: subscribes to ws:out:{user_id}, forwards to Electron
- Single-worker Dockerfile (long-lived WS connections)
Chat Service:
- Redis consumer: subscribes to chat:request:* pattern
- Redis-based ws_context: tool_call→publish, BRPOP tool_result (30s timeout)
- deep_agent: single-agent runner with home/floating/stream variants
- memory_middleware: core/associative/episodic/proactive memory with Fernet
- Domain agents: task (8 tools), note (5), project (6), timeline (4)
- LLM factory via LiteLLM (100+ providers)
- Output formatter (StreamFormatter)
- POST /chat REST fallback with Traefik header auth
- Multi-worker Dockerfile with 120s timeout for LLM calls
37 lines
1.2 KiB
Docker
37 lines
1.2 KiB
Docker
# ── builder ──────────────────────────────────────────────────────────────────
|
|
FROM python:3.12-slim AS builder
|
|
|
|
WORKDIR /build
|
|
|
|
COPY services/chat/requirements.txt ./requirements.txt
|
|
RUN pip install --upgrade pip && \
|
|
pip install --no-cache-dir --prefix=/install -r requirements.txt
|
|
|
|
# ── runtime ──────────────────────────────────────────────────────────────────
|
|
FROM python:3.12-slim AS runtime
|
|
|
|
RUN addgroup --system appgroup && adduser --system --ingroup appgroup appuser
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=builder /install /usr/local
|
|
|
|
# Shared module
|
|
COPY shared/ shared/
|
|
|
|
# Service source
|
|
COPY services/chat/app/ app/
|
|
|
|
RUN chown -R appuser:appgroup /app
|
|
|
|
USER appuser
|
|
|
|
EXPOSE 8000
|
|
|
|
# Chat service is CPU-bound (LLM calls) — use multiple workers
|
|
CMD ["gunicorn", "app.main:app", \
|
|
"-k", "uvicorn.workers.UvicornWorker", \
|
|
"--bind", "0.0.0.0:8000", \
|
|
"--workers", "2", \
|
|
"--timeout", "120"]
|