diff --git a/src/lib/evaluators/__tests__/reflect.test.ts b/src/lib/evaluators/__tests__/reflect.test.ts index ae0d4a3..4cf0fb0 100644 --- a/src/lib/evaluators/__tests__/reflect.test.ts +++ b/src/lib/evaluators/__tests__/reflect.test.ts @@ -115,13 +115,11 @@ describe("User Profile", () => { const result = (await handler(runtime, message)) as string[]; const resultConcatenated = result.join("\n"); - const state = await runtime.composeState(message); - - console.log("************ state.recentMessages\n", state.recentMessages); - console.log("************ resultConcatenated\n", resultConcatenated); - - console.log("Expecting the facts to contain programmer and Jim"); + // const state = await runtime.composeState(message); + // console.log("************ state.recentMessages\n", state.recentMessages); + // console.log("************ resultConcatenated\n", resultConcatenated); + // console.log("Expecting the facts to contain programmer and Jim"); expect(resultConcatenated.toLowerCase()).toMatch(/programmer|startup/); expect(resultConcatenated.toLowerCase()).toMatch(/jim/); @@ -138,15 +136,16 @@ describe("User Profile", () => { const result2 = (await handler(runtime, message)) as string[]; const resultConcatenated2 = result2.join("\n"); - const state2 = await runtime.composeState(message); + // const state2 = await runtime.composeState(message); + // console.log("************ state.recentMessages\n", state2.recentMessages); + // console.log("************ resultConcatenated2\n", resultConcatenated2); + // console.log("Expecting the facts to contain francisco"); - console.log("************ state.recentMessages\n", state2.recentMessages); - console.log("************ resultConcatenated2\n", resultConcatenated2); - console.log("Expecting the facts to contain francisco"); + // expect result to ignore 'francisco' and '38' since they are already known + expect(resultConcatenated2.toLowerCase()).not.toMatch(/francisco/); + expect(resultConcatenated2.toLowerCase()).not.toMatch(/38/); - // expect result to not match 38 - expect(resultConcatenated2.toLowerCase()).toMatch(/francisco/); - expect(resultConcatenated2.toLowerCase()).toMatch(/38/); + // expect result to contain 'married' since it is not already known expect(resultConcatenated2.toLowerCase()).toMatch(/married/); }, 60000); }); diff --git a/src/lib/evaluators/reflect.ts b/src/lib/evaluators/reflect.ts index be00873..2b19f6c 100644 --- a/src/lib/evaluators/reflect.ts +++ b/src/lib/evaluators/reflect.ts @@ -86,6 +86,7 @@ Extract any claims from the conversation in the ACTUAL scene that are not alread - Status is pertinent to the current scene or character's immediate situation, also includes the character's thoughts, feelings, judgments or recommendations - Response should be a JSON object array inside a JSON markdown block - Ignore the examples when considering facts +- Include any factual detail, including where the user lives, works, or goes to school, what they do for a living, their hobbies, and any other relevant information Correct response format: \`\`\`json @@ -112,7 +113,16 @@ Scene Dialog: {{recentMessages}} \`\`\` -INSTRUCTIONS: Extract any claims from the conversation in the scene that are not already present in the list of facts.`; +INSTRUCTIONS: Extract ALL claims from the conversation in the scene that are not already present in the list of facts. + +Correct response format: +\`\`\`json +[ + {claim: string, type: enum, in_bio: boolean, already_known: boolean }, + {claim: string, type: enum, in_bio: boolean, already_known: boolean }, + ... +] +\`\`\``; async function handler(runtime: BgentRuntime, message: Message) { const state = (await runtime.composeState(message)) as State; @@ -150,13 +160,13 @@ async function handler(runtime: BgentRuntime, message: Message) { template, }); - if (runtime.debugMode) { + // if (runtime.debugMode) { logger.log(context, { title: "Reflection context", frame: true, color: "cyan", }); - } + // } let reflections = null; @@ -165,6 +175,7 @@ async function handler(runtime: BgentRuntime, message: Message) { context, stop: [], }); + console.log('reflectionText', reflectionText) const parsedReflections = parseJsonArrayFromText(reflectionText); if (parsedReflections) { reflections = parsedReflections; diff --git a/src/lib/logger.ts b/src/lib/logger.ts index 23523cb..6fb4063 100644 --- a/src/lib/logger.ts +++ b/src/lib/logger.ts @@ -658,7 +658,7 @@ const applyStyle = (self: { (...arguments_: any[]): any;[x: string]: any; "__@GE Object.defineProperties(createChalk.prototype, styles2); const chalk = createChalk({ level: 0 }); -export const chalkStderr = createChalk({ level: stderrColor ? (stderrColor as { level?: number}).level : 0 }); +export const chalkStderr = createChalk({ level: stderrColor ? (stderrColor as { level?: number }).level : 0 }); export { stdoutColor as supportsColor, @@ -700,25 +700,16 @@ class Logger { frameMessage(message: string, title: string) { const lines = message.split("\n"); - const maxLength = Math.max( - ...lines.map((line: string) => line.length), - title.length, - ); - const topFrame = title - ? this.frameChar.repeat(maxLength + 4) + - "\n" + + const frameHorizontalLength = 30; + const topFrame = this.frameChar.repeat(frameHorizontalLength + 4) + + " " + this.frameChar + " " + - title + - " ".repeat(maxLength - title.length + 1) + - this.frameChar - : this.frameChar.repeat(maxLength + 4); - const bottomFrame = this.frameChar.repeat(maxLength + 4); - const framedLines = lines.map( - (line: string) => - `${this.frameChar} ${line} ${" ".repeat(maxLength - line.length)} ${this.frameChar}`, - ); - return [topFrame, ...framedLines, bottomFrame].join("\n"); + (title ?? 'log') + + " ".repeat(frameHorizontalLength - (title as string ?? 'log' as string).length + 1) + + this.frameChar.repeat(frameHorizontalLength + 4); + const bottomFrame = this.frameChar.repeat(frameHorizontalLength + 4); + return [topFrame, ...lines, bottomFrame].join("\n"); } }