Skip to content

Commit

Permalink
Warn about GPT3.5-turbo models in regular completion (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
sashabaranov authored Mar 6, 2023
1 parent c5fe874 commit 522ae20
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 522ae20

Please sign in to comment.