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

Function getMessagesWithFeedback

packages/server/src/utils/getChatMessage.ts:224–296  ·  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[]
    },
    useSessionList: boolean = false,
    sessionIdList?: string[]
)

Source from the content-addressed store, hash-verified

222}
223
224async function getMessagesWithFeedback(
225 params: {
226 chatflowid: string
227 chatTypes?: ChatType[]
228 sortOrder: string
229 chatId?: string
230 memoryType?: string
231 sessionId?: string
232 startDate?: string
233 endDate?: string
234 messageId?: string
235 feedbackTypes?: ChatMessageRatingType[]
236 },
237 useSessionList: boolean = false,
238 sessionIdList?: string[]
239): Promise<ChatMessage[]> {
240 const { chatflowid, chatTypes, sortOrder, chatId, memoryType, sessionId, startDate, endDate, messageId, feedbackTypes } = params
241
242 const appServer = getRunningExpressApp()
243 const query = appServer.AppDataSource.getRepository(ChatMessage).createQueryBuilder('chat_message')
244
245 query
246 .leftJoinAndSelect('chat_message.execution', 'execution')
247 .leftJoinAndMapOne('chat_message.feedback', ChatMessageFeedback, 'feedback', 'feedback.messageId = chat_message.id')
248 .where('chat_message.chatflowid = :chatflowid', { chatflowid })
249
250 // Apply filters
251 if (useSessionList && sessionIdList && sessionIdList.length > 0) {
252 query.andWhere('chat_message.sessionId IN (:...sessionIds)', { sessionIds: sessionIdList })
253 }
254
255 if (chatTypes && chatTypes.length > 0) {
256 query.andWhere('chat_message.chatType IN (:...chatTypes)', { chatTypes })
257 }
258 if (chatId) {
259 query.andWhere('chat_message.chatId = :chatId', { chatId })
260 }
261 if (memoryType) {
262 query.andWhere('chat_message.memoryType = :memoryType', { memoryType })
263 }
264 if (sessionId) {
265 query.andWhere('chat_message.sessionId = :sessionId', { sessionId })
266 }
267 if (messageId) {
268 query.andWhere('chat_message.id = :messageId', { messageId })
269 }
270 if (startDate && typeof startDate === 'string') {
271 query.andWhere('chat_message.createdDate >= :startDateTime', {
272 startDateTime: new Date(startDate)
273 })
274 }
275 if (endDate && typeof endDate === 'string') {
276 query.andWhere('chat_message.createdDate <= :endDateTime', {
277 endDateTime: new Date(endDate)
278 })
279 }
280
281 // Pre-filter by feedback types if specified (more efficient than post-processing)

Callers 1

handleFeedbackQueryFunction · 0.85

Calls 2

getRunningExpressAppFunction · 0.90

Tested by

no test coverage detected