49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
"""kb_overview: single-row, lite-generated knowledge-base outline
|
|
|
|
Revision ID: 0005
|
|
Revises: 0004
|
|
Create Date: 2026-08-25
|
|
|
|
Phase 31 (kb-overview-prompt story, A13 — one additive, reversible table,
|
|
no other schema change):
|
|
|
|
* ``kb_overview`` — a **single-row** table (``id INTEGER PK DEFAULT 1``)
|
|
holding a plain-text outline of the knowledge base's basic categories,
|
|
generated by the aipi ``lite`` model (phase 30's ``LLMClient.chat``)
|
|
whenever an import changes the KB. Chat turns only *read* the row (one
|
|
indexed PK lookup) and inject it into the system prompt as the
|
|
``<knowledge_base>`` section, so the agent knows roughly what the KB
|
|
contains before retrieval returns documents. ``content`` defaults to the
|
|
empty string — no row / empty row means the prompts are byte-identical
|
|
to the pre-phase text (phase 15 convention); ``updated_at`` is stamped
|
|
server-side on every upsert.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import sqlalchemy as sa
|
|
|
|
from alembic import op
|
|
|
|
revision = "0005"
|
|
down_revision = "0004"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"kb_overview",
|
|
sa.Column("id", sa.Integer(), primary_key=True, server_default=sa.text("1")),
|
|
sa.Column("content", sa.Text(), nullable=False, server_default=sa.text("''")),
|
|
sa.Column(
|
|
"updated_at",
|
|
sa.DateTime(timezone=True),
|
|
nullable=False,
|
|
server_default=sa.func.now(),
|
|
),
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_table("kb_overview")
|