Add SystemFingerprint and chatMsg.ToolCallID field (#543)
* fix ToolChoiche typo * add tool_call_id to ChatCompletionMessage * add /chat system_fingerprint response field * check empty ToolCallID JSON marshaling and add omitempty for tool_call_id * messages also required; don't omitempty * add Type to ToolCall, required by the API * fix test, omitempty for response_format ptr * fix casing of role values in comments
This commit is contained in:
14
chat_test.go
14
chat_test.go
@@ -51,6 +51,20 @@ func TestChatCompletionsWrongModel(t *testing.T) {
|
||||
checks.ErrorIs(t, err, openai.ErrChatCompletionInvalidModel, msg)
|
||||
}
|
||||
|
||||
func TestChatRequestOmitEmpty(t *testing.T) {
|
||||
data, err := json.Marshal(openai.ChatCompletionRequest{
|
||||
// We set model b/c it's required, so omitempty doesn't make sense
|
||||
Model: "gpt-4",
|
||||
})
|
||||
checks.NoError(t, err)
|
||||
|
||||
// messages is also required so isn't omitted
|
||||
const expected = `{"model":"gpt-4","messages":null}`
|
||||
if string(data) != expected {
|
||||
t.Errorf("expected JSON with all empty fields to be %v but was %v", expected, string(data))
|
||||
}
|
||||
}
|
||||
|
||||
func TestChatCompletionsWithStream(t *testing.T) {
|
||||
config := openai.DefaultConfig("whatever")
|
||||
config.BaseURL = "http://localhost/v1"
|
||||
|
||||
Reference in New Issue
Block a user