From a80ac42c92846cff34083218978f5f09ba36d2f2 Mon Sep 17 00:00:00 2001 From: Hk-Gosuto Date: Wed, 26 Feb 2025 17:27:00 +0800 Subject: [PATCH] fix: MYFILES_BROWSER_TOOLS_SYSTEM_PROMPT --- app/store/chat.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/store/chat.ts b/app/store/chat.ts index bb2284563..db4220b48 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -36,6 +36,7 @@ import { createEmptyMask, Mask } from "./mask"; import { FileInfo, WebApi } from "../client/platforms/utils"; import { usePluginStore } from "./plugin"; import { TavilySearchResponse } from "@tavily/core"; +import { MYFILES_BROWSER_TOOLS_SYSTEM_PROMPT } from "../prompt"; export interface ChatToolMessage { toolName: string; @@ -648,13 +649,23 @@ export const useChatStore = createPersistStore( session.mask.modelConfig.model.startsWith("chatgpt-")); var systemPrompts: ChatMessage[] = []; + var template = DEFAULT_SYSTEM_TEMPLATE; + if (session.attachFiles && session.attachFiles.length > 0) { + template += MYFILES_BROWSER_TOOLS_SYSTEM_PROMPT; + session.attachFiles.forEach((file) => { + template += `filename: \`${file.originalFilename}\` +partialDocument: \`\`\` +${file.partial} +\`\`\``; + }); + } systemPrompts = shouldInjectSystemPrompts ? [ createMessage({ role: "system", content: fillTemplateWith("", { ...modelConfig, - template: DEFAULT_SYSTEM_TEMPLATE, + template: template, }), }), ]