@@ -12,6 +12,8 @@ import {
12
12
ModelClass ,
13
13
State ,
14
14
} from "@ai16z/eliza" ;
15
+ import * as fs from 'fs' ;
16
+
15
17
export const summarizationTemplate = `# Summarized so far (we are adding to this)
16
18
{{currentSummary}}
17
19
@@ -225,16 +227,35 @@ ${currentSummary.trim()}
225
227
` ;
226
228
await callback ( callbackData ) ;
227
229
} else if ( currentSummary . trim ( ) ) {
228
- const summaryFilename = `content/summary_${ Date . now ( ) } ` ;
229
- await runtime . cacheManager . set ( summaryFilename , currentSummary ) ;
230
- // save the summary to a file
231
- await callback (
232
- {
233
- ...callbackData ,
234
- text : `I've attached the summary of the requested attachments as a text file.` ,
235
- } ,
236
- [ summaryFilename ]
237
- ) ;
230
+ const summaryFilename = `content/summary_${ Date . now ( ) } .md` ;
231
+
232
+ try {
233
+ // Debug: Log before file operations
234
+ console . log ( "Creating summary file:" , {
235
+ filename : summaryFilename ,
236
+ summaryLength : currentSummary . length
237
+ } ) ;
238
+
239
+ // Write file directly first
240
+ await fs . promises . writeFile ( summaryFilename , currentSummary , 'utf8' ) ;
241
+ console . log ( "File written successfully" ) ;
242
+
243
+ // Then cache it
244
+ await runtime . cacheManager . set ( summaryFilename , currentSummary ) ;
245
+ console . log ( "Cache set operation completed" ) ;
246
+
247
+ await callback (
248
+ {
249
+ ...callbackData ,
250
+ text : `I've attached the summary of the requested attachments as a text file.` ,
251
+ } ,
252
+ [ summaryFilename ]
253
+ ) ;
254
+ console . log ( "Callback completed with summary file" ) ;
255
+ } catch ( error ) {
256
+ console . error ( "Error in file/cache process:" , error ) ;
257
+ throw error ;
258
+ }
238
259
} else {
239
260
console . warn (
240
261
"Empty response from chat with attachments action, skipping"
0 commit comments