Reorganize core into subpackages, add local KB, ruff/pyright tooling

- Split backend/app/core into weather/, discord/, memory_kb/, search/
  subpackages by responsibility, keeping config.py and llm.py as the
  shared foundation; updated all import sites accordingly.
- Add local Markdown knowledge base support (local_knowledge.py,
  knowledge_base/fgo.md, LOCAL_KB_* settings) that embeds and injects
  relevant docs into the system prompt by topic similarity.
- Add ruff and pyright as backend dev dependencies with basic config
  in pyproject.toml for linting and type checking.
- Document local machine quirks in CLAUDE.md (Postgres on port 8080,
  SSLKEYLOGFILE breaking litellm/pyright via OPENSSL_Uplink crashes).
- Add backend/run_dev.ps1 dev launcher and docs/discord-bot.md.
This commit is contained in:
2026-06-21 11:44:11 +09:00
parent 234ebba103
commit 347230e3c8
29 changed files with 825 additions and 31 deletions
+16
View File
@@ -88,6 +88,22 @@ class KnowledgeSource(Base):
entry: Mapped["KnowledgeEntry"] = relationship(back_populates="sources")
class LocalKnowledgeDoc(Base):
"""backend/knowledge_base/ 配下のMarkdownファイルとその埋め込みベクトル。
話題に応じて関連ファイルをシステムプロンプトに注入するために使う。
ファイル内容のハッシュが変わった時だけ埋め込みを再計算する。
"""
__tablename__ = "local_knowledge_docs"
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
path: Mapped[str] = mapped_column(String, unique=True)
title: Mapped[str] = mapped_column(String)
content_hash: Mapped[str] = mapped_column(String)
embedding_json: Mapped[str] = mapped_column(Text)
updated_at: Mapped[datetime] = mapped_column(DateTime, default=lambda: datetime.now(timezone.utc), onupdate=lambda: datetime.now(timezone.utc))
class ApiLog(Base):
__tablename__ = "api_logs"