From 5fbe3810382416e5b508005e2edf005ed8364bc7 Mon Sep 17 00:00:00 2001 From: an-lee Date: Sun, 13 Oct 2024 11:58:28 +0800 Subject: [PATCH] escape { in prompt --- enjoy/src/commands/summarize-topic.command.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/enjoy/src/commands/summarize-topic.command.ts b/enjoy/src/commands/summarize-topic.command.ts index c188f151..86690abb 100644 --- a/enjoy/src/commands/summarize-topic.command.ts +++ b/enjoy/src/commands/summarize-topic.command.ts @@ -14,9 +14,11 @@ export const summarizeTopicCommand = async ( ): Promise => { if (!text) throw new Error("Text is required"); + const formattedText = text.replace(/\{/g, "{{").replace(/\}/g, "}}"); + const prompt = await ChatPromptTemplate.fromMessages([ ["system", SYSTEM_PROMPT], - ["human", text], + ["human", formattedText], ]).format({ learning_language: LANGUAGES.find((l) => l.code === learningLanguage).name, });