* fix: invalid schema for function 'func_name': None is not of type 'object' (#429)(#432) * test: add integration test for function call (#429)(#432) * style: remove duplicate import (#429)(#432)
This commit is contained in:
committed by
GitHub
parent
f028c289d2
commit
c3b2451f7c
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
. "github.com/sashabaranov/go-openai"
|
||||
"github.com/sashabaranov/go-openai/internal/test/checks"
|
||||
"github.com/sashabaranov/go-openai/jsonschema"
|
||||
)
|
||||
|
||||
func TestAPI(t *testing.T) {
|
||||
@@ -100,6 +101,37 @@ func TestAPI(t *testing.T) {
|
||||
if counter == 0 {
|
||||
t.Error("Stream did not return any responses")
|
||||
}
|
||||
|
||||
_, err = c.CreateChatCompletion(
|
||||
context.Background(),
|
||||
ChatCompletionRequest{
|
||||
Model: GPT3Dot5Turbo,
|
||||
Messages: []ChatCompletionMessage{
|
||||
{
|
||||
Role: ChatMessageRoleUser,
|
||||
Content: "What is the weather like in Boston?",
|
||||
},
|
||||
},
|
||||
Functions: []FunctionDefinition{{
|
||||
Name: "get_current_weather",
|
||||
Parameters: jsonschema.Definition{
|
||||
Type: jsonschema.Object,
|
||||
Properties: map[string]jsonschema.Definition{
|
||||
"location": {
|
||||
Type: jsonschema.String,
|
||||
Description: "The city and state, e.g. San Francisco, CA",
|
||||
},
|
||||
"unit": {
|
||||
Type: jsonschema.String,
|
||||
Enum: []string{"celsius", "fahrenheit"},
|
||||
},
|
||||
},
|
||||
Required: []string{"location"},
|
||||
},
|
||||
}},
|
||||
},
|
||||
)
|
||||
checks.NoError(t, err, "CreateChatCompletion (with functions) returned error")
|
||||
}
|
||||
|
||||
func TestAPIError(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user