Check for Stream parameter usage (#174)
* check for stream:true usage * lint
This commit is contained in:
11
chat.go
11
chat.go
@@ -14,7 +14,8 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
ErrChatCompletionInvalidModel = errors.New("currently, only gpt-3.5-turbo and gpt-3.5-turbo-0301 are supported")
|
||||
ErrChatCompletionInvalidModel = errors.New("currently, only gpt-3.5-turbo and gpt-3.5-turbo-0301 are supported") //nolint:lll
|
||||
ErrChatCompletionStreamNotSupported = errors.New("streaming is not supported with this method, please use CreateChatCompletionStream") //nolint:lll
|
||||
)
|
||||
|
||||
type ChatCompletionMessage struct {
|
||||
@@ -65,8 +66,12 @@ func (c *Client) CreateChatCompletion(
|
||||
ctx context.Context,
|
||||
request ChatCompletionRequest,
|
||||
) (response ChatCompletionResponse, err error) {
|
||||
model := request.Model
|
||||
switch model {
|
||||
if request.Stream {
|
||||
err = ErrChatCompletionStreamNotSupported
|
||||
return
|
||||
}
|
||||
|
||||
switch request.Model {
|
||||
case GPT3Dot5Turbo0301, GPT3Dot5Turbo, GPT4, GPT40314, GPT432K0314, GPT432K:
|
||||
default:
|
||||
err = ErrChatCompletionInvalidModel
|
||||
|
||||
Reference in New Issue
Block a user