Skip to content

Commit

Permalink
Merge branch 'chatchat-space:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
3togo authored May 21, 2024
2 parents d23c921 + b982752 commit ea3e50f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 6 additions & 6 deletions server/knowledge_base/kb_service/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,14 @@ def update_doc_by_ids(self, docs: Dict[str, Document]) -> bool:
如果对应 doc_id 的值为 None,或其 page_content 为空,则删除该文档
'''
self.del_doc_by_ids(list(docs.keys()))
docs = []
pending_docs = []
ids = []
for k, v in docs.items():
if not v or not v.page_content.strip():
for _id, doc in docs.items():
if not doc or not doc.page_content.strip():
continue
ids.append(k)
docs.append(v)
self.do_add_doc(docs=docs, ids=ids)
ids.append(_id)
pending_docs.append(doc)
self.do_add_doc(docs=pending_docs, ids=ids)
return True

def list_docs(self, file_name: str = None, metadata: Dict = {}) -> List[DocumentWithVSId]:
Expand Down
5 changes: 4 additions & 1 deletion server/knowledge_base/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ def get_vs_path(knowledge_base_name: str, vector_name: str):


def get_file_path(knowledge_base_name: str, doc_name: str):
return os.path.join(get_doc_path(knowledge_base_name), doc_name)
doc_path = Path(get_doc_path(knowledge_base_name)).resolve()
file_path = (doc_path / doc_name).resolve()
if str(file_path).startswith(str(doc_path)):
return str(file_path)


def list_kbs_from_folder():
Expand Down

0 comments on commit ea3e50f

Please sign in to comment.