Add streaming to AI

This commit is contained in:
Emily
2024-12-11 18:32:22 +01:00
parent 23b8f7229a
commit f358bb9bb6
5 changed files with 271 additions and 51 deletions

View File

@@ -0,0 +1,17 @@
import { AiChatModel } from "@schema/ai/AiChatSchema";
export default defineEventHandler(async event => {
const data = await getRequestData(event);
if (!data) return;
const { project_id } = data;
if (!event.context.params) return;
const chat_id = event.context.params['chat_id'];
const chat = await AiChatModel.findOne({ _id: chat_id, project_id }, { status: 1, completed: 1 });
if (!chat) return;
return { status: chat.status, completed: chat.completed || false }
});