Test request builder + streams (#242)

* test request builder + streams

* provide prompt to test
This commit is contained in:
sashabaranov
2023-04-09 18:46:58 +04:00
committed by GitHub
parent 9a1ecf5f4a
commit d94c5e7edd
2 changed files with 6 additions and 1 deletions

View File

@@ -9,7 +9,7 @@ import (
var ( var (
ErrCompletionUnsupportedModel = errors.New("this model is not supported with this method, please use CreateChatCompletion client method instead") //nolint:lll 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 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 // GPT3 Defines the models provided by OpenAI to use when generating

View File

@@ -145,6 +145,11 @@ func TestClientReturnsRequestBuilderErrors(t *testing.T) {
if !errors.Is(err, errTestRequestBuilderFailed) { if !errors.Is(err, errTestRequestBuilderFailed) {
t.Fatalf("Did not return error when request builder failed: %v", err) 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) { func TestReturnsRequestBuilderErrorsAddtion(t *testing.T) {