Repository: sashabaranov/go-openai (go)

Issue:
Missing pagination parameters for list message beta API
Describe the bug
Similar to https://github.com/sashabaranov/go-openai/issues/572

Missing pagination parameters for list message beta API:

```
first_id
last_id
has_more
```

To Reproduce

```
curl https://api.openai.com/v1/threads/thread_abc123/messages \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "OpenAI-Beta: assistants=v1"
{
  "object": "list",
  "data": [],
  "first_id": "msg_abc123",
  "last_id": "msg_abc456",
  "has_more": false
}
```

Pull request:
Add missing response fields for pagination
Describe the change
Missing pagination parameters for new assistants list API

Describe your solution
Add missing parameters

Tests
Verified against endpoint

Additional context

```
curl https://api.openai.com/v1/threads/thread_abc123/messages \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "OpenAI-Beta: assistants=v1"
{
  "object": "list",
  "data": [],
  "first_id": "msg_abc123",
  "last_id": "msg_abc456",
  "has_more": false
}
```

Issue: resolves #583 
Similar PR: https://github.com/sashabaranov/go-openai/pull/571

Patch:
diff --git a/files.go b/files.go
index 371d06c..a37d45f 100644
--- a/files.go
+++ b/files.go
@@ -19,8 +19,10 @@ type FileRequest struct {
 type PurposeType string
 
 const (
-	PurposeFineTune   PurposeType = "fine-tune"
-	PurposeAssistants PurposeType = "assistants"
+	PurposeFineTune         PurposeType = "fine-tune"
+	PurposeFineTuneResults  PurposeType = "fine-tune-results"
+	PurposeAssistants       PurposeType = "assistants"
+	PurposeAssistantsOutput PurposeType = "assistants_output"
 )
 
 // FileBytesRequest represents a file upload request.
diff --git a/messages.go b/messages.go
index 3fd377f..ead247f 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/run.go b/run.go
index f95bf0e..dbb708a 100644
--- a/run.go
+++ b/run.go
@@ -142,17 +142,13 @@ const (
 type StepDetails struct {
 	Type            RunStepType                 `json:"type"`
 	MessageCreation *StepDetailsMessageCreation `json:"message_creation,omitempty"`
-	ToolCalls       *StepDetailsToolCalls       `json:"tool_calls,omitempty"`
+	ToolCalls       []ToolCall                  `json:"tool_calls,omitempty"`
 }
 
 type StepDetailsMessageCreation struct {
 	MessageID string `json:"message_id"`
 }
 
-type StepDetailsToolCalls struct {
-	ToolCalls []ToolCall `json:"tool_calls"`
-}
-
 // RunStepList is a list of steps.
 type RunStepList struct {
 	RunSteps []RunStep `json:"data"`


Test patch:
diff --git a/messages_test.go b/messages_test.go
index 282b1cc..9168d6c 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)