From a130cfee26427b99ae0bf957be74e32ca8a7f567 Mon Sep 17 00:00:00 2001 From: Albert Putra Purnama <14824254+albertpurnama@users.noreply.github.com> Date: Fri, 17 Nov 2023 23:01:06 -0800 Subject: [PATCH] Add missing response fields for pagination (#584) --- messages.go | 5 +++++ messages_test.go | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/messages.go b/messages.go index 3fd377fcb..ead247f5b 100644 --- a/messages.go +++ b/messages.go @@ -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 } diff --git a/messages_test.go b/messages_test.go index 282b1cc9d..9168d6ccf 100644 --- a/messages_test.go +++ b/messages_test.go @@ -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", @@ -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)