@@ -2,7 +2,7 @@ import type { ProfileResponse } from "supermemory/resources";
22import { CONFIG } from "../config.js" ;
33
44interface MemoryResultMinimal {
5- similarity : number ;
5+ similarity ? : number ;
66 memory ?: string ;
77 chunk ?: string ;
88}
@@ -24,14 +24,16 @@ export function formatContextForPrompt(
2424 if ( staticFacts . length > 0 ) {
2525 parts . push ( "\nUser Profile:" ) ;
2626 staticFacts . slice ( 0 , CONFIG . maxProfileItems ) . forEach ( ( fact ) => {
27- parts . push ( `- ${ fact } ` ) ;
27+ const text = typeof fact === "string" ? fact : ( fact as { content ?: string } ) . content ?? String ( fact ) ;
28+ parts . push ( `- ${ text } ` ) ;
2829 } ) ;
2930 }
3031
3132 if ( dynamicFacts . length > 0 ) {
3233 parts . push ( "\nRecent Context:" ) ;
3334 dynamicFacts . slice ( 0 , CONFIG . maxProfileItems ) . forEach ( ( fact ) => {
34- parts . push ( `- ${ fact } ` ) ;
35+ const text = typeof fact === "string" ? fact : ( fact as { content ?: string } ) . content ?? String ( fact ) ;
36+ parts . push ( `- ${ text } ` ) ;
3537 } ) ;
3638 }
3739 }
@@ -40,7 +42,7 @@ export function formatContextForPrompt(
4042 if ( projectResults . length > 0 ) {
4143 parts . push ( "\nProject Knowledge:" ) ;
4244 projectResults . forEach ( ( mem ) => {
43- const similarity = Math . round ( mem . similarity * 100 ) ;
45+ const similarity = Math . round ( ( mem . similarity ?? 0 ) * 100 ) ;
4446 const content = mem . memory || mem . chunk || "" ;
4547 parts . push ( `- [${ similarity } %] ${ content } ` ) ;
4648 } ) ;
@@ -50,7 +52,7 @@ export function formatContextForPrompt(
5052 if ( userResults . length > 0 ) {
5153 parts . push ( "\nRelevant Memories:" ) ;
5254 userResults . forEach ( ( mem ) => {
53- const similarity = Math . round ( mem . similarity * 100 ) ;
55+ const similarity = Math . round ( ( mem . similarity ?? 0 ) * 100 ) ;
5456 const content = mem . memory || mem . chunk || "" ;
5557 parts . push ( `- [${ similarity } %] ${ content } ` ) ;
5658 } ) ;
0 commit comments