fix chat streaming + add "deleted" field to chats

This commit is contained in:
Emily
2024-12-13 15:07:34 +01:00
parent f358bb9bb6
commit 6307e09dc3
7 changed files with 36 additions and 26 deletions

View File

@@ -1,4 +1,4 @@
import { getUserProjectFromId } from "~/server/LIVE_DEMO_DATA";
import { AiChatModel } from "@schema/ai/AiChatSchema";
export default defineEventHandler(async event => {
@@ -7,10 +7,10 @@ export default defineEventHandler(async event => {
if (!data) return;
const { project_id } = data;
if (!event.context.params) return;
const chat_id = event.context.params['chat_id'];
const result = await AiChatModel.deleteOne({ _id: chat_id, project_id });
return result.deletedCount > 0;
const result = await AiChatModel.updateOne({ _id: chat_id, project_id }, { deleted: true });
return result.modifiedCount > 0;
});

View File

@@ -9,7 +9,7 @@ export default defineEventHandler(async event => {
const { project_id } = data;
const chatList = await AiChatModel.find({ project_id }, { _id: 1, title: 1 }, { sort: { updated_at: 1 } });
const chatList = await AiChatModel.find({ project_id, deleted: false }, { _id: 1, title: 1 }, { sort: { updated_at: 1 } });
return chatList.map(e => e.toJSON());

View File

@@ -47,8 +47,8 @@ export default defineEventHandler(async event => {
await updateChatStatus(targetChatId, currentStatus.join(''), false);
},
onFinish: async calls => {
currentStatus.push('[data:FunctionFinish]');
await updateChatStatus(targetChatId, currentStatus.join(''), false);
// currentStatus.push('[data:FunctionFinish]');
// await updateChatStatus(targetChatId, currentStatus.join(''), false);
}
});