betathreadrunstep.go

   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
  13	"github.com/openai/openai-go/internal/apijson"
  14	"github.com/openai/openai-go/internal/apiquery"
  15	"github.com/openai/openai-go/internal/requestconfig"
  16	"github.com/openai/openai-go/option"
  17	"github.com/openai/openai-go/packages/pagination"
  18	"github.com/openai/openai-go/packages/param"
  19	"github.com/openai/openai-go/packages/resp"
  20	"github.com/openai/openai-go/shared"
  21	"github.com/openai/openai-go/shared/constant"
  22)
  23
  24// BetaThreadRunStepService contains methods and other services that help with
  25// interacting with the openai API.
  26//
  27// Note, unlike clients, this service does not read variables from the environment
  28// automatically. You should not instantiate this service directly, and instead use
  29// the [NewBetaThreadRunStepService] method instead.
  30type BetaThreadRunStepService struct {
  31	Options []option.RequestOption
  32}
  33
  34// NewBetaThreadRunStepService generates a new service that applies the given
  35// options to each request. These options are applied after the parent client's
  36// options (if there is one), and before any request-specific options.
  37func NewBetaThreadRunStepService(opts ...option.RequestOption) (r BetaThreadRunStepService) {
  38	r = BetaThreadRunStepService{}
  39	r.Options = opts
  40	return
  41}
  42
  43// Retrieves a run step.
  44func (r *BetaThreadRunStepService) Get(ctx context.Context, threadID string, runID string, stepID string, query BetaThreadRunStepGetParams, opts ...option.RequestOption) (res *RunStep, err error) {
  45	opts = append(r.Options[:], opts...)
  46	opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
  47	if threadID == "" {
  48		err = errors.New("missing required thread_id parameter")
  49		return
  50	}
  51	if runID == "" {
  52		err = errors.New("missing required run_id parameter")
  53		return
  54	}
  55	if stepID == "" {
  56		err = errors.New("missing required step_id parameter")
  57		return
  58	}
  59	path := fmt.Sprintf("threads/%s/runs/%s/steps/%s", threadID, runID, stepID)
  60	err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
  61	return
  62}
  63
  64// Returns a list of run steps belonging to a run.
  65func (r *BetaThreadRunStepService) List(ctx context.Context, threadID string, runID string, query BetaThreadRunStepListParams, opts ...option.RequestOption) (res *pagination.CursorPage[RunStep], err error) {
  66	var raw *http.Response
  67	opts = append(r.Options[:], opts...)
  68	opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithResponseInto(&raw)}, opts...)
  69	if threadID == "" {
  70		err = errors.New("missing required thread_id parameter")
  71		return
  72	}
  73	if runID == "" {
  74		err = errors.New("missing required run_id parameter")
  75		return
  76	}
  77	path := fmt.Sprintf("threads/%s/runs/%s/steps", threadID, runID)
  78	cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
  79	if err != nil {
  80		return nil, err
  81	}
  82	err = cfg.Execute()
  83	if err != nil {
  84		return nil, err
  85	}
  86	res.SetPageConfig(cfg, raw)
  87	return res, nil
  88}
  89
  90// Returns a list of run steps belonging to a run.
  91func (r *BetaThreadRunStepService) ListAutoPaging(ctx context.Context, threadID string, runID string, query BetaThreadRunStepListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[RunStep] {
  92	return pagination.NewCursorPageAutoPager(r.List(ctx, threadID, runID, query, opts...))
  93}
  94
  95// Text output from the Code Interpreter tool call as part of a run step.
  96type CodeInterpreterLogs struct {
  97	// The index of the output in the outputs array.
  98	Index int64 `json:"index,required"`
  99	// Always `logs`.
 100	Type constant.Logs `json:"type,required"`
 101	// The text output from the Code Interpreter tool call.
 102	Logs string `json:"logs"`
 103	// Metadata for the response, check the presence of optional fields with the
 104	// [resp.Field.IsPresent] method.
 105	JSON struct {
 106		Index       resp.Field
 107		Type        resp.Field
 108		Logs        resp.Field
 109		ExtraFields map[string]resp.Field
 110		raw         string
 111	} `json:"-"`
 112}
 113
 114// Returns the unmodified JSON received from the API
 115func (r CodeInterpreterLogs) RawJSON() string { return r.JSON.raw }
 116func (r *CodeInterpreterLogs) UnmarshalJSON(data []byte) error {
 117	return apijson.UnmarshalRoot(data, r)
 118}
 119
 120type CodeInterpreterOutputImage struct {
 121	// The index of the output in the outputs array.
 122	Index int64 `json:"index,required"`
 123	// Always `image`.
 124	Type  constant.Image                  `json:"type,required"`
 125	Image CodeInterpreterOutputImageImage `json:"image"`
 126	// Metadata for the response, check the presence of optional fields with the
 127	// [resp.Field.IsPresent] method.
 128	JSON struct {
 129		Index       resp.Field
 130		Type        resp.Field
 131		Image       resp.Field
 132		ExtraFields map[string]resp.Field
 133		raw         string
 134	} `json:"-"`
 135}
 136
 137// Returns the unmodified JSON received from the API
 138func (r CodeInterpreterOutputImage) RawJSON() string { return r.JSON.raw }
 139func (r *CodeInterpreterOutputImage) UnmarshalJSON(data []byte) error {
 140	return apijson.UnmarshalRoot(data, r)
 141}
 142
 143type CodeInterpreterOutputImageImage struct {
 144	// The [file](https://platform.openai.com/docs/api-reference/files) ID of the
 145	// image.
 146	FileID string `json:"file_id"`
 147	// Metadata for the response, check the presence of optional fields with the
 148	// [resp.Field.IsPresent] method.
 149	JSON struct {
 150		FileID      resp.Field
 151		ExtraFields map[string]resp.Field
 152		raw         string
 153	} `json:"-"`
 154}
 155
 156// Returns the unmodified JSON received from the API
 157func (r CodeInterpreterOutputImageImage) RawJSON() string { return r.JSON.raw }
 158func (r *CodeInterpreterOutputImageImage) UnmarshalJSON(data []byte) error {
 159	return apijson.UnmarshalRoot(data, r)
 160}
 161
 162// Details of the Code Interpreter tool call the run step was involved in.
 163type CodeInterpreterToolCall struct {
 164	// The ID of the tool call.
 165	ID string `json:"id,required"`
 166	// The Code Interpreter tool call definition.
 167	CodeInterpreter CodeInterpreterToolCallCodeInterpreter `json:"code_interpreter,required"`
 168	// The type of tool call. This is always going to be `code_interpreter` for this
 169	// type of tool call.
 170	Type constant.CodeInterpreter `json:"type,required"`
 171	// Metadata for the response, check the presence of optional fields with the
 172	// [resp.Field.IsPresent] method.
 173	JSON struct {
 174		ID              resp.Field
 175		CodeInterpreter resp.Field
 176		Type            resp.Field
 177		ExtraFields     map[string]resp.Field
 178		raw             string
 179	} `json:"-"`
 180}
 181
 182// Returns the unmodified JSON received from the API
 183func (r CodeInterpreterToolCall) RawJSON() string { return r.JSON.raw }
 184func (r *CodeInterpreterToolCall) UnmarshalJSON(data []byte) error {
 185	return apijson.UnmarshalRoot(data, r)
 186}
 187
 188// The Code Interpreter tool call definition.
 189type CodeInterpreterToolCallCodeInterpreter struct {
 190	// The input to the Code Interpreter tool call.
 191	Input string `json:"input,required"`
 192	// The outputs from the Code Interpreter tool call. Code Interpreter can output one
 193	// or more items, including text (`logs`) or images (`image`). Each of these are
 194	// represented by a different object type.
 195	Outputs []CodeInterpreterToolCallCodeInterpreterOutputUnion `json:"outputs,required"`
 196	// Metadata for the response, check the presence of optional fields with the
 197	// [resp.Field.IsPresent] method.
 198	JSON struct {
 199		Input       resp.Field
 200		Outputs     resp.Field
 201		ExtraFields map[string]resp.Field
 202		raw         string
 203	} `json:"-"`
 204}
 205
 206// Returns the unmodified JSON received from the API
 207func (r CodeInterpreterToolCallCodeInterpreter) RawJSON() string { return r.JSON.raw }
 208func (r *CodeInterpreterToolCallCodeInterpreter) UnmarshalJSON(data []byte) error {
 209	return apijson.UnmarshalRoot(data, r)
 210}
 211
 212// CodeInterpreterToolCallCodeInterpreterOutputUnion contains all possible
 213// properties and values from [CodeInterpreterToolCallCodeInterpreterOutputLogs],
 214// [CodeInterpreterToolCallCodeInterpreterOutputImage].
 215//
 216// Use the [CodeInterpreterToolCallCodeInterpreterOutputUnion.AsAny] method to
 217// switch on the variant.
 218//
 219// Use the methods beginning with 'As' to cast the union to one of its variants.
 220type CodeInterpreterToolCallCodeInterpreterOutputUnion struct {
 221	// This field is from variant [CodeInterpreterToolCallCodeInterpreterOutputLogs].
 222	Logs string `json:"logs"`
 223	// Any of "logs", "image".
 224	Type string `json:"type"`
 225	// This field is from variant [CodeInterpreterToolCallCodeInterpreterOutputImage].
 226	Image CodeInterpreterToolCallCodeInterpreterOutputImageImage `json:"image"`
 227	JSON  struct {
 228		Logs  resp.Field
 229		Type  resp.Field
 230		Image resp.Field
 231		raw   string
 232	} `json:"-"`
 233}
 234
 235// Use the following switch statement to find the correct variant
 236//
 237//	switch variant := CodeInterpreterToolCallCodeInterpreterOutputUnion.AsAny().(type) {
 238//	case CodeInterpreterToolCallCodeInterpreterOutputLogs:
 239//	case CodeInterpreterToolCallCodeInterpreterOutputImage:
 240//	default:
 241//	  fmt.Errorf("no variant present")
 242//	}
 243func (u CodeInterpreterToolCallCodeInterpreterOutputUnion) AsAny() any {
 244	switch u.Type {
 245	case "logs":
 246		return u.AsLogs()
 247	case "image":
 248		return u.AsImage()
 249	}
 250	return nil
 251}
 252
 253func (u CodeInterpreterToolCallCodeInterpreterOutputUnion) AsLogs() (v CodeInterpreterToolCallCodeInterpreterOutputLogs) {
 254	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 255	return
 256}
 257
 258func (u CodeInterpreterToolCallCodeInterpreterOutputUnion) AsImage() (v CodeInterpreterToolCallCodeInterpreterOutputImage) {
 259	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 260	return
 261}
 262
 263// Returns the unmodified JSON received from the API
 264func (u CodeInterpreterToolCallCodeInterpreterOutputUnion) RawJSON() string { return u.JSON.raw }
 265
 266func (r *CodeInterpreterToolCallCodeInterpreterOutputUnion) UnmarshalJSON(data []byte) error {
 267	return apijson.UnmarshalRoot(data, r)
 268}
 269
 270// Text output from the Code Interpreter tool call as part of a run step.
 271type CodeInterpreterToolCallCodeInterpreterOutputLogs struct {
 272	// The text output from the Code Interpreter tool call.
 273	Logs string `json:"logs,required"`
 274	// Always `logs`.
 275	Type constant.Logs `json:"type,required"`
 276	// Metadata for the response, check the presence of optional fields with the
 277	// [resp.Field.IsPresent] method.
 278	JSON struct {
 279		Logs        resp.Field
 280		Type        resp.Field
 281		ExtraFields map[string]resp.Field
 282		raw         string
 283	} `json:"-"`
 284}
 285
 286// Returns the unmodified JSON received from the API
 287func (r CodeInterpreterToolCallCodeInterpreterOutputLogs) RawJSON() string { return r.JSON.raw }
 288func (r *CodeInterpreterToolCallCodeInterpreterOutputLogs) UnmarshalJSON(data []byte) error {
 289	return apijson.UnmarshalRoot(data, r)
 290}
 291
 292type CodeInterpreterToolCallCodeInterpreterOutputImage struct {
 293	Image CodeInterpreterToolCallCodeInterpreterOutputImageImage `json:"image,required"`
 294	// Always `image`.
 295	Type constant.Image `json:"type,required"`
 296	// Metadata for the response, check the presence of optional fields with the
 297	// [resp.Field.IsPresent] method.
 298	JSON struct {
 299		Image       resp.Field
 300		Type        resp.Field
 301		ExtraFields map[string]resp.Field
 302		raw         string
 303	} `json:"-"`
 304}
 305
 306// Returns the unmodified JSON received from the API
 307func (r CodeInterpreterToolCallCodeInterpreterOutputImage) RawJSON() string { return r.JSON.raw }
 308func (r *CodeInterpreterToolCallCodeInterpreterOutputImage) UnmarshalJSON(data []byte) error {
 309	return apijson.UnmarshalRoot(data, r)
 310}
 311
 312type CodeInterpreterToolCallCodeInterpreterOutputImageImage struct {
 313	// The [file](https://platform.openai.com/docs/api-reference/files) ID of the
 314	// image.
 315	FileID string `json:"file_id,required"`
 316	// Metadata for the response, check the presence of optional fields with the
 317	// [resp.Field.IsPresent] method.
 318	JSON struct {
 319		FileID      resp.Field
 320		ExtraFields map[string]resp.Field
 321		raw         string
 322	} `json:"-"`
 323}
 324
 325// Returns the unmodified JSON received from the API
 326func (r CodeInterpreterToolCallCodeInterpreterOutputImageImage) RawJSON() string { return r.JSON.raw }
 327func (r *CodeInterpreterToolCallCodeInterpreterOutputImageImage) UnmarshalJSON(data []byte) error {
 328	return apijson.UnmarshalRoot(data, r)
 329}
 330
 331// Details of the Code Interpreter tool call the run step was involved in.
 332type CodeInterpreterToolCallDelta struct {
 333	// The index of the tool call in the tool calls array.
 334	Index int64 `json:"index,required"`
 335	// The type of tool call. This is always going to be `code_interpreter` for this
 336	// type of tool call.
 337	Type constant.CodeInterpreter `json:"type,required"`
 338	// The ID of the tool call.
 339	ID string `json:"id"`
 340	// The Code Interpreter tool call definition.
 341	CodeInterpreter CodeInterpreterToolCallDeltaCodeInterpreter `json:"code_interpreter"`
 342	// Metadata for the response, check the presence of optional fields with the
 343	// [resp.Field.IsPresent] method.
 344	JSON struct {
 345		Index           resp.Field
 346		Type            resp.Field
 347		ID              resp.Field
 348		CodeInterpreter resp.Field
 349		ExtraFields     map[string]resp.Field
 350		raw             string
 351	} `json:"-"`
 352}
 353
 354// Returns the unmodified JSON received from the API
 355func (r CodeInterpreterToolCallDelta) RawJSON() string { return r.JSON.raw }
 356func (r *CodeInterpreterToolCallDelta) UnmarshalJSON(data []byte) error {
 357	return apijson.UnmarshalRoot(data, r)
 358}
 359
 360// The Code Interpreter tool call definition.
 361type CodeInterpreterToolCallDeltaCodeInterpreter struct {
 362	// The input to the Code Interpreter tool call.
 363	Input string `json:"input"`
 364	// The outputs from the Code Interpreter tool call. Code Interpreter can output one
 365	// or more items, including text (`logs`) or images (`image`). Each of these are
 366	// represented by a different object type.
 367	Outputs []CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion `json:"outputs"`
 368	// Metadata for the response, check the presence of optional fields with the
 369	// [resp.Field.IsPresent] method.
 370	JSON struct {
 371		Input       resp.Field
 372		Outputs     resp.Field
 373		ExtraFields map[string]resp.Field
 374		raw         string
 375	} `json:"-"`
 376}
 377
 378// Returns the unmodified JSON received from the API
 379func (r CodeInterpreterToolCallDeltaCodeInterpreter) RawJSON() string { return r.JSON.raw }
 380func (r *CodeInterpreterToolCallDeltaCodeInterpreter) UnmarshalJSON(data []byte) error {
 381	return apijson.UnmarshalRoot(data, r)
 382}
 383
 384// CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion contains all possible
 385// properties and values from [CodeInterpreterLogs], [CodeInterpreterOutputImage].
 386//
 387// Use the [CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion.AsAny] method to
 388// switch on the variant.
 389//
 390// Use the methods beginning with 'As' to cast the union to one of its variants.
 391type CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion struct {
 392	Index int64 `json:"index"`
 393	// Any of "logs", "image".
 394	Type string `json:"type"`
 395	// This field is from variant [CodeInterpreterLogs].
 396	Logs string `json:"logs"`
 397	// This field is from variant [CodeInterpreterOutputImage].
 398	Image CodeInterpreterOutputImageImage `json:"image"`
 399	JSON  struct {
 400		Index resp.Field
 401		Type  resp.Field
 402		Logs  resp.Field
 403		Image resp.Field
 404		raw   string
 405	} `json:"-"`
 406}
 407
 408// Use the following switch statement to find the correct variant
 409//
 410//	switch variant := CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion.AsAny().(type) {
 411//	case CodeInterpreterLogs:
 412//	case CodeInterpreterOutputImage:
 413//	default:
 414//	  fmt.Errorf("no variant present")
 415//	}
 416func (u CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion) AsAny() any {
 417	switch u.Type {
 418	case "logs":
 419		return u.AsLogs()
 420	case "image":
 421		return u.AsImage()
 422	}
 423	return nil
 424}
 425
 426func (u CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion) AsLogs() (v CodeInterpreterLogs) {
 427	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 428	return
 429}
 430
 431func (u CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion) AsImage() (v CodeInterpreterOutputImage) {
 432	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 433	return
 434}
 435
 436// Returns the unmodified JSON received from the API
 437func (u CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion) RawJSON() string { return u.JSON.raw }
 438
 439func (r *CodeInterpreterToolCallDeltaCodeInterpreterOutputUnion) UnmarshalJSON(data []byte) error {
 440	return apijson.UnmarshalRoot(data, r)
 441}
 442
 443type FileSearchToolCall struct {
 444	// The ID of the tool call object.
 445	ID string `json:"id,required"`
 446	// For now, this is always going to be an empty object.
 447	FileSearch FileSearchToolCallFileSearch `json:"file_search,required"`
 448	// The type of tool call. This is always going to be `file_search` for this type of
 449	// tool call.
 450	Type constant.FileSearch `json:"type,required"`
 451	// Metadata for the response, check the presence of optional fields with the
 452	// [resp.Field.IsPresent] method.
 453	JSON struct {
 454		ID          resp.Field
 455		FileSearch  resp.Field
 456		Type        resp.Field
 457		ExtraFields map[string]resp.Field
 458		raw         string
 459	} `json:"-"`
 460}
 461
 462// Returns the unmodified JSON received from the API
 463func (r FileSearchToolCall) RawJSON() string { return r.JSON.raw }
 464func (r *FileSearchToolCall) UnmarshalJSON(data []byte) error {
 465	return apijson.UnmarshalRoot(data, r)
 466}
 467
 468// For now, this is always going to be an empty object.
 469type FileSearchToolCallFileSearch struct {
 470	// The ranking options for the file search.
 471	RankingOptions FileSearchToolCallFileSearchRankingOptions `json:"ranking_options"`
 472	// The results of the file search.
 473	Results []FileSearchToolCallFileSearchResult `json:"results"`
 474	// Metadata for the response, check the presence of optional fields with the
 475	// [resp.Field.IsPresent] method.
 476	JSON struct {
 477		RankingOptions resp.Field
 478		Results        resp.Field
 479		ExtraFields    map[string]resp.Field
 480		raw            string
 481	} `json:"-"`
 482}
 483
 484// Returns the unmodified JSON received from the API
 485func (r FileSearchToolCallFileSearch) RawJSON() string { return r.JSON.raw }
 486func (r *FileSearchToolCallFileSearch) UnmarshalJSON(data []byte) error {
 487	return apijson.UnmarshalRoot(data, r)
 488}
 489
 490// The ranking options for the file search.
 491type FileSearchToolCallFileSearchRankingOptions struct {
 492	// The ranker to use for the file search. If not specified will use the `auto`
 493	// ranker.
 494	//
 495	// Any of "auto", "default_2024_08_21".
 496	Ranker string `json:"ranker,required"`
 497	// The score threshold for the file search. All values must be a floating point
 498	// number between 0 and 1.
 499	ScoreThreshold float64 `json:"score_threshold,required"`
 500	// Metadata for the response, check the presence of optional fields with the
 501	// [resp.Field.IsPresent] method.
 502	JSON struct {
 503		Ranker         resp.Field
 504		ScoreThreshold resp.Field
 505		ExtraFields    map[string]resp.Field
 506		raw            string
 507	} `json:"-"`
 508}
 509
 510// Returns the unmodified JSON received from the API
 511func (r FileSearchToolCallFileSearchRankingOptions) RawJSON() string { return r.JSON.raw }
 512func (r *FileSearchToolCallFileSearchRankingOptions) UnmarshalJSON(data []byte) error {
 513	return apijson.UnmarshalRoot(data, r)
 514}
 515
 516// A result instance of the file search.
 517type FileSearchToolCallFileSearchResult struct {
 518	// The ID of the file that result was found in.
 519	FileID string `json:"file_id,required"`
 520	// The name of the file that result was found in.
 521	FileName string `json:"file_name,required"`
 522	// The score of the result. All values must be a floating point number between 0
 523	// and 1.
 524	Score float64 `json:"score,required"`
 525	// The content of the result that was found. The content is only included if
 526	// requested via the include query parameter.
 527	Content []FileSearchToolCallFileSearchResultContent `json:"content"`
 528	// Metadata for the response, check the presence of optional fields with the
 529	// [resp.Field.IsPresent] method.
 530	JSON struct {
 531		FileID      resp.Field
 532		FileName    resp.Field
 533		Score       resp.Field
 534		Content     resp.Field
 535		ExtraFields map[string]resp.Field
 536		raw         string
 537	} `json:"-"`
 538}
 539
 540// Returns the unmodified JSON received from the API
 541func (r FileSearchToolCallFileSearchResult) RawJSON() string { return r.JSON.raw }
 542func (r *FileSearchToolCallFileSearchResult) UnmarshalJSON(data []byte) error {
 543	return apijson.UnmarshalRoot(data, r)
 544}
 545
 546type FileSearchToolCallFileSearchResultContent struct {
 547	// The text content of the file.
 548	Text string `json:"text"`
 549	// The type of the content.
 550	//
 551	// Any of "text".
 552	Type string `json:"type"`
 553	// Metadata for the response, check the presence of optional fields with the
 554	// [resp.Field.IsPresent] method.
 555	JSON struct {
 556		Text        resp.Field
 557		Type        resp.Field
 558		ExtraFields map[string]resp.Field
 559		raw         string
 560	} `json:"-"`
 561}
 562
 563// Returns the unmodified JSON received from the API
 564func (r FileSearchToolCallFileSearchResultContent) RawJSON() string { return r.JSON.raw }
 565func (r *FileSearchToolCallFileSearchResultContent) UnmarshalJSON(data []byte) error {
 566	return apijson.UnmarshalRoot(data, r)
 567}
 568
 569type FileSearchToolCallDelta struct {
 570	// For now, this is always going to be an empty object.
 571	FileSearch interface{} `json:"file_search,required"`
 572	// The index of the tool call in the tool calls array.
 573	Index int64 `json:"index,required"`
 574	// The type of tool call. This is always going to be `file_search` for this type of
 575	// tool call.
 576	Type constant.FileSearch `json:"type,required"`
 577	// The ID of the tool call object.
 578	ID string `json:"id"`
 579	// Metadata for the response, check the presence of optional fields with the
 580	// [resp.Field.IsPresent] method.
 581	JSON struct {
 582		FileSearch  resp.Field
 583		Index       resp.Field
 584		Type        resp.Field
 585		ID          resp.Field
 586		ExtraFields map[string]resp.Field
 587		raw         string
 588	} `json:"-"`
 589}
 590
 591// Returns the unmodified JSON received from the API
 592func (r FileSearchToolCallDelta) RawJSON() string { return r.JSON.raw }
 593func (r *FileSearchToolCallDelta) UnmarshalJSON(data []byte) error {
 594	return apijson.UnmarshalRoot(data, r)
 595}
 596
 597type FunctionToolCall struct {
 598	// The ID of the tool call object.
 599	ID string `json:"id,required"`
 600	// The definition of the function that was called.
 601	Function FunctionToolCallFunction `json:"function,required"`
 602	// The type of tool call. This is always going to be `function` for this type of
 603	// tool call.
 604	Type constant.Function `json:"type,required"`
 605	// Metadata for the response, check the presence of optional fields with the
 606	// [resp.Field.IsPresent] method.
 607	JSON struct {
 608		ID          resp.Field
 609		Function    resp.Field
 610		Type        resp.Field
 611		ExtraFields map[string]resp.Field
 612		raw         string
 613	} `json:"-"`
 614}
 615
 616// Returns the unmodified JSON received from the API
 617func (r FunctionToolCall) RawJSON() string { return r.JSON.raw }
 618func (r *FunctionToolCall) UnmarshalJSON(data []byte) error {
 619	return apijson.UnmarshalRoot(data, r)
 620}
 621
 622// The definition of the function that was called.
 623type FunctionToolCallFunction struct {
 624	// The arguments passed to the function.
 625	Arguments string `json:"arguments,required"`
 626	// The name of the function.
 627	Name string `json:"name,required"`
 628	// The output of the function. This will be `null` if the outputs have not been
 629	// [submitted](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs)
 630	// yet.
 631	Output string `json:"output,required"`
 632	// Metadata for the response, check the presence of optional fields with the
 633	// [resp.Field.IsPresent] method.
 634	JSON struct {
 635		Arguments   resp.Field
 636		Name        resp.Field
 637		Output      resp.Field
 638		ExtraFields map[string]resp.Field
 639		raw         string
 640	} `json:"-"`
 641}
 642
 643// Returns the unmodified JSON received from the API
 644func (r FunctionToolCallFunction) RawJSON() string { return r.JSON.raw }
 645func (r *FunctionToolCallFunction) UnmarshalJSON(data []byte) error {
 646	return apijson.UnmarshalRoot(data, r)
 647}
 648
 649type FunctionToolCallDelta struct {
 650	// The index of the tool call in the tool calls array.
 651	Index int64 `json:"index,required"`
 652	// The type of tool call. This is always going to be `function` for this type of
 653	// tool call.
 654	Type constant.Function `json:"type,required"`
 655	// The ID of the tool call object.
 656	ID string `json:"id"`
 657	// The definition of the function that was called.
 658	Function FunctionToolCallDeltaFunction `json:"function"`
 659	// Metadata for the response, check the presence of optional fields with the
 660	// [resp.Field.IsPresent] method.
 661	JSON struct {
 662		Index       resp.Field
 663		Type        resp.Field
 664		ID          resp.Field
 665		Function    resp.Field
 666		ExtraFields map[string]resp.Field
 667		raw         string
 668	} `json:"-"`
 669}
 670
 671// Returns the unmodified JSON received from the API
 672func (r FunctionToolCallDelta) RawJSON() string { return r.JSON.raw }
 673func (r *FunctionToolCallDelta) UnmarshalJSON(data []byte) error {
 674	return apijson.UnmarshalRoot(data, r)
 675}
 676
 677// The definition of the function that was called.
 678type FunctionToolCallDeltaFunction struct {
 679	// The arguments passed to the function.
 680	Arguments string `json:"arguments"`
 681	// The name of the function.
 682	Name string `json:"name"`
 683	// The output of the function. This will be `null` if the outputs have not been
 684	// [submitted](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs)
 685	// yet.
 686	Output string `json:"output,nullable"`
 687	// Metadata for the response, check the presence of optional fields with the
 688	// [resp.Field.IsPresent] method.
 689	JSON struct {
 690		Arguments   resp.Field
 691		Name        resp.Field
 692		Output      resp.Field
 693		ExtraFields map[string]resp.Field
 694		raw         string
 695	} `json:"-"`
 696}
 697
 698// Returns the unmodified JSON received from the API
 699func (r FunctionToolCallDeltaFunction) RawJSON() string { return r.JSON.raw }
 700func (r *FunctionToolCallDeltaFunction) UnmarshalJSON(data []byte) error {
 701	return apijson.UnmarshalRoot(data, r)
 702}
 703
 704// Details of the message creation by the run step.
 705type MessageCreationStepDetails struct {
 706	MessageCreation MessageCreationStepDetailsMessageCreation `json:"message_creation,required"`
 707	// Always `message_creation`.
 708	Type constant.MessageCreation `json:"type,required"`
 709	// Metadata for the response, check the presence of optional fields with the
 710	// [resp.Field.IsPresent] method.
 711	JSON struct {
 712		MessageCreation resp.Field
 713		Type            resp.Field
 714		ExtraFields     map[string]resp.Field
 715		raw             string
 716	} `json:"-"`
 717}
 718
 719// Returns the unmodified JSON received from the API
 720func (r MessageCreationStepDetails) RawJSON() string { return r.JSON.raw }
 721func (r *MessageCreationStepDetails) UnmarshalJSON(data []byte) error {
 722	return apijson.UnmarshalRoot(data, r)
 723}
 724
 725type MessageCreationStepDetailsMessageCreation struct {
 726	// The ID of the message that was created by this run step.
 727	MessageID string `json:"message_id,required"`
 728	// Metadata for the response, check the presence of optional fields with the
 729	// [resp.Field.IsPresent] method.
 730	JSON struct {
 731		MessageID   resp.Field
 732		ExtraFields map[string]resp.Field
 733		raw         string
 734	} `json:"-"`
 735}
 736
 737// Returns the unmodified JSON received from the API
 738func (r MessageCreationStepDetailsMessageCreation) RawJSON() string { return r.JSON.raw }
 739func (r *MessageCreationStepDetailsMessageCreation) UnmarshalJSON(data []byte) error {
 740	return apijson.UnmarshalRoot(data, r)
 741}
 742
 743// Represents a step in execution of a run.
 744type RunStep struct {
 745	// The identifier of the run step, which can be referenced in API endpoints.
 746	ID string `json:"id,required"`
 747	// The ID of the
 748	// [assistant](https://platform.openai.com/docs/api-reference/assistants)
 749	// associated with the run step.
 750	AssistantID string `json:"assistant_id,required"`
 751	// The Unix timestamp (in seconds) for when the run step was cancelled.
 752	CancelledAt int64 `json:"cancelled_at,required"`
 753	// The Unix timestamp (in seconds) for when the run step completed.
 754	CompletedAt int64 `json:"completed_at,required"`
 755	// The Unix timestamp (in seconds) for when the run step was created.
 756	CreatedAt int64 `json:"created_at,required"`
 757	// The Unix timestamp (in seconds) for when the run step expired. A step is
 758	// considered expired if the parent run is expired.
 759	ExpiredAt int64 `json:"expired_at,required"`
 760	// The Unix timestamp (in seconds) for when the run step failed.
 761	FailedAt int64 `json:"failed_at,required"`
 762	// The last error associated with this run step. Will be `null` if there are no
 763	// errors.
 764	LastError RunStepLastError `json:"last_error,required"`
 765	// Set of 16 key-value pairs that can be attached to an object. This can be useful
 766	// for storing additional information about the object in a structured format, and
 767	// querying for objects via API or the dashboard.
 768	//
 769	// Keys are strings with a maximum length of 64 characters. Values are strings with
 770	// a maximum length of 512 characters.
 771	Metadata shared.Metadata `json:"metadata,required"`
 772	// The object type, which is always `thread.run.step`.
 773	Object constant.ThreadRunStep `json:"object,required"`
 774	// The ID of the [run](https://platform.openai.com/docs/api-reference/runs) that
 775	// this run step is a part of.
 776	RunID string `json:"run_id,required"`
 777	// The status of the run step, which can be either `in_progress`, `cancelled`,
 778	// `failed`, `completed`, or `expired`.
 779	//
 780	// Any of "in_progress", "cancelled", "failed", "completed", "expired".
 781	Status RunStepStatus `json:"status,required"`
 782	// The details of the run step.
 783	StepDetails RunStepStepDetailsUnion `json:"step_details,required"`
 784	// The ID of the [thread](https://platform.openai.com/docs/api-reference/threads)
 785	// that was run.
 786	ThreadID string `json:"thread_id,required"`
 787	// The type of run step, which can be either `message_creation` or `tool_calls`.
 788	//
 789	// Any of "message_creation", "tool_calls".
 790	Type RunStepType `json:"type,required"`
 791	// Usage statistics related to the run step. This value will be `null` while the
 792	// run step's status is `in_progress`.
 793	Usage RunStepUsage `json:"usage,required"`
 794	// Metadata for the response, check the presence of optional fields with the
 795	// [resp.Field.IsPresent] method.
 796	JSON struct {
 797		ID          resp.Field
 798		AssistantID resp.Field
 799		CancelledAt resp.Field
 800		CompletedAt resp.Field
 801		CreatedAt   resp.Field
 802		ExpiredAt   resp.Field
 803		FailedAt    resp.Field
 804		LastError   resp.Field
 805		Metadata    resp.Field
 806		Object      resp.Field
 807		RunID       resp.Field
 808		Status      resp.Field
 809		StepDetails resp.Field
 810		ThreadID    resp.Field
 811		Type        resp.Field
 812		Usage       resp.Field
 813		ExtraFields map[string]resp.Field
 814		raw         string
 815	} `json:"-"`
 816}
 817
 818// Returns the unmodified JSON received from the API
 819func (r RunStep) RawJSON() string { return r.JSON.raw }
 820func (r *RunStep) UnmarshalJSON(data []byte) error {
 821	return apijson.UnmarshalRoot(data, r)
 822}
 823
 824// The last error associated with this run step. Will be `null` if there are no
 825// errors.
 826type RunStepLastError struct {
 827	// One of `server_error` or `rate_limit_exceeded`.
 828	//
 829	// Any of "server_error", "rate_limit_exceeded".
 830	Code string `json:"code,required"`
 831	// A human-readable description of the error.
 832	Message string `json:"message,required"`
 833	// Metadata for the response, check the presence of optional fields with the
 834	// [resp.Field.IsPresent] method.
 835	JSON struct {
 836		Code        resp.Field
 837		Message     resp.Field
 838		ExtraFields map[string]resp.Field
 839		raw         string
 840	} `json:"-"`
 841}
 842
 843// Returns the unmodified JSON received from the API
 844func (r RunStepLastError) RawJSON() string { return r.JSON.raw }
 845func (r *RunStepLastError) UnmarshalJSON(data []byte) error {
 846	return apijson.UnmarshalRoot(data, r)
 847}
 848
 849// The status of the run step, which can be either `in_progress`, `cancelled`,
 850// `failed`, `completed`, or `expired`.
 851type RunStepStatus string
 852
 853const (
 854	RunStepStatusInProgress RunStepStatus = "in_progress"
 855	RunStepStatusCancelled  RunStepStatus = "cancelled"
 856	RunStepStatusFailed     RunStepStatus = "failed"
 857	RunStepStatusCompleted  RunStepStatus = "completed"
 858	RunStepStatusExpired    RunStepStatus = "expired"
 859)
 860
 861// RunStepStepDetailsUnion contains all possible properties and values from
 862// [MessageCreationStepDetails], [ToolCallsStepDetails].
 863//
 864// Use the [RunStepStepDetailsUnion.AsAny] method to switch on the variant.
 865//
 866// Use the methods beginning with 'As' to cast the union to one of its variants.
 867type RunStepStepDetailsUnion struct {
 868	// This field is from variant [MessageCreationStepDetails].
 869	MessageCreation MessageCreationStepDetailsMessageCreation `json:"message_creation"`
 870	// Any of "message_creation", "tool_calls".
 871	Type string `json:"type"`
 872	// This field is from variant [ToolCallsStepDetails].
 873	ToolCalls []ToolCallUnion `json:"tool_calls"`
 874	JSON      struct {
 875		MessageCreation resp.Field
 876		Type            resp.Field
 877		ToolCalls       resp.Field
 878		raw             string
 879	} `json:"-"`
 880}
 881
 882// Use the following switch statement to find the correct variant
 883//
 884//	switch variant := RunStepStepDetailsUnion.AsAny().(type) {
 885//	case MessageCreationStepDetails:
 886//	case ToolCallsStepDetails:
 887//	default:
 888//	  fmt.Errorf("no variant present")
 889//	}
 890func (u RunStepStepDetailsUnion) AsAny() any {
 891	switch u.Type {
 892	case "message_creation":
 893		return u.AsMessageCreation()
 894	case "tool_calls":
 895		return u.AsToolCalls()
 896	}
 897	return nil
 898}
 899
 900func (u RunStepStepDetailsUnion) AsMessageCreation() (v MessageCreationStepDetails) {
 901	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 902	return
 903}
 904
 905func (u RunStepStepDetailsUnion) AsToolCalls() (v ToolCallsStepDetails) {
 906	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
 907	return
 908}
 909
 910// Returns the unmodified JSON received from the API
 911func (u RunStepStepDetailsUnion) RawJSON() string { return u.JSON.raw }
 912
 913func (r *RunStepStepDetailsUnion) UnmarshalJSON(data []byte) error {
 914	return apijson.UnmarshalRoot(data, r)
 915}
 916
 917// The type of run step, which can be either `message_creation` or `tool_calls`.
 918type RunStepType string
 919
 920const (
 921	RunStepTypeMessageCreation RunStepType = "message_creation"
 922	RunStepTypeToolCalls       RunStepType = "tool_calls"
 923)
 924
 925// Usage statistics related to the run step. This value will be `null` while the
 926// run step's status is `in_progress`.
 927type RunStepUsage struct {
 928	// Number of completion tokens used over the course of the run step.
 929	CompletionTokens int64 `json:"completion_tokens,required"`
 930	// Number of prompt tokens used over the course of the run step.
 931	PromptTokens int64 `json:"prompt_tokens,required"`
 932	// Total number of tokens used (prompt + completion).
 933	TotalTokens int64 `json:"total_tokens,required"`
 934	// Metadata for the response, check the presence of optional fields with the
 935	// [resp.Field.IsPresent] method.
 936	JSON struct {
 937		CompletionTokens resp.Field
 938		PromptTokens     resp.Field
 939		TotalTokens      resp.Field
 940		ExtraFields      map[string]resp.Field
 941		raw              string
 942	} `json:"-"`
 943}
 944
 945// Returns the unmodified JSON received from the API
 946func (r RunStepUsage) RawJSON() string { return r.JSON.raw }
 947func (r *RunStepUsage) UnmarshalJSON(data []byte) error {
 948	return apijson.UnmarshalRoot(data, r)
 949}
 950
 951// The delta containing the fields that have changed on the run step.
 952type RunStepDelta struct {
 953	// The details of the run step.
 954	StepDetails RunStepDeltaStepDetailsUnion `json:"step_details"`
 955	// Metadata for the response, check the presence of optional fields with the
 956	// [resp.Field.IsPresent] method.
 957	JSON struct {
 958		StepDetails resp.Field
 959		ExtraFields map[string]resp.Field
 960		raw         string
 961	} `json:"-"`
 962}
 963
 964// Returns the unmodified JSON received from the API
 965func (r RunStepDelta) RawJSON() string { return r.JSON.raw }
 966func (r *RunStepDelta) UnmarshalJSON(data []byte) error {
 967	return apijson.UnmarshalRoot(data, r)
 968}
 969
 970// RunStepDeltaStepDetailsUnion contains all possible properties and values from
 971// [RunStepDeltaMessageDelta], [ToolCallDeltaObject].
 972//
 973// Use the [RunStepDeltaStepDetailsUnion.AsAny] method to switch on the variant.
 974//
 975// Use the methods beginning with 'As' to cast the union to one of its variants.
 976type RunStepDeltaStepDetailsUnion struct {
 977	// Any of "message_creation", "tool_calls".
 978	Type string `json:"type"`
 979	// This field is from variant [RunStepDeltaMessageDelta].
 980	MessageCreation RunStepDeltaMessageDeltaMessageCreation `json:"message_creation"`
 981	// This field is from variant [ToolCallDeltaObject].
 982	ToolCalls []ToolCallDeltaUnion `json:"tool_calls"`
 983	JSON      struct {
 984		Type            resp.Field
 985		MessageCreation resp.Field
 986		ToolCalls       resp.Field
 987		raw             string
 988	} `json:"-"`
 989}
 990
 991// Use the following switch statement to find the correct variant
 992//
 993//	switch variant := RunStepDeltaStepDetailsUnion.AsAny().(type) {
 994//	case RunStepDeltaMessageDelta:
 995//	case ToolCallDeltaObject:
 996//	default:
 997//	  fmt.Errorf("no variant present")
 998//	}
 999func (u RunStepDeltaStepDetailsUnion) AsAny() any {
1000	switch u.Type {
1001	case "message_creation":
1002		return u.AsMessageCreation()
1003	case "tool_calls":
1004		return u.AsToolCalls()
1005	}
1006	return nil
1007}
1008
1009func (u RunStepDeltaStepDetailsUnion) AsMessageCreation() (v RunStepDeltaMessageDelta) {
1010	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1011	return
1012}
1013
1014func (u RunStepDeltaStepDetailsUnion) AsToolCalls() (v ToolCallDeltaObject) {
1015	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1016	return
1017}
1018
1019// Returns the unmodified JSON received from the API
1020func (u RunStepDeltaStepDetailsUnion) RawJSON() string { return u.JSON.raw }
1021
1022func (r *RunStepDeltaStepDetailsUnion) UnmarshalJSON(data []byte) error {
1023	return apijson.UnmarshalRoot(data, r)
1024}
1025
1026// Represents a run step delta i.e. any changed fields on a run step during
1027// streaming.
1028type RunStepDeltaEvent struct {
1029	// The identifier of the run step, which can be referenced in API endpoints.
1030	ID string `json:"id,required"`
1031	// The delta containing the fields that have changed on the run step.
1032	Delta RunStepDelta `json:"delta,required"`
1033	// The object type, which is always `thread.run.step.delta`.
1034	Object constant.ThreadRunStepDelta `json:"object,required"`
1035	// Metadata for the response, check the presence of optional fields with the
1036	// [resp.Field.IsPresent] method.
1037	JSON struct {
1038		ID          resp.Field
1039		Delta       resp.Field
1040		Object      resp.Field
1041		ExtraFields map[string]resp.Field
1042		raw         string
1043	} `json:"-"`
1044}
1045
1046// Returns the unmodified JSON received from the API
1047func (r RunStepDeltaEvent) RawJSON() string { return r.JSON.raw }
1048func (r *RunStepDeltaEvent) UnmarshalJSON(data []byte) error {
1049	return apijson.UnmarshalRoot(data, r)
1050}
1051
1052// Details of the message creation by the run step.
1053type RunStepDeltaMessageDelta struct {
1054	// Always `message_creation`.
1055	Type            constant.MessageCreation                `json:"type,required"`
1056	MessageCreation RunStepDeltaMessageDeltaMessageCreation `json:"message_creation"`
1057	// Metadata for the response, check the presence of optional fields with the
1058	// [resp.Field.IsPresent] method.
1059	JSON struct {
1060		Type            resp.Field
1061		MessageCreation resp.Field
1062		ExtraFields     map[string]resp.Field
1063		raw             string
1064	} `json:"-"`
1065}
1066
1067// Returns the unmodified JSON received from the API
1068func (r RunStepDeltaMessageDelta) RawJSON() string { return r.JSON.raw }
1069func (r *RunStepDeltaMessageDelta) UnmarshalJSON(data []byte) error {
1070	return apijson.UnmarshalRoot(data, r)
1071}
1072
1073type RunStepDeltaMessageDeltaMessageCreation struct {
1074	// The ID of the message that was created by this run step.
1075	MessageID string `json:"message_id"`
1076	// Metadata for the response, check the presence of optional fields with the
1077	// [resp.Field.IsPresent] method.
1078	JSON struct {
1079		MessageID   resp.Field
1080		ExtraFields map[string]resp.Field
1081		raw         string
1082	} `json:"-"`
1083}
1084
1085// Returns the unmodified JSON received from the API
1086func (r RunStepDeltaMessageDeltaMessageCreation) RawJSON() string { return r.JSON.raw }
1087func (r *RunStepDeltaMessageDeltaMessageCreation) UnmarshalJSON(data []byte) error {
1088	return apijson.UnmarshalRoot(data, r)
1089}
1090
1091type RunStepInclude string
1092
1093const (
1094	RunStepIncludeStepDetailsToolCallsFileSearchResultsContent RunStepInclude = "step_details.tool_calls[*].file_search.results[*].content"
1095)
1096
1097// ToolCallUnion contains all possible properties and values from
1098// [CodeInterpreterToolCall], [FileSearchToolCall], [FunctionToolCall].
1099//
1100// Use the [ToolCallUnion.AsAny] method to switch on the variant.
1101//
1102// Use the methods beginning with 'As' to cast the union to one of its variants.
1103type ToolCallUnion struct {
1104	ID string `json:"id"`
1105	// This field is from variant [CodeInterpreterToolCall].
1106	CodeInterpreter CodeInterpreterToolCallCodeInterpreter `json:"code_interpreter"`
1107	// Any of "code_interpreter", "file_search", "function".
1108	Type string `json:"type"`
1109	// This field is from variant [FileSearchToolCall].
1110	FileSearch FileSearchToolCallFileSearch `json:"file_search"`
1111	// This field is from variant [FunctionToolCall].
1112	Function FunctionToolCallFunction `json:"function"`
1113	JSON     struct {
1114		ID              resp.Field
1115		CodeInterpreter resp.Field
1116		Type            resp.Field
1117		FileSearch      resp.Field
1118		Function        resp.Field
1119		raw             string
1120	} `json:"-"`
1121}
1122
1123// Use the following switch statement to find the correct variant
1124//
1125//	switch variant := ToolCallUnion.AsAny().(type) {
1126//	case CodeInterpreterToolCall:
1127//	case FileSearchToolCall:
1128//	case FunctionToolCall:
1129//	default:
1130//	  fmt.Errorf("no variant present")
1131//	}
1132func (u ToolCallUnion) AsAny() any {
1133	switch u.Type {
1134	case "code_interpreter":
1135		return u.AsCodeInterpreter()
1136	case "file_search":
1137		return u.AsFileSearch()
1138	case "function":
1139		return u.AsFunction()
1140	}
1141	return nil
1142}
1143
1144func (u ToolCallUnion) AsCodeInterpreter() (v CodeInterpreterToolCall) {
1145	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1146	return
1147}
1148
1149func (u ToolCallUnion) AsFileSearch() (v FileSearchToolCall) {
1150	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1151	return
1152}
1153
1154func (u ToolCallUnion) AsFunction() (v FunctionToolCall) {
1155	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1156	return
1157}
1158
1159// Returns the unmodified JSON received from the API
1160func (u ToolCallUnion) RawJSON() string { return u.JSON.raw }
1161
1162func (r *ToolCallUnion) UnmarshalJSON(data []byte) error {
1163	return apijson.UnmarshalRoot(data, r)
1164}
1165
1166// ToolCallDeltaUnion contains all possible properties and values from
1167// [CodeInterpreterToolCallDelta], [FileSearchToolCallDelta],
1168// [FunctionToolCallDelta].
1169//
1170// Use the [ToolCallDeltaUnion.AsAny] method to switch on the variant.
1171//
1172// Use the methods beginning with 'As' to cast the union to one of its variants.
1173type ToolCallDeltaUnion struct {
1174	Index int64 `json:"index"`
1175	// Any of "code_interpreter", "file_search", "function".
1176	Type string `json:"type"`
1177	ID   string `json:"id"`
1178	// This field is from variant [CodeInterpreterToolCallDelta].
1179	CodeInterpreter CodeInterpreterToolCallDeltaCodeInterpreter `json:"code_interpreter"`
1180	// This field is from variant [FileSearchToolCallDelta].
1181	FileSearch interface{} `json:"file_search"`
1182	// This field is from variant [FunctionToolCallDelta].
1183	Function FunctionToolCallDeltaFunction `json:"function"`
1184	JSON     struct {
1185		Index           resp.Field
1186		Type            resp.Field
1187		ID              resp.Field
1188		CodeInterpreter resp.Field
1189		FileSearch      resp.Field
1190		Function        resp.Field
1191		raw             string
1192	} `json:"-"`
1193}
1194
1195// Use the following switch statement to find the correct variant
1196//
1197//	switch variant := ToolCallDeltaUnion.AsAny().(type) {
1198//	case CodeInterpreterToolCallDelta:
1199//	case FileSearchToolCallDelta:
1200//	case FunctionToolCallDelta:
1201//	default:
1202//	  fmt.Errorf("no variant present")
1203//	}
1204func (u ToolCallDeltaUnion) AsAny() any {
1205	switch u.Type {
1206	case "code_interpreter":
1207		return u.AsCodeInterpreter()
1208	case "file_search":
1209		return u.AsFileSearch()
1210	case "function":
1211		return u.AsFunction()
1212	}
1213	return nil
1214}
1215
1216func (u ToolCallDeltaUnion) AsCodeInterpreter() (v CodeInterpreterToolCallDelta) {
1217	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1218	return
1219}
1220
1221func (u ToolCallDeltaUnion) AsFileSearch() (v FileSearchToolCallDelta) {
1222	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1223	return
1224}
1225
1226func (u ToolCallDeltaUnion) AsFunction() (v FunctionToolCallDelta) {
1227	apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
1228	return
1229}
1230
1231// Returns the unmodified JSON received from the API
1232func (u ToolCallDeltaUnion) RawJSON() string { return u.JSON.raw }
1233
1234func (r *ToolCallDeltaUnion) UnmarshalJSON(data []byte) error {
1235	return apijson.UnmarshalRoot(data, r)
1236}
1237
1238// Details of the tool call.
1239type ToolCallDeltaObject struct {
1240	// Always `tool_calls`.
1241	Type constant.ToolCalls `json:"type,required"`
1242	// An array of tool calls the run step was involved in. These can be associated
1243	// with one of three types of tools: `code_interpreter`, `file_search`, or
1244	// `function`.
1245	ToolCalls []ToolCallDeltaUnion `json:"tool_calls"`
1246	// Metadata for the response, check the presence of optional fields with the
1247	// [resp.Field.IsPresent] method.
1248	JSON struct {
1249		Type        resp.Field
1250		ToolCalls   resp.Field
1251		ExtraFields map[string]resp.Field
1252		raw         string
1253	} `json:"-"`
1254}
1255
1256// Returns the unmodified JSON received from the API
1257func (r ToolCallDeltaObject) RawJSON() string { return r.JSON.raw }
1258func (r *ToolCallDeltaObject) UnmarshalJSON(data []byte) error {
1259	return apijson.UnmarshalRoot(data, r)
1260}
1261
1262// Details of the tool call.
1263type ToolCallsStepDetails struct {
1264	// An array of tool calls the run step was involved in. These can be associated
1265	// with one of three types of tools: `code_interpreter`, `file_search`, or
1266	// `function`.
1267	ToolCalls []ToolCallUnion `json:"tool_calls,required"`
1268	// Always `tool_calls`.
1269	Type constant.ToolCalls `json:"type,required"`
1270	// Metadata for the response, check the presence of optional fields with the
1271	// [resp.Field.IsPresent] method.
1272	JSON struct {
1273		ToolCalls   resp.Field
1274		Type        resp.Field
1275		ExtraFields map[string]resp.Field
1276		raw         string
1277	} `json:"-"`
1278}
1279
1280// Returns the unmodified JSON received from the API
1281func (r ToolCallsStepDetails) RawJSON() string { return r.JSON.raw }
1282func (r *ToolCallsStepDetails) UnmarshalJSON(data []byte) error {
1283	return apijson.UnmarshalRoot(data, r)
1284}
1285
1286type BetaThreadRunStepGetParams struct {
1287	// A list of additional fields to include in the response. Currently the only
1288	// supported value is `step_details.tool_calls[*].file_search.results[*].content`
1289	// to fetch the file search result content.
1290	//
1291	// See the
1292	// [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
1293	// for more information.
1294	Include []RunStepInclude `query:"include,omitzero" json:"-"`
1295	paramObj
1296}
1297
1298// IsPresent returns true if the field's value is not omitted and not the JSON
1299// "null". To check if this field is omitted, use [param.IsOmitted].
1300func (f BetaThreadRunStepGetParams) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
1301
1302// URLQuery serializes [BetaThreadRunStepGetParams]'s query parameters as
1303// `url.Values`.
1304func (r BetaThreadRunStepGetParams) URLQuery() (v url.Values) {
1305	return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
1306		ArrayFormat:  apiquery.ArrayQueryFormatBrackets,
1307		NestedFormat: apiquery.NestedQueryFormatBrackets,
1308	})
1309}
1310
1311type BetaThreadRunStepListParams struct {
1312	// A cursor for use in pagination. `after` is an object ID that defines your place
1313	// in the list. For instance, if you make a list request and receive 100 objects,
1314	// ending with obj_foo, your subsequent call can include after=obj_foo in order to
1315	// fetch the next page of the list.
1316	After param.Opt[string] `query:"after,omitzero" json:"-"`
1317	// A cursor for use in pagination. `before` is an object ID that defines your place
1318	// in the list. For instance, if you make a list request and receive 100 objects,
1319	// starting with obj_foo, your subsequent call can include before=obj_foo in order
1320	// to fetch the previous page of the list.
1321	Before param.Opt[string] `query:"before,omitzero" json:"-"`
1322	// A limit on the number of objects to be returned. Limit can range between 1 and
1323	// 100, and the default is 20.
1324	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
1325	// A list of additional fields to include in the response. Currently the only
1326	// supported value is `step_details.tool_calls[*].file_search.results[*].content`
1327	// to fetch the file search result content.
1328	//
1329	// See the
1330	// [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
1331	// for more information.
1332	Include []RunStepInclude `query:"include,omitzero" json:"-"`
1333	// Sort order by the `created_at` timestamp of the objects. `asc` for ascending
1334	// order and `desc` for descending order.
1335	//
1336	// Any of "asc", "desc".
1337	Order BetaThreadRunStepListParamsOrder `query:"order,omitzero" json:"-"`
1338	paramObj
1339}
1340
1341// IsPresent returns true if the field's value is not omitted and not the JSON
1342// "null". To check if this field is omitted, use [param.IsOmitted].
1343func (f BetaThreadRunStepListParams) IsPresent() bool { return !param.IsOmitted(f) && !f.IsNull() }
1344
1345// URLQuery serializes [BetaThreadRunStepListParams]'s query parameters as
1346// `url.Values`.
1347func (r BetaThreadRunStepListParams) URLQuery() (v url.Values) {
1348	return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
1349		ArrayFormat:  apiquery.ArrayQueryFormatBrackets,
1350		NestedFormat: apiquery.NestedQueryFormatBrackets,
1351	})
1352}
1353
1354// Sort order by the `created_at` timestamp of the objects. `asc` for ascending
1355// order and `desc` for descending order.
1356type BetaThreadRunStepListParamsOrder string
1357
1358const (
1359	BetaThreadRunStepListParamsOrderAsc  BetaThreadRunStepListParamsOrder = "asc"
1360	BetaThreadRunStepListParamsOrderDesc BetaThreadRunStepListParamsOrder = "desc"
1361)