From d94c5e7edde5daf3c9ab73eea906e559f3c79cfb Mon Sep 17 00:00:00 2001 From: sashabaranov <677093+sashabaranov@users.noreply.github.com> Date: Sun, 9 Apr 2023 18:46:58 +0400 Subject: [PATCH] Test request builder + streams (#242) * test request builder + streams * provide prompt to test --- completion.go | 2 +- request_builder_test.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/completion.go b/completion.go index 44057616f..5eec88c29 100644 --- a/completion.go +++ b/completion.go @@ -9,7 +9,7 @@ import ( var ( ErrCompletionUnsupportedModel = errors.New("this model is not supported with this method, please use CreateChatCompletion client method instead") //nolint:lll ErrCompletionStreamNotSupported = errors.New("streaming is not supported with this method, please use CreateCompletionStream") //nolint:lll - ErrCompletionRequestPromptTypeNotSupported = errors.New("the type of CompletionRequest.Promp only supports string and []string") //nolint:lll + ErrCompletionRequestPromptTypeNotSupported = errors.New("the type of CompletionRequest.Prompt only supports string and []string") //nolint:lll ) // GPT3 Defines the models provided by OpenAI to use when generating diff --git a/request_builder_test.go b/request_builder_test.go index e5b65df0c..b1adbf1c6 100644 --- a/request_builder_test.go +++ b/request_builder_test.go @@ -145,6 +145,11 @@ func TestClientReturnsRequestBuilderErrors(t *testing.T) { if !errors.Is(err, errTestRequestBuilderFailed) { t.Fatalf("Did not return error when request builder failed: %v", err) } + + _, err = client.CreateCompletionStream(ctx, CompletionRequest{Prompt: ""}) + if !errors.Is(err, errTestRequestBuilderFailed) { + t.Fatalf("Did not return error when request builder failed: %v", err) + } } func TestReturnsRequestBuilderErrorsAddtion(t *testing.T) {