File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -39,13 +39,15 @@ export const POST: RequestHandler = async ({ locals, request }) => {
39
39
}
40
40
41
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 ;
42
44
43
45
const res = await collections . conversations . insertOne ( {
44
46
_id : new ObjectId ( ) ,
45
47
title : title || "New Chat" ,
46
48
messages,
47
49
model : values . model ,
48
- preprompt : preprompt === model ?. preprompt ? undefined : preprompt ,
50
+ preprompt : preprompt === model ?. preprompt ? model ?. preprompt : preprompt ,
49
51
createdAt : new Date ( ) ,
50
52
updatedAt : new Date ( ) ,
51
53
...( locals . user ? { userId : locals . user . _id } : { sessionId : locals . sessionId } ) ,
You can’t perform that action at this time.
0 commit comments