Skip to content

Commit

Permalink
Allows query chatmessage API endpoint by messageId
Browse files Browse the repository at this point in the history
This will be useful when the exact message is required by another system.
  • Loading branch information
Jaredude committed Feb 13, 2024
1 parent 4e8bf49 commit a6abd59
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ export class App {
const chatId = req.query?.chatId as string | undefined
const memoryType = req.query?.memoryType as string | undefined
const sessionId = req.query?.sessionId as string | undefined
const messageId = req.query?.messageId as string | undefined
const startDate = req.query?.startDate as string | undefined
const endDate = req.query?.endDate as string | undefined
let chatTypeFilter = req.query?.chatType as chatType | undefined
Expand Down Expand Up @@ -538,7 +539,8 @@ export class App {
memoryType,
sessionId,
startDate,
endDate
endDate,
messageId
)
return res.json(chatmessages)
})
Expand Down Expand Up @@ -1440,7 +1442,8 @@ export class App {
memoryType?: string,
sessionId?: string,
startDate?: string,
endDate?: string
endDate?: string,
messageId?: string
): Promise<ChatMessage[]> {
let fromDate
if (startDate) fromDate = new Date(startDate)
Expand All @@ -1455,7 +1458,8 @@ export class App {
chatId,
memoryType: memoryType ?? (chatId ? IsNull() : undefined),
sessionId: sessionId ?? undefined,
createdDate: toDate && fromDate ? Between(fromDate, toDate) : undefined
createdDate: toDate && fromDate ? Between(fromDate, toDate) : undefined,
id: messageId ?? undefined
},
order: {
createdDate: sortOrder === 'DESC' ? 'DESC' : 'ASC'
Expand Down

0 comments on commit a6abd59

Please sign in to comment.