JoFrost
update to current version
5528541
import { buildPrompt } from "$lib/buildPrompt";
import { authCondition } from "$lib/server/auth";
import { collections } from "$lib/server/database";
import { generateFromDefaultEndpoint } from "$lib/server/generateFromDefaultEndpoint";
import { defaultModel } from "$lib/server/models";
import { error } from "@sveltejs/kit";
export async function POST({ params, locals }) {
/*const convId = new ObjectId(params.id);
const conversation = await collections.conversations.findOne({
_id: convId,
...authCondition(locals),
});
if (!conversation) {
throw error(404, "Conversation not found");
}
const firstMessage = conversation.messages.find((m) => m.from === "user");
const userPrompt =
`Please summarize the following message as a single sentence of less than 5 words:\n` +
firstMessage?.content;
const prompt = await buildPrompt({
messages: [{ from: "user", content: userPrompt }],
model: defaultModel,
});
const generated_text = await generateFromDefaultEndpoint(prompt);
if (generated_text) {
await collections.conversations.updateOne(
{
_id: convId,
...authCondition(locals),
},
{
$set: { title: generated_text },
}
);
}
return new Response(
JSON.stringify(
generated_text
? {
title: generated_text,
}
: {}
),
{ headers: { "Content-Type": "application/json" } }
);*/
return new Response(JSON.stringify({}), { headers: { "Content-Type": "application/json" } });
}