diff --git a/.env.example b/.env.example deleted file mode 100644 index b9e5cff..0000000 --- a/.env.example +++ /dev/null @@ -1 +0,0 @@ -OPENAI_API_KEY="MY_SECRET" diff --git a/README.md b/README.md index 99fd87f..ac69d4e 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ plugins: - plugin: http://localhost:4000 with: # Use your own app name for local testing - ubiquity_os_app_slug: "UbiquityOS" + ubiquityOsAppSlug: "UbiquityOS" ``` `.dev.vars` (for local testing): diff --git a/src/handlers/ask-gpt.ts b/src/handlers/ask-gpt.ts index 15f77a2..fe3101e 100644 --- a/src/handlers/ask-gpt.ts +++ b/src/handlers/ask-gpt.ts @@ -20,10 +20,6 @@ export async function askGpt(context: Context, formattedChat: string) { env: { OPENAI_API_KEY }, } = context; - if (!OPENAI_API_KEY) { - throw logger.error(`No OpenAI API Key detected!`); - } - const openAi = new OpenAI({ apiKey: OPENAI_API_KEY }); const chat = createChatHistory(formattedChat); diff --git a/src/plugin.ts b/src/plugin.ts index 1c3c5e3..680245d 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -24,11 +24,11 @@ export async function plugin(inputs: PluginInputs, env: Env) { export async function runPlugin(context: Context) { const { logger, - config: { ubiquity_os_app_slug }, + config: { ubiquityOsAppSlug }, } = context; const question = context.payload.comment.body; - const slugRegex = new RegExp(`@${ubiquity_os_app_slug} `, "gi"); + const slugRegex = new RegExp(`@${ubiquityOsAppSlug} `, "gi"); if (!question.match(slugRegex)) { logger.info("Comment does not mention the app. Skipping."); diff --git a/src/types/plugin-inputs.ts b/src/types/plugin-inputs.ts index b04d5f1..78c05a3 100644 --- a/src/types/plugin-inputs.ts +++ b/src/types/plugin-inputs.ts @@ -20,7 +20,7 @@ export interface PluginInputs { expect(infoSpy).toHaveBeenCalledWith("Comment is empty. Skipping."); }); - - it("should not ask GPT a question if no OpenAI API key is provided", async () => { - const ctx = createContext(TEST_SLASH_COMMAND); - const errorSpy = jest.spyOn(ctx.logger, "error"); - - createComments([transformCommentTemplate(1, 1, TEST_QUESTION, "ubiquity", "test-repo", true)]); - ctx.env.OPENAI_API_KEY = ""; - await runPlugin(ctx); - - expect(errorSpy).toHaveBeenNthCalledWith(1, "No OpenAI API Key detected!"); + it("Should throw if OPENAI_API_KEY is not defined", () => { + const settings = {}; + expect(() => Value.Decode(envSchema, settings)).toThrow(TransformDecodeCheckError); }); it("should construct the chat history correctly", async () => { @@ -305,7 +300,7 @@ function createContext(body = TEST_SLASH_COMMAND) { }, logger: new Logs("debug"), config: { - ubiquity_os_app_slug: "UbiquityOS", + ubiquityOsAppSlug: "UbiquityOS", }, env: { OPENAI_API_KEY: "test",