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
Go: add parameter parsing of list chats (#14026)
Jin Hai3d59448b0d36
diff --git a/internal/handler/chat.go b/internal/handler/chat.goindex 4fa7928126..186763cbcc 100644--- a/internal/handler/chat.go+++ b/internal/handler/chat.go@@ -56,8 +56,32 @@ func (h *ChatHandler) ListChats(c *gin.Context) {}userID := user.ID+ // Parse query parameters+ keywords := c.Query("keywords")++ page := 0+ if pageStr := c.Query("page"); pageStr != "" {+ if p, err := strconv.Atoi(pageStr); err == nil && p > 0 {+ page = p+ }+ }++ pageSize := 0+ if pageSizeStr := c.Query("page_size"); pageSizeStr != "" {+ if ps, err := strconv.Atoi(pageSizeStr); err == nil && ps > 0 {+ pageSize = ps+ }+ }++ orderby := c.DefaultQuery("orderby", "create_time")++ desc := true+ if descStr := c.Query("desc"); descStr != "" {+ desc = descStr != "false"+ }+// List chats - default to valid status "1" (same as Python StatusEnum.VALID.value)- result, err := h.chatService.ListChats(userID, "1")+ result, err := h.chatService.ListChats(userID, keywords, "1", page, pageSize, orderby, desc)if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"code": 500,diff --git a/internal/service/chat.go b/internal/service/chat.goindex d02ffd200f..832154ffd7 100644--- a/internal/service/chat.go+++ b/internal/service/chat.go@@ -59,7 +59,7 @@ type ListChatsResponse struct {}// ListChats list chats for a user-func (s *ChatService) ListChats(userID string, status string) (*ListChatsResponse, error) {+func (s *ChatService) ListChats(userID, status, keywords string, page, pageSize int, orderby string, desc bool) (*ListChatsResponse, error) {// Get tenant IDs by user IDtenantIDs, err := s.userTenantDAO.GetTenantIDsByUserID(userID)if err != nil {@@ -81,6 +81,21 @@ func (s *ChatService) ListChats(userID string, status string) (*ListChatsResponsreturn nil, err}+ total := int64(len(chats))++ if page > 0 && pageSize > 0 {+ start := (page - 1) * pageSize+ end := start + pageSize+ if start < int(total) {+ if end > int(total) {+ end = int(total)+ }+ chats = chats[start:end]+ } else {+ chats = []*entity.Chat{}+ }+ }+// Enrich with knowledge base nameschatsWithKBNames := make([]*ChatWithKBNames, 0, len(chats))for _, chat := range chats {