From 68a861116033ac1459971375bcc632b5155a9dca Mon Sep 17 00:00:00 2001 From: haouarihk Date: Mon, 18 Mar 2024 18:08:58 +0100 Subject: [PATCH] . --- src/scope/context-manager.ts | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/scope/context-manager.ts b/src/scope/context-manager.ts index 462831e0..d94aafe2 100644 --- a/src/scope/context-manager.ts +++ b/src/scope/context-manager.ts @@ -123,7 +123,7 @@ export default class ContextManager { const contextTemplate = this.plugin.settings.context.customInstructEnabled ? this.plugin.settings.context.customInstruct || - this.plugin.defaultSettings.context.customInstruct + this.plugin.defaultSettings.context.customInstruct : "{{tg_selection}}"; const options = await this.getDefaultContext( @@ -385,7 +385,7 @@ export default class ContextManager { keys?: ReturnType["getApiKeys"]>; _variables: Record; } = { - _variables: {}, + _variables: {} }; const vars = @@ -395,9 +395,9 @@ export default class ContextManager { const title = vars["title"] || vars["mentions"] ? (filePath - ? this.app.vault.getAbstractFileByPath(filePath)?.name || - this.getActiveFileTitle() - : this.getActiveFileTitle()) || "" + ? this.app.vault.getAbstractFileByPath(filePath)?.name || + this.getActiveFileTitle() + : this.getActiveFileTitle()) || "" : ""; const activeDocCache = this.getMetaData(filePath || ""); @@ -526,18 +526,18 @@ export default class ContextManager { const preRunnerTemplate = preRunnerContent ? this.handlebarsMiddleware( - Handlebars.compile(preRunnerContent, { - noEscape: true, - }) - ) + Handlebars.compile(preRunnerContent, { + noEscape: true, + }) + ) : null; const outputTemplate = outputContent ? this.handlebarsMiddleware( - Handlebars.compile(outputContent, { - noEscape: true, - }) - ) + Handlebars.compile(outputContent, { + noEscape: true, + }) + ) : null; return { @@ -847,13 +847,13 @@ export default class ContextManager { const extractorMethods = getExtractorMethods().filter( (e) => this.plugin.settings.extractorsOptions[ - e as keyof typeof this.plugin.settings.extractorsOptions + e as keyof typeof this.plugin.settings.extractorsOptions ] ); const targetFile = filePath ? app.vault.getAbstractFileByPath(filePath) || - this.app.workspace.getActiveFile() + this.app.workspace.getActiveFile() : this.app.workspace.getActiveFile(); const targetFileContent = editor @@ -1372,4 +1372,9 @@ Or example: `{{error "Selection was empty"}}`, hint: "Shows a error notice to the user, and it will stop the execution.", }, + + keys: { + example: `{{keys.openAIChat}}`, + hint: "Gives access to generic provider's api keys", + }, };