huggi / src /routes /conversation /[id] /+page.server.ts
julien-c's picture
julien-c HF staff
Auto-naming convos by summarizing them (#58)
3e9f86e unverified
raw
history blame
538 Bytes
import type { PageServerLoad } from "./$types";
import { collections } from "$lib/server/database";
import { ObjectId } from "mongodb";
import { error } from "@sveltejs/kit";
export const load: PageServerLoad = async (event) => {
// todo: add validation on params.id
const conversation = await collections.conversations.findOne({
_id: new ObjectId(event.params.id),
sessionId: event.locals.sessionId,
});
if (!conversation) {
throw error(404, "Conversation not found");
}
return {
messages: conversation.messages,
};
};