mirror of
https://github.com/logancyang/obsidian-copilot.git
synced 2026-07-22 07:50:24 +00:00
Fix web search, list indexed files, pass current time to vault search (#921)
* Enhance vault search with current time info * Fix file already exists for list indexed files * Fix safeFetch for GET request
This commit is contained in:
parent
06a405aa5f
commit
a049e1cdaa
3 changed files with 12 additions and 4 deletions
|
|
@ -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
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -551,8 +551,8 @@ export async function safeFetch(url: string, options: RequestInit): Promise<Resp
|
|||
url,
|
||||
contentType: "application/json",
|
||||
headers: options.headers as Record<string, string>,
|
||||
method: "POST",
|
||||
body: options.body?.toString(),
|
||||
method: options.method,
|
||||
...(options.method === "POST" && { body: options.body?.toString() }),
|
||||
});
|
||||
|
||||
return {
|
||||
|
|
|
|||
Loading…
Reference in a new issue