Add shared ai-service container as AI provider intermediary
All feature containers now POST messages to ai-service (port 8010) instead of calling AI providers directly. ai-service routes to LM Studio, Ollama, or Anthropic based on /config/ai_service_config.json. doc-service AI providers removed; replaced by httpx ai_client.py. Backend settings restructured to /api/settings/ai. Frontend gets dedicated AIAdminSettingsPage and AI Service card in AppsPage. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,3 +22,45 @@ Added pytest test suite for doc-service, updated the AI prompt to return suggest
|
||||
- `features/doc-service/app/services/config_reader.py` — default provider changed to `lmstudio`; URLs changed to `host.docker.internal:1234/v1` (Docker→host resolution on macOS/Windows)
|
||||
- `backend/app/core/app_config.py` — default `LMStudioConfig.base_url` = `http://host.docker.internal:1234/v1`; default provider = `lmstudio`
|
||||
- `frontend/src/pages/DocumentsPage.tsx` — added `SuggestionChip` component and `suggested_categories` section in DocumentRow: checks if suggestion already exists as a user category, shows "Assign" (existing) or "Create & Assign" (new), dismiss removes from local state
|
||||
|
||||
---
|
||||
|
||||
# 2026-04-14 — AI service container (shared AI intermediary)
|
||||
|
||||
**Timestamp:** 2026-04-14T12:00:00+00:00
|
||||
|
||||
## Summary
|
||||
|
||||
Extracted all AI provider logic from doc-service into a new standalone `ai-service` container (port 8010). All feature containers now POST messages to ai-service instead of calling AI providers directly. Added tests for ai-service, updated backend settings routes to /api/settings/ai, added AI Service card to frontend AppsPage with dedicated settings page.
|
||||
|
||||
## Files Added
|
||||
|
||||
- `features/ai-service/` — full new microservice: Dockerfile, pyproject.toml, scripts/, app/ (providers, schemas, routers, services), tests/
|
||||
- `features/ai-service/.env` — gitignored, holds LM Studio API key for dev
|
||||
- `features/ai-service/.env.example`
|
||||
- `features/doc-service/app/services/prompts.py` — domain prompts extracted from deleted base.py
|
||||
- `features/doc-service/app/services/ai_client.py` — httpx client that calls ai-service /chat
|
||||
|
||||
## Files Modified
|
||||
|
||||
- `features/doc-service/app/routers/documents.py` — replaced provider call with classify_document()
|
||||
- `features/doc-service/app/services/config_reader.py` — removed AI config section (owned by ai-service now)
|
||||
- `features/doc-service/app/core/config.py` — added AI_SERVICE_URL setting
|
||||
- `features/doc-service/pyproject.toml` — removed anthropic/openai, added httpx
|
||||
- `features/doc-service/.env` — removed LMSTUDIO_* vars, added AI_SERVICE_URL
|
||||
- `features/doc-service/tests/conftest.py` — renamed mock_ai → mock_ai_service, patching classify_document
|
||||
- `features/doc-service/tests/test_documents.py` — mock_ai → mock_ai_service; added graceful 502 test
|
||||
- `backend/app/core/app_config.py` — AIServiceConfig split from DocServiceConfig; new load/save/mask helpers
|
||||
- `backend/app/core/config.py` — added AI_SERVICE_URL setting
|
||||
- `backend/app/routers/settings.py` — new /api/settings/ai routes; test endpoint proxies to ai-service via httpx
|
||||
- `docker-compose.yml` — added ai-service container; AI_SERVICE_URL env on backend + doc-service
|
||||
- `docker-compose.dev.yml` — added ai-service dev override with hot reload and .env
|
||||
- `frontend/src/api/client.ts` — renamed getDocumentSettings→getAISettings, updateDocumentAISettings→updateAISettings, testDocumentAIConnection→testAIConnection; added getDocumentLimits
|
||||
- `frontend/src/pages/AIAdminSettingsPage.tsx` — new page at /apps/ai/settings/admin
|
||||
- `frontend/src/pages/DocumentAdminSettingsPage.tsx` — now shows Upload Limits only
|
||||
- `frontend/src/pages/AppsPage.tsx` — added AI Service card (admin settings link, no Open button)
|
||||
- `frontend/src/App.tsx` — added /apps/ai/settings/admin route
|
||||
|
||||
## Files Deleted
|
||||
|
||||
- `features/doc-service/app/services/ai/` — anthropic_provider.py, openai_compat.py, base.py, __init__.py
|
||||
|
||||
Reference in New Issue
Block a user