mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-30 05:34:21 +03:00
fix: re-create session should skip rewrite messages (#6513)
This commit is contained in:
parent
5cd4c051fd
commit
db1206dbd5
@ -111,8 +111,9 @@ class CopilotHistoriesType implements Partial<ChatHistory> {
|
||||
|
||||
@Field(() => String, {
|
||||
description: 'An mark identifying which view to use to display the session',
|
||||
nullable: true,
|
||||
})
|
||||
action!: string;
|
||||
action!: string | undefined;
|
||||
|
||||
@Field(() => Number, {
|
||||
description: 'The number of tokens used in the session',
|
||||
|
@ -138,6 +138,11 @@ export class ChatSessionService {
|
||||
if (id) sessionId = id;
|
||||
}
|
||||
|
||||
const messages = state.messages.map(m => ({
|
||||
...m,
|
||||
params: m.params || undefined,
|
||||
}));
|
||||
|
||||
await tx.aiSession.upsert({
|
||||
where: {
|
||||
id: sessionId,
|
||||
@ -145,12 +150,9 @@ export class ChatSessionService {
|
||||
},
|
||||
update: {
|
||||
messages: {
|
||||
// delete old messages
|
||||
deleteMany: {},
|
||||
create: state.messages.map(m => ({
|
||||
...m,
|
||||
params: m.params || undefined,
|
||||
})),
|
||||
// skip delete old messages if no new messages
|
||||
deleteMany: messages.length ? {} : undefined,
|
||||
create: messages,
|
||||
},
|
||||
},
|
||||
create: {
|
||||
@ -158,10 +160,7 @@ export class ChatSessionService {
|
||||
workspaceId: state.workspaceId,
|
||||
docId: state.docId,
|
||||
messages: {
|
||||
create: state.messages.map(m => ({
|
||||
...m,
|
||||
params: m.params || undefined,
|
||||
})),
|
||||
create: messages,
|
||||
},
|
||||
// connect
|
||||
user: { connect: { id: state.userId } },
|
||||
|
@ -24,7 +24,7 @@ type Copilot {
|
||||
|
||||
type CopilotHistories {
|
||||
"""An mark identifying which view to use to display the session"""
|
||||
action: String!
|
||||
action: String
|
||||
messages: [ChatMessage!]!
|
||||
sessionId: String!
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user