Fix a small typo in count of used fragments (#8673)
### What problem does this PR solve? Fix a small typo in count of used fragments. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --------- Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
This commit is contained in:
parent
1ac61c0f0f
commit
8a3b5d1d76
1 changed files with 2 additions and 1 deletions
|
|
@ -104,6 +104,7 @@ def kb_prompt(kbinfos, max_tokens):
|
||||||
from api.db.services.document_service import DocumentService
|
from api.db.services.document_service import DocumentService
|
||||||
|
|
||||||
knowledges = [ck["content_with_weight"] for ck in kbinfos["chunks"]]
|
knowledges = [ck["content_with_weight"] for ck in kbinfos["chunks"]]
|
||||||
|
kwlg_len = len(knowledges)
|
||||||
used_token_count = 0
|
used_token_count = 0
|
||||||
chunks_num = 0
|
chunks_num = 0
|
||||||
for i, c in enumerate(knowledges):
|
for i, c in enumerate(knowledges):
|
||||||
|
|
@ -111,7 +112,7 @@ def kb_prompt(kbinfos, max_tokens):
|
||||||
chunks_num += 1
|
chunks_num += 1
|
||||||
if max_tokens * 0.97 < used_token_count:
|
if max_tokens * 0.97 < used_token_count:
|
||||||
knowledges = knowledges[:i]
|
knowledges = knowledges[:i]
|
||||||
logging.warning(f"Not all the retrieval into prompt: {i + 1}/{len(knowledges)}")
|
logging.warning(f"Not all the retrieval into prompt: {len(knowledges)}/{kwlg_len}")
|
||||||
break
|
break
|
||||||
|
|
||||||
docs = DocumentService.get_by_ids([ck["doc_id"] for ck in kbinfos["chunks"][:chunks_num]])
|
docs = DocumentService.get_by_ids([ck["doc_id"] for ck in kbinfos["chunks"][:chunks_num]])
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue