From a93db65e4be0d8383c3b38abcafa827661c6599c Mon Sep 17 00:00:00 2001 From: Saiyam Pathak Date: Wed, 14 Feb 2024 09:39:51 +0530 Subject: [PATCH 1/2] Update client.go with a meaningful message to set openAPI key Update client.go with a meaningful message to set openAPI key Signed-off-by: Saiyam Pathak --- pkg/openai/client.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/openai/client.go b/pkg/openai/client.go index 6ee8b1bd..45dacbf9 100644 --- a/pkg/openai/client.go +++ b/pkg/openai/client.go @@ -71,7 +71,11 @@ func complete(opts ...Options) (result Options, err error) { if result.APIKey == "" && key != "" { result.APIKey = key } - + + if result.APIKey == "" { + return result, fmt.Errorf("OPENAI_API_KEY is not set. Please set the OPENAI_API_KEY environment variable") + } + return result, err } From c9397ffcdd684727c69ee0b98f352edb0c1c30c6 Mon Sep 17 00:00:00 2001 From: Saiyam Pathak Date: Wed, 14 Feb 2024 10:21:17 +0530 Subject: [PATCH 2/2] format --- pkg/openai/client.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/openai/client.go b/pkg/openai/client.go index 45dacbf9..a8b08076 100644 --- a/pkg/openai/client.go +++ b/pkg/openai/client.go @@ -71,11 +71,11 @@ func complete(opts ...Options) (result Options, err error) { if result.APIKey == "" && key != "" { result.APIKey = key } - - if result.APIKey == "" { - return result, fmt.Errorf("OPENAI_API_KEY is not set. Please set the OPENAI_API_KEY environment variable") - } - + + if result.APIKey == "" { + return result, fmt.Errorf("OPENAI_API_KEY is not set. Please set the OPENAI_API_KEY environment variable") + } + return result, err }