From 1be90834ef22be6ee37219526bd8dbef20daf494 Mon Sep 17 00:00:00 2001 From: Thomas Legris Date: Tue, 11 Apr 2023 15:05:34 +0900 Subject: [PATCH] Change env from OPENAI_KEY to OPENAI_API_KEY --- README.md | 4 ++-- ais/chatgpt.go | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 851b665..bc5c27b 100644 --- a/README.md +++ b/README.md @@ -22,10 +22,10 @@ Find your key `` [here](https://platform.openai.com/account/api-keys) Then run: ``` -$ OPENAI_KEY= prompt-ai +$ OPENAI_API_KEY= prompt-ai ``` or ``` -$ export OPENAI_KEY= +$ export OPENAI_API_KEY= $ prompt-ai ``` diff --git a/ais/chatgpt.go b/ais/chatgpt.go index 40382fd..65cd0f0 100644 --- a/ais/chatgpt.go +++ b/ais/chatgpt.go @@ -16,12 +16,16 @@ var ( http_timeout = 30 * time.Second ) +const ( + API_KEY_ENV = "OPENAI_API_KEY" +) + var apiKey string func init() { - apiKey = os.Getenv("OPENAI_KEY") + apiKey = os.Getenv(API_KEY_ENV) if apiKey == "" { - log.Fatal("OPENAI_KEY not set") + log.Fatalf("%s not set\n", API_KEY_ENV) } }