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 {