970c8e4e44
- Delete backend/data/ tracked files (D-04): flat-file metadata, settings.json, topics.json, and uploaded files removed from git; backend/data/ added to .gitignore (empty dir remains on macOS due to ACL — no tracked files remain) - Prune backend/config.py: remove DATA_DIR, UPLOADS_DIR, METADATA_DIR, TOPICS_FILE, ensure_data_dirs(); rebase SETTINGS_FILE as derived path from settings.data_dir (Phase 1 flat-file settings kept per plan decision) - Prune backend/tests/conftest.py: remove isolated_data_dir autouse fixture and sync TestClient client fixture; add SQLite type compatibility shim (visit_INET/JSONB) so in-memory db_session can create tables with PostgreSQL-specific column types; add live_services_available fixture - Rewrite backend/tests/test_documents.py: delete all legacy sync tests, remove all @pytest.mark.xfail markers; async-only document tests now use async_client + storage service directly for topic wiring - Rewrite backend/tests/test_health.py: delete legacy sync test_health(client); remove @pytest.mark.xfail from test_health_checks_postgres_and_minio - Port backend/tests/test_topics.py to async_client (sync client removed) - Port backend/tests/test_settings.py to async_client with monkeypatch for SETTINGS_FILE isolation (settings remain flat-file in Phase 1)
70 lines
2.3 KiB
Python
70 lines
2.3 KiB
Python
from pathlib import Path
|
|
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""Phase 1 Pydantic Settings — reads all Phase 1 env vars from environment or .env file."""
|
|
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env",
|
|
env_file_encoding="utf-8",
|
|
extra="ignore",
|
|
)
|
|
|
|
# Data directory — used only for the flat-file settings.json path (Phase 1)
|
|
data_dir: str = "/app/data"
|
|
|
|
# PostgreSQL
|
|
database_url: str = "postgresql+psycopg://docuvault_app:changeme_app@postgres:5432/docuvault"
|
|
database_migrate_url: str = "postgresql+psycopg://docuvault_migrate:changeme_migrate@postgres:5432/docuvault"
|
|
|
|
# MinIO
|
|
minio_endpoint: str = "minio:9000"
|
|
minio_access_key: str = "docuvault_app"
|
|
minio_secret_key: str = "changeme_minio_app"
|
|
minio_bucket: str = "docuvault"
|
|
|
|
# Redis / Celery
|
|
redis_url: str = "redis://:changeme_redis@redis:6379/0"
|
|
|
|
# Security (Phase 2 — documented now, not read by Phase 1 code paths)
|
|
secret_key: str = "CHANGEME"
|
|
|
|
|
|
settings = Settings()
|
|
|
|
# SETTINGS_FILE: still flat-file in Phase 1; migrates to users.ai_provider in Phase 2
|
|
SETTINGS_FILE = Path(settings.data_dir) / "settings.json"
|
|
|
|
DEFAULT_SYSTEM_PROMPT = """You are a document classification assistant. When given a document's text content and a list of existing topics, you must:
|
|
1. Assign the document to one or more relevant topics from the list.
|
|
2. If no existing topics fit well, suggest new topic names.
|
|
Return ONLY valid JSON in this exact format, with no additional text or explanation:
|
|
{"assigned_topics": ["topic1"], "new_topic_suggestions": ["new topic name"]}
|
|
If the document fits no topics and you have no suggestions, return: {"assigned_topics": [], "new_topic_suggestions": []}"""
|
|
|
|
DEFAULT_SETTINGS = {
|
|
"system_prompt": DEFAULT_SYSTEM_PROMPT,
|
|
"active_provider": "lmstudio",
|
|
"providers": {
|
|
"anthropic": {
|
|
"api_key": "",
|
|
"model": "claude-sonnet-4-6"
|
|
},
|
|
"openai": {
|
|
"api_key": "",
|
|
"model": "gpt-4o",
|
|
"base_url": None
|
|
},
|
|
"ollama": {
|
|
"base_url": "http://host.docker.internal:11434",
|
|
"model": "llama3.2"
|
|
},
|
|
"lmstudio": {
|
|
"base_url": "http://host.docker.internal:1234",
|
|
"model": "gemma-4-e4b-it"
|
|
}
|
|
}
|
|
}
|