Galén commited on
Commit
e6e851b
1 Parent(s): bb33d30

Fix preprompt so it gets read correctly from the model.preprompt (#595)

Browse files
Files changed (1) hide show
  1. src/routes/conversation/+server.ts +3 -1
src/routes/conversation/+server.ts CHANGED
@@ -39,13 +39,15 @@ export const POST: RequestHandler = async ({ locals, request }) => {
39
  }
40
 
41
  const model = models.find((m) => m.name === values.model);
 
 
42
 
43
  const res = await collections.conversations.insertOne({
44
  _id: new ObjectId(),
45
  title: title || "New Chat",
46
  messages,
47
  model: values.model,
48
- preprompt: preprompt === model?.preprompt ? undefined : preprompt,
49
  createdAt: new Date(),
50
  updatedAt: new Date(),
51
  ...(locals.user ? { userId: locals.user._id } : { sessionId: locals.sessionId }),
 
39
  }
40
 
41
  const model = models.find((m) => m.name === values.model);
42
+ // Use the model preprompt if there is no conversation/preprompt in the request body
43
+ preprompt = preprompt === undefined ? model?.preprompt : preprompt;
44
 
45
  const res = await collections.conversations.insertOne({
46
  _id: new ObjectId(),
47
  title: title || "New Chat",
48
  messages,
49
  model: values.model,
50
+ preprompt: preprompt === model?.preprompt ? model?.preprompt : preprompt,
51
  createdAt: new Date(),
52
  updatedAt: new Date(),
53
  ...(locals.user ? { userId: locals.user._id } : { sessionId: locals.sessionId }),