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, }), }), ]