From 82317e47570b61ab2565287aae644bc807d93f47 Mon Sep 17 00:00:00 2001 From: Rahmania Astrid Mochtar Date: Tue, 24 Dec 2024 15:09:48 +0100 Subject: [PATCH 1/2] Add additional backslash to escapedPrompt --- src/components/chat-item/chat-prompt-input.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/chat-item/chat-prompt-input.ts b/src/components/chat-item/chat-prompt-input.ts index c84d1b9c..5b616246 100644 --- a/src/components/chat-item/chat-prompt-input.ts +++ b/src/components/chat-item/chat-prompt-input.ts @@ -679,7 +679,7 @@ export class ChatPromptInput { context.push(match); } return `**${match}**`; - })); + })).replace(/\\/g, '\\\\'); const promptData: {tabId: string; prompt: ChatPrompt} = { tabId: this.props.tabId, From 995563af24167f22b798c831ada12105f89d8f47 Mon Sep 17 00:00:00 2001 From: Rahmania Astrid Mochtar Date: Tue, 24 Dec 2024 15:47:24 +0100 Subject: [PATCH 2/2] Improve regex to ignore if inside backticks --- src/components/chat-item/chat-prompt-input.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/chat-item/chat-prompt-input.ts b/src/components/chat-item/chat-prompt-input.ts index 5b616246..3ca83151 100644 --- a/src/components/chat-item/chat-prompt-input.ts +++ b/src/components/chat-item/chat-prompt-input.ts @@ -679,7 +679,7 @@ export class ChatPromptInput { context.push(match); } return `**${match}**`; - })).replace(/\\/g, '\\\\'); + })).replace(/\\(?![^`]*`[^`]*(?:`[^`]*`[^`]*)*$)/g, '\\\\'); const promptData: {tabId: string; prompt: ChatPrompt} = { tabId: this.props.tabId,