Skip to content

Commit a130cfe

Browse files
Add missing response fields for pagination (#584)
1 parent 9efad28 commit a130cfe

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

messages.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ type Message struct {
2929
type MessagesList struct {
3030
Messages []Message `json:"data"`
3131

32+
Object string `json:"object"`
33+
FirstID *string `json:"first_id"`
34+
LastID *string `json:"last_id"`
35+
HasMore bool `json:"has_more"`
36+
3237
httpHeader
3338
}
3439

messages_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ func TestMessages(t *testing.T) {
142142
fmt.Fprintln(w, string(resBytes))
143143
case http.MethodGet:
144144
resBytes, _ := json.Marshal(openai.MessagesList{
145+
Object: "list",
145146
Messages: []openai.Message{{
146147
ID: messageID,
147148
Object: "thread.message",
@@ -159,7 +160,11 @@ func TestMessages(t *testing.T) {
159160
AssistantID: &emptyStr,
160161
RunID: &emptyStr,
161162
Metadata: nil,
162-
}}})
163+
}},
164+
FirstID: &messageID,
165+
LastID: &messageID,
166+
HasMore: false,
167+
})
163168
fmt.Fprintln(w, string(resBytes))
164169
default:
165170
t.Fatalf("unsupported messages http method: %s", r.Method)

0 commit comments

Comments
 (0)