MCPcopy Index your code
hub / github.com/FlowiseAI/Flowise / handleFeedbackQuery

Function handleFeedbackQuery

packages/server/src/utils/getChatMessage.ts:124–222  ·  view source on GitHub ↗
(params: {
    chatflowid: string
    chatTypes?: ChatType[]
    sortOrder: string
    chatId?: string
    memoryType?: string
    sessionId?: string
    startDate?: string
    endDate?: string
    messageId?: string
    feedbackTypes?: ChatMessageRatingType[]
    page: number
    pageSize: number
})

Source from the content-addressed store, hash-verified

122}
123
124async function handleFeedbackQuery(params: {
125 chatflowid: string
126 chatTypes?: ChatType[]
127 sortOrder: string
128 chatId?: string
129 memoryType?: string
130 sessionId?: string
131 startDate?: string
132 endDate?: string
133 messageId?: string
134 feedbackTypes?: ChatMessageRatingType[]
135 page: number
136 pageSize: number
137}): Promise<ChatMessage[]> {
138 const {
139 chatflowid,
140 chatTypes,
141 sortOrder,
142 chatId,
143 memoryType,
144 sessionId,
145 startDate,
146 endDate,
147 messageId,
148 feedbackTypes,
149 page,
150 pageSize
151 } = params
152
153 const appServer = getRunningExpressApp()
154
155 // For specific session/message queries, no pagination needed
156 if (sessionId || messageId) {
157 return await getMessagesWithFeedback(params, false)
158 }
159
160 // For paginated queries, handle session-based pagination efficiently
161 if (page > -1 && pageSize > -1) {
162 // First get session IDs with pagination
163 const sessionQuery = appServer.AppDataSource.getRepository(ChatMessage)
164 .createQueryBuilder('chat_message')
165 .select('chat_message.sessionId', 'sessionId')
166 .where('chat_message.chatflowid = :chatflowid', { chatflowid })
167
168 // Apply basic filters
169 if (chatTypes && chatTypes.length > 0) {
170 sessionQuery.andWhere('chat_message.chatType IN (:...chatTypes)', { chatTypes })
171 }
172 if (chatId) {
173 sessionQuery.andWhere('chat_message.chatId = :chatId', { chatId })
174 }
175 if (memoryType) {
176 sessionQuery.andWhere('chat_message.memoryType = :memoryType', { memoryType })
177 }
178 if (startDate && typeof startDate === 'string') {
179 sessionQuery.andWhere('chat_message.createdDate >= :startDateTime', {
180 startDateTime: new Date(startDate)
181 })

Callers 1

utilGetChatMessageFunction · 0.85

Calls 2

getRunningExpressAppFunction · 0.90
getMessagesWithFeedbackFunction · 0.85

Tested by

no test coverage detected