88c1ea297e
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>
4.6 KiB
4.6 KiB
2026-04-14 — Doc-service tests, AI category suggestions, LM Studio default
Timestamp: 2026-04-14T00:00:00+00:00
Summary
Added pytest test suite for doc-service, updated the AI prompt to return suggested categories, wired up a suggestions UI in DocumentsPage (per-suggestion Accept/Create&Assign/Dismiss), changed the default AI provider to LM Studio at host.docker.internal:1234, and created a gitignored test PDF directory.
Files Added
features/doc-service/tests/__init__.pyfeatures/doc-service/tests/conftest.py— SQLite in-memory DB, tmp DATA_DIR, mock AI provider, minimal+invoice PDF builders, real_pdfs fixture (auto-skips if no PDFs present)features/doc-service/tests/test_categories.py— full CRUD + per-user isolationfeatures/doc-service/tests/test_documents.py— upload, list, get, status, delete, category assignment, AI processing integration, live PDF testsfeatures/doc-service/tests/pdfs/.gitkeep— tracked empty directory; drop PDFs here for live testing
Files Modified
.gitignore— ignorefeatures/doc-service/tests/pdfs/*.pdffeatures/doc-service/pyproject.toml— addedaiosqlite>=0.20to dev depsfeatures/doc-service/app/services/ai/base.py— addedsuggested_categoriesto AI prompt (2–5 category names per document)features/doc-service/app/services/config_reader.py— default provider changed tolmstudio; URLs changed tohost.docker.internal:1234/v1(Docker→host resolution on macOS/Windows)backend/app/core/app_config.py— defaultLMStudioConfig.base_url=http://host.docker.internal:1234/v1; default provider =lmstudiofrontend/src/pages/DocumentsPage.tsx— addedSuggestionChipcomponent andsuggested_categoriessection 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 devfeatures/ai-service/.env.examplefeatures/doc-service/app/services/prompts.py— domain prompts extracted from deleted base.pyfeatures/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 settingfeatures/doc-service/pyproject.toml— removed anthropic/openai, added httpxfeatures/doc-service/.env— removed LMSTUDIO_* vars, added AI_SERVICE_URLfeatures/doc-service/tests/conftest.py— renamed mock_ai → mock_ai_service, patching classify_documentfeatures/doc-service/tests/test_documents.py— mock_ai → mock_ai_service; added graceful 502 testbackend/app/core/app_config.py— AIServiceConfig split from DocServiceConfig; new load/save/mask helpersbackend/app/core/config.py— added AI_SERVICE_URL settingbackend/app/routers/settings.py— new /api/settings/ai routes; test endpoint proxies to ai-service via httpxdocker-compose.yml— added ai-service container; AI_SERVICE_URL env on backend + doc-servicedocker-compose.dev.yml— added ai-service dev override with hot reload and .envfrontend/src/api/client.ts— renamed getDocumentSettings→getAISettings, updateDocumentAISettings→updateAISettings, testDocumentAIConnection→testAIConnection; added getDocumentLimitsfrontend/src/pages/AIAdminSettingsPage.tsx— new page at /apps/ai/settings/adminfrontend/src/pages/DocumentAdminSettingsPage.tsx— now shows Upload Limits onlyfrontend/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