mirror of
https://github.com/RYDE-WORK/Langchain-Chatchat.git
synced 2026-01-19 13:23:16 +08:00
fix: 扩展文档的代码逻辑 (#227)
* fix: 扩展文档的代码逻辑 * Update local_doc_qa.py --------- Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
This commit is contained in:
parent
07ff81a119
commit
47922d2ee3
@ -68,6 +68,7 @@ def similarity_search_with_score_by_vector(
|
||||
scores, indices = self.index.search(np.array([embedding], dtype=np.float32), k)
|
||||
docs = []
|
||||
id_set = set()
|
||||
store_len = len(self.index_to_docstore_id)
|
||||
for j, i in enumerate(indices[0]):
|
||||
if i == -1:
|
||||
# This happens when not enough docs are returned.
|
||||
@ -76,7 +77,7 @@ def similarity_search_with_score_by_vector(
|
||||
doc = self.docstore.search(_id)
|
||||
id_set.add(i)
|
||||
docs_len = len(doc.page_content)
|
||||
for k in range(1, max(i, len(docs) - i)):
|
||||
for k in range(1, max(i, store_len-i)):
|
||||
break_flag = False
|
||||
for l in [i + k, i - k]:
|
||||
if 0 <= l < len(self.index_to_docstore_id):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user