mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-29 15:22:02 +03:00
feat(server): add created timestamp to history (#6607)
This commit is contained in:
parent
5fc56a20ac
commit
d9e6561762
@ -123,6 +123,9 @@ class CopilotHistoriesType implements Partial<ChatHistory> {
|
||||
|
||||
@Field(() => [ChatMessageType])
|
||||
messages!: ChatMessageType[];
|
||||
|
||||
@Field(() => Date)
|
||||
createdAt!: Date;
|
||||
}
|
||||
|
||||
@ObjectType('CopilotQuota')
|
||||
|
@ -318,6 +318,7 @@ export class ChatSessionService {
|
||||
select: {
|
||||
id: true,
|
||||
promptName: true,
|
||||
createdAt: true,
|
||||
messages: {
|
||||
select: {
|
||||
role: true,
|
||||
@ -335,7 +336,7 @@ export class ChatSessionService {
|
||||
})
|
||||
.then(sessions =>
|
||||
Promise.all(
|
||||
sessions.map(async ({ id, promptName, messages }) => {
|
||||
sessions.map(async ({ id, promptName, messages, createdAt }) => {
|
||||
try {
|
||||
const ret = PromptMessageSchema.array().safeParse(messages);
|
||||
if (ret.success) {
|
||||
@ -357,6 +358,7 @@ export class ChatSessionService {
|
||||
sessionId: id,
|
||||
action: prompt.action || undefined,
|
||||
tokens,
|
||||
createdAt,
|
||||
messages: preload.concat(ret.data),
|
||||
};
|
||||
} else {
|
||||
|
@ -93,6 +93,7 @@ export const ChatHistorySchema = z
|
||||
action: z.string().optional(),
|
||||
tokens: z.number(),
|
||||
messages: z.array(PromptMessageSchema.or(ChatMessageSchema)),
|
||||
createdAt: z.date(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
|
@ -9,6 +9,7 @@ query getCopilotHistories(
|
||||
sessionId
|
||||
tokens
|
||||
action
|
||||
createdAt
|
||||
messages {
|
||||
role
|
||||
content
|
||||
|
Loading…
Reference in New Issue
Block a user