From 48de6c97e3352d68591e85af4d8192b74fb6a18e Mon Sep 17 00:00:00 2001 From: Joshua <64296537+HashWarlock@users.noreply.github.com> Date: Fri, 24 Jan 2025 23:51:15 -0600 Subject: [PATCH] fix: make template message footer more explicit --- packages/core/src/parsing.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/core/src/parsing.ts b/packages/core/src/parsing.ts index 8a153e9df2b..4407a13abd8 100644 --- a/packages/core/src/parsing.ts +++ b/packages/core/src/parsing.ts @@ -1,10 +1,13 @@ import type { ActionResponse } from "./types.ts"; const jsonBlockPattern = /```json\n([\s\S]*?)\n```/; -export const messageCompletionFooter = `\nResponse format should be formatted in a JSON block like this: +export const messageCompletionFooter = `\nResponse format should be formatted in a valid JSON block like this: \`\`\`json -{ "user": "{{agentName}}", "text": "string", "action": "string" } -\`\`\``; +{ "user": "{{agentName}}", "text": "", "action": "" } +\`\`\` + +The “action” field should be one of the options in [Available Actions] and the "text" field should be the response you want to send. +`; export const shouldRespondFooter = `The available options are [RESPOND], [IGNORE], or [STOP]. Choose the most appropriate option. If {{agentName}} is talking too much, you can choose [IGNORE] @@ -60,7 +63,7 @@ export const parseBooleanFromText = (text: string) => { return null; // Return null for unrecognized inputs }; -export const stringArrayFooter = `Respond with a JSON array containing the values in a JSON block formatted for markdown with this structure: +export const stringArrayFooter = `Respond with a JSON array containing the values in a valid JSON block formatted for markdown with this structure: \`\`\`json [ 'value', @@ -68,7 +71,7 @@ export const stringArrayFooter = `Respond with a JSON array containing the value ] \`\`\` -Your response must include the JSON block.`; +Your response must include the valid JSON block.`; /** * Parses a JSON array from a given text. The function looks for a JSON block wrapped in triple backticks