浏览代码

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>
tags/v0.20.0
kwrobel.eth 4 个月前
父节点
当前提交
8a3b5d1d76
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2
    1
      rag/prompts.py

+ 2
- 1
rag/prompts.py 查看文件

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):
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]])

正在加载...
取消
保存