adds the ability to rename chats
This commit is contained in:
@@ -754,9 +754,13 @@ export async function registerRoutes(app: FastifyInstance) {
|
||||
const suggestedRaw = await generateChatTitle(body.content);
|
||||
const title = normalizeSuggestedTitle(suggestedRaw, fallback);
|
||||
|
||||
const chat = await prisma.chat.update({
|
||||
where: { id: body.chatId },
|
||||
await prisma.chat.updateMany({
|
||||
where: { id: body.chatId, title: existing.title },
|
||||
data: { title },
|
||||
});
|
||||
|
||||
const chat = await prisma.chat.findUnique({
|
||||
where: { id: body.chatId },
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
@@ -768,6 +772,7 @@ export async function registerRoutes(app: FastifyInstance) {
|
||||
lastUsedModel: true,
|
||||
},
|
||||
});
|
||||
if (!chat) return app.httpErrors.notFound("chat not found");
|
||||
|
||||
return { chat: serializeProviderFields(chat) };
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user