75048bb88e
Первый кусок Спринта 2: подключаем SQLite через SQLAlchemy 2.0 (async, ORM-стиль) и Alembic для миграций. Схема выбрана под будущий рост — в threads сразу заведены nullable user_id и agent_config_id, чтобы Спринты 3+ не тащили миграции задним числом. - requirements.txt: sqlalchemy[asyncio]==2.0.36, aiosqlite==0.20.0, alembic==1.14.0. - config: database_url + sqlite_path (./data/sqlite/app.db). - db/base.py: DeclarativeBase; db/session.py: async engine, async_sessionmaker, get_session — FastAPI-dependency. - db/models/Thread: id, name, user_id?, agent_config_id?, created_at, updated_at; relationship messages с cascade all, delete-orphan. - db/models/Message: id, thread_id FK CASCADE, role, text, sources_json, assembled_prompt, created_at. - Alembic инициализирован через async-шаблон, env.py доработан: sys.path, url из settings, target_metadata = Base.metadata. - Начальная миграция e7199587be4b применена, таблицы threads/messages с индексами на FK и nullable-колонки созданы в data/sqlite/app.db. - .gitignore: исключаем data/sqlite/ (БД — артефакт, не исходник). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
22 lines
639 B
Python
22 lines
639 B
Python
from pydantic_settings import BaseSettings
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
chroma_persist_dir: str = "./data/chroma"
|
|
sqlite_path: str = "./data/sqlite/app.db"
|
|
database_url: str = "sqlite+aiosqlite:///./data/sqlite/app.db"
|
|
embedding_model: str = "intfloat/multilingual-e5-large"
|
|
deepseek_api_key: str = ""
|
|
deepseek_model: str = "deepseek-chat"
|
|
deepseek_base_url: str = "https://api.deepseek.com"
|
|
log_level: str = "info"
|
|
|
|
max_chunk_size: int = 1200
|
|
min_chunk_size: int = 200
|
|
overlap_sentences: int = 2
|
|
|
|
model_config = {"env_file": ".env", "env_file_encoding": "utf-8"}
|
|
|
|
|
|
settings = Settings()
|