- GlobalKnowledge 模型新增 confidence 和 expires_at 字段 - save_global_knowledge 增加 MD5 去重、置信度评分、TTL过期 - _global_knowledge_search 增加过期过滤、置信度优先排序 - run()/run_stream() 所有完成路径补齐知识提取调用 - 新增 Alembic 迁移 010_add_global_knowledge Cl oses #9 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
"""add confidence and expires_at columns to global_knowledge table
|
||
|
||
Revision ID: 010_add_global_knowledge
|
||
Revises: 009_notif_sched_feishu
|
||
Create Date: 2026-05-06
|
||
"""
|
||
from alembic import op
|
||
import sqlalchemy as sa
|
||
|
||
|
||
revision = "010_add_global_knowledge"
|
||
down_revision = "009_notif_sched_feishu"
|
||
branch_labels = None
|
||
depends_on = None
|
||
|
||
|
||
def upgrade() -> None:
|
||
# Add confidence column (if table doesn't exist, this is a no-op handled below)
|
||
try:
|
||
op.add_column(
|
||
"global_knowledge",
|
||
sa.Column("confidence", sa.String(20), default="medium", comment="置信度: low/medium/high"),
|
||
)
|
||
except Exception:
|
||
pass
|
||
|
||
# Add expires_at column
|
||
try:
|
||
op.add_column(
|
||
"global_knowledge",
|
||
sa.Column("expires_at", sa.DateTime(), nullable=True, comment="过期时间,NULL 表示永不过期"),
|
||
)
|
||
except Exception:
|
||
pass
|
||
|
||
|
||
def downgrade() -> None:
|
||
try:
|
||
op.drop_column("global_knowledge", "expires_at")
|
||
except Exception:
|
||
pass
|
||
try:
|
||
op.drop_column("global_knowledge", "confidence")
|
||
except Exception:
|
||
pass
|