mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-14 04:15:53 +08:00
Fix Voyage re-rank model. Limit file name length. (#4171)
### What problem does this PR solve? #4152 #4154 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
parent
85083ad400
commit
cb45431412
@ -345,6 +345,8 @@ class FileService(CommonService):
|
|||||||
MAX_FILE_NUM_PER_USER = int(os.environ.get('MAX_FILE_NUM_PER_USER', 0))
|
MAX_FILE_NUM_PER_USER = int(os.environ.get('MAX_FILE_NUM_PER_USER', 0))
|
||||||
if MAX_FILE_NUM_PER_USER > 0 and DocumentService.get_doc_count(kb.tenant_id) >= MAX_FILE_NUM_PER_USER:
|
if MAX_FILE_NUM_PER_USER > 0 and DocumentService.get_doc_count(kb.tenant_id) >= MAX_FILE_NUM_PER_USER:
|
||||||
raise RuntimeError("Exceed the maximum file number of a free user!")
|
raise RuntimeError("Exceed the maximum file number of a free user!")
|
||||||
|
if len(file.filename) >= 128:
|
||||||
|
raise RuntimeError("Exceed the maximum length of file name!")
|
||||||
|
|
||||||
filename = duplicate_name(
|
filename = duplicate_name(
|
||||||
DocumentService.query,
|
DocumentService.query,
|
||||||
|
@ -422,10 +422,12 @@ class VoyageRerank(Base):
|
|||||||
self.model_name = model_name
|
self.model_name = model_name
|
||||||
|
|
||||||
def similarity(self, query: str, texts: list):
|
def similarity(self, query: str, texts: list):
|
||||||
|
rank = np.zeros(len(texts), dtype=float)
|
||||||
|
if not texts:
|
||||||
|
return rank, 0
|
||||||
res = self.client.rerank(
|
res = self.client.rerank(
|
||||||
query=query, documents=texts, model=self.model_name, top_k=len(texts)
|
query=query, documents=texts, model=self.model_name, top_k=len(texts)
|
||||||
)
|
)
|
||||||
rank = np.zeros(len(texts), dtype=float)
|
|
||||||
for r in res.results:
|
for r in res.results:
|
||||||
rank[r.index] = r.relevance_score
|
rank[r.index] = r.relevance_score
|
||||||
return rank, res.total_tokens
|
return rank, res.total_tokens
|
||||||
|
Loading…
x
Reference in New Issue
Block a user