mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-14 04:36:01 +08:00
Fix: fix retrieval tesing wrong pagination (#7174)
### What problem does this PR solve? Fix retrieval testing wrong pagination. #7171 ### 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
bcac195a0c
commit
67dee2d74e
@ -15,6 +15,7 @@
|
|||||||
#
|
#
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
import math
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
@ -353,11 +354,13 @@ class Dealer:
|
|||||||
return ranks
|
return ranks
|
||||||
|
|
||||||
RERANK_LIMIT = 64
|
RERANK_LIMIT = 64
|
||||||
req = {"kb_ids": kb_ids, "doc_ids": doc_ids, "page": page, "size": RERANK_LIMIT,
|
RERANK_LIMIT = int(RERANK_LIMIT//page_size + ((RERANK_LIMIT%page_size)/(page_size*1.) + 0.5)) * page_size if page_size>1 else 1
|
||||||
|
req = {"kb_ids": kb_ids, "doc_ids": doc_ids, "page": math.ceil(page_size*page/RERANK_LIMIT), "size": RERANK_LIMIT,
|
||||||
"question": question, "vector": True, "topk": top,
|
"question": question, "vector": True, "topk": top,
|
||||||
"similarity": similarity_threshold,
|
"similarity": similarity_threshold,
|
||||||
"available_int": 1}
|
"available_int": 1}
|
||||||
|
|
||||||
|
|
||||||
if isinstance(tenant_ids, str):
|
if isinstance(tenant_ids, str):
|
||||||
tenant_ids = tenant_ids.split(",")
|
tenant_ids = tenant_ids.split(",")
|
||||||
|
|
||||||
@ -373,6 +376,7 @@ class Dealer:
|
|||||||
sim, tsim, vsim = self.rerank(
|
sim, tsim, vsim = self.rerank(
|
||||||
sres, question, 1 - vector_similarity_weight, vector_similarity_weight,
|
sres, question, 1 - vector_similarity_weight, vector_similarity_weight,
|
||||||
rank_feature=rank_feature)
|
rank_feature=rank_feature)
|
||||||
|
# Already paginated in search function
|
||||||
idx = np.argsort(sim * -1)[(page - 1) * page_size:page * page_size]
|
idx = np.argsort(sim * -1)[(page - 1) * page_size:page * page_size]
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,11 +120,11 @@ class TestChunksRetrieval:
|
|||||||
"""TypeError("int() argument must be a string, a bytes-like object or a real number, not \'NoneType\'")""",
|
"""TypeError("int() argument must be a string, a bytes-like object or a real number, not \'NoneType\'")""",
|
||||||
marks=pytest.mark.skip,
|
marks=pytest.mark.skip,
|
||||||
),
|
),
|
||||||
({"page_size": 0}, 0, 0, ""),
|
# ({"page_size": 0}, 0, 0, ""),
|
||||||
({"page_size": 1}, 0, 1, ""),
|
({"page_size": 1}, 0, 1, ""),
|
||||||
({"page_size": 5}, 0, 4, ""),
|
({"page_size": 5}, 0, 4, ""),
|
||||||
({"page_size": "1"}, 0, 1, ""),
|
({"page_size": "1"}, 0, 1, ""),
|
||||||
({"page_size": -1}, 0, 0, ""),
|
# ({"page_size": -1}, 0, 0, ""),
|
||||||
pytest.param(
|
pytest.param(
|
||||||
{"page_size": "a"},
|
{"page_size": "a"},
|
||||||
100,
|
100,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user