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