From 522ae20999425b23a2b0001494467731bda3a847 Mon Sep 17 00:00:00 2001 From: sashabaranov <677093+sashabaranov@users.noreply.github.com> Date: Mon, 6 Mar 2023 12:55:21 +0400 Subject: [PATCH] Warn about GPT3.5-turbo models in regular completion (#127) --- completion.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/completion.go b/completion.go index c3b2aa3..b060815 100644 --- a/completion.go +++ b/completion.go @@ -4,9 +4,14 @@ import ( "bytes" "context" "encoding/json" + "errors" "net/http" ) +var ( + ErrCompletionUnsupportedModel = errors.New("this model is not supported with this method, please use CreateChatCompletion client method instead") //nolint:lll +) + // GPT3 Defines the models provided by OpenAI to use when generating // completions from OpenAI. // GPT3 Models are designed for text-based tasks. For code-specific @@ -92,6 +97,11 @@ func (c *Client) CreateCompletion( ctx context.Context, request CompletionRequest, ) (response CompletionResponse, err error) { + if request.Model == GPT3Dot5Turbo0301 || request.Model == GPT3Dot5Turbo { + err = ErrCompletionUnsupportedModel + return + } + var reqBytes []byte reqBytes, err = json.Marshal(request) if err != nil {