Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix Voyage re-rank model. Limit file name length. (#4171)

Kevin Hucb454314125a
diff --git a/api/db/services/file_service.py b/api/db/services/file_service.py
index be225aeeb9..48a665f063 100644
--- a/api/db/services/file_service.py
+++ b/api/db/services/file_service.py
@@ -345,6 +345,8 @@ class FileService(CommonService):
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:
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(
DocumentService.query,
diff --git a/rag/llm/rerank_model.py b/rag/llm/rerank_model.py
index 925e08aa2a..c42ee89445 100644
--- a/rag/llm/rerank_model.py
+++ b/rag/llm/rerank_model.py
@@ -422,10 +422,12 @@ class VoyageRerank(Base):
self.model_name = model_name
def similarity(self, query: str, texts: list):
+ rank = np.zeros(len(texts), dtype=float)
+ if not texts:
+ return rank, 0
res = self.client.rerank(
query=query, documents=texts, model=self.model_name, top_k=len(texts)
)
- rank = np.zeros(len(texts), dtype=float)
for r in res.results:
rank[r.index] = r.relevance_score
return rank, res.total_tokens