Skip to content

Commit

Permalink
Merge branch 'master' of github.com:3togo/Langchain-Chatchat
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Jul 2, 2024
2 parents 1d250f4 + f465490 commit 5c5db80
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion runme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ do_cmd(){
echo "$@"
eval $@
}

git checkout dev
. ~/jvenv311/bin/activate
./shutdown_all.sh
#for port in 20000 20001 20002 7861 8501; do
Expand Down
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 5c5db80

Please sign in to comment.