1// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3package openai
4
5import (
6 "context"
7 "encoding/json"
8 "errors"
9 "fmt"
10 "net/http"
11 "net/url"
12 "reflect"
13
14 "github.com/openai/openai-go/internal/apijson"
15 "github.com/openai/openai-go/internal/apiquery"
16 "github.com/openai/openai-go/internal/requestconfig"
17 "github.com/openai/openai-go/option"
18 "github.com/openai/openai-go/packages/pagination"
19 "github.com/openai/openai-go/packages/param"
20 "github.com/openai/openai-go/packages/resp"
21 "github.com/openai/openai-go/shared"
22 "github.com/openai/openai-go/shared/constant"
23 "github.com/tidwall/gjson"
24)
25
26// BetaAssistantService contains methods and other services that help with
27// interacting with the openai API.
28//
29// Note, unlike clients, this service does not read variables from the environment
30// automatically. You should not instantiate this service directly, and instead use
31// the [NewBetaAssistantService] method instead.
32type BetaAssistantService struct {
33 Options []option.RequestOption
34}
35
36// NewBetaAssistantService generates a new service that applies the given options
37// to each request. These options are applied after the parent client's options (if
38// there is one), and before any request-specific options.
39func NewBetaAssistantService(opts ...option.RequestOption) (r BetaAssistantService) {
40 r = BetaAssistantService{}
41 r.Options = opts
42 return
43}
44
45// Create an assistant with a model and instructions.
46func (r *BetaAssistantService) New(ctx context.Context, body BetaAssistantNewParams, opts ...option.RequestOption) (res *Assistant, err error) {
47 opts = append(r.Options[:], opts...)
48 opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
49 path := "assistants"
50 err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
51 return
52}
53
54// Retrieves an assistant.
55func (r *BetaAssistantService) Get(ctx context.Context, assistantID string, opts ...option.RequestOption) (res *Assistant, err error) {
56 opts = append(r.Options[:], opts...)
57 opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
58 if assistantID == "" {
59 err = errors.New("missing required assistant_id parameter")
60 return
61 }
62 path := fmt.Sprintf("assistants/%s", assistantID)
63 err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
64 return
65}
66
67// Modifies an assistant.
68func (r *BetaAssistantService) Update(ctx context.Context, assistantID string, body BetaAssistantUpdateParams, opts ...option.RequestOption) (res *Assistant, err error) {
69 opts = append(r.Options[:], opts...)
70 opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
71 if assistantID == "" {
72 err = errors.New("missing required assistant_id parameter")
73 return
74 }
75 path := fmt.Sprintf("assistants/%s", assistantID)
76 err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
77 return
78}
79
80// Returns a list of assistants.
81func (r *BetaAssistantService) List(ctx context.Context, query BetaAssistantListParams, opts ...option.RequestOption) (res *pagination.CursorPage[Assistant], err error) {
82 var raw *http.Response
83 opts = append(r.Options[:], opts...)
84 opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithResponseInto(&raw)}, opts...)
85 path := "assistants"
86 cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
87 if err != nil {
88 return nil, err
89 }
90 err = cfg.Execute()
91 if err != nil {
92 return nil, err
93 }
94 res.SetPageConfig(cfg, raw)
95 return res, nil
96}
97
98// Returns a list of assistants.
99func (r *BetaAssistantService) ListAutoPaging(ctx context.Context, query BetaAssistantListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[Assistant] {
100 return pagination.NewCursorPageAutoPager(r.List(ctx, query, opts...))
101}
102
103// Delete an assistant.
104func (r *BetaAssistantService) Delete(ctx context.Context, assistantID string, opts ...option.RequestOption) (res *AssistantDeleted, err error) {
105 opts = append(r.Options[:], opts...)
106 opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
107 if assistantID == "" {
108 err = errors.New("missing required assistant_id parameter")
109 return
110 }
111 path := fmt.Sprintf("assistants/%s", assistantID)
112 err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
113 return
114}
115
116// Represents an `assistant` that can call the model and use tools.
117type Assistant struct {
118 // The identifier, which can be referenced in API endpoints.
119 ID string `json:"id,required"`
120 // The Unix timestamp (in seconds) for when the assistant was created.
121 CreatedAt int64 `json:"created_at,required"`
122 // The description of the assistant. The maximum length is 512 characters.
123 Description string `json:"description,required"`
124 // The system instructions that the assistant uses. The maximum length is 256,000
125 // characters.
126 Instructions string `json:"instructions,required"`
127 // Set of 16 key-value pairs that can be attached to an object. This can be useful
128 // for storing additional information about the object in a structured format, and
129 // querying for objects via API or the dashboard.
130 //
131 // Keys are strings with a maximum length of 64 characters. Values are strings with
132 // a maximum length of 512 characters.
133 Metadata shared.Metadata `json:"metadata,required"`
134 // ID of the model to use. You can use the
135 // [List models](https://platform.openai.com/docs/api-reference/models/list) API to
136 // see all of your available models, or see our
137 // [Model overview](https://platform.openai.com/docs/models) for descriptions of
138 // them.
139 Model string `json:"model,required"`
140 // The name of the assistant. The maximum length is 256 characters.
141 Name string `json:"name,required"`
142 // The object type, which is always `assistant`.
143 Object constant.Assistant `json:"object,required"`
144 // A list of tool enabled on the assistant. There can be a maximum of 128 tools per
145 // assistant. Tools can be of types `code_interpreter`, `file_search`, or
146 // `function`.
147 Tools []AssistantToolUnion `json:"tools,required"`
148 // Specifies the format that the model must output. Compatible with
149 // [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
150 // [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
151 // and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
152 //
153 // Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
154 // Outputs which ensures the model will match your supplied JSON schema. Learn more
155 // in the
156 // [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
157 //
158 // Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
159 // message the model generates is valid JSON.
160 //
161 // **Important:** when using JSON mode, you **must** also instruct the model to
162 // produce JSON yourself via a system or user message. Without this, the model may
163 // generate an unending stream of whitespace until the generation reaches the token
164 // limit, resulting in a long-running and seemingly "stuck" request. Also note that
165 // the message content may be partially cut off if `finish_reason="length"`, which
166 // indicates the generation exceeded `max_tokens` or the conversation exceeded the
167 // max context length.
168 ResponseFormat AssistantResponseFormatOptionUnion `json:"response_format,nullable"`
169 // What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
170 // make the output more random, while lower values like 0.2 will make it more
171 // focused and deterministic.
172 Temperature float64 `json:"temperature,nullable"`
173 // A set of resources that are used by the assistant's tools. The resources are
174 // specific to the type of tool. For example, the `code_interpreter` tool requires
175 // a list of file IDs, while the `file_search` tool requires a list of vector store
176 // IDs.
177 ToolResources AssistantToolResources `json:"tool_resources,nullable"`
178 // An alternative to sampling with temperature, called nucleus sampling, where the
179 // model considers the results of the tokens with top_p probability mass. So 0.1
180 // means only the tokens comprising the top 10% probability mass are considered.
181 //
182 // We generally recommend altering this or temperature but not both.
183 TopP float64 `json:"top_p,nullable"`
184 // Metadata for the response, check the presence of optional fields with the
185 // [resp.Field.IsPresent] method.
186 JSON struct {
187 ID resp.Field
188 CreatedAt resp.Field
189 Description resp.Field
190 Instructions resp.Field
191 Metadata resp.Field
192 Model resp.Field
193 Name resp.Field
194 Object resp.Field
195 Tools resp.Field
196 ResponseFormat resp.Field
197 Temperature resp.Field
198 ToolResources resp.Field
199 TopP resp.Field
200 ExtraFields map[string]resp.Field
201 raw string
202 } `json:"-"`
203}
204
205// Returns the unmodified JSON received from the API
206func (r Assistant) RawJSON() string { return r.JSON.raw }
207func (r *Assistant) UnmarshalJSON(data []byte) error {
208 return apijson.UnmarshalRoot(data, r)
209}
210
211// A set of resources that are used by the assistant's tools. The resources are
212// specific to the type of tool. For example, the `code_interpreter` tool requires
213// a list of file IDs, while the `file_search` tool requires a list of vector store
214// IDs.
215type AssistantToolResources struct {
216 CodeInterpreter AssistantToolResourcesCodeInterpreter `json:"code_interpreter"`
217 FileSearch AssistantToolResourcesFileSearch `json:"file_search"`
218 // Metadata for the response, check the presence of optional fields with the
219 // [resp.Field.IsPresent] method.
220 JSON struct {
221 CodeInterpreter resp.Field
222 FileSearch resp.Field
223 ExtraFields map[string]resp.Field
224 raw string
225 } `json:"-"`
226}
227
228// Returns the unmodified JSON received from the API
229func (r AssistantToolResources) RawJSON() string { return r.JSON.raw }
230func (r *AssistantToolResources) UnmarshalJSON(data []byte) error {
231 return apijson.UnmarshalRoot(data, r)
232}
233
234type AssistantToolResourcesCodeInterpreter struct {
235 // A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
236 // available to the `code_interpreter“ tool. There can be a maximum of 20 files
237 // associated with the tool.
238 FileIDs []string `json:"file_ids"`
239 // Metadata for the response, check the presence of optional fields with the
240 // [resp.Field.IsPresent] method.
241 JSON struct {
242 FileIDs resp.Field
243 ExtraFields map[string]resp.Field
244 raw string
245 } `json:"-"`
246}
247
248// Returns the unmodified JSON received from the API
249func (r AssistantToolResourcesCodeInterpreter) RawJSON() string { return r.JSON.raw }
250func (r *AssistantToolResourcesCodeInterpreter) UnmarshalJSON(data []byte) error {
251 return apijson.UnmarshalRoot(data, r)
252}
253
254type AssistantToolResourcesFileSearch struct {
255 // The ID of the
256 // [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
257 // attached to this assistant. There can be a maximum of 1 vector store attached to
258 // the assistant.
259 VectorStoreIDs []string `json:"vector_store_ids"`
260 // Metadata for the response, check the presence of optional fields with the
261 // [resp.Field.IsPresent] method.
262 JSON struct {
263 VectorStoreIDs resp.Field
264 ExtraFields map[string]resp.Field
265 raw string
266 } `json:"-"`
267}
268
269// Returns the unmodified JSON received from the API
270func (r AssistantToolResourcesFileSearch) RawJSON() string { return r.JSON.raw }
271func (r *AssistantToolResourcesFileSearch) UnmarshalJSON(data []byte) error {
272 return apijson.UnmarshalRoot(data, r)
273}
274
275type AssistantDeleted struct {
276 ID string `json:"id,required"`
277 Deleted bool `json:"deleted,required"`
278 Object constant.AssistantDeleted `json:"object,required"`
279 // Metadata for the response, check the presence of optional fields with the
280 // [resp.Field.IsPresent] method.
281 JSON struct {
282 ID resp.Field
283 Deleted resp.Field
284 Object resp.Field
285 ExtraFields map[string]resp.Field
286 raw string
287 } `json:"-"`
288}
289
290// Returns the unmodified JSON received from the API
291func (r AssistantDeleted) RawJSON() string { return r.JSON.raw }
292func (r *AssistantDeleted) UnmarshalJSON(data []byte) error {
293 return apijson.UnmarshalRoot(data, r)
294}
295
296// AssistantStreamEventUnion contains all possible properties and values from
297// [AssistantStreamEventThreadCreated], [AssistantStreamEventThreadRunCreated],
298// [AssistantStreamEventThreadRunQueued],
299// [AssistantStreamEventThreadRunInProgress],
300// [AssistantStreamEventThreadRunRequiresAction],
301// [AssistantStreamEventThreadRunCompleted],
302// [AssistantStreamEventThreadRunIncomplete],
303// [AssistantStreamEventThreadRunFailed],
304// [AssistantStreamEventThreadRunCancelling],
305// [AssistantStreamEventThreadRunCancelled],
306// [AssistantStreamEventThreadRunExpired],
307// [AssistantStreamEventThreadRunStepCreated],
308// [AssistantStreamEventThreadRunStepInProgress],
309// [AssistantStreamEventThreadRunStepDelta],
310// [AssistantStreamEventThreadRunStepCompleted],
311// [AssistantStreamEventThreadRunStepFailed],
312// [AssistantStreamEventThreadRunStepCancelled],
313// [AssistantStreamEventThreadRunStepExpired],
314// [AssistantStreamEventThreadMessageCreated],
315// [AssistantStreamEventThreadMessageInProgress],
316// [AssistantStreamEventThreadMessageDelta],
317// [AssistantStreamEventThreadMessageCompleted],
318// [AssistantStreamEventThreadMessageIncomplete], [AssistantStreamEventErrorEvent].
319//
320// Use the [AssistantStreamEventUnion.AsAny] method to switch on the variant.
321//
322// Use the methods beginning with 'As' to cast the union to one of its variants.
323type AssistantStreamEventUnion struct {
324 // This field is a union of [Thread], [Run], [RunStep], [RunStepDeltaEvent],
325 // [Message], [MessageDeltaEvent], [shared.ErrorObject]
326 Data AssistantStreamEventUnionData `json:"data"`
327 // Any of "thread.created", "thread.run.created", "thread.run.queued",
328 // "thread.run.in_progress", "thread.run.requires_action", "thread.run.completed",
329 // "thread.run.incomplete", "thread.run.failed", "thread.run.cancelling",
330 // "thread.run.cancelled", "thread.run.expired", "thread.run.step.created",
331 // "thread.run.step.in_progress", "thread.run.step.delta",
332 // "thread.run.step.completed", "thread.run.step.failed",
333 // "thread.run.step.cancelled", "thread.run.step.expired",
334 // "thread.message.created", "thread.message.in_progress", "thread.message.delta",
335 // "thread.message.completed", "thread.message.incomplete", "error".
336 Event string `json:"event"`
337 // This field is from variant [AssistantStreamEventThreadCreated].
338 Enabled bool `json:"enabled"`
339 JSON struct {
340 Data resp.Field
341 Event resp.Field
342 Enabled resp.Field
343 raw string
344 } `json:"-"`
345}
346
347// Use the following switch statement to find the correct variant
348//
349// switch variant := AssistantStreamEventUnion.AsAny().(type) {
350// case AssistantStreamEventThreadCreated:
351// case AssistantStreamEventThreadRunCreated:
352// case AssistantStreamEventThreadRunQueued:
353// case AssistantStreamEventThreadRunInProgress:
354// case AssistantStreamEventThreadRunRequiresAction:
355// case AssistantStreamEventThreadRunCompleted:
356// case AssistantStreamEventThreadRunIncomplete:
357// case AssistantStreamEventThreadRunFailed:
358// case AssistantStreamEventThreadRunCancelling:
359// case AssistantStreamEventThreadRunCancelled:
360// case AssistantStreamEventThreadRunExpired:
361// case AssistantStreamEventThreadRunStepCreated:
362// case AssistantStreamEventThreadRunStepInProgress:
363// case AssistantStreamEventThreadRunStepDelta:
364// case AssistantStreamEventThreadRunStepCompleted:
365// case AssistantStreamEventThreadRunStepFailed:
366// case AssistantStreamEventThreadRunStepCancelled:
367// case AssistantStreamEventThreadRunStepExpired:
368// case AssistantStreamEventThreadMessageCreated:
369// case AssistantStreamEventThreadMessageInProgress:
370// case AssistantStreamEventThreadMessageDelta:
371// case AssistantStreamEventThreadMessageCompleted:
372// case AssistantStreamEventThreadMessageIncomplete:
373// case AssistantStreamEventErrorEvent:
374// default:
375// fmt.Errorf("no variant present")
376// }
377func (u AssistantStreamEventUnion) AsAny() any {
378 switch u.Event {
379 case "thread.created":
380 return u.AsThreadCreated()
381 case "thread.run.created":
382 return u.AsThreadRunCreated()
383 case "thread.run.queued":
384 return u.AsThreadRunQueued()
385 case "thread.run.in_progress":
386 return u.AsThreadRunInProgress()
387 case "thread.run.requires_action":
388 return u.AsThreadRunRequiresAction()
389 case "thread.run.completed":
390 return u.AsThreadRunCompleted()
391 case "thread.run.incomplete":
392 return u.AsThreadRunIncomplete()
393 case "thread.run.failed":
394 return u.AsThreadRunFailed()
395 case "thread.run.cancelling":
396 return u.AsThreadRunCancelling()
397 case "thread.run.cancelled":
398 return u.AsThreadRunCancelled()
399 case "thread.run.expired":
400 return u.AsThreadRunExpired()
401 case "thread.run.step.created":
402 return u.AsThreadRunStepCreated()
403 case "thread.run.step.in_progress":
404 return u.AsThreadRunStepInProgress()
405 case "thread.run.step.delta":
406 return u.AsThreadRunStepDelta()
407 case "thread.run.step.completed":
408 return u.AsThreadRunStepCompleted()
409 case "thread.run.step.failed":
410 return u.AsThreadRunStepFailed()
411 case "thread.run.step.cancelled":
412 return u.AsThreadRunStepCancelled()
413 case "thread.run.step.expired":
414 return u.AsThreadRunStepExpired()
415 case "thread.message.created":
416 return u.AsThreadMessageCreated()
417 case "thread.message.in_progress":
418 return u.AsThreadMessageInProgress()
419 case "thread.message.delta":
420 return u.AsThreadMessageDelta()
421 case "thread.message.completed":
422 return u.AsThreadMessageCompleted()
423 case "thread.message.incomplete":
424 return u.AsThreadMessageIncomplete()
425 case "error":
426 return u.AsErrorEvent()
427 }
428 return nil
429}
430
431func (u AssistantStreamEventUnion) AsThreadCreated() (v AssistantStreamEventThreadCreated) {
432 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
433 return
434}
435
436func (u AssistantStreamEventUnion) AsThreadRunCreated() (v AssistantStreamEventThreadRunCreated) {
437 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
438 return
439}
440
441func (u AssistantStreamEventUnion) AsThreadRunQueued() (v AssistantStreamEventThreadRunQueued) {
442 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
443 return
444}
445
446func (u AssistantStreamEventUnion) AsThreadRunInProgress() (v AssistantStreamEventThreadRunInProgress) {
447 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
448 return
449}
450
451func (u AssistantStreamEventUnion) AsThreadRunRequiresAction() (v AssistantStreamEventThreadRunRequiresAction) {
452 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
453 return
454}
455
456func (u AssistantStreamEventUnion) AsThreadRunCompleted() (v AssistantStreamEventThreadRunCompleted) {
457 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
458 return
459}
460
461func (u AssistantStreamEventUnion) AsThreadRunIncomplete() (v AssistantStreamEventThreadRunIncomplete) {
462 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
463 return
464}
465
466func (u AssistantStreamEventUnion) AsThreadRunFailed() (v AssistantStreamEventThreadRunFailed) {
467 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
468 return
469}
470
471func (u AssistantStreamEventUnion) AsThreadRunCancelling() (v AssistantStreamEventThreadRunCancelling) {
472 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
473 return
474}
475
476func (u AssistantStreamEventUnion) AsThreadRunCancelled() (v AssistantStreamEventThreadRunCancelled) {
477 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
478 return
479}
480
481func (u AssistantStreamEventUnion) AsThreadRunExpired() (v AssistantStreamEventThreadRunExpired) {
482 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
483 return
484}
485
486func (u AssistantStreamEventUnion) AsThreadRunStepCreated() (v AssistantStreamEventThreadRunStepCreated) {
487 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
488 return
489}
490
491func (u AssistantStreamEventUnion) AsThreadRunStepInProgress() (v AssistantStreamEventThreadRunStepInProgress) {
492 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
493 return
494}
495
496func (u AssistantStreamEventUnion) AsThreadRunStepDelta() (v AssistantStreamEventThreadRunStepDelta) {
497 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
498 return
499}
500
501func (u AssistantStreamEventUnion) AsThreadRunStepCompleted() (v AssistantStreamEventThreadRunStepCompleted) {
502 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
503 return
504}
505
506func (u AssistantStreamEventUnion) AsThreadRunStepFailed() (v AssistantStreamEventThreadRunStepFailed) {
507 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
508 return
509}
510
511func (u AssistantStreamEventUnion) AsThreadRunStepCancelled() (v AssistantStreamEventThreadRunStepCancelled) {
512 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
513 return
514}
515
516func (u AssistantStreamEventUnion) AsThreadRunStepExpired() (v AssistantStreamEventThreadRunStepExpired) {
517 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
518 return
519}
520
521func (u AssistantStreamEventUnion) AsThreadMessageCreated() (v AssistantStreamEventThreadMessageCreated) {
522 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
523 return
524}
525
526func (u AssistantStreamEventUnion) AsThreadMessageInProgress() (v AssistantStreamEventThreadMessageInProgress) {
527 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
528 return
529}
530
531func (u AssistantStreamEventUnion) AsThreadMessageDelta() (v AssistantStreamEventThreadMessageDelta) {
532 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
533 return
534}
535
536func (u AssistantStreamEventUnion) AsThreadMessageCompleted() (v AssistantStreamEventThreadMessageCompleted) {
537 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
538 return
539}
540
541func (u AssistantStreamEventUnion) AsThreadMessageIncomplete() (v AssistantStreamEventThreadMessageIncomplete) {
542 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
543 return
544}
545
546func (u AssistantStreamEventUnion) AsErrorEvent() (v AssistantStreamEventErrorEvent) {
547 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
548 return
549}
550
551// Returns the unmodified JSON received from the API
552func (u AssistantStreamEventUnion) RawJSON() string { return u.JSON.raw }
553
554func (r *AssistantStreamEventUnion) UnmarshalJSON(data []byte) error {
555 return apijson.UnmarshalRoot(data, r)
556}
557
558// AssistantStreamEventUnionData is an implicit subunion of
559// [AssistantStreamEventUnion]. AssistantStreamEventUnionData provides convenient
560// access to the sub-properties of the union.
561//
562// For type safety it is recommended to directly use a variant of the
563// [AssistantStreamEventUnion].
564type AssistantStreamEventUnionData struct {
565 ID string `json:"id"`
566 CreatedAt int64 `json:"created_at"`
567 // This field is from variant [Thread].
568 Metadata shared.Metadata `json:"metadata"`
569 Object string `json:"object"`
570 // This field is from variant [Thread].
571 ToolResources ThreadToolResources `json:"tool_resources"`
572 AssistantID string `json:"assistant_id"`
573 CancelledAt int64 `json:"cancelled_at"`
574 CompletedAt int64 `json:"completed_at"`
575 // This field is from variant [Run].
576 ExpiresAt int64 `json:"expires_at"`
577 FailedAt int64 `json:"failed_at"`
578 // This field is a union of [RunIncompleteDetails], [MessageIncompleteDetails]
579 IncompleteDetails AssistantStreamEventUnionDataIncompleteDetails `json:"incomplete_details"`
580 // This field is from variant [Run].
581 Instructions string `json:"instructions"`
582 // This field is a union of [RunLastError], [RunStepLastError]
583 LastError AssistantStreamEventUnionDataLastError `json:"last_error"`
584 // This field is from variant [Run].
585 MaxCompletionTokens int64 `json:"max_completion_tokens"`
586 // This field is from variant [Run].
587 MaxPromptTokens int64 `json:"max_prompt_tokens"`
588 // This field is from variant [Run].
589 Model string `json:"model"`
590 // This field is from variant [Run].
591 ParallelToolCalls bool `json:"parallel_tool_calls"`
592 // This field is from variant [Run].
593 RequiredAction RunRequiredAction `json:"required_action"`
594 // This field is from variant [Run].
595 ResponseFormat AssistantResponseFormatOptionUnion `json:"response_format"`
596 // This field is from variant [Run].
597 StartedAt int64 `json:"started_at"`
598 Status string `json:"status"`
599 ThreadID string `json:"thread_id"`
600 // This field is from variant [Run].
601 ToolChoice AssistantToolChoiceOptionUnion `json:"tool_choice"`
602 // This field is from variant [Run].
603 Tools []AssistantToolUnion `json:"tools"`
604 // This field is from variant [Run].
605 TruncationStrategy RunTruncationStrategy `json:"truncation_strategy"`
606 // This field is a union of [RunUsage], [RunStepUsage]
607 Usage AssistantStreamEventUnionDataUsage `json:"usage"`
608 // This field is from variant [Run].
609 Temperature float64 `json:"temperature"`
610 // This field is from variant [Run].
611 TopP float64 `json:"top_p"`
612 // This field is from variant [RunStep].
613 ExpiredAt int64 `json:"expired_at"`
614 RunID string `json:"run_id"`
615 // This field is from variant [RunStep].
616 StepDetails RunStepStepDetailsUnion `json:"step_details"`
617 Type string `json:"type"`
618 // This field is a union of [RunStepDelta], [MessageDelta]
619 Delta AssistantStreamEventUnionDataDelta `json:"delta"`
620 // This field is from variant [Message].
621 Attachments []MessageAttachment `json:"attachments"`
622 // This field is from variant [Message].
623 Content []MessageContentUnion `json:"content"`
624 // This field is from variant [Message].
625 IncompleteAt int64 `json:"incomplete_at"`
626 // This field is from variant [Message].
627 Role MessageRole `json:"role"`
628 // This field is from variant [shared.ErrorObject].
629 Code string `json:"code"`
630 // This field is from variant [shared.ErrorObject].
631 Message string `json:"message"`
632 // This field is from variant [shared.ErrorObject].
633 Param string `json:"param"`
634 JSON struct {
635 ID resp.Field
636 CreatedAt resp.Field
637 Metadata resp.Field
638 Object resp.Field
639 ToolResources resp.Field
640 AssistantID resp.Field
641 CancelledAt resp.Field
642 CompletedAt resp.Field
643 ExpiresAt resp.Field
644 FailedAt resp.Field
645 IncompleteDetails resp.Field
646 Instructions resp.Field
647 LastError resp.Field
648 MaxCompletionTokens resp.Field
649 MaxPromptTokens resp.Field
650 Model resp.Field
651 ParallelToolCalls resp.Field
652 RequiredAction resp.Field
653 ResponseFormat resp.Field
654 StartedAt resp.Field
655 Status resp.Field
656 ThreadID resp.Field
657 ToolChoice resp.Field
658 Tools resp.Field
659 TruncationStrategy resp.Field
660 Usage resp.Field
661 Temperature resp.Field
662 TopP resp.Field
663 ExpiredAt resp.Field
664 RunID resp.Field
665 StepDetails resp.Field
666 Type resp.Field
667 Delta resp.Field
668 Attachments resp.Field
669 Content resp.Field
670 IncompleteAt resp.Field
671 Role resp.Field
672 Code resp.Field
673 Message resp.Field
674 Param resp.Field
675 raw string
676 } `json:"-"`
677}
678
679func (r *AssistantStreamEventUnionData) UnmarshalJSON(data []byte) error {
680 return apijson.UnmarshalRoot(data, r)
681}
682
683// AssistantStreamEventUnionDataIncompleteDetails is an implicit subunion of
684// [AssistantStreamEventUnion]. AssistantStreamEventUnionDataIncompleteDetails
685// provides convenient access to the sub-properties of the union.
686//
687// For type safety it is recommended to directly use a variant of the
688// [AssistantStreamEventUnion].
689type AssistantStreamEventUnionDataIncompleteDetails struct {
690 Reason string `json:"reason"`
691 JSON struct {
692 Reason resp.Field
693 raw string
694 } `json:"-"`
695}
696
697func (r *AssistantStreamEventUnionDataIncompleteDetails) UnmarshalJSON(data []byte) error {
698 return apijson.UnmarshalRoot(data, r)
699}
700
701// AssistantStreamEventUnionDataLastError is an implicit subunion of
702// [AssistantStreamEventUnion]. AssistantStreamEventUnionDataLastError provides
703// convenient access to the sub-properties of the union.
704//
705// For type safety it is recommended to directly use a variant of the
706// [AssistantStreamEventUnion].
707type AssistantStreamEventUnionDataLastError struct {
708 Code string `json:"code"`
709 Message string `json:"message"`
710 JSON struct {
711 Code resp.Field
712 Message resp.Field
713 raw string
714 } `json:"-"`
715}
716
717func (r *AssistantStreamEventUnionDataLastError) UnmarshalJSON(data []byte) error {
718 return apijson.UnmarshalRoot(data, r)
719}
720
721// AssistantStreamEventUnionDataUsage is an implicit subunion of
722// [AssistantStreamEventUnion]. AssistantStreamEventUnionDataUsage provides
723// convenient access to the sub-properties of the union.
724//
725// For type safety it is recommended to directly use a variant of the
726// [AssistantStreamEventUnion].
727type AssistantStreamEventUnionDataUsage struct {
728 CompletionTokens int64 `json:"completion_tokens"`
729 PromptTokens int64 `json:"prompt_tokens"`
730 TotalTokens int64 `json:"total_tokens"`
731 JSON struct {
732 CompletionTokens resp.Field
733 PromptTokens resp.Field
734 TotalTokens resp.Field
735 raw string
736 } `json:"-"`
737}
738
739func (r *AssistantStreamEventUnionDataUsage) UnmarshalJSON(data []byte) error {
740 return apijson.UnmarshalRoot(data, r)
741}
742
743// AssistantStreamEventUnionDataDelta is an implicit subunion of
744// [AssistantStreamEventUnion]. AssistantStreamEventUnionDataDelta provides
745// convenient access to the sub-properties of the union.
746//
747// For type safety it is recommended to directly use a variant of the
748// [AssistantStreamEventUnion].
749type AssistantStreamEventUnionDataDelta struct {
750 // This field is from variant [RunStepDelta].
751 StepDetails RunStepDeltaStepDetailsUnion `json:"step_details"`
752 // This field is from variant [MessageDelta].
753 Content []MessageContentDeltaUnion `json:"content"`
754 // This field is from variant [MessageDelta].
755 Role MessageDeltaRole `json:"role"`
756 JSON struct {
757 StepDetails resp.Field
758 Content resp.Field
759 Role resp.Field
760 raw string
761 } `json:"-"`
762}
763
764func (r *AssistantStreamEventUnionDataDelta) UnmarshalJSON(data []byte) error {
765 return apijson.UnmarshalRoot(data, r)
766}
767
768// Occurs when a new
769// [thread](https://platform.openai.com/docs/api-reference/threads/object) is
770// created.
771type AssistantStreamEventThreadCreated struct {
772 // Represents a thread that contains
773 // [messages](https://platform.openai.com/docs/api-reference/messages).
774 Data Thread `json:"data,required"`
775 Event constant.ThreadCreated `json:"event,required"`
776 // Whether to enable input audio transcription.
777 Enabled bool `json:"enabled"`
778 // Metadata for the response, check the presence of optional fields with the
779 // [resp.Field.IsPresent] method.
780 JSON struct {
781 Data resp.Field
782 Event resp.Field
783 Enabled resp.Field
784 ExtraFields map[string]resp.Field
785 raw string
786 } `json:"-"`
787}
788
789// Returns the unmodified JSON received from the API
790func (r AssistantStreamEventThreadCreated) RawJSON() string { return r.JSON.raw }
791func (r *AssistantStreamEventThreadCreated) UnmarshalJSON(data []byte) error {
792 return apijson.UnmarshalRoot(data, r)
793}
794
795// Occurs when a new
796// [run](https://platform.openai.com/docs/api-reference/runs/object) is created.
797type AssistantStreamEventThreadRunCreated struct {
798 // Represents an execution run on a
799 // [thread](https://platform.openai.com/docs/api-reference/threads).
800 Data Run `json:"data,required"`
801 Event constant.ThreadRunCreated `json:"event,required"`
802 // Metadata for the response, check the presence of optional fields with the
803 // [resp.Field.IsPresent] method.
804 JSON struct {
805 Data resp.Field
806 Event resp.Field
807 ExtraFields map[string]resp.Field
808 raw string
809 } `json:"-"`
810}
811
812// Returns the unmodified JSON received from the API
813func (r AssistantStreamEventThreadRunCreated) RawJSON() string { return r.JSON.raw }
814func (r *AssistantStreamEventThreadRunCreated) UnmarshalJSON(data []byte) error {
815 return apijson.UnmarshalRoot(data, r)
816}
817
818// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
819// moves to a `queued` status.
820type AssistantStreamEventThreadRunQueued struct {
821 // Represents an execution run on a
822 // [thread](https://platform.openai.com/docs/api-reference/threads).
823 Data Run `json:"data,required"`
824 Event constant.ThreadRunQueued `json:"event,required"`
825 // Metadata for the response, check the presence of optional fields with the
826 // [resp.Field.IsPresent] method.
827 JSON struct {
828 Data resp.Field
829 Event resp.Field
830 ExtraFields map[string]resp.Field
831 raw string
832 } `json:"-"`
833}
834
835// Returns the unmodified JSON received from the API
836func (r AssistantStreamEventThreadRunQueued) RawJSON() string { return r.JSON.raw }
837func (r *AssistantStreamEventThreadRunQueued) UnmarshalJSON(data []byte) error {
838 return apijson.UnmarshalRoot(data, r)
839}
840
841// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
842// moves to an `in_progress` status.
843type AssistantStreamEventThreadRunInProgress struct {
844 // Represents an execution run on a
845 // [thread](https://platform.openai.com/docs/api-reference/threads).
846 Data Run `json:"data,required"`
847 Event constant.ThreadRunInProgress `json:"event,required"`
848 // Metadata for the response, check the presence of optional fields with the
849 // [resp.Field.IsPresent] method.
850 JSON struct {
851 Data resp.Field
852 Event resp.Field
853 ExtraFields map[string]resp.Field
854 raw string
855 } `json:"-"`
856}
857
858// Returns the unmodified JSON received from the API
859func (r AssistantStreamEventThreadRunInProgress) RawJSON() string { return r.JSON.raw }
860func (r *AssistantStreamEventThreadRunInProgress) UnmarshalJSON(data []byte) error {
861 return apijson.UnmarshalRoot(data, r)
862}
863
864// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
865// moves to a `requires_action` status.
866type AssistantStreamEventThreadRunRequiresAction struct {
867 // Represents an execution run on a
868 // [thread](https://platform.openai.com/docs/api-reference/threads).
869 Data Run `json:"data,required"`
870 Event constant.ThreadRunRequiresAction `json:"event,required"`
871 // Metadata for the response, check the presence of optional fields with the
872 // [resp.Field.IsPresent] method.
873 JSON struct {
874 Data resp.Field
875 Event resp.Field
876 ExtraFields map[string]resp.Field
877 raw string
878 } `json:"-"`
879}
880
881// Returns the unmodified JSON received from the API
882func (r AssistantStreamEventThreadRunRequiresAction) RawJSON() string { return r.JSON.raw }
883func (r *AssistantStreamEventThreadRunRequiresAction) UnmarshalJSON(data []byte) error {
884 return apijson.UnmarshalRoot(data, r)
885}
886
887// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
888// is completed.
889type AssistantStreamEventThreadRunCompleted struct {
890 // Represents an execution run on a
891 // [thread](https://platform.openai.com/docs/api-reference/threads).
892 Data Run `json:"data,required"`
893 Event constant.ThreadRunCompleted `json:"event,required"`
894 // Metadata for the response, check the presence of optional fields with the
895 // [resp.Field.IsPresent] method.
896 JSON struct {
897 Data resp.Field
898 Event resp.Field
899 ExtraFields map[string]resp.Field
900 raw string
901 } `json:"-"`
902}
903
904// Returns the unmodified JSON received from the API
905func (r AssistantStreamEventThreadRunCompleted) RawJSON() string { return r.JSON.raw }
906func (r *AssistantStreamEventThreadRunCompleted) UnmarshalJSON(data []byte) error {
907 return apijson.UnmarshalRoot(data, r)
908}
909
910// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
911// ends with status `incomplete`.
912type AssistantStreamEventThreadRunIncomplete struct {
913 // Represents an execution run on a
914 // [thread](https://platform.openai.com/docs/api-reference/threads).
915 Data Run `json:"data,required"`
916 Event constant.ThreadRunIncomplete `json:"event,required"`
917 // Metadata for the response, check the presence of optional fields with the
918 // [resp.Field.IsPresent] method.
919 JSON struct {
920 Data resp.Field
921 Event resp.Field
922 ExtraFields map[string]resp.Field
923 raw string
924 } `json:"-"`
925}
926
927// Returns the unmodified JSON received from the API
928func (r AssistantStreamEventThreadRunIncomplete) RawJSON() string { return r.JSON.raw }
929func (r *AssistantStreamEventThreadRunIncomplete) UnmarshalJSON(data []byte) error {
930 return apijson.UnmarshalRoot(data, r)
931}
932
933// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
934// fails.
935type AssistantStreamEventThreadRunFailed struct {
936 // Represents an execution run on a
937 // [thread](https://platform.openai.com/docs/api-reference/threads).
938 Data Run `json:"data,required"`
939 Event constant.ThreadRunFailed `json:"event,required"`
940 // Metadata for the response, check the presence of optional fields with the
941 // [resp.Field.IsPresent] method.
942 JSON struct {
943 Data resp.Field
944 Event resp.Field
945 ExtraFields map[string]resp.Field
946 raw string
947 } `json:"-"`
948}
949
950// Returns the unmodified JSON received from the API
951func (r AssistantStreamEventThreadRunFailed) RawJSON() string { return r.JSON.raw }
952func (r *AssistantStreamEventThreadRunFailed) UnmarshalJSON(data []byte) error {
953 return apijson.UnmarshalRoot(data, r)
954}
955
956// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
957// moves to a `cancelling` status.
958type AssistantStreamEventThreadRunCancelling struct {
959 // Represents an execution run on a
960 // [thread](https://platform.openai.com/docs/api-reference/threads).
961 Data Run `json:"data,required"`
962 Event constant.ThreadRunCancelling `json:"event,required"`
963 // Metadata for the response, check the presence of optional fields with the
964 // [resp.Field.IsPresent] method.
965 JSON struct {
966 Data resp.Field
967 Event resp.Field
968 ExtraFields map[string]resp.Field
969 raw string
970 } `json:"-"`
971}
972
973// Returns the unmodified JSON received from the API
974func (r AssistantStreamEventThreadRunCancelling) RawJSON() string { return r.JSON.raw }
975func (r *AssistantStreamEventThreadRunCancelling) UnmarshalJSON(data []byte) error {
976 return apijson.UnmarshalRoot(data, r)
977}
978
979// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
980// is cancelled.
981type AssistantStreamEventThreadRunCancelled struct {
982 // Represents an execution run on a
983 // [thread](https://platform.openai.com/docs/api-reference/threads).
984 Data Run `json:"data,required"`
985 Event constant.ThreadRunCancelled `json:"event,required"`
986 // Metadata for the response, check the presence of optional fields with the
987 // [resp.Field.IsPresent] method.
988 JSON struct {
989 Data resp.Field
990 Event resp.Field
991 ExtraFields map[string]resp.Field
992 raw string
993 } `json:"-"`
994}
995
996// Returns the unmodified JSON received from the API
997func (r AssistantStreamEventThreadRunCancelled) RawJSON() string { return r.JSON.raw }
998func (r *AssistantStreamEventThreadRunCancelled) UnmarshalJSON(data []byte) error {
999 return apijson.UnmarshalRoot(data, r)
1000}
1001
1002// Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
1003// expires.
1004type AssistantStreamEventThreadRunExpired struct {
1005 // Represents an execution run on a
1006 // [thread](https://platform.openai.com/docs/api-reference/threads).
1007 Data Run `json:"data,required"`
1008 Event constant.ThreadRunExpired `json:"event,required"`
1009 // Metadata for the response, check the presence of optional fields with the
1010 // [resp.Field.IsPresent] method.
1011 JSON struct {
1012 Data resp.Field
1013 Event resp.Field
1014 ExtraFields map[string]resp.Field
1015 raw string
1016 } `json:"-"`
1017}
1018
1019// Returns the unmodified JSON received from the API
1020func (r AssistantStreamEventThreadRunExpired) RawJSON() string { return r.JSON.raw }
1021func (r *AssistantStreamEventThreadRunExpired) UnmarshalJSON(data []byte) error {
1022 return apijson.UnmarshalRoot(data, r)
1023}
1024
1025// Occurs when a
1026// [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
1027// is created.
1028type AssistantStreamEventThreadRunStepCreated struct {
1029 // Represents a step in execution of a run.
1030 Data RunStep `json:"data,required"`
1031 Event constant.ThreadRunStepCreated `json:"event,required"`
1032 // Metadata for the response, check the presence of optional fields with the
1033 // [resp.Field.IsPresent] method.
1034 JSON struct {
1035 Data resp.Field
1036 Event resp.Field
1037 ExtraFields map[string]resp.Field
1038 raw string
1039 } `json:"-"`
1040}
1041
1042// Returns the unmodified JSON received from the API
1043func (r AssistantStreamEventThreadRunStepCreated) RawJSON() string { return r.JSON.raw }
1044func (r *AssistantStreamEventThreadRunStepCreated) UnmarshalJSON(data []byte) error {
1045 return apijson.UnmarshalRoot(data, r)
1046}
1047
1048// Occurs when a
1049// [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
1050// moves to an `in_progress` state.
1051type AssistantStreamEventThreadRunStepInProgress struct {
1052 // Represents a step in execution of a run.
1053 Data RunStep `json:"data,required"`
1054 Event constant.ThreadRunStepInProgress `json:"event,required"`
1055 // Metadata for the response, check the presence of optional fields with the
1056 // [resp.Field.IsPresent] method.
1057 JSON struct {
1058 Data resp.Field
1059 Event resp.Field
1060 ExtraFields map[string]resp.Field
1061 raw string
1062 } `json:"-"`
1063}
1064
1065// Returns the unmodified JSON received from the API
1066func (r AssistantStreamEventThreadRunStepInProgress) RawJSON() string { return r.JSON.raw }
1067func (r *AssistantStreamEventThreadRunStepInProgress) UnmarshalJSON(data []byte) error {
1068 return apijson.UnmarshalRoot(data, r)
1069}
1070
1071// Occurs when parts of a
1072// [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
1073// are being streamed.
1074type AssistantStreamEventThreadRunStepDelta struct {
1075 // Represents a run step delta i.e. any changed fields on a run step during
1076 // streaming.
1077 Data RunStepDeltaEvent `json:"data,required"`
1078 Event constant.ThreadRunStepDelta `json:"event,required"`
1079 // Metadata for the response, check the presence of optional fields with the
1080 // [resp.Field.IsPresent] method.
1081 JSON struct {
1082 Data resp.Field
1083 Event resp.Field
1084 ExtraFields map[string]resp.Field
1085 raw string
1086 } `json:"-"`
1087}
1088
1089// Returns the unmodified JSON received from the API
1090func (r AssistantStreamEventThreadRunStepDelta) RawJSON() string { return r.JSON.raw }
1091func (r *AssistantStreamEventThreadRunStepDelta) UnmarshalJSON(data []byte) error {
1092 return apijson.UnmarshalRoot(data, r)
1093}
1094
1095// Occurs when a
1096// [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
1097// is completed.
1098type AssistantStreamEventThreadRunStepCompleted struct {
1099 // Represents a step in execution of a run.
1100 Data RunStep `json:"data,required"`
1101 Event constant.ThreadRunStepCompleted `json:"event,required"`
1102 // Metadata for the response, check the presence of optional fields with the
1103 // [resp.Field.IsPresent] method.
1104 JSON struct {
1105 Data resp.Field
1106 Event resp.Field
1107 ExtraFields map[string]resp.Field
1108 raw string
1109 } `json:"-"`
1110}
1111
1112// Returns the unmodified JSON received from the API
1113func (r AssistantStreamEventThreadRunStepCompleted) RawJSON() string { return r.JSON.raw }
1114func (r *AssistantStreamEventThreadRunStepCompleted) UnmarshalJSON(data []byte) error {
1115 return apijson.UnmarshalRoot(data, r)
1116}
1117
1118// Occurs when a
1119// [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
1120// fails.
1121type AssistantStreamEventThreadRunStepFailed struct {
1122 // Represents a step in execution of a run.
1123 Data RunStep `json:"data,required"`
1124 Event constant.ThreadRunStepFailed `json:"event,required"`
1125 // Metadata for the response, check the presence of optional fields with the
1126 // [resp.Field.IsPresent] method.
1127 JSON struct {
1128 Data resp.Field
1129 Event resp.Field
1130 ExtraFields map[string]resp.Field
1131 raw string
1132 } `json:"-"`
1133}
1134
1135// Returns the unmodified JSON received from the API
1136func (r AssistantStreamEventThreadRunStepFailed) RawJSON() string { return r.JSON.raw }
1137func (r *AssistantStreamEventThreadRunStepFailed) UnmarshalJSON(data []byte) error {
1138 return apijson.UnmarshalRoot(data, r)
1139}
1140
1141// Occurs when a
1142// [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
1143// is cancelled.
1144type AssistantStreamEventThreadRunStepCancelled struct {
1145 // Represents a step in execution of a run.
1146 Data RunStep `json:"data,required"`
1147 Event constant.ThreadRunStepCancelled `json:"event,required"`
1148 // Metadata for the response, check the presence of optional fields with the
1149 // [resp.Field.IsPresent] method.
1150 JSON struct {
1151 Data resp.Field
1152 Event resp.Field
1153 ExtraFields map[string]resp.Field
1154 raw string
1155 } `json:"-"`
1156}
1157
1158// Returns the unmodified JSON received from the API
1159func (r AssistantStreamEventThreadRunStepCancelled) RawJSON() string { return r.JSON.raw }
1160func (r *AssistantStreamEventThreadRunStepCancelled) UnmarshalJSON(data []byte) error {
1161 return apijson.UnmarshalRoot(data, r)
1162}
1163
1164// Occurs when a
1165// [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
1166// expires.
1167type AssistantStreamEventThreadRunStepExpired struct {
1168 // Represents a step in execution of a run.
1169 Data RunStep `json:"data,required"`
1170 Event constant.ThreadRunStepExpired `json:"event,required"`
1171 // Metadata for the response, check the presence of optional fields with the
1172 // [resp.Field.IsPresent] method.
1173 JSON struct {
1174 Data resp.Field
1175 Event resp.Field
1176 ExtraFields map[string]resp.Field
1177 raw string
1178 } `json:"-"`
1179}
1180
1181// Returns the unmodified JSON received from the API
1182func (r AssistantStreamEventThreadRunStepExpired) RawJSON() string { return r.JSON.raw }
1183func (r *AssistantStreamEventThreadRunStepExpired) UnmarshalJSON(data []byte) error {
1184 return apijson.UnmarshalRoot(data, r)
1185}
1186
1187// Occurs when a
1188// [message](https://platform.openai.com/docs/api-reference/messages/object) is
1189// created.
1190type AssistantStreamEventThreadMessageCreated struct {
1191 // Represents a message within a
1192 // [thread](https://platform.openai.com/docs/api-reference/threads).
1193 Data Message `json:"data,required"`
1194 Event constant.ThreadMessageCreated `json:"event,required"`
1195 // Metadata for the response, check the presence of optional fields with the
1196 // [resp.Field.IsPresent] method.
1197 JSON struct {
1198 Data resp.Field
1199 Event resp.Field
1200 ExtraFields map[string]resp.Field
1201 raw string
1202 } `json:"-"`
1203}
1204
1205// Returns the unmodified JSON received from the API
1206func (r AssistantStreamEventThreadMessageCreated) RawJSON() string { return r.JSON.raw }
1207func (r *AssistantStreamEventThreadMessageCreated) UnmarshalJSON(data []byte) error {
1208 return apijson.UnmarshalRoot(data, r)
1209}
1210
1211// Occurs when a
1212// [message](https://platform.openai.com/docs/api-reference/messages/object) moves
1213// to an `in_progress` state.
1214type AssistantStreamEventThreadMessageInProgress struct {
1215 // Represents a message within a
1216 // [thread](https://platform.openai.com/docs/api-reference/threads).
1217 Data Message `json:"data,required"`
1218 Event constant.ThreadMessageInProgress `json:"event,required"`
1219 // Metadata for the response, check the presence of optional fields with the
1220 // [resp.Field.IsPresent] method.
1221 JSON struct {
1222 Data resp.Field
1223 Event resp.Field
1224 ExtraFields map[string]resp.Field
1225 raw string
1226 } `json:"-"`
1227}
1228
1229// Returns the unmodified JSON received from the API
1230func (r AssistantStreamEventThreadMessageInProgress) RawJSON() string { return r.JSON.raw }
1231func (r *AssistantStreamEventThreadMessageInProgress) UnmarshalJSON(data []byte) error {
1232 return apijson.UnmarshalRoot(data, r)
1233}
1234
1235// Occurs when parts of a
1236// [Message](https://platform.openai.com/docs/api-reference/messages/object) are
1237// being streamed.
1238type AssistantStreamEventThreadMessageDelta struct {
1239 // Represents a message delta i.e. any changed fields on a message during
1240 // streaming.
1241 Data MessageDeltaEvent `json:"data,required"`
1242 Event constant.ThreadMessageDelta `json:"event,required"`
1243 // Metadata for the response, check the presence of optional fields with the
1244 // [resp.Field.IsPresent] method.
1245 JSON struct {
1246 Data resp.Field
1247 Event resp.Field
1248 ExtraFields map[string]resp.Field
1249 raw string
1250 } `json:"-"`
1251}
1252
1253// Returns the unmodified JSON received from the API
1254func (r AssistantStreamEventThreadMessageDelta) RawJSON() string { return r.JSON.raw }
1255func (r *AssistantStreamEventThreadMessageDelta) UnmarshalJSON(data []byte) error {
1256 return apijson.UnmarshalRoot(data, r)
1257}
1258
1259// Occurs when a
1260// [message](https://platform.openai.com/docs/api-reference/messages/object) is
1261// completed.
1262type AssistantStreamEventThreadMessageCompleted struct {
1263 // Represents a message within a
1264 // [thread](https://platform.openai.com/docs/api-reference/threads).
1265 Data Message `json:"data,required"`
1266 Event constant.ThreadMessageCompleted `json:"event,required"`
1267 // Metadata for the response, check the presence of optional fields with the
1268 // [resp.Field.IsPresent] method.
1269 JSON struct {
1270 Data resp.Field
1271 Event resp.Field
1272 ExtraFields map[string]resp.Field
1273 raw string
1274 } `json:"-"`
1275}
1276
1277// Returns the unmodified JSON received from the API
1278func (r AssistantStreamEventThreadMessageCompleted) RawJSON() string { return r.JSON.raw }
1279func (r *AssistantStreamEventThreadMessageCompleted) UnmarshalJSON(data []byte) error {
1280 return apijson.UnmarshalRoot(data, r)
1281}
1282
1283// Occurs when a
1284// [message](https://platform.openai.com/docs/api-reference/messages/object) ends
1285// before it is completed.
1286type AssistantStreamEventThreadMessageIncomplete struct {
1287 // Represents a message within a
1288 // [thread](https://platform.openai.com/docs/api-reference/threads).
1289 Data Message `json:"data,required"`
1290 Event constant.ThreadMessageIncomplete `json:"event,required"`
1291 // Metadata for the response, check the presence of optional fields with the
1292 // [resp.Field.IsPresent] method.
1293 JSON struct {
1294 Data resp.Field
1295 Event resp.Field
1296 ExtraFields map[string]resp.Field
1297 raw string
1298 } `json:"-"`
1299}
1300
1301// Returns the unmodified JSON received from the API
1302func (r AssistantStreamEventThreadMessageIncomplete) RawJSON() string { return r.JSON.raw }
1303func (r *AssistantStreamEventThreadMessageIncomplete) UnmarshalJSON(data []byte) error {
1304 return apijson.UnmarshalRoot(data, r)
1305}
1306
1307// Occurs when an
1308// [error](https://platform.openai.com/docs/guides/error-codes#api-errors) occurs.
1309// This can happen due to an internal server error or a timeout.
1310type AssistantStreamEventErrorEvent struct {
1311 Data shared.ErrorObject `json:"data,required"`
1312 Event constant.Error `json:"event,required"`
1313 // Metadata for the response, check the presence of optional fields with the
1314 // [resp.Field.IsPresent] method.
1315 JSON struct {
1316 Data resp.Field
1317 Event resp.Field
1318 ExtraFields map[string]resp.Field
1319 raw string
1320 } `json:"-"`
1321}
1322
1323// Returns the unmodified JSON received from the API
1324func (r AssistantStreamEventErrorEvent) RawJSON() string { return r.JSON.raw }
1325func (r *AssistantStreamEventErrorEvent) UnmarshalJSON(data []byte) error {
1326 return apijson.UnmarshalRoot(data, r)
1327}
1328
1329// AssistantToolUnion contains all possible properties and values from
1330// [CodeInterpreterTool], [FileSearchTool], [FunctionTool].
1331//
1332// Use the [AssistantToolUnion.AsAny] method to switch on the variant.
1333//
1334// Use the methods beginning with 'As' to cast the union to one of its variants.
1335type AssistantToolUnion struct {
1336 // Any of "code_interpreter", "file_search", "function".
1337 Type string `json:"type"`
1338 // This field is from variant [FileSearchTool].
1339 FileSearch FileSearchToolFileSearch `json:"file_search"`
1340 // This field is from variant [FunctionTool].
1341 Function shared.FunctionDefinition `json:"function"`
1342 JSON struct {
1343 Type resp.Field
1344 FileSearch resp.Field
1345 Function resp.Field
1346 raw string
1347 } `json:"-"`
1348}
1349
1350// Use the following switch statement to find the correct variant
1351//
1352// switch variant := AssistantToolUnion.AsAny().(type) {
1353// case CodeInterpreterTool:
1354// case FileSearchTool:
1355// case FunctionTool:
1356// default:
1357// fmt.Errorf("no variant present")
1358// }
1359func (u AssistantToolUnion) AsAny() any {
1360 switch u.Type {
1361 case "code_interpreter":
1362 return u.AsCodeInterpreter()
1363 case "file_search":
1364 return u.AsFileSearch()
1365 case "function":
1366 return u.AsFunction()
1367 }
1368 return nil
1369}
1370
1371func (u AssistantToolUnion) AsCodeInterpreter() (v CodeInterpreterTool) {
1372 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1373 return
1374}
1375
1376func (u AssistantToolUnion) AsFileSearch() (v FileSearchTool) {
1377 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1378 return
1379}
1380
1381func (u AssistantToolUnion) AsFunction() (v FunctionTool) {
1382 apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1383 return
1384}
1385
1386// Returns the unmodified JSON received from the API
1387func (u AssistantToolUnion) RawJSON() string { return u.JSON.raw }
1388
1389func (r *AssistantToolUnion) UnmarshalJSON(data []byte) error {
1390 return apijson.UnmarshalRoot(data, r)
1391}
1392
1393// ToParam converts this AssistantToolUnion to a AssistantToolUnionParam.
1394//
1395// Warning: the fields of the param type will not be present. ToParam should only
1396// be used at the last possible moment before sending a request. Test for this with
1397// AssistantToolUnionParam.IsOverridden()
1398func (r AssistantToolUnion) ToParam() AssistantToolUnionParam {
1399 return param.OverrideObj[AssistantToolUnionParam](r.RawJSON())
1400}
1401
1402func AssistantToolParamOfFunction(function shared.FunctionDefinitionParam) AssistantToolUnionParam {
1403 var variant FunctionToolParam
1404 variant.Function = function
1405 return AssistantToolUnionParam{OfFunction: &variant}
1406}
1407
1408// Only one field can be non-zero.
1409//
1410// Use [param.IsOmitted] to confirm if a field is set.
1411type AssistantToolUnionParam struct {
1412 OfCodeInterpreter *CodeInterpreterToolParam `json:",omitzero,inline"`
1413 OfFileSearch *FileSearchToolParam `json:",omitzero,inline"`
1414 OfFunction *FunctionToolParam `json:",omitzero,inline"`
1415 paramUnion
1416}
1417
1418// IsPresent returns true if the field's value is not omitted and not the JSON
1419// "null". To check if this field is omitted, use [param.IsOmitted].
1420func (u AssistantToolUnionParam) IsPresent() bool { return !param.IsOmitted(u) && !u.IsNull() }
1421func (u AssistantToolUnionParam) MarshalJSON() ([]byte, error) {
1422 return param.MarshalUnion[AssistantToolUnionParam](u.OfCodeInterpreter, u.OfFileSearch, u.OfFunction)
1423}
1424
1425func (u *AssistantToolUnionParam) asAny() any {
1426 if !param.IsOmitted(u.OfCodeInterpreter) {
1427 return u.OfCodeInterpreter
1428 } else if !param.IsOmitted(u.OfFileSearch) {
1429 return u.OfFileSearch
1430 } else if !param.IsOmitted(u.OfFunction) {
1431 return u.OfFunction
1432 }
1433 return nil
1434}
1435
1436// Returns a pointer to the underlying variant's property, if present.
1437func (u AssistantToolUnionParam) GetFileSearch() *FileSearchToolFileSearchParam {
1438 if vt := u.OfFileSearch; vt != nil {
1439 return &vt.FileSearch
1440 }
1441 return nil
1442}
1443
1444// Returns a pointer to the underlying variant's property, if present.
1445func (u AssistantToolUnionParam) GetFunction() *shared.FunctionDefinitionParam {
1446 if vt := u.OfFunction; vt != nil {
1447 return &vt.Function
1448 }
1449 return nil
1450}
1451
1452// Returns a pointer to the underlying variant's property, if present.
1453func (u AssistantToolUnionParam) GetType() *string {
1454 if vt := u.OfCodeInterpreter; vt != nil {
1455 return (*string)(&vt.Type)
1456 } else if vt := u.OfFileSearch; vt != nil {
1457 return (*string)(&vt.Type)
1458 } else if vt := u.OfFunction; vt != nil {
1459 return (*string)(&vt.Type)
1460 }
1461 return nil
1462}
1463
1464func init() {
1465 apijson.RegisterUnion[AssistantToolUnionParam](
1466 "type",
1467 apijson.UnionVariant{
1468 TypeFilter: gjson.JSON,
1469 Type: reflect.TypeOf(CodeInterpreterToolParam{}),
1470 DiscriminatorValue: "code_interpreter",
1471 },
1472 apijson.UnionVariant{
1473 TypeFilter: gjson.JSON,
1474 Type: reflect.TypeOf(FileSearchToolParam{}),
1475 DiscriminatorValue: "file_search",
1476 },
1477 apijson.UnionVariant{
1478 TypeFilter: gjson.JSON,
1479 Type: reflect.TypeOf(FunctionToolParam{}),
1480 DiscriminatorValue: "function",
1481 },
1482 )
1483}
1484
1485type CodeInterpreterTool struct {
1486 // The type of tool being defined: `code_interpreter`
1487 Type constant.CodeInterpreter `json:"type,required"`
1488 // Metadata for the response, check the presence of optional fields with the
1489 // [resp.Field.IsPresent] method.
1490 JSON struct {
1491 Type resp.Field
1492 ExtraFields map[string]resp.Field
1493 raw string
1494 } `json:"-"`
1495}
1496
1497// Returns the unmodified JSON received from the API
1498func (r CodeInterpreterTool) RawJSON() string { return r.JSON.raw }
1499func (r *CodeInterpreterTool) UnmarshalJSON(data []byte) error {
1500 return apijson.UnmarshalRoot(data, r)
1501}
1502
1503// ToParam converts this CodeInterpreterTool to a CodeInterpreterToolParam.
1504//
1505// Warning: the fields of the param type will not be present. ToParam should only
1506// be used at the last possible moment before sending a request. Test for this with
1507// CodeInterpreterToolParam.IsOverridden()
1508func (r CodeInterpreterTool) ToParam() CodeInterpreterToolParam {
1509 return param.OverrideObj[CodeInterpreterToolParam](r.RawJSON())
1510}
1511
1512// The property Type is required.
1513type CodeInterpreterToolParam struct {
1514 // The type of tool being defined: `code_interpreter`
1515 //
1516 // This field can be elided, and will marshal its zero value as "code_interpreter".
1517 Type constant.CodeInterpreter `json:"type,required"`
1518 paramObj
1519}
1520
1521// IsPresent returns true if the field's value is not omitted and not the JSON
1522// "null". To check if this field is omitted, use [param.IsOmitted].
1523func (f CodeInterpreterToolParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
1524func (r CodeInterpreterToolParam) MarshalJSON() (data []byte, err error) {
1525 type shadow CodeInterpreterToolParam
1526 return param.MarshalObject(r, (*shadow)(&r))
1527}
1528
1529type FileSearchTool struct {
1530 // The type of tool being defined: `file_search`
1531 Type constant.FileSearch `json:"type,required"`
1532 // Overrides for the file search tool.
1533 FileSearch FileSearchToolFileSearch `json:"file_search"`
1534 // Metadata for the response, check the presence of optional fields with the
1535 // [resp.Field.IsPresent] method.
1536 JSON struct {
1537 Type resp.Field
1538 FileSearch resp.Field
1539 ExtraFields map[string]resp.Field
1540 raw string
1541 } `json:"-"`
1542}
1543
1544// Returns the unmodified JSON received from the API
1545func (r FileSearchTool) RawJSON() string { return r.JSON.raw }
1546func (r *FileSearchTool) UnmarshalJSON(data []byte) error {
1547 return apijson.UnmarshalRoot(data, r)
1548}
1549
1550// ToParam converts this FileSearchTool to a FileSearchToolParam.
1551//
1552// Warning: the fields of the param type will not be present. ToParam should only
1553// be used at the last possible moment before sending a request. Test for this with
1554// FileSearchToolParam.IsOverridden()
1555func (r FileSearchTool) ToParam() FileSearchToolParam {
1556 return param.OverrideObj[FileSearchToolParam](r.RawJSON())
1557}
1558
1559// Overrides for the file search tool.
1560type FileSearchToolFileSearch struct {
1561 // The maximum number of results the file search tool should output. The default is
1562 // 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between
1563 // 1 and 50 inclusive.
1564 //
1565 // Note that the file search tool may output fewer than `max_num_results` results.
1566 // See the
1567 // [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
1568 // for more information.
1569 MaxNumResults int64 `json:"max_num_results"`
1570 // The ranking options for the file search. If not specified, the file search tool
1571 // will use the `auto` ranker and a score_threshold of 0.
1572 //
1573 // See the
1574 // [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
1575 // for more information.
1576 RankingOptions FileSearchToolFileSearchRankingOptions `json:"ranking_options"`
1577 // Metadata for the response, check the presence of optional fields with the
1578 // [resp.Field.IsPresent] method.
1579 JSON struct {
1580 MaxNumResults resp.Field
1581 RankingOptions resp.Field
1582 ExtraFields map[string]resp.Field
1583 raw string
1584 } `json:"-"`
1585}
1586
1587// Returns the unmodified JSON received from the API
1588func (r FileSearchToolFileSearch) RawJSON() string { return r.JSON.raw }
1589func (r *FileSearchToolFileSearch) UnmarshalJSON(data []byte) error {
1590 return apijson.UnmarshalRoot(data, r)
1591}
1592
1593// The ranking options for the file search. If not specified, the file search tool
1594// will use the `auto` ranker and a score_threshold of 0.
1595//
1596// See the
1597// [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
1598// for more information.
1599type FileSearchToolFileSearchRankingOptions struct {
1600 // The score threshold for the file search. All values must be a floating point
1601 // number between 0 and 1.
1602 ScoreThreshold float64 `json:"score_threshold,required"`
1603 // The ranker to use for the file search. If not specified will use the `auto`
1604 // ranker.
1605 //
1606 // Any of "auto", "default_2024_08_21".
1607 Ranker string `json:"ranker"`
1608 // Metadata for the response, check the presence of optional fields with the
1609 // [resp.Field.IsPresent] method.
1610 JSON struct {
1611 ScoreThreshold resp.Field
1612 Ranker resp.Field
1613 ExtraFields map[string]resp.Field
1614 raw string
1615 } `json:"-"`
1616}
1617
1618// Returns the unmodified JSON received from the API
1619func (r FileSearchToolFileSearchRankingOptions) RawJSON() string { return r.JSON.raw }
1620func (r *FileSearchToolFileSearchRankingOptions) UnmarshalJSON(data []byte) error {
1621 return apijson.UnmarshalRoot(data, r)
1622}
1623
1624// The property Type is required.
1625type FileSearchToolParam struct {
1626 // Overrides for the file search tool.
1627 FileSearch FileSearchToolFileSearchParam `json:"file_search,omitzero"`
1628 // The type of tool being defined: `file_search`
1629 //
1630 // This field can be elided, and will marshal its zero value as "file_search".
1631 Type constant.FileSearch `json:"type,required"`
1632 paramObj
1633}
1634
1635// IsPresent returns true if the field's value is not omitted and not the JSON
1636// "null". To check if this field is omitted, use [param.IsOmitted].
1637func (f FileSearchToolParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
1638func (r FileSearchToolParam) MarshalJSON() (data []byte, err error) {
1639 type shadow FileSearchToolParam
1640 return param.MarshalObject(r, (*shadow)(&r))
1641}
1642
1643// Overrides for the file search tool.
1644type FileSearchToolFileSearchParam struct {
1645 // The maximum number of results the file search tool should output. The default is
1646 // 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between
1647 // 1 and 50 inclusive.
1648 //
1649 // Note that the file search tool may output fewer than `max_num_results` results.
1650 // See the
1651 // [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
1652 // for more information.
1653 MaxNumResults param.Opt[int64] `json:"max_num_results,omitzero"`
1654 // The ranking options for the file search. If not specified, the file search tool
1655 // will use the `auto` ranker and a score_threshold of 0.
1656 //
1657 // See the
1658 // [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
1659 // for more information.
1660 RankingOptions FileSearchToolFileSearchRankingOptionsParam `json:"ranking_options,omitzero"`
1661 paramObj
1662}
1663
1664// IsPresent returns true if the field's value is not omitted and not the JSON
1665// "null". To check if this field is omitted, use [param.IsOmitted].
1666func (f FileSearchToolFileSearchParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
1667func (r FileSearchToolFileSearchParam) MarshalJSON() (data []byte, err error) {
1668 type shadow FileSearchToolFileSearchParam
1669 return param.MarshalObject(r, (*shadow)(&r))
1670}
1671
1672// The ranking options for the file search. If not specified, the file search tool
1673// will use the `auto` ranker and a score_threshold of 0.
1674//
1675// See the
1676// [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
1677// for more information.
1678//
1679// The property ScoreThreshold is required.
1680type FileSearchToolFileSearchRankingOptionsParam struct {
1681 // The score threshold for the file search. All values must be a floating point
1682 // number between 0 and 1.
1683 ScoreThreshold float64 `json:"score_threshold,required"`
1684 // The ranker to use for the file search. If not specified will use the `auto`
1685 // ranker.
1686 //
1687 // Any of "auto", "default_2024_08_21".
1688 Ranker string `json:"ranker,omitzero"`
1689 paramObj
1690}
1691
1692// IsPresent returns true if the field's value is not omitted and not the JSON
1693// "null". To check if this field is omitted, use [param.IsOmitted].
1694func (f FileSearchToolFileSearchRankingOptionsParam) IsPresent() bool {
1695 return !param.IsOmitted(f) && !f.IsNull()
1696}
1697func (r FileSearchToolFileSearchRankingOptionsParam) MarshalJSON() (data []byte, err error) {
1698 type shadow FileSearchToolFileSearchRankingOptionsParam
1699 return param.MarshalObject(r, (*shadow)(&r))
1700}
1701
1702func init() {
1703 apijson.RegisterFieldValidator[FileSearchToolFileSearchRankingOptionsParam](
1704 "Ranker", false, "auto", "default_2024_08_21",
1705 )
1706}
1707
1708type FunctionTool struct {
1709 Function shared.FunctionDefinition `json:"function,required"`
1710 // The type of tool being defined: `function`
1711 Type constant.Function `json:"type,required"`
1712 // Metadata for the response, check the presence of optional fields with the
1713 // [resp.Field.IsPresent] method.
1714 JSON struct {
1715 Function resp.Field
1716 Type resp.Field
1717 ExtraFields map[string]resp.Field
1718 raw string
1719 } `json:"-"`
1720}
1721
1722// Returns the unmodified JSON received from the API
1723func (r FunctionTool) RawJSON() string { return r.JSON.raw }
1724func (r *FunctionTool) UnmarshalJSON(data []byte) error {
1725 return apijson.UnmarshalRoot(data, r)
1726}
1727
1728// ToParam converts this FunctionTool to a FunctionToolParam.
1729//
1730// Warning: the fields of the param type will not be present. ToParam should only
1731// be used at the last possible moment before sending a request. Test for this with
1732// FunctionToolParam.IsOverridden()
1733func (r FunctionTool) ToParam() FunctionToolParam {
1734 return param.OverrideObj[FunctionToolParam](r.RawJSON())
1735}
1736
1737// The properties Function, Type are required.
1738type FunctionToolParam struct {
1739 Function shared.FunctionDefinitionParam `json:"function,omitzero,required"`
1740 // The type of tool being defined: `function`
1741 //
1742 // This field can be elided, and will marshal its zero value as "function".
1743 Type constant.Function `json:"type,required"`
1744 paramObj
1745}
1746
1747// IsPresent returns true if the field's value is not omitted and not the JSON
1748// "null". To check if this field is omitted, use [param.IsOmitted].
1749func (f FunctionToolParam) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
1750func (r FunctionToolParam) MarshalJSON() (data []byte, err error) {
1751 type shadow FunctionToolParam
1752 return param.MarshalObject(r, (*shadow)(&r))
1753}
1754
1755type BetaAssistantNewParams struct {
1756 // ID of the model to use. You can use the
1757 // [List models](https://platform.openai.com/docs/api-reference/models/list) API to
1758 // see all of your available models, or see our
1759 // [Model overview](https://platform.openai.com/docs/models) for descriptions of
1760 // them.
1761 Model shared.ChatModel `json:"model,omitzero,required"`
1762 // The description of the assistant. The maximum length is 512 characters.
1763 Description param.Opt[string] `json:"description,omitzero"`
1764 // The system instructions that the assistant uses. The maximum length is 256,000
1765 // characters.
1766 Instructions param.Opt[string] `json:"instructions,omitzero"`
1767 // The name of the assistant. The maximum length is 256 characters.
1768 Name param.Opt[string] `json:"name,omitzero"`
1769 // What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
1770 // make the output more random, while lower values like 0.2 will make it more
1771 // focused and deterministic.
1772 Temperature param.Opt[float64] `json:"temperature,omitzero"`
1773 // An alternative to sampling with temperature, called nucleus sampling, where the
1774 // model considers the results of the tokens with top_p probability mass. So 0.1
1775 // means only the tokens comprising the top 10% probability mass are considered.
1776 //
1777 // We generally recommend altering this or temperature but not both.
1778 TopP param.Opt[float64] `json:"top_p,omitzero"`
1779 // Set of 16 key-value pairs that can be attached to an object. This can be useful
1780 // for storing additional information about the object in a structured format, and
1781 // querying for objects via API or the dashboard.
1782 //
1783 // Keys are strings with a maximum length of 64 characters. Values are strings with
1784 // a maximum length of 512 characters.
1785 Metadata shared.MetadataParam `json:"metadata,omitzero"`
1786 // **o-series models only**
1787 //
1788 // Constrains effort on reasoning for
1789 // [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
1790 // supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
1791 // result in faster responses and fewer tokens used on reasoning in a response.
1792 //
1793 // Any of "low", "medium", "high".
1794 ReasoningEffort shared.ReasoningEffort `json:"reasoning_effort,omitzero"`
1795 // A set of resources that are used by the assistant's tools. The resources are
1796 // specific to the type of tool. For example, the `code_interpreter` tool requires
1797 // a list of file IDs, while the `file_search` tool requires a list of vector store
1798 // IDs.
1799 ToolResources BetaAssistantNewParamsToolResources `json:"tool_resources,omitzero"`
1800 // Specifies the format that the model must output. Compatible with
1801 // [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
1802 // [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
1803 // and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
1804 //
1805 // Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
1806 // Outputs which ensures the model will match your supplied JSON schema. Learn more
1807 // in the
1808 // [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
1809 //
1810 // Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
1811 // message the model generates is valid JSON.
1812 //
1813 // **Important:** when using JSON mode, you **must** also instruct the model to
1814 // produce JSON yourself via a system or user message. Without this, the model may
1815 // generate an unending stream of whitespace until the generation reaches the token
1816 // limit, resulting in a long-running and seemingly "stuck" request. Also note that
1817 // the message content may be partially cut off if `finish_reason="length"`, which
1818 // indicates the generation exceeded `max_tokens` or the conversation exceeded the
1819 // max context length.
1820 ResponseFormat AssistantResponseFormatOptionUnionParam `json:"response_format,omitzero"`
1821 // A list of tool enabled on the assistant. There can be a maximum of 128 tools per
1822 // assistant. Tools can be of types `code_interpreter`, `file_search`, or
1823 // `function`.
1824 Tools []AssistantToolUnionParam `json:"tools,omitzero"`
1825 paramObj
1826}
1827
1828// IsPresent returns true if the field's value is not omitted and not the JSON
1829// "null". To check if this field is omitted, use [param.IsOmitted].
1830func (f BetaAssistantNewParams) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
1831
1832func (r BetaAssistantNewParams) MarshalJSON() (data []byte, err error) {
1833 type shadow BetaAssistantNewParams
1834 return param.MarshalObject(r, (*shadow)(&r))
1835}
1836
1837// A set of resources that are used by the assistant's tools. The resources are
1838// specific to the type of tool. For example, the `code_interpreter` tool requires
1839// a list of file IDs, while the `file_search` tool requires a list of vector store
1840// IDs.
1841type BetaAssistantNewParamsToolResources struct {
1842 CodeInterpreter BetaAssistantNewParamsToolResourcesCodeInterpreter `json:"code_interpreter,omitzero"`
1843 FileSearch BetaAssistantNewParamsToolResourcesFileSearch `json:"file_search,omitzero"`
1844 paramObj
1845}
1846
1847// IsPresent returns true if the field's value is not omitted and not the JSON
1848// "null". To check if this field is omitted, use [param.IsOmitted].
1849func (f BetaAssistantNewParamsToolResources) IsPresent() bool {
1850 return !param.IsOmitted(f) && !f.IsNull()
1851}
1852func (r BetaAssistantNewParamsToolResources) MarshalJSON() (data []byte, err error) {
1853 type shadow BetaAssistantNewParamsToolResources
1854 return param.MarshalObject(r, (*shadow)(&r))
1855}
1856
1857type BetaAssistantNewParamsToolResourcesCodeInterpreter struct {
1858 // A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
1859 // available to the `code_interpreter` tool. There can be a maximum of 20 files
1860 // associated with the tool.
1861 FileIDs []string `json:"file_ids,omitzero"`
1862 paramObj
1863}
1864
1865// IsPresent returns true if the field's value is not omitted and not the JSON
1866// "null". To check if this field is omitted, use [param.IsOmitted].
1867func (f BetaAssistantNewParamsToolResourcesCodeInterpreter) IsPresent() bool {
1868 return !param.IsOmitted(f) && !f.IsNull()
1869}
1870func (r BetaAssistantNewParamsToolResourcesCodeInterpreter) MarshalJSON() (data []byte, err error) {
1871 type shadow BetaAssistantNewParamsToolResourcesCodeInterpreter
1872 return param.MarshalObject(r, (*shadow)(&r))
1873}
1874
1875type BetaAssistantNewParamsToolResourcesFileSearch struct {
1876 // The
1877 // [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
1878 // attached to this assistant. There can be a maximum of 1 vector store attached to
1879 // the assistant.
1880 VectorStoreIDs []string `json:"vector_store_ids,omitzero"`
1881 // A helper to create a
1882 // [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
1883 // with file_ids and attach it to this assistant. There can be a maximum of 1
1884 // vector store attached to the assistant.
1885 VectorStores []BetaAssistantNewParamsToolResourcesFileSearchVectorStore `json:"vector_stores,omitzero"`
1886 paramObj
1887}
1888
1889// IsPresent returns true if the field's value is not omitted and not the JSON
1890// "null". To check if this field is omitted, use [param.IsOmitted].
1891func (f BetaAssistantNewParamsToolResourcesFileSearch) IsPresent() bool {
1892 return !param.IsOmitted(f) && !f.IsNull()
1893}
1894func (r BetaAssistantNewParamsToolResourcesFileSearch) MarshalJSON() (data []byte, err error) {
1895 type shadow BetaAssistantNewParamsToolResourcesFileSearch
1896 return param.MarshalObject(r, (*shadow)(&r))
1897}
1898
1899type BetaAssistantNewParamsToolResourcesFileSearchVectorStore struct {
1900 // Set of 16 key-value pairs that can be attached to an object. This can be useful
1901 // for storing additional information about the object in a structured format, and
1902 // querying for objects via API or the dashboard.
1903 //
1904 // Keys are strings with a maximum length of 64 characters. Values are strings with
1905 // a maximum length of 512 characters.
1906 Metadata shared.MetadataParam `json:"metadata,omitzero"`
1907 // The chunking strategy used to chunk the file(s). If not set, will use the `auto`
1908 // strategy.
1909 ChunkingStrategy BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion `json:"chunking_strategy,omitzero"`
1910 // A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
1911 // add to the vector store. There can be a maximum of 10000 files in a vector
1912 // store.
1913 FileIDs []string `json:"file_ids,omitzero"`
1914 paramObj
1915}
1916
1917// IsPresent returns true if the field's value is not omitted and not the JSON
1918// "null". To check if this field is omitted, use [param.IsOmitted].
1919func (f BetaAssistantNewParamsToolResourcesFileSearchVectorStore) IsPresent() bool {
1920 return !param.IsOmitted(f) && !f.IsNull()
1921}
1922func (r BetaAssistantNewParamsToolResourcesFileSearchVectorStore) MarshalJSON() (data []byte, err error) {
1923 type shadow BetaAssistantNewParamsToolResourcesFileSearchVectorStore
1924 return param.MarshalObject(r, (*shadow)(&r))
1925}
1926
1927// Only one field can be non-zero.
1928//
1929// Use [param.IsOmitted] to confirm if a field is set.
1930type BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion struct {
1931 OfAuto *BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto `json:",omitzero,inline"`
1932 OfStatic *BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic `json:",omitzero,inline"`
1933 paramUnion
1934}
1935
1936// IsPresent returns true if the field's value is not omitted and not the JSON
1937// "null". To check if this field is omitted, use [param.IsOmitted].
1938func (u BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion) IsPresent() bool {
1939 return !param.IsOmitted(u) && !u.IsNull()
1940}
1941func (u BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion) MarshalJSON() ([]byte, error) {
1942 return param.MarshalUnion[BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion](u.OfAuto, u.OfStatic)
1943}
1944
1945func (u *BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion) asAny() any {
1946 if !param.IsOmitted(u.OfAuto) {
1947 return u.OfAuto
1948 } else if !param.IsOmitted(u.OfStatic) {
1949 return u.OfStatic
1950 }
1951 return nil
1952}
1953
1954// Returns a pointer to the underlying variant's property, if present.
1955func (u BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion) GetStatic() *BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic {
1956 if vt := u.OfStatic; vt != nil {
1957 return &vt.Static
1958 }
1959 return nil
1960}
1961
1962// Returns a pointer to the underlying variant's property, if present.
1963func (u BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion) GetType() *string {
1964 if vt := u.OfAuto; vt != nil {
1965 return (*string)(&vt.Type)
1966 } else if vt := u.OfStatic; vt != nil {
1967 return (*string)(&vt.Type)
1968 }
1969 return nil
1970}
1971
1972func init() {
1973 apijson.RegisterUnion[BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyUnion](
1974 "type",
1975 apijson.UnionVariant{
1976 TypeFilter: gjson.JSON,
1977 Type: reflect.TypeOf(BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto{}),
1978 DiscriminatorValue: "auto",
1979 },
1980 apijson.UnionVariant{
1981 TypeFilter: gjson.JSON,
1982 Type: reflect.TypeOf(BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic{}),
1983 DiscriminatorValue: "static",
1984 },
1985 )
1986}
1987
1988// The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
1989// `800` and `chunk_overlap_tokens` of `400`.
1990//
1991// The property Type is required.
1992type BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto struct {
1993 // Always `auto`.
1994 //
1995 // This field can be elided, and will marshal its zero value as "auto".
1996 Type constant.Auto `json:"type,required"`
1997 paramObj
1998}
1999
2000// IsPresent returns true if the field's value is not omitted and not the JSON
2001// "null". To check if this field is omitted, use [param.IsOmitted].
2002func (f BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto) IsPresent() bool {
2003 return !param.IsOmitted(f) && !f.IsNull()
2004}
2005func (r BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto) MarshalJSON() (data []byte, err error) {
2006 type shadow BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyAuto
2007 return param.MarshalObject(r, (*shadow)(&r))
2008}
2009
2010// The properties Static, Type are required.
2011type BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic struct {
2012 Static BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic `json:"static,omitzero,required"`
2013 // Always `static`.
2014 //
2015 // This field can be elided, and will marshal its zero value as "static".
2016 Type constant.Static `json:"type,required"`
2017 paramObj
2018}
2019
2020// IsPresent returns true if the field's value is not omitted and not the JSON
2021// "null". To check if this field is omitted, use [param.IsOmitted].
2022func (f BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic) IsPresent() bool {
2023 return !param.IsOmitted(f) && !f.IsNull()
2024}
2025func (r BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic) MarshalJSON() (data []byte, err error) {
2026 type shadow BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStatic
2027 return param.MarshalObject(r, (*shadow)(&r))
2028}
2029
2030// The properties ChunkOverlapTokens, MaxChunkSizeTokens are required.
2031type BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic struct {
2032 // The number of tokens that overlap between chunks. The default value is `400`.
2033 //
2034 // Note that the overlap must not exceed half of `max_chunk_size_tokens`.
2035 ChunkOverlapTokens int64 `json:"chunk_overlap_tokens,required"`
2036 // The maximum number of tokens in each chunk. The default value is `800`. The
2037 // minimum value is `100` and the maximum value is `4096`.
2038 MaxChunkSizeTokens int64 `json:"max_chunk_size_tokens,required"`
2039 paramObj
2040}
2041
2042// IsPresent returns true if the field's value is not omitted and not the JSON
2043// "null". To check if this field is omitted, use [param.IsOmitted].
2044func (f BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic) IsPresent() bool {
2045 return !param.IsOmitted(f) && !f.IsNull()
2046}
2047func (r BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic) MarshalJSON() (data []byte, err error) {
2048 type shadow BetaAssistantNewParamsToolResourcesFileSearchVectorStoreChunkingStrategyStaticStatic
2049 return param.MarshalObject(r, (*shadow)(&r))
2050}
2051
2052type BetaAssistantUpdateParams struct {
2053 // The description of the assistant. The maximum length is 512 characters.
2054 Description param.Opt[string] `json:"description,omitzero"`
2055 // The system instructions that the assistant uses. The maximum length is 256,000
2056 // characters.
2057 Instructions param.Opt[string] `json:"instructions,omitzero"`
2058 // The name of the assistant. The maximum length is 256 characters.
2059 Name param.Opt[string] `json:"name,omitzero"`
2060 // What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
2061 // make the output more random, while lower values like 0.2 will make it more
2062 // focused and deterministic.
2063 Temperature param.Opt[float64] `json:"temperature,omitzero"`
2064 // An alternative to sampling with temperature, called nucleus sampling, where the
2065 // model considers the results of the tokens with top_p probability mass. So 0.1
2066 // means only the tokens comprising the top 10% probability mass are considered.
2067 //
2068 // We generally recommend altering this or temperature but not both.
2069 TopP param.Opt[float64] `json:"top_p,omitzero"`
2070 // Set of 16 key-value pairs that can be attached to an object. This can be useful
2071 // for storing additional information about the object in a structured format, and
2072 // querying for objects via API or the dashboard.
2073 //
2074 // Keys are strings with a maximum length of 64 characters. Values are strings with
2075 // a maximum length of 512 characters.
2076 Metadata shared.MetadataParam `json:"metadata,omitzero"`
2077 // **o-series models only**
2078 //
2079 // Constrains effort on reasoning for
2080 // [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
2081 // supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
2082 // result in faster responses and fewer tokens used on reasoning in a response.
2083 //
2084 // Any of "low", "medium", "high".
2085 ReasoningEffort shared.ReasoningEffort `json:"reasoning_effort,omitzero"`
2086 // A set of resources that are used by the assistant's tools. The resources are
2087 // specific to the type of tool. For example, the `code_interpreter` tool requires
2088 // a list of file IDs, while the `file_search` tool requires a list of vector store
2089 // IDs.
2090 ToolResources BetaAssistantUpdateParamsToolResources `json:"tool_resources,omitzero"`
2091 // ID of the model to use. You can use the
2092 // [List models](https://platform.openai.com/docs/api-reference/models/list) API to
2093 // see all of your available models, or see our
2094 // [Model overview](https://platform.openai.com/docs/models) for descriptions of
2095 // them.
2096 Model string `json:"model,omitzero"`
2097 // Specifies the format that the model must output. Compatible with
2098 // [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
2099 // [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
2100 // and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
2101 //
2102 // Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
2103 // Outputs which ensures the model will match your supplied JSON schema. Learn more
2104 // in the
2105 // [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
2106 //
2107 // Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
2108 // message the model generates is valid JSON.
2109 //
2110 // **Important:** when using JSON mode, you **must** also instruct the model to
2111 // produce JSON yourself via a system or user message. Without this, the model may
2112 // generate an unending stream of whitespace until the generation reaches the token
2113 // limit, resulting in a long-running and seemingly "stuck" request. Also note that
2114 // the message content may be partially cut off if `finish_reason="length"`, which
2115 // indicates the generation exceeded `max_tokens` or the conversation exceeded the
2116 // max context length.
2117 ResponseFormat AssistantResponseFormatOptionUnionParam `json:"response_format,omitzero"`
2118 // A list of tool enabled on the assistant. There can be a maximum of 128 tools per
2119 // assistant. Tools can be of types `code_interpreter`, `file_search`, or
2120 // `function`.
2121 Tools []AssistantToolUnionParam `json:"tools,omitzero"`
2122 paramObj
2123}
2124
2125// IsPresent returns true if the field's value is not omitted and not the JSON
2126// "null". To check if this field is omitted, use [param.IsOmitted].
2127func (f BetaAssistantUpdateParams) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
2128
2129func (r BetaAssistantUpdateParams) MarshalJSON() (data []byte, err error) {
2130 type shadow BetaAssistantUpdateParams
2131 return param.MarshalObject(r, (*shadow)(&r))
2132}
2133
2134// A set of resources that are used by the assistant's tools. The resources are
2135// specific to the type of tool. For example, the `code_interpreter` tool requires
2136// a list of file IDs, while the `file_search` tool requires a list of vector store
2137// IDs.
2138type BetaAssistantUpdateParamsToolResources struct {
2139 CodeInterpreter BetaAssistantUpdateParamsToolResourcesCodeInterpreter `json:"code_interpreter,omitzero"`
2140 FileSearch BetaAssistantUpdateParamsToolResourcesFileSearch `json:"file_search,omitzero"`
2141 paramObj
2142}
2143
2144// IsPresent returns true if the field's value is not omitted and not the JSON
2145// "null". To check if this field is omitted, use [param.IsOmitted].
2146func (f BetaAssistantUpdateParamsToolResources) IsPresent() bool {
2147 return !param.IsOmitted(f) && !f.IsNull()
2148}
2149func (r BetaAssistantUpdateParamsToolResources) MarshalJSON() (data []byte, err error) {
2150 type shadow BetaAssistantUpdateParamsToolResources
2151 return param.MarshalObject(r, (*shadow)(&r))
2152}
2153
2154type BetaAssistantUpdateParamsToolResourcesCodeInterpreter struct {
2155 // Overrides the list of
2156 // [file](https://platform.openai.com/docs/api-reference/files) IDs made available
2157 // to the `code_interpreter` tool. There can be a maximum of 20 files associated
2158 // with the tool.
2159 FileIDs []string `json:"file_ids,omitzero"`
2160 paramObj
2161}
2162
2163// IsPresent returns true if the field's value is not omitted and not the JSON
2164// "null". To check if this field is omitted, use [param.IsOmitted].
2165func (f BetaAssistantUpdateParamsToolResourcesCodeInterpreter) IsPresent() bool {
2166 return !param.IsOmitted(f) && !f.IsNull()
2167}
2168func (r BetaAssistantUpdateParamsToolResourcesCodeInterpreter) MarshalJSON() (data []byte, err error) {
2169 type shadow BetaAssistantUpdateParamsToolResourcesCodeInterpreter
2170 return param.MarshalObject(r, (*shadow)(&r))
2171}
2172
2173type BetaAssistantUpdateParamsToolResourcesFileSearch struct {
2174 // Overrides the
2175 // [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
2176 // attached to this assistant. There can be a maximum of 1 vector store attached to
2177 // the assistant.
2178 VectorStoreIDs []string `json:"vector_store_ids,omitzero"`
2179 paramObj
2180}
2181
2182// IsPresent returns true if the field's value is not omitted and not the JSON
2183// "null". To check if this field is omitted, use [param.IsOmitted].
2184func (f BetaAssistantUpdateParamsToolResourcesFileSearch) IsPresent() bool {
2185 return !param.IsOmitted(f) && !f.IsNull()
2186}
2187func (r BetaAssistantUpdateParamsToolResourcesFileSearch) MarshalJSON() (data []byte, err error) {
2188 type shadow BetaAssistantUpdateParamsToolResourcesFileSearch
2189 return param.MarshalObject(r, (*shadow)(&r))
2190}
2191
2192type BetaAssistantListParams struct {
2193 // A cursor for use in pagination. `after` is an object ID that defines your place
2194 // in the list. For instance, if you make a list request and receive 100 objects,
2195 // ending with obj_foo, your subsequent call can include after=obj_foo in order to
2196 // fetch the next page of the list.
2197 After param.Opt[string] `query:"after,omitzero" json:"-"`
2198 // A cursor for use in pagination. `before` is an object ID that defines your place
2199 // in the list. For instance, if you make a list request and receive 100 objects,
2200 // starting with obj_foo, your subsequent call can include before=obj_foo in order
2201 // to fetch the previous page of the list.
2202 Before param.Opt[string] `query:"before,omitzero" json:"-"`
2203 // A limit on the number of objects to be returned. Limit can range between 1 and
2204 // 100, and the default is 20.
2205 Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
2206 // Sort order by the `created_at` timestamp of the objects. `asc` for ascending
2207 // order and `desc` for descending order.
2208 //
2209 // Any of "asc", "desc".
2210 Order BetaAssistantListParamsOrder `query:"order,omitzero" json:"-"`
2211 paramObj
2212}
2213
2214// IsPresent returns true if the field's value is not omitted and not the JSON
2215// "null". To check if this field is omitted, use [param.IsOmitted].
2216func (f BetaAssistantListParams) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
2217
2218// URLQuery serializes [BetaAssistantListParams]'s query parameters as
2219// `url.Values`.
2220func (r BetaAssistantListParams) URLQuery() (v url.Values) {
2221 return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
2222 ArrayFormat: apiquery.ArrayQueryFormatBrackets,
2223 NestedFormat: apiquery.NestedQueryFormatBrackets,
2224 })
2225}
2226
2227// Sort order by the `created_at` timestamp of the objects. `asc` for ascending
2228// order and `desc` for descending order.
2229type BetaAssistantListParamsOrder string
2230
2231const (
2232 BetaAssistantListParamsOrderAsc BetaAssistantListParamsOrder = "asc"
2233 BetaAssistantListParamsOrderDesc BetaAssistantListParamsOrder = "desc"
2234)