feat(todo): 知识库入库建议待办——todo_detail渲染kb_ingest_confirm+kb_ingest_decide端点
This commit is contained in:
parent
c2c89ef680
commit
9f5fbdacfc
@ -130,6 +130,7 @@ PATHS_LOGINED = [
|
||||
f"/{MOD}/api/human_task_create.dspy",
|
||||
f"/{MOD}/api/human_task_complete.dspy",
|
||||
f"/{MOD}/api/bug_accept.dspy",
|
||||
f"/{MOD}/api/kb_ingest_decide.dspy",
|
||||
f"/{MOD}/api/fix_stuck.dspy",
|
||||
# 工作环境 / 部署账号(普通用户可用)
|
||||
f"/{MOD}/api/work_env.dspy",
|
||||
|
||||
17
wwwroot/api/kb_ingest_decide.dspy
Normal file
17
wwwroot/api/kb_ingest_decide.dspy
Normal file
@ -0,0 +1,17 @@
|
||||
# kb_ingest_decide.dspy - owner 批准/驳回「知识库入库建议」(待办内完成)
|
||||
|
||||
user_id = await get_user()
|
||||
if not user_id:
|
||||
return json.dumps({"success": False, "error": "未登录"}, ensure_ascii=False)
|
||||
|
||||
suggestion_id = params_kw.get('suggestion_id', '').strip()
|
||||
approve = params_kw.get('approve', '').strip().lower() in ('1', 'true', 'yes', '批准')
|
||||
comment = params_kw.get('comment', '')
|
||||
|
||||
if not suggestion_id:
|
||||
return json.dumps({"success": False, "error": "缺少 suggestion_id"}, ensure_ascii=False)
|
||||
|
||||
ok, msg = await decide_kb_ingest(suggestion_id, approve, user_id, comment=comment)
|
||||
if ok:
|
||||
return json.dumps({"success": True, "message": msg}, ensure_ascii=False)
|
||||
return json.dumps({"success": False, "error": msg}, ensure_ascii=False)
|
||||
@ -21,11 +21,13 @@ TYPE_LABEL = {
|
||||
'requirement_confirmation': '需求确认',
|
||||
'design_confirmation': '设计确认',
|
||||
'bug_acceptance': 'Bug 验收',
|
||||
'kb_ingest_confirm': '知识库入库建议',
|
||||
}
|
||||
TYPE_COLOR = {
|
||||
'requirement_confirmation': '#2563eb',
|
||||
'design_confirmation': '#2563eb',
|
||||
'bug_acceptance': '#f0a040',
|
||||
'kb_ingest_confirm': '#10b981',
|
||||
}
|
||||
|
||||
|
||||
@ -525,6 +527,73 @@ async with DBPools().sqlorContext(dbname) as sor:
|
||||
md.append('未找到该项目的标书文件记录。')
|
||||
md.append('')
|
||||
|
||||
elif task_type == 'kb_ingest_confirm':
|
||||
# PM 建议文件入知识库:展示建议详情 + 文件(打开/下载)+ 批准/驳回
|
||||
_sg = None
|
||||
try:
|
||||
_fsj = _s(getattr(h, 'form_schema', ''))
|
||||
if _fsj:
|
||||
_sg = (_json.loads(_fsj) or {}).get('suggestion_id') or ''
|
||||
except Exception:
|
||||
_sg = ''
|
||||
sgrecs = []
|
||||
if _sg:
|
||||
sgrecs = await sor.sqlExe(
|
||||
"SELECT kb_id, file_path, file_name, reason, status FROM "
|
||||
"pipeline_kb_suggestions WHERE id=${i}$", {"i": _sg})
|
||||
await sor.sqlExe("COMMIT", {})
|
||||
if sgrecs:
|
||||
sg0 = sgrecs[0]
|
||||
_fname = _s(getattr(sg0, 'file_name', '')) or '-'
|
||||
_fpath = _s(getattr(sg0, 'file_path', ''))
|
||||
_reason = _s(getattr(sg0, 'reason', '')) or '(未填写理由)'
|
||||
_kbid = _s(getattr(sg0, 'kb_id', ''))
|
||||
_kbname = _kbid
|
||||
if _kbid:
|
||||
krecs = await sor.sqlExe(
|
||||
"SELECT name FROM rag_knowledge_bases WHERE id=${k}$", {"k": _kbid})
|
||||
await sor.sqlExe("COMMIT", {})
|
||||
if krecs:
|
||||
_kbname = _s(getattr(krecs[0], 'name', '')) or _kbid
|
||||
md.append('## 入库建议')
|
||||
md.append('')
|
||||
md.append('- 文件:`' + _fname + '`')
|
||||
md.append('- 目标知识库:' + _kbname + '(ID: ' + _kbid + ')')
|
||||
md.append('')
|
||||
md.append('### PM 给出的理由')
|
||||
md.append('')
|
||||
md.append(_reason)
|
||||
md.append('')
|
||||
md.append('批准后系统将以项目 owner 身份把该文件上传入库(后台解析,稍后可检索)。')
|
||||
md.append('')
|
||||
if _fpath:
|
||||
_file_rows.append(_file_link_row(_fname, project_id, _fpath))
|
||||
else:
|
||||
md.append('## 入库建议')
|
||||
md.append('')
|
||||
md.append('未找到对应的建议记录。')
|
||||
md.append('')
|
||||
kbi_url = entire_url("/pipeline-sdlc/api/kb_ingest_decide.dspy")
|
||||
ok_script = (_post_js(kbi_url, [('suggestion_id', _json.dumps(_sg or '')),
|
||||
('human_task_id', _json.dumps(oid)),
|
||||
('approve', "'1'")]) + _tail)
|
||||
no_script = (_read_input_js('kb_ingest_comment') +
|
||||
_post_js(kbi_url, [('suggestion_id', _json.dumps(_sg or '')),
|
||||
('human_task_id', _json.dumps(oid)),
|
||||
('approve', "'0'"), ('comment', 'cv')]) +
|
||||
_tail)
|
||||
action_widgets.append(_input_box('kb_ingest_comment', '驳回意见(驳回时填写)', '可选:驳回原因'))
|
||||
action_widgets.append({
|
||||
"widgettype": "HBox",
|
||||
"options": {"width": "100%", "gap": "8px", "padding": "12px 14px", "halign": "right"},
|
||||
"subwidgets": [
|
||||
_btn('批准入库', 'primary', ok_script,
|
||||
conform={"title": "批准入库", "message": "确认将该文件上传到目标知识库?",
|
||||
"conform": {"label": "批准"}, "discard": {"label": "再看看"}}),
|
||||
_btn('驳回', 'small', no_script)
|
||||
]
|
||||
})
|
||||
|
||||
else:
|
||||
if not desc:
|
||||
md.append('## 待办说明')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user