27 lines
891 B
Python
27 lines
891 B
Python
"""清理未完成的 SRT 导入:重置 kb_3 collection + 更新库状态为空"""
|
|
import sys
|
|
sys.path.insert(0, r'C:\Users\xinmiclaw\Desktop\雅文内容创造工作台\server')
|
|
from sqlmodel import Session, select
|
|
from app.db import engine
|
|
from app.models import KnowledgeBase
|
|
from app.rag import store
|
|
|
|
# 重置向量 collection(防半成品索引损坏)
|
|
try:
|
|
store.reset_kb(3)
|
|
print("kb_3 collection 已重置")
|
|
except Exception as e:
|
|
print("重置异常:", e)
|
|
|
|
# 更新库状态
|
|
with Session(engine) as s:
|
|
kb = s.exec(select(KnowledgeBase).where(KnowledgeBase.name == "直播原文库")).first()
|
|
if kb:
|
|
kb.index_status = "empty"
|
|
kb.file_count = 0
|
|
kb.chunk_count = 0
|
|
s.add(kb); s.commit()
|
|
print("直播原文库状态 → empty(以后想导入随时可导)")
|
|
else:
|
|
print("未找到直播原文库记录")
|