Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

roll back rerank topn setting (#11297)

Jyongc58d2fce89c0
diff --git a/api/.env.example b/api/.env.example
index 00b6c28a919..52cdd9ecb28 100644
--- a/api/.env.example
+++ b/api/.env.example
@@ -413,4 +413,3 @@ RESET_PASSWORD_TOKEN_EXPIRY_MINUTES=5
CREATE_TIDB_SERVICE_JOB_ENABLED=false
-RETRIEVAL_TOP_N=0
diff --git a/api/configs/feature/__init__.py b/api/configs/feature/__init__.py
index e88eb980577..f1cb3efda7b 100644
--- a/api/configs/feature/__init__.py
+++ b/api/configs/feature/__init__.py
@@ -626,8 +626,6 @@ class DataSetConfig(BaseSettings):
default=30,
)
- RETRIEVAL_TOP_N: int = Field(description="number of retrieval top_n", default=0)
-
class WorkspaceConfig(BaseSettings):
"""
diff --git a/api/core/rag/datasource/retrieval_service.py b/api/core/rag/datasource/retrieval_service.py
index 759166da4c4..b2141396d6d 100644
--- a/api/core/rag/datasource/retrieval_service.py
+++ b/api/core/rag/datasource/retrieval_service.py
@@ -3,7 +3,6 @@ from typing import Optional
from flask import Flask, current_app
-from configs import DifyConfig
from core.rag.data_post_processor.data_post_processor import DataPostProcessor
from core.rag.datasource.keyword.keyword_factory import Keyword
from core.rag.datasource.vdb.vector_factory import Vector
@@ -114,7 +113,7 @@ class RetrievalService:
query=query,
documents=all_documents,
score_threshold=score_threshold,
- top_n=DifyConfig.RETRIEVAL_TOP_N or top_k,
+ top_n=top_k,
)
return all_documents
@@ -186,7 +185,7 @@ class RetrievalService:
query=query,
documents=documents,
score_threshold=score_threshold,
- top_n=DifyConfig.RETRIEVAL_TOP_N or len(documents),
+ top_n=len(documents),
)
)
else:
@@ -231,7 +230,7 @@ class RetrievalService:
query=query,
documents=documents,
score_threshold=score_threshold,
- top_n=DifyConfig.RETRIEVAL_TOP_N or len(documents),
+ top_n=len(documents),
)
)
else: