Skip to content

Commit

Permalink
fix test, omitempty for response_format ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
gburt committed Nov 8, 2023
1 parent af52e90 commit 0dbd303
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ type ChatCompletionRequest struct {
Stream bool `json:"stream,omitempty"`
Stop []string `json:"stop,omitempty"`
PresencePenalty float32 `json:"presence_penalty,omitempty"`
ResponseFormat *ChatCompletionResponseFormat `json:"response_format"`
ResponseFormat *ChatCompletionResponseFormat `json:"response_format,omitempty"`
Seed *int `json:"seed,omitempty"`
FrequencyPenalty float32 `json:"frequency_penalty,omitempty"`
// LogitBias is must be a token id string (specified by their token ID in the tokenizer), not a word string.
Expand Down
5 changes: 2 additions & 3 deletions chat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ func TestChatRequestOmitEmpty(t *testing.T) {
})
checks.NoError(t, err)

// response_format is also set b/c it's a non-pointer struct
// and messages is also required
const expected = `{"model":"gpt-4","messages":null,"response_format":{}}`
// 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))
}
Expand Down

0 comments on commit 0dbd303

Please sign in to comment.