diff --git a/src/LLMProviders/chainRunner.ts b/src/LLMProviders/chainRunner.ts index 5af5675a..f96abd9f 100644 --- a/src/LLMProviders/chainRunner.ts +++ b/src/LLMProviders/chainRunner.ts @@ -427,10 +427,16 @@ class CopilotPlusChainRunner extends BaseChainRunner { const timeExpression = this.getTimeExpression(toolCalls); const context = this.formatLocalSearchResult(documents, timeExpression); + const currentTimeOutputs = toolOutputs.filter((output) => output.tool === "getCurrentTime"); + const enhancedQuestion = this.prepareEnhancedUserMessage( + standaloneQuestion, + currentTimeOutputs + ); + if (debug) console.log(context); if (debug) console.log("==== Step 5: Invoking QA Chain ===="); const qaPrompt = await this.chainManager.promptManager.getQAPrompt({ - question: standaloneQuestion, + question: enhancedQuestion, context: context, systemMessage: "", // System prompt is added separately in streamMultimodalResponse }); diff --git a/src/main.ts b/src/main.ts index 3905a9dd..876236c8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -355,7 +355,9 @@ export default class CopilotPlugin extends Plugin { const fileName = `Copilot-Indexed-Files-${new Date().toLocaleDateString().replace(/\//g, "-")}.md`; const filePath = `${fileName}`; - await this.app.vault.create(filePath, content); + if (!this.app.vault.getAbstractFileByPath(filePath)) { + await this.app.vault.create(filePath, content); + } // Open the newly created file const createdFile = this.app.vault.getAbstractFileByPath(filePath); diff --git a/src/utils.ts b/src/utils.ts index 858763e3..a5c88f13 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -551,8 +551,8 @@ export async function safeFetch(url: string, options: RequestInit): Promise, - method: "POST", - body: options.body?.toString(), + method: options.method, + ...(options.method === "POST" && { body: options.body?.toString() }), }); return {