Skip to content

Commit

Permalink
Add missing response fields for pagination (sashabaranov#584)
Browse files Browse the repository at this point in the history
  • Loading branch information
albertpurnama authored Nov 18, 2023
1 parent 9efad28 commit a130cfe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ type Message struct {
type MessagesList struct {
Messages []Message `json:"data"`

Object string `json:"object"`
FirstID *string `json:"first_id"`
LastID *string `json:"last_id"`
HasMore bool `json:"has_more"`

httpHeader
}

Expand Down
7 changes: 6 additions & 1 deletion messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ func TestMessages(t *testing.T) {
fmt.Fprintln(w, string(resBytes))
case http.MethodGet:
resBytes, _ := json.Marshal(openai.MessagesList{
Object: "list",
Messages: []openai.Message{{
ID: messageID,
Object: "thread.message",
Expand All @@ -159,7 +160,11 @@ func TestMessages(t *testing.T) {
AssistantID: &emptyStr,
RunID: &emptyStr,
Metadata: nil,
}}})
}},
FirstID: &messageID,
LastID: &messageID,
HasMore: false,
})
fmt.Fprintln(w, string(resBytes))
default:
t.Fatalf("unsupported messages http method: %s", r.Method)
Expand Down

0 comments on commit a130cfe

Please sign in to comment.