mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
@@ -235,6 +235,12 @@ class CopilotHistoriesType implements Partial<ChatHistory> {
|
||||
@Field(() => String)
|
||||
sessionId!: string;
|
||||
|
||||
@Field(() => String)
|
||||
workspaceId!: string;
|
||||
|
||||
@Field(() => String, { nullable: true })
|
||||
docId!: string | null;
|
||||
|
||||
@Field(() => Boolean)
|
||||
pinned!: boolean;
|
||||
|
||||
@@ -254,6 +260,9 @@ class CopilotHistoriesType implements Partial<ChatHistory> {
|
||||
|
||||
@Field(() => Date)
|
||||
createdAt!: Date;
|
||||
|
||||
@Field(() => Date)
|
||||
updatedAt!: Date;
|
||||
}
|
||||
|
||||
@ObjectType('CopilotQuota')
|
||||
|
||||
@@ -298,13 +298,16 @@ export class ChatSessionService {
|
||||
const histories = await Promise.all(
|
||||
sessions.map(
|
||||
async ({
|
||||
id,
|
||||
userId: uid,
|
||||
id,
|
||||
workspaceId,
|
||||
docId,
|
||||
pinned,
|
||||
promptName,
|
||||
tokenCost,
|
||||
messages,
|
||||
createdAt,
|
||||
updatedAt,
|
||||
}) => {
|
||||
try {
|
||||
const prompt = await this.prompt.get(promptName);
|
||||
@@ -341,10 +344,13 @@ export class ChatSessionService {
|
||||
|
||||
return {
|
||||
sessionId: id,
|
||||
workspaceId,
|
||||
docId,
|
||||
pinned,
|
||||
action: prompt.action || null,
|
||||
tokens: tokenCost,
|
||||
createdAt,
|
||||
updatedAt,
|
||||
messages: preload.concat(ret.data).map(m => ({
|
||||
...m,
|
||||
attachments: m.attachments
|
||||
|
||||
@@ -47,11 +47,14 @@ export type ChatMessage = z.infer<typeof ChatMessageSchema>;
|
||||
export const ChatHistorySchema = z
|
||||
.object({
|
||||
sessionId: z.string(),
|
||||
workspaceId: z.string(),
|
||||
docId: z.string().nullable(),
|
||||
pinned: z.boolean(),
|
||||
action: z.string().nullable(),
|
||||
tokens: z.number(),
|
||||
messages: z.array(ChatMessageSchema),
|
||||
createdAt: z.date(),
|
||||
updatedAt: z.date(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user