Skip to content

Commit

Permalink
Fix slicing of doc
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudotensor committed Oct 26, 2024
1 parent 6348f31 commit 95761c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/utils_langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ def _huggingface_tokenizer_length(text: str) -> int:


def select_docs_with_score(docs_with_score, top_k_docs, one_doc_size):
if top_k_docs > 0:
if one_doc_size is not None and len(docs_with_score) > 0:
doc1 = Document(page_content=docs_with_score[0][0].page_content[:one_doc_size], metadata=docs_with_score[0][0].metadata)
docs_with_score = [(doc1, docs_with_score[0][1])]
elif top_k_docs > 0:
docs_with_score = docs_with_score[:top_k_docs]
elif one_doc_size is not None:
docs_with_score = [(docs_with_score[0][:one_doc_size], docs_with_score[0][1])]
else:
# do nothing
pass
Expand Down
2 changes: 1 addition & 1 deletion src/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2f91e7bd7e48904bed9ac1e50d5eca1ca6da541f"
__version__ = "6348f316022b004dd125d2e465df07e654b4287b"

0 comments on commit 95761c2

Please sign in to comment.