From 8fda69740f74afebffa4b977afe914a53ecd800b Mon Sep 17 00:00:00 2001 From: Simon Yang Date: Tue, 14 Mar 2023 15:50:43 +1100 Subject: [PATCH] Add prompt check for image generator --- main.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/main.ts b/main.ts index 9574ce8..4878f31 100644 --- a/main.ts +++ b/main.ts @@ -50,9 +50,7 @@ export default class AICommanderPlugin extends Plugin { } async generateText(prompt: string, contextPrompt?: string) { - if (prompt.length < 1 ) throw new Error('Cannot find prompt.'); - if (this.settings.apiKey.length <= 1) throw new Error('OpenAI API Key is not provided.'); const configuration = new Configuration({ apiKey: this.settings.apiKey }); @@ -124,6 +122,7 @@ export default class AICommanderPlugin extends Plugin { } async generateImage(prompt: string) { + if (prompt.length < 1 ) throw new Error('Cannot find prompt.'); if (this.settings.apiKey.length <= 1) throw new Error('OpenAI API Key is not provided.'); const configuration = new Configuration({