Check for GPT-4 models (#169)
* add chat gpt4 model support (#158) * remove check for gpt4 for CreateCompletion * test for model check --------- Co-authored-by: aeieli <aeliieli@gmail.com>
This commit is contained in:
4
chat.go
4
chat.go
@@ -66,7 +66,9 @@ func (c *Client) CreateChatCompletion(
|
|||||||
request ChatCompletionRequest,
|
request ChatCompletionRequest,
|
||||||
) (response ChatCompletionResponse, err error) {
|
) (response ChatCompletionResponse, err error) {
|
||||||
model := request.Model
|
model := request.Model
|
||||||
if model != GPT3Dot5Turbo0301 && model != GPT3Dot5Turbo {
|
switch model {
|
||||||
|
case GPT3Dot5Turbo0301, GPT3Dot5Turbo, GPT4, GPT40314, GPT432K0314, GPT432K:
|
||||||
|
default:
|
||||||
err = ErrChatCompletionInvalidModel
|
err = ErrChatCompletionInvalidModel
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -15,6 +16,23 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestCompletionsWrongModel(t *testing.T) {
|
||||||
|
config := DefaultConfig("whatever")
|
||||||
|
config.BaseURL = "http://localhost/v1"
|
||||||
|
client := NewClientWithConfig(config)
|
||||||
|
|
||||||
|
_, err := client.CreateCompletion(
|
||||||
|
context.Background(),
|
||||||
|
CompletionRequest{
|
||||||
|
MaxTokens: 5,
|
||||||
|
Model: GPT3Dot5Turbo,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
if !errors.Is(err, ErrCompletionUnsupportedModel) {
|
||||||
|
t.Fatalf("CreateCompletion should return ErrCompletionUnsupportedModel, but returned: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TestCompletions Tests the completions endpoint of the API using the mocked server.
|
// TestCompletions Tests the completions endpoint of the API using the mocked server.
|
||||||
func TestCompletions(t *testing.T) {
|
func TestCompletions(t *testing.T) {
|
||||||
server := test.NewTestServer()
|
server := test.NewTestServer()
|
||||||
|
|||||||
Reference in New Issue
Block a user