Skip to content

Commit 645e881

Browse files
feat(client): rename union helpers
1 parent 1d0e22f commit 645e881

19 files changed

+237
-138
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 97
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-f5c45f4ae5c2075cbc603d6910bba3da31c23714c209fbd3fd82a94f634a126b.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-d7e255da603b878e7e823135520211ce6a9e02890c9d549bbf3953a877ee5ef3.yml
33
openapi_spec_hash: 3eb8d86c06f0bb5e1190983e5acfc9ba
4-
config_hash: e53ea2d984c4e05a57eb0227fa379b2b
4+
config_hash: f0e0ce47bee61bd779ccaad22930f186

api.md

Lines changed: 20 additions & 20 deletions
Large diffs are not rendered by default.

betathreadmessage.go

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,38 +60,38 @@ func (r *BetaThreadMessageService) New(ctx context.Context, threadID string, bod
6060
// Retrieve a message.
6161
//
6262
// Deprecated: The Assistants API is deprecated in favor of the Responses API
63-
func (r *BetaThreadMessageService) Get(ctx context.Context, threadID string, messageID string, opts ...option.RequestOption) (res *Message, err error) {
63+
func (r *BetaThreadMessageService) Get(ctx context.Context, messageID string, query BetaThreadMessageGetParams, opts ...option.RequestOption) (res *Message, err error) {
6464
opts = append(r.Options[:], opts...)
6565
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
66-
if threadID == "" {
66+
if query.ThreadID == "" {
6767
err = errors.New("missing required thread_id parameter")
6868
return
6969
}
7070
if messageID == "" {
7171
err = errors.New("missing required message_id parameter")
7272
return
7373
}
74-
path := fmt.Sprintf("threads/%s/messages/%s", threadID, messageID)
74+
path := fmt.Sprintf("threads/%s/messages/%s", query.ThreadID, messageID)
7575
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
7676
return
7777
}
7878

7979
// Modifies a message.
8080
//
8181
// Deprecated: The Assistants API is deprecated in favor of the Responses API
82-
func (r *BetaThreadMessageService) Update(ctx context.Context, threadID string, messageID string, body BetaThreadMessageUpdateParams, opts ...option.RequestOption) (res *Message, err error) {
82+
func (r *BetaThreadMessageService) Update(ctx context.Context, messageID string, params BetaThreadMessageUpdateParams, opts ...option.RequestOption) (res *Message, err error) {
8383
opts = append(r.Options[:], opts...)
8484
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
85-
if threadID == "" {
85+
if params.ThreadID == "" {
8686
err = errors.New("missing required thread_id parameter")
8787
return
8888
}
8989
if messageID == "" {
9090
err = errors.New("missing required message_id parameter")
9191
return
9292
}
93-
path := fmt.Sprintf("threads/%s/messages/%s", threadID, messageID)
94-
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
93+
path := fmt.Sprintf("threads/%s/messages/%s", params.ThreadID, messageID)
94+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
9595
return
9696
}
9797

@@ -129,18 +129,18 @@ func (r *BetaThreadMessageService) ListAutoPaging(ctx context.Context, threadID
129129
// Deletes a message.
130130
//
131131
// Deprecated: The Assistants API is deprecated in favor of the Responses API
132-
func (r *BetaThreadMessageService) Delete(ctx context.Context, threadID string, messageID string, opts ...option.RequestOption) (res *MessageDeleted, err error) {
132+
func (r *BetaThreadMessageService) Delete(ctx context.Context, messageID string, body BetaThreadMessageDeleteParams, opts ...option.RequestOption) (res *MessageDeleted, err error) {
133133
opts = append(r.Options[:], opts...)
134134
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
135-
if threadID == "" {
135+
if body.ThreadID == "" {
136136
err = errors.New("missing required thread_id parameter")
137137
return
138138
}
139139
if messageID == "" {
140140
err = errors.New("missing required message_id parameter")
141141
return
142142
}
143-
path := fmt.Sprintf("threads/%s/messages/%s", threadID, messageID)
143+
path := fmt.Sprintf("threads/%s/messages/%s", body.ThreadID, messageID)
144144
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
145145
return
146146
}
@@ -1650,7 +1650,13 @@ func (r *BetaThreadMessageNewParamsAttachmentToolFileSearch) UnmarshalJSON(data
16501650
return apijson.UnmarshalRoot(data, r)
16511651
}
16521652

1653+
type BetaThreadMessageGetParams struct {
1654+
ThreadID string `path:"thread_id,required" json:"-"`
1655+
paramObj
1656+
}
1657+
16531658
type BetaThreadMessageUpdateParams struct {
1659+
ThreadID string `path:"thread_id,required" json:"-"`
16541660
// Set of 16 key-value pairs that can be attached to an object. This can be useful
16551661
// for storing additional information about the object in a structured format, and
16561662
// querying for objects via API or the dashboard.
@@ -1710,3 +1716,8 @@ const (
17101716
BetaThreadMessageListParamsOrderAsc BetaThreadMessageListParamsOrder = "asc"
17111717
BetaThreadMessageListParamsOrderDesc BetaThreadMessageListParamsOrder = "desc"
17121718
)
1719+
1720+
type BetaThreadMessageDeleteParams struct {
1721+
ThreadID string `path:"thread_id,required" json:"-"`
1722+
paramObj
1723+
}

betathreadmessage_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ func TestBetaThreadMessageGet(t *testing.T) {
6868
)
6969
_, err := client.Beta.Threads.Messages.Get(
7070
context.TODO(),
71-
"thread_id",
7271
"message_id",
72+
openai.BetaThreadMessageGetParams{
73+
ThreadID: "thread_id",
74+
},
7375
)
7476
if err != nil {
7577
var apierr *openai.Error
@@ -94,9 +96,9 @@ func TestBetaThreadMessageUpdateWithOptionalParams(t *testing.T) {
9496
)
9597
_, err := client.Beta.Threads.Messages.Update(
9698
context.TODO(),
97-
"thread_id",
9899
"message_id",
99100
openai.BetaThreadMessageUpdateParams{
101+
ThreadID: "thread_id",
100102
Metadata: shared.Metadata{
101103
"foo": "string",
102104
},
@@ -157,8 +159,10 @@ func TestBetaThreadMessageDelete(t *testing.T) {
157159
)
158160
_, err := client.Beta.Threads.Messages.Delete(
159161
context.TODO(),
160-
"thread_id",
161162
"message_id",
163+
openai.BetaThreadMessageDeleteParams{
164+
ThreadID: "thread_id",
165+
},
162166
)
163167
if err != nil {
164168
var apierr *openai.Error

betathreadrun.go

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -82,38 +82,38 @@ func (r *BetaThreadRunService) NewStreaming(ctx context.Context, threadID string
8282
// Retrieves a run.
8383
//
8484
// Deprecated: The Assistants API is deprecated in favor of the Responses API
85-
func (r *BetaThreadRunService) Get(ctx context.Context, threadID string, runID string, opts ...option.RequestOption) (res *Run, err error) {
85+
func (r *BetaThreadRunService) Get(ctx context.Context, runID string, query BetaThreadRunGetParams, opts ...option.RequestOption) (res *Run, err error) {
8686
opts = append(r.Options[:], opts...)
8787
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
88-
if threadID == "" {
88+
if query.ThreadID == "" {
8989
err = errors.New("missing required thread_id parameter")
9090
return
9191
}
9292
if runID == "" {
9393
err = errors.New("missing required run_id parameter")
9494
return
9595
}
96-
path := fmt.Sprintf("threads/%s/runs/%s", threadID, runID)
96+
path := fmt.Sprintf("threads/%s/runs/%s", query.ThreadID, runID)
9797
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
9898
return
9999
}
100100

101101
// Modifies a run.
102102
//
103103
// Deprecated: The Assistants API is deprecated in favor of the Responses API
104-
func (r *BetaThreadRunService) Update(ctx context.Context, threadID string, runID string, body BetaThreadRunUpdateParams, opts ...option.RequestOption) (res *Run, err error) {
104+
func (r *BetaThreadRunService) Update(ctx context.Context, runID string, params BetaThreadRunUpdateParams, opts ...option.RequestOption) (res *Run, err error) {
105105
opts = append(r.Options[:], opts...)
106106
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
107-
if threadID == "" {
107+
if params.ThreadID == "" {
108108
err = errors.New("missing required thread_id parameter")
109109
return
110110
}
111111
if runID == "" {
112112
err = errors.New("missing required run_id parameter")
113113
return
114114
}
115-
path := fmt.Sprintf("threads/%s/runs/%s", threadID, runID)
116-
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
115+
path := fmt.Sprintf("threads/%s/runs/%s", params.ThreadID, runID)
116+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
117117
return
118118
}
119119

@@ -151,18 +151,18 @@ func (r *BetaThreadRunService) ListAutoPaging(ctx context.Context, threadID stri
151151
// Cancels a run that is `in_progress`.
152152
//
153153
// Deprecated: The Assistants API is deprecated in favor of the Responses API
154-
func (r *BetaThreadRunService) Cancel(ctx context.Context, threadID string, runID string, opts ...option.RequestOption) (res *Run, err error) {
154+
func (r *BetaThreadRunService) Cancel(ctx context.Context, runID string, body BetaThreadRunCancelParams, opts ...option.RequestOption) (res *Run, err error) {
155155
opts = append(r.Options[:], opts...)
156156
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
157-
if threadID == "" {
157+
if body.ThreadID == "" {
158158
err = errors.New("missing required thread_id parameter")
159159
return
160160
}
161161
if runID == "" {
162162
err = errors.New("missing required run_id parameter")
163163
return
164164
}
165-
path := fmt.Sprintf("threads/%s/runs/%s/cancel", threadID, runID)
165+
path := fmt.Sprintf("threads/%s/runs/%s/cancel", body.ThreadID, runID)
166166
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
167167
return
168168
}
@@ -173,19 +173,19 @@ func (r *BetaThreadRunService) Cancel(ctx context.Context, threadID string, runI
173173
// request.
174174
//
175175
// Deprecated: The Assistants API is deprecated in favor of the Responses API
176-
func (r *BetaThreadRunService) SubmitToolOutputs(ctx context.Context, threadID string, runID string, body BetaThreadRunSubmitToolOutputsParams, opts ...option.RequestOption) (res *Run, err error) {
176+
func (r *BetaThreadRunService) SubmitToolOutputs(ctx context.Context, runID string, params BetaThreadRunSubmitToolOutputsParams, opts ...option.RequestOption) (res *Run, err error) {
177177
opts = append(r.Options[:], opts...)
178178
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
179-
if threadID == "" {
179+
if params.ThreadID == "" {
180180
err = errors.New("missing required thread_id parameter")
181181
return
182182
}
183183
if runID == "" {
184184
err = errors.New("missing required run_id parameter")
185185
return
186186
}
187-
path := fmt.Sprintf("threads/%s/runs/%s/submit_tool_outputs", threadID, runID)
188-
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
187+
path := fmt.Sprintf("threads/%s/runs/%s/submit_tool_outputs", params.ThreadID, runID)
188+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
189189
return
190190
}
191191

@@ -195,23 +195,23 @@ func (r *BetaThreadRunService) SubmitToolOutputs(ctx context.Context, threadID s
195195
// request.
196196
//
197197
// Deprecated: The Assistants API is deprecated in favor of the Responses API
198-
func (r *BetaThreadRunService) SubmitToolOutputsStreaming(ctx context.Context, threadID string, runID string, body BetaThreadRunSubmitToolOutputsParams, opts ...option.RequestOption) (stream *ssestream.Stream[AssistantStreamEventUnion]) {
198+
func (r *BetaThreadRunService) SubmitToolOutputsStreaming(ctx context.Context, runID string, params BetaThreadRunSubmitToolOutputsParams, opts ...option.RequestOption) (stream *ssestream.Stream[AssistantStreamEventUnion]) {
199199
var (
200200
raw *http.Response
201201
err error
202202
)
203203
opts = append(r.Options[:], opts...)
204204
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithJSONSet("stream", true)}, opts...)
205-
if threadID == "" {
205+
if params.ThreadID == "" {
206206
err = errors.New("missing required thread_id parameter")
207207
return
208208
}
209209
if runID == "" {
210210
err = errors.New("missing required run_id parameter")
211211
return
212212
}
213-
path := fmt.Sprintf("threads/%s/runs/%s/submit_tool_outputs", threadID, runID)
214-
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &raw, opts...)
213+
path := fmt.Sprintf("threads/%s/runs/%s/submit_tool_outputs", params.ThreadID, runID)
214+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &raw, opts...)
215215
return ssestream.NewStream[AssistantStreamEventUnion](ssestream.NewDecoder(raw), err)
216216
}
217217

@@ -868,7 +868,13 @@ func init() {
868868
)
869869
}
870870

871+
type BetaThreadRunGetParams struct {
872+
ThreadID string `path:"thread_id,required" json:"-"`
873+
paramObj
874+
}
875+
871876
type BetaThreadRunUpdateParams struct {
877+
ThreadID string `path:"thread_id,required" json:"-"`
872878
// Set of 16 key-value pairs that can be attached to an object. This can be useful
873879
// for storing additional information about the object in a structured format, and
874880
// querying for objects via API or the dashboard.
@@ -927,7 +933,13 @@ const (
927933
BetaThreadRunListParamsOrderDesc BetaThreadRunListParamsOrder = "desc"
928934
)
929935

936+
type BetaThreadRunCancelParams struct {
937+
ThreadID string `path:"thread_id,required" json:"-"`
938+
paramObj
939+
}
940+
930941
type BetaThreadRunSubmitToolOutputsParams struct {
942+
ThreadID string `path:"thread_id,required" json:"-"`
931943
// A list of tools for which the outputs are being submitted.
932944
ToolOutputs []BetaThreadRunSubmitToolOutputsParamsToolOutput `json:"tool_outputs,omitzero,required"`
933945
paramObj

betathreadrun_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ func TestBetaThreadRunGet(t *testing.T) {
9898
)
9999
_, err := client.Beta.Threads.Runs.Get(
100100
context.TODO(),
101-
"thread_id",
102101
"run_id",
102+
openai.BetaThreadRunGetParams{
103+
ThreadID: "thread_id",
104+
},
103105
)
104106
if err != nil {
105107
var apierr *openai.Error
@@ -124,9 +126,9 @@ func TestBetaThreadRunUpdateWithOptionalParams(t *testing.T) {
124126
)
125127
_, err := client.Beta.Threads.Runs.Update(
126128
context.TODO(),
127-
"thread_id",
128129
"run_id",
129130
openai.BetaThreadRunUpdateParams{
131+
ThreadID: "thread_id",
130132
Metadata: shared.Metadata{
131133
"foo": "string",
132134
},
@@ -186,8 +188,10 @@ func TestBetaThreadRunCancel(t *testing.T) {
186188
)
187189
_, err := client.Beta.Threads.Runs.Cancel(
188190
context.TODO(),
189-
"thread_id",
190191
"run_id",
192+
openai.BetaThreadRunCancelParams{
193+
ThreadID: "thread_id",
194+
},
191195
)
192196
if err != nil {
193197
var apierr *openai.Error
@@ -212,9 +216,9 @@ func TestBetaThreadRunSubmitToolOutputsWithOptionalParams(t *testing.T) {
212216
)
213217
_, err := client.Beta.Threads.Runs.SubmitToolOutputs(
214218
context.TODO(),
215-
"thread_id",
216219
"run_id",
217220
openai.BetaThreadRunSubmitToolOutputsParams{
221+
ThreadID: "thread_id",
218222
ToolOutputs: []openai.BetaThreadRunSubmitToolOutputsParamsToolOutput{{
219223
Output: openai.String("output"),
220224
ToolCallID: openai.String("tool_call_id"),

0 commit comments

Comments
 (0)