Fix out of boundary. (#3786)

### What problem does this PR solve?

#3769
### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
Kevin Hu 2024-12-02 11:38:53 +08:00 committed by GitHub
parent a7efd3cac5
commit 7058ac0041
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 23 deletions

View File

@ -452,6 +452,7 @@ def delete(tenant_id,chat_id):
ConversationService.delete_by_id(id) ConversationService.delete_by_id(id)
return get_result() return get_result()
@manager.route('/sessions/ask', methods=['POST']) @manager.route('/sessions/ask', methods=['POST'])
@token_required @token_required
def ask_about(tenant_id): def ask_about(tenant_id):
@ -471,6 +472,7 @@ def ask_about(tenant_id):
if kb.chunk_num == 0: if kb.chunk_num == 0:
return get_error_data_result(f"The dataset {kb_id} doesn't own parsed file") return get_error_data_result(f"The dataset {kb_id} doesn't own parsed file")
uid = tenant_id uid = tenant_id
def stream(): def stream():
nonlocal req, uid nonlocal req, uid
try: try:

View File

@ -152,7 +152,7 @@ class RAGFlowPdfParser:
max(len(up["text"]), len(down["text"])), max(len(up["text"]), len(down["text"])),
len(tks_all) - len(tks_up) - len(tks_down), len(tks_all) - len(tks_up) - len(tks_down),
len(tks_down) - len(tks_up), len(tks_down) - len(tks_up),
tks_down[-1] == tks_up[-1], tks_down[-1] == tks_up[-1] if tks_down and tks_up else False,
max(down["in_row"], up["in_row"]), max(down["in_row"], up["in_row"]),
abs(down["in_row"] - up["in_row"]), abs(down["in_row"] - up["in_row"]),
len(tks_down) == 1 and rag_tokenizer.tag(tks_down[0]).find("n") >= 0, len(tks_down) == 1 and rag_tokenizer.tag(tks_down[0]).find("n") >= 0,