@@ -214,17 +214,31 @@ export async function POST({ request, locals, params, getClientAddress }) {
214
214
if ( messageToRetry . from === "user" && newPrompt ) {
215
215
// add a sibling to this message from the user, with the alternative prompt
216
216
// add a children to that sibling, where we can write to
217
- const newUserMessageId = addSibling ( conv , { from : "user" , content : newPrompt } , messageId ) ;
217
+ const newUserMessageId = addSibling (
218
+ conv ,
219
+ { from : "user" , content : newPrompt , createdAt : new Date ( ) , updatedAt : new Date ( ) } ,
220
+ messageId
221
+ ) ;
218
222
messageToWriteToId = addChildren (
219
223
conv ,
220
- { from : "assistant" , content : "" , files : hashes } ,
224
+ {
225
+ from : "assistant" ,
226
+ content : "" ,
227
+ files : hashes ,
228
+ createdAt : new Date ( ) ,
229
+ updatedAt : new Date ( ) ,
230
+ } ,
221
231
newUserMessageId
222
232
) ;
223
233
messagesForPrompt = buildSubtree ( conv , newUserMessageId ) ;
224
234
} else if ( messageToRetry . from === "assistant" ) {
225
235
// we're retrying an assistant message, to generate a new answer
226
236
// just add a sibling to the assistant answer where we can write to
227
- messageToWriteToId = addSibling ( conv , { from : "assistant" , content : "" } , messageId ) ;
237
+ messageToWriteToId = addSibling (
238
+ conv ,
239
+ { from : "assistant" , content : "" , createdAt : new Date ( ) , updatedAt : new Date ( ) } ,
240
+ messageId
241
+ ) ;
228
242
messagesForPrompt = buildSubtree ( conv , messageId ) ;
229
243
messagesForPrompt . pop ( ) ; // don't need the latest assistant message in the prompt since we're retrying it
230
244
}
@@ -410,6 +424,8 @@ export async function POST({ request, locals, params, getClientAddress }) {
410
424
411
425
let buffer = "" ;
412
426
427
+ messageToWriteTo . updatedAt = new Date ( ) ;
428
+
413
429
try {
414
430
const endpoint = await model . getEndpoint ( ) ;
415
431
for await ( const output of await endpoint ( {
@@ -460,7 +476,6 @@ export async function POST({ request, locals, params, getClientAddress }) {
460
476
} , output . generated_text . trimEnd ( ) ) ;
461
477
462
478
messageToWriteTo . content = previousText + text ;
463
- messageToWriteTo . updatedAt = new Date ( ) ;
464
479
}
465
480
}
466
481
} catch ( e ) {
0 commit comments