RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Refactor: retrieval test -> retrieval (#21748)
Wang Qi10601a981374
diff --git a/internal/handler/searchbot.go b/internal/handler/searchbot.goindex 30fcbff4fe..df2d73d944 100644--- a/internal/handler/searchbot.go+++ b/internal/handler/searchbot.go@@ -48,7 +48,7 @@ type SearchBotMindMapRequest struct {SearchID string `json:"search_id,omitempty"`}-// SearchBotRetrievalTestRequest is the request body for POST /api/v1/searchbots/retrieval-test.+// SearchBotRetrievalTestRequest is the request body for POST /api/v1/searchbots/retrieval.type SearchBotRetrievalTestRequest struct {KbIDs common.StringSlice `json:"kb_ids" binding:"required"`Question string `json:"question" binding:"required"`@@ -99,7 +99,7 @@ type SearchBotRequest struct {// SearchBotHandler handles searchbot endpoints://// POST /api/v1/searchbots/related-questions-// POST /api/v1/searchbots/retrieval-test+// POST /api/v1/searchbots/retrieval// POST /api/v1/searchbots/ask// POST /api/v1/searchbots/mindmaptype SearchBotHandler struct {@@ -166,7 +166,7 @@ func (h *SearchBotHandler) Handle(c *gin.Context) {// @Tags searchBots// @Param request body SearchBotRetrievalTestRequest true "Retrieval test parameters"// @Success 200 {object} map[string]interface{}-// @Router /api/v1/searchbots/retrieval-test [post]+// @Router /api/v1/searchbots/retrieval [post]func (h *SearchBotHandler) RetrievalTest(c *gin.Context) {user, errorCode, errorMessage := GetUser(c)if errorCode != common.CodeSuccess {diff --git a/internal/handler/searchbot_test.go b/internal/handler/searchbot_test.goindex 617470e482..2f4273dae6 100644--- a/internal/handler/searchbot_test.go+++ b/internal/handler/searchbot_test.go@@ -62,7 +62,7 @@ func setupSearchbotsTest(userID string) (*SearchBotHandler, *mockChunkService, *r.Use(func(c *gin.Context) {c.Set("user", &entity.User{ID: userID})})- r.POST("/api/v1/searchbots/retrieval-test", h.RetrievalTest)+ r.POST("/api/v1/searchbots/retrieval", h.RetrievalTest)return h, mockSvc, r}@@ -71,7 +71,7 @@ func TestSearchBotsRetrieval_Basic(t *testing.T) {body := `{"kb_ids": ["kb1"], "question": "test question"}`w := httptest.NewRecorder()- req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval-test", strings.NewReader(body))+ req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval", strings.NewReader(body))req.Header.Set("Content-Type", "application/json")r.ServeHTTP(w, req)@@ -107,7 +107,7 @@ func TestSearchBotsRetrieval_MissingKbID(t *testing.T) {_, _, r := setupSearchbotsTest("user1")body := `{"question": "test"}`w := httptest.NewRecorder()- req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval-test", strings.NewReader(body))+ req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval", strings.NewReader(body))req.Header.Set("Content-Type", "application/json")r.ServeHTTP(w, req)if w.Code != http.StatusBadRequest {@@ -130,7 +130,7 @@ func TestSearchBotsRetrieval_MissingQuestion(t *testing.T) {_, _, r := setupSearchbotsTest("user1")body := `{"kb_ids": ["kb1"]}`w := httptest.NewRecorder()- req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval-test", strings.NewReader(body))+ req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval", strings.NewReader(body))req.Header.Set("Content-Type", "application/json")r.ServeHTTP(w, req)if w.Code != http.StatusBadRequest {@@ -153,10 +153,10 @@ func TestSearchBotsRetrieval_NoAuth(t *testing.T) {h := NewSearchBotHandler(nil, nil, nil, &mockChunkService{})gin.SetMode(gin.TestMode)r := gin.New()- r.POST("/api/v1/searchbots/retrieval-test", h.RetrievalTest)+ r.POST("/api/v1/searchbots/retrieval", h.RetrievalTest)w := httptest.NewRecorder()body := `{"kb_ids": ["kb1"], "question": "test"}`- req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval-test", strings.NewReader(body))+ req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval", strings.NewReader(body))req.Header.Set("Content-Type", "application/json")r.ServeHTTP(w, req)if w.Code != http.StatusUnauthorized {@@ -173,7 +173,7 @@ func TestSearchBotsRetrieval_ServiceError(t *testing.T) {}w := httptest.NewRecorder()body := `{"kb_ids": ["kb1"], "question": "test"}`- req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval-test", strings.NewReader(body))+ req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval", strings.NewReader(body))req.Header.Set("Content-Type", "application/json")r.ServeHTTP(w, req)if w.Code != http.StatusOK {@@ -197,7 +197,7 @@ func TestSearchBotsRetrieval_KbIDSingleString(t *testing.T) {body := `{"kb_ids": "kb1", "question": "test"}`w := httptest.NewRecorder()- req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval-test", strings.NewReader(body))+ req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval", strings.NewReader(body))req.Header.Set("Content-Type", "application/json")r.ServeHTTP(w, req)@@ -218,7 +218,7 @@ func TestSearchBotsRetrieval_KbIDArray(t *testing.T) {body := `{"kb_ids": ["a","b"], "question": "test"}`w := httptest.NewRecorder()- req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval-test", strings.NewReader(body))+ req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval", strings.NewReader(body))req.Header.Set("Content-Type", "application/json")r.ServeHTTP(w, req)@@ -236,7 +236,7 @@ func TestSearchBotsRetrieval_KbIDArray(t *testing.T) {func TestSearchBotsRetrieval_InvalidJSON(t *testing.T) {_, _, r := setupSearchbotsTest("user1")w := httptest.NewRecorder()- req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval-test", strings.NewReader("{invalid}"))+ req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval", strings.NewReader("{invalid}"))req.Header.Set("Content-Type", "application/json")r.ServeHTTP(w, req)if w.Code != http.StatusBadRequest {@@ -248,7 +248,7 @@ func TestSearchBotsRetrieval_EmptyStringKbID(t *testing.T) {_, _, r := setupSearchbotsTest("user1")body := `{"kb_ids": "", "question": "test"}`w := httptest.NewRecorder()- req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval-test", strings.NewReader(body))+ req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval", strings.NewReader(body))req.Header.Set("Content-Type", "application/json")r.ServeHTTP(w, req)if w.Code != http.StatusBadRequest {@@ -267,7 +267,7 @@ func TestSearchBotsRetrieval_WhitespaceOnlyKbID(t *testing.T) {_, _, r := setupSearchbotsTest("user1")body := `{"kb_ids": " ", "question": "test"}`w := httptest.NewRecorder()- req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval-test", strings.NewReader(body))+ req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval", strings.NewReader(body))req.Header.Set("Content-Type", "application/json")r.ServeHTTP(w, req)if w.Code != http.StatusBadRequest {@@ -291,7 +291,7 @@ func TestSearchBotsRetrieval_DefaultsApplied(t *testing.T) {body := `{"kb_ids": ["kb1"], "question": "does this default?"}`w := httptest.NewRecorder()- req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval-test", strings.NewReader(body))+ req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval", strings.NewReader(body))req.Header.Set("Content-Type", "application/json")r.ServeHTTP(w, req)@@ -330,7 +330,7 @@ func TestSearchBotsRetrieval_TopKZero(t *testing.T) {_, _, r := setupSearchbotsTest("user1")body := `{"kb_ids": ["kb1"], "question": "test", "top_k": 0}`w := httptest.NewRecorder()- req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval-test", strings.NewReader(body))+ req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval", strings.NewReader(body))req.Header.Set("Content-Type", "application/json")r.ServeHTTP(w, req)if w.Code != http.StatusBadRequest {@@ -349,7 +349,7 @@ func TestSearchBotsRetrieval_TopKNegative(t *testing.T) {_, _, r := setupSearchbotsTest("user1")body := `{"kb_ids": ["kb1"], "question": "test", "top_k": -1}`w := httptest.NewRecorder()- req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval-test", strings.NewReader(body))+ req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval", strings.NewReader(body))req.Header.Set("Content-Type", "application/json")r.ServeHTTP(w, req)if w.Code != http.StatusBadRequest {@@ -393,7 +393,7 @@ func TestSearchBotsRetrieval_EmptyQuestion(t *testing.T) {_, _, r := setupSearchbotsTest("user1")body := `{"kb_ids": ["kb1"], "question": ""}`w := httptest.NewRecorder()- req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval-test", strings.NewReader(body))+ req, _ := http.NewRequest("POST", "/api/v1/searchbots/retrieval", strings.NewReader(body))req.Header.Set("Content-Type", "application/json")r.ServeHTTP(w, req)if w.Code != http.StatusBadRequest {diff --git a/internal/router/router.go b/internal/router/router.goindex 854739d03f..845820d7aa 100644--- a/internal/router/router.go+++ b/internal/router/router.go@@ -204,7 +204,7 @@ func (r *Router) Setup(engine *gin.Engine) {{searchBotGroup := apiBetaAuth.Group("/searchbots")searchBotGroup.POST("/related-questions", r.searchBotHandler.Handle)- searchBotGroup.POST("/retrieval-test", r.searchBotHandler.RetrievalTest)+ searchBotGroup.POST("/retrieval", r.searchBotHandler.RetrievalTest)searchBotGroup.POST("/ask", r.searchBotHandler.Ask)searchBotGroup.POST("/mindmap", r.searchBotHandler.MindMap)diff --git a/web/src/utils/api.ts b/web/src/utils/api.tsindex c9c33a5ba0..dddb1effe7 100644--- a/web/src/utils/api.ts+++ b/web/src/utils/api.ts@@ -449,7 +449,7 @@ const apiEndpoints = {askShare: `${restAPIv1}/searchbots/ask`,mindmapShare: `${restAPIv1}/searchbots/mindmap`,getRelatedQuestionsShare: `${restAPIv1}/searchbots/related-questions`,- retrievalTestShare: `${restAPIv1}/searchbots/retrieval-test`,+ retrievalTestShare: `${restAPIv1}/searchbots/retrieval`,// memorycreateMemory: `${restAPIv1}/memories`,