解决文件内文件列表不能删除的问题

This commit is contained in:
weiweiw 2025-02-20 17:50:56 +08:00
parent 7f57a4ede8
commit b78d56fdd4
1 changed files with 18 additions and 11 deletions

View File

@ -406,8 +406,8 @@ def knowledge_base_page(api: ApiRequest, is_lite: bool = None):
editable=True, editable=True,
width=50, width=50,
wrapHeaderText=True, wrapHeaderText=True,
cellEditor="agCheckboxCellEditor", cellEditor="agTextCellEditor",
cellRender="agCheckboxCellRenderer", cellRender="agTextCellRenderer",
) )
# 启用分页 # 启用分页
gb.configure_pagination( gb.configure_pagination(
@ -428,17 +428,21 @@ def knowledge_base_page(api: ApiRequest, is_lite: bool = None):
changed_docs = [] changed_docs = []
for index, row in edit_docs.data.iterrows(): for index, row in edit_docs.data.iterrows():
origin_doc = origin_docs[row["id"]] origin_doc = origin_docs[row["id"]]
if row["page_content"] != origin_doc["page_content"]: # if row["page_content"] != origin_doc["page_content"]:
if row["to_del"] not in ["Y", "y", 1]: if row["to_del"] not in ["Y", "y", 1]:
changed_docs.append( changed_docs.append(
{ {
"page_content": row["page_content"], "page_content": row["page_content"],
"type": row["type"], "type": row["type"],
"metadata": json.loads(row["metadata"]), "metadata": json.loads(row["metadata"]),
} }
) )
elif row["to_del"] in ["Y", "y", 1]:
print(f"""删除的文档id,row[seq]:{row["seq"]}""")
print(f"操作后的文档一共有:{len(changed_docs)}")
if changed_docs: if changed_docs:
print(f"操作后的文档一共有:{len(changed_docs)}")
if api.update_kb_docs( if api.update_kb_docs(
knowledge_base_name=selected_kb, knowledge_base_name=selected_kb,
file_names=[file_name], file_names=[file_name],
@ -447,3 +451,6 @@ def knowledge_base_page(api: ApiRequest, is_lite: bool = None):
st.toast("更新文档成功") st.toast("更新文档成功")
else: else:
st.toast("更新文档失败") st.toast("更新文档失败")
else:
print(f"没有进行文档更新操作")