From 9f5188c8a9db5f6cc43f5aebf7a22b48b3916ff9 Mon Sep 17 00:00:00 2001 From: Gyan172004 Date: Thu, 12 Dec 2024 03:04:26 +0530 Subject: [PATCH] minor changes --- src/background/index.ts | 10 +++++++++- src/docFillerCore/engines/gptEngine.ts | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/background/index.ts b/src/background/index.ts index ad8c180..c3ae395 100644 --- a/src/background/index.ts +++ b/src/background/index.ts @@ -13,7 +13,15 @@ interface ChromeResponseMessage { chrome.runtime.onMessage.addListener( (message: ChromeResponseMessage, _sender, sendResponse) => { if (message.type === 'RESET_SETTINGS') { - LLMEngine.resetAll(); + void (async () => { + try { + await LLMEngine.resetAll(); + sendResponse({ success: true }); + } catch (error) { + console.error('Error resetting settings:', error); + sendResponse({ success: false, error: String(error) }); + } + })(); return true; } if (message.type === 'API_CALL') { diff --git a/src/docFillerCore/engines/gptEngine.ts b/src/docFillerCore/engines/gptEngine.ts index 6dbb3e2..5096f67 100644 --- a/src/docFillerCore/engines/gptEngine.ts +++ b/src/docFillerCore/engines/gptEngine.ts @@ -73,7 +73,7 @@ export class LLMEngine { console.error('Error fetching API keys:', error); }); } - public static resetAll(): void { + public static async resetAll(): Promise { this.instances = { [LLMEngineType.ChatGPT]: undefined, [LLMEngineType.Gemini]: undefined, @@ -88,6 +88,7 @@ export class LLMEngine { mistralApiKey: undefined, anthropicApiKey: undefined, }; + await this.fetchApiKeys(); } private static async fetchApiKeys(): Promise {