From 931c4056032e045e9a5d381611d8b8ad8c097289 Mon Sep 17 00:00:00 2001 From: Stainless Bot Date: Thu, 29 Aug 2024 16:09:03 +0000 Subject: [PATCH] feat(api): add file search result details to run steps --- .stats.yml | 2 +- api.md | 8 +- betaassistant.go | 116 +++++++++++++++++++---- betathreadrun.go | 24 ++++- betathreadrun_test.go | 1 + betathreadrunstep.go | 192 +++++++++++++++++++++++++++++++++++++- betathreadrunstep_test.go | 14 ++- 7 files changed, 323 insertions(+), 34 deletions(-) diff --git a/.stats.yml b/.stats.yml index e9aeeaae..fd4f2713 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 68 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-8e569a23f15a599dd4aee8a53431962bcba4985ab6cfb66c53c1434b99026b37.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-1dbac0e95bdb5a89a0dd3d93265475a378214551b7d8c22862928e0d87ace94b.yml diff --git a/api.md b/api.md index 4c359342..e0b22f2e 100644 --- a/api.md +++ b/api.md @@ -308,7 +308,7 @@ Response Types: Methods: -- client.Beta.Threads.Runs.New(ctx context.Context, threadID string, body openai.BetaThreadRunNewParams) (openai.Run, error) +- client.Beta.Threads.Runs.New(ctx context.Context, threadID string, params openai.BetaThreadRunNewParams) (openai.Run, error) - client.Beta.Threads.Runs.Get(ctx context.Context, threadID string, runID string) (openai.Run, error) - client.Beta.Threads.Runs.Update(ctx context.Context, threadID string, runID string, body openai.BetaThreadRunUpdateParams) (openai.Run, error) - client.Beta.Threads.Runs.List(ctx context.Context, threadID string, query openai.BetaThreadRunListParams) (pagination.CursorPage[openai.Run], error) @@ -317,6 +317,10 @@ Methods: #### Steps +Params Types: + +- openai.RunStepInclude + Response Types: - openai.CodeInterpreterLogs @@ -339,7 +343,7 @@ Response Types: Methods: -- client.Beta.Threads.Runs.Steps.Get(ctx context.Context, threadID string, runID string, stepID string) (openai.RunStep, error) +- client.Beta.Threads.Runs.Steps.Get(ctx context.Context, threadID string, runID string, stepID string, query openai.BetaThreadRunStepGetParams) (openai.RunStep, error) - client.Beta.Threads.Runs.Steps.List(ctx context.Context, threadID string, runID string, query openai.BetaThreadRunStepListParams) (pagination.CursorPage[openai.RunStep], error) ### Messages diff --git a/betaassistant.go b/betaassistant.go index 28ae56ea..5d001c59 100644 --- a/betaassistant.go +++ b/betaassistant.go @@ -1040,8 +1040,8 @@ func (r AssistantStreamEventThreadRunExpiredEvent) IsKnown() bool { } // Occurs when a -// [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is -// created. +// [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) +// is created. type AssistantStreamEventThreadRunStepCreated struct { // Represents a step in execution of a run. Data RunStep `json:"data,required"` @@ -1083,7 +1083,7 @@ func (r AssistantStreamEventThreadRunStepCreatedEvent) IsKnown() bool { } // Occurs when a -// [run step](https://platform.openai.com/docs/api-reference/runs/step-object) +// [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) // moves to an `in_progress` state. type AssistantStreamEventThreadRunStepInProgress struct { // Represents a step in execution of a run. @@ -1126,8 +1126,8 @@ func (r AssistantStreamEventThreadRunStepInProgressEvent) IsKnown() bool { } // Occurs when parts of a -// [run step](https://platform.openai.com/docs/api-reference/runs/step-object) are -// being streamed. +// [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) +// are being streamed. type AssistantStreamEventThreadRunStepDelta struct { // Represents a run step delta i.e. any changed fields on a run step during // streaming. @@ -1170,8 +1170,8 @@ func (r AssistantStreamEventThreadRunStepDeltaEvent) IsKnown() bool { } // Occurs when a -// [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is -// completed. +// [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) +// is completed. type AssistantStreamEventThreadRunStepCompleted struct { // Represents a step in execution of a run. Data RunStep `json:"data,required"` @@ -1213,7 +1213,7 @@ func (r AssistantStreamEventThreadRunStepCompletedEvent) IsKnown() bool { } // Occurs when a -// [run step](https://platform.openai.com/docs/api-reference/runs/step-object) +// [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) // fails. type AssistantStreamEventThreadRunStepFailed struct { // Represents a step in execution of a run. @@ -1256,8 +1256,8 @@ func (r AssistantStreamEventThreadRunStepFailedEvent) IsKnown() bool { } // Occurs when a -// [run step](https://platform.openai.com/docs/api-reference/runs/step-object) is -// cancelled. +// [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) +// is cancelled. type AssistantStreamEventThreadRunStepCancelled struct { // Represents a step in execution of a run. Data RunStep `json:"data,required"` @@ -1299,7 +1299,7 @@ func (r AssistantStreamEventThreadRunStepCancelledEvent) IsKnown() bool { } // Occurs when a -// [run step](https://platform.openai.com/docs/api-reference/runs/step-object) +// [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) // expires. type AssistantStreamEventThreadRunStepExpired struct { // Represents a step in execution of a run. @@ -1857,18 +1857,25 @@ type FileSearchToolFileSearch struct { // // Note that the file search tool may output fewer than `max_num_results` results. // See the - // [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/number-of-chunks-returned) + // [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings) // for more information. - MaxNumResults int64 `json:"max_num_results"` - JSON fileSearchToolFileSearchJSON `json:"-"` + MaxNumResults int64 `json:"max_num_results"` + // The ranking options for the file search. + // + // See the + // [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings) + // for more information. + RankingOptions FileSearchToolFileSearchRankingOptions `json:"ranking_options"` + JSON fileSearchToolFileSearchJSON `json:"-"` } // fileSearchToolFileSearchJSON contains the JSON metadata for the struct // [FileSearchToolFileSearch] type fileSearchToolFileSearchJSON struct { - MaxNumResults apijson.Field - raw string - ExtraFields map[string]apijson.Field + MaxNumResults apijson.Field + RankingOptions apijson.Field + raw string + ExtraFields map[string]apijson.Field } func (r *FileSearchToolFileSearch) UnmarshalJSON(data []byte) (err error) { @@ -1879,6 +1886,55 @@ func (r fileSearchToolFileSearchJSON) RawJSON() string { return r.raw } +// The ranking options for the file search. +// +// See the +// [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings) +// for more information. +type FileSearchToolFileSearchRankingOptions struct { + // The ranker to use for the file search. If not specified will use the `auto` + // ranker. + Ranker FileSearchToolFileSearchRankingOptionsRanker `json:"ranker"` + // The score threshold for the file search. All values must be a floating point + // number between 0 and 1. + ScoreThreshold float64 `json:"score_threshold"` + JSON fileSearchToolFileSearchRankingOptionsJSON `json:"-"` +} + +// fileSearchToolFileSearchRankingOptionsJSON contains the JSON metadata for the +// struct [FileSearchToolFileSearchRankingOptions] +type fileSearchToolFileSearchRankingOptionsJSON struct { + Ranker apijson.Field + ScoreThreshold apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FileSearchToolFileSearchRankingOptions) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r fileSearchToolFileSearchRankingOptionsJSON) RawJSON() string { + return r.raw +} + +// The ranker to use for the file search. If not specified will use the `auto` +// ranker. +type FileSearchToolFileSearchRankingOptionsRanker string + +const ( + FileSearchToolFileSearchRankingOptionsRankerAuto FileSearchToolFileSearchRankingOptionsRanker = "auto" + FileSearchToolFileSearchRankingOptionsRankerDefault2024_08_21 FileSearchToolFileSearchRankingOptionsRanker = "default_2024_08_21" +) + +func (r FileSearchToolFileSearchRankingOptionsRanker) IsKnown() bool { + switch r { + case FileSearchToolFileSearchRankingOptionsRankerAuto, FileSearchToolFileSearchRankingOptionsRankerDefault2024_08_21: + return true + } + return false +} + type FileSearchToolParam struct { // The type of tool being defined: `file_search` Type param.Field[FileSearchToolType] `json:"type,required"` @@ -1902,15 +1958,39 @@ type FileSearchToolFileSearchParam struct { // // Note that the file search tool may output fewer than `max_num_results` results. // See the - // [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/number-of-chunks-returned) + // [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings) // for more information. MaxNumResults param.Field[int64] `json:"max_num_results"` + // The ranking options for the file search. + // + // See the + // [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings) + // for more information. + RankingOptions param.Field[FileSearchToolFileSearchRankingOptionsParam] `json:"ranking_options"` } func (r FileSearchToolFileSearchParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } +// The ranking options for the file search. +// +// See the +// [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings) +// for more information. +type FileSearchToolFileSearchRankingOptionsParam struct { + // The ranker to use for the file search. If not specified will use the `auto` + // ranker. + Ranker param.Field[FileSearchToolFileSearchRankingOptionsRanker] `json:"ranker"` + // The score threshold for the file search. All values must be a floating point + // number between 0 and 1. + ScoreThreshold param.Field[float64] `json:"score_threshold"` +} + +func (r FileSearchToolFileSearchRankingOptionsParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type FunctionTool struct { Function shared.FunctionDefinition `json:"function,required"` // The type of tool being defined: `function` diff --git a/betathreadrun.go b/betathreadrun.go index e211dc66..9b298b85 100644 --- a/betathreadrun.go +++ b/betathreadrun.go @@ -40,19 +40,19 @@ func NewBetaThreadRunService(opts ...option.RequestOption) (r *BetaThreadRunServ } // Create a run. -func (r *BetaThreadRunService) New(ctx context.Context, threadID string, body BetaThreadRunNewParams, opts ...option.RequestOption) (res *Run, err error) { +func (r *BetaThreadRunService) New(ctx context.Context, threadID string, params BetaThreadRunNewParams, opts ...option.RequestOption) (res *Run, err error) { opts = append(r.Options[:], opts...) if threadID == "" { err = errors.New("missing required thread_id parameter") return } path := fmt.Sprintf("threads/%s/runs", threadID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...) return } // Create a run. -func (r *BetaThreadRunService) NewStreaming(ctx context.Context, threadID string, body BetaThreadRunNewParams, opts ...option.RequestOption) (stream *ssestream.Stream[AssistantStreamEvent]) { +func (r *BetaThreadRunService) NewStreaming(ctx context.Context, threadID string, params BetaThreadRunNewParams, opts ...option.RequestOption) (stream *ssestream.Stream[AssistantStreamEvent]) { var ( raw *http.Response err error @@ -64,7 +64,7 @@ func (r *BetaThreadRunService) NewStreaming(ctx context.Context, threadID string return } path := fmt.Sprintf("threads/%s/runs", threadID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &raw, opts...) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &raw, opts...) return ssestream.NewStream[AssistantStreamEvent](ssestream.NewDecoder(raw), err) } @@ -660,6 +660,14 @@ type BetaThreadRunNewParams struct { // [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to // execute this run. AssistantID param.Field[string] `json:"assistant_id,required"` + // A list of additional fields to include in the response. Currently the only + // supported value is `step_details.tool_calls[*].file_search.results[*].content` + // to fetch the file search result content. + // + // See the + // [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings) + // for more information. + Include param.Field[[]RunStepInclude] `query:"include"` // Appends additional instructions at the end of the instructions for the run. This // is useful for modifying the behavior on a per-run basis without overriding other // instructions. @@ -726,6 +734,14 @@ func (r BetaThreadRunNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } +// URLQuery serializes [BetaThreadRunNewParams]'s query parameters as `url.Values`. +func (r BetaThreadRunNewParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + type BetaThreadRunNewParamsAdditionalMessage struct { // An array of content parts with a defined type, each can be of type `text` or // images can be passed with `image_url` or `image_file`. Image types are only diff --git a/betathreadrun_test.go b/betathreadrun_test.go index 6950ec30..50fe8584 100644 --- a/betathreadrun_test.go +++ b/betathreadrun_test.go @@ -30,6 +30,7 @@ func TestBetaThreadRunNewWithOptionalParams(t *testing.T) { "thread_id", openai.BetaThreadRunNewParams{ AssistantID: openai.F("assistant_id"), + Include: openai.F([]openai.RunStepInclude{openai.RunStepIncludeStepDetailsToolCallsFileSearchResultsContent}), AdditionalInstructions: openai.F("additional_instructions"), AdditionalMessages: openai.F([]openai.BetaThreadRunNewParamsAdditionalMessage{{ Content: openai.F([]openai.MessageContentPartParamUnion{openai.ImageFileContentBlockParam{ImageFile: openai.F(openai.ImageFileParam{FileID: openai.F("file_id"), Detail: openai.F(openai.ImageFileDetailAuto)}), Type: openai.F(openai.ImageFileContentBlockTypeImageFile)}}), diff --git a/betathreadrunstep.go b/betathreadrunstep.go index 59779b5a..78425cfd 100644 --- a/betathreadrunstep.go +++ b/betathreadrunstep.go @@ -39,7 +39,7 @@ func NewBetaThreadRunStepService(opts ...option.RequestOption) (r *BetaThreadRun } // Retrieves a run step. -func (r *BetaThreadRunStepService) Get(ctx context.Context, threadID string, runID string, stepID string, opts ...option.RequestOption) (res *RunStep, err error) { +func (r *BetaThreadRunStepService) Get(ctx context.Context, threadID string, runID string, stepID string, query BetaThreadRunStepGetParams, opts ...option.RequestOption) (res *RunStep, err error) { opts = append(r.Options[:], opts...) if threadID == "" { err = errors.New("missing required thread_id parameter") @@ -54,7 +54,7 @@ func (r *BetaThreadRunStepService) Get(ctx context.Context, threadID string, run return } path := fmt.Sprintf("threads/%s/runs/%s/steps/%s", threadID, runID, stepID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) return } @@ -645,7 +645,7 @@ type FileSearchToolCall struct { // The ID of the tool call object. ID string `json:"id,required"` // For now, this is always going to be an empty object. - FileSearch interface{} `json:"file_search,required"` + FileSearch FileSearchToolCallFileSearch `json:"file_search,required"` // The type of tool call. This is always going to be `file_search` for this type of // tool call. Type FileSearchToolCallType `json:"type,required"` @@ -672,6 +672,148 @@ func (r fileSearchToolCallJSON) RawJSON() string { func (r FileSearchToolCall) implementsToolCall() {} +// For now, this is always going to be an empty object. +type FileSearchToolCallFileSearch struct { + // The ranking options for the file search. + RankingOptions FileSearchToolCallFileSearchRankingOptions `json:"ranking_options"` + // The results of the file search. + Results []FileSearchToolCallFileSearchResult `json:"results"` + JSON fileSearchToolCallFileSearchJSON `json:"-"` +} + +// fileSearchToolCallFileSearchJSON contains the JSON metadata for the struct +// [FileSearchToolCallFileSearch] +type fileSearchToolCallFileSearchJSON struct { + RankingOptions apijson.Field + Results apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FileSearchToolCallFileSearch) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r fileSearchToolCallFileSearchJSON) RawJSON() string { + return r.raw +} + +// The ranking options for the file search. +type FileSearchToolCallFileSearchRankingOptions struct { + // The ranker used for the file search. + Ranker FileSearchToolCallFileSearchRankingOptionsRanker `json:"ranker,required"` + // The score threshold for the file search. All values must be a floating point + // number between 0 and 1. + ScoreThreshold float64 `json:"score_threshold,required"` + JSON fileSearchToolCallFileSearchRankingOptionsJSON `json:"-"` +} + +// fileSearchToolCallFileSearchRankingOptionsJSON contains the JSON metadata for +// the struct [FileSearchToolCallFileSearchRankingOptions] +type fileSearchToolCallFileSearchRankingOptionsJSON struct { + Ranker apijson.Field + ScoreThreshold apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FileSearchToolCallFileSearchRankingOptions) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r fileSearchToolCallFileSearchRankingOptionsJSON) RawJSON() string { + return r.raw +} + +// The ranker used for the file search. +type FileSearchToolCallFileSearchRankingOptionsRanker string + +const ( + FileSearchToolCallFileSearchRankingOptionsRankerDefault2024_08_21 FileSearchToolCallFileSearchRankingOptionsRanker = "default_2024_08_21" +) + +func (r FileSearchToolCallFileSearchRankingOptionsRanker) IsKnown() bool { + switch r { + case FileSearchToolCallFileSearchRankingOptionsRankerDefault2024_08_21: + return true + } + return false +} + +// A result instance of the file search. +type FileSearchToolCallFileSearchResult struct { + // The ID of the file that result was found in. + FileID string `json:"file_id,required"` + // The name of the file that result was found in. + FileName string `json:"file_name,required"` + // The score of the result. All values must be a floating point number between 0 + // and 1. + Score float64 `json:"score,required"` + // The content of the result that was found. The content is only included if + // requested via the include query parameter. + Content []FileSearchToolCallFileSearchResultsContent `json:"content"` + JSON fileSearchToolCallFileSearchResultJSON `json:"-"` +} + +// fileSearchToolCallFileSearchResultJSON contains the JSON metadata for the struct +// [FileSearchToolCallFileSearchResult] +type fileSearchToolCallFileSearchResultJSON struct { + FileID apijson.Field + FileName apijson.Field + Score apijson.Field + Content apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FileSearchToolCallFileSearchResult) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r fileSearchToolCallFileSearchResultJSON) RawJSON() string { + return r.raw +} + +type FileSearchToolCallFileSearchResultsContent struct { + // The text content of the file. + Text string `json:"text"` + // The type of the content. + Type FileSearchToolCallFileSearchResultsContentType `json:"type"` + JSON fileSearchToolCallFileSearchResultsContentJSON `json:"-"` +} + +// fileSearchToolCallFileSearchResultsContentJSON contains the JSON metadata for +// the struct [FileSearchToolCallFileSearchResultsContent] +type fileSearchToolCallFileSearchResultsContentJSON struct { + Text apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FileSearchToolCallFileSearchResultsContent) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r fileSearchToolCallFileSearchResultsContentJSON) RawJSON() string { + return r.raw +} + +// The type of the content. +type FileSearchToolCallFileSearchResultsContentType string + +const ( + FileSearchToolCallFileSearchResultsContentTypeText FileSearchToolCallFileSearchResultsContentType = "text" +) + +func (r FileSearchToolCallFileSearchResultsContentType) IsKnown() bool { + switch r { + case FileSearchToolCallFileSearchResultsContentTypeText: + return true + } + return false +} + // The type of tool call. This is always going to be `file_search` for this type of // tool call. type FileSearchToolCallType string @@ -1463,6 +1605,20 @@ func (r runStepDeltaMessageDeltaMessageCreationJSON) RawJSON() string { return r.raw } +type RunStepInclude string + +const ( + RunStepIncludeStepDetailsToolCallsFileSearchResultsContent RunStepInclude = "step_details.tool_calls[*].file_search.results[*].content" +) + +func (r RunStepInclude) IsKnown() bool { + switch r { + case RunStepIncludeStepDetailsToolCallsFileSearchResultsContent: + return true + } + return false +} + // Details of the Code Interpreter tool call the run step was involved in. type ToolCall struct { // The ID of the tool call. @@ -1473,7 +1629,7 @@ type ToolCall struct { // This field can have the runtime type of // [CodeInterpreterToolCallCodeInterpreter]. CodeInterpreter interface{} `json:"code_interpreter,required"` - // This field can have the runtime type of [interface{}]. + // This field can have the runtime type of [FileSearchToolCallFileSearch]. FileSearch interface{} `json:"file_search,required"` // This field can have the runtime type of [FunctionToolCallFunction]. Function interface{} `json:"function,required"` @@ -1754,6 +1910,26 @@ func (r ToolCallsStepDetailsType) IsKnown() bool { return false } +type BetaThreadRunStepGetParams struct { + // A list of additional fields to include in the response. Currently the only + // supported value is `step_details.tool_calls[*].file_search.results[*].content` + // to fetch the file search result content. + // + // See the + // [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings) + // for more information. + Include param.Field[[]RunStepInclude] `query:"include"` +} + +// URLQuery serializes [BetaThreadRunStepGetParams]'s query parameters as +// `url.Values`. +func (r BetaThreadRunStepGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatBrackets, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + type BetaThreadRunStepListParams struct { // A cursor for use in pagination. `after` is an object ID that defines your place // in the list. For instance, if you make a list request and receive 100 objects, @@ -1765,6 +1941,14 @@ type BetaThreadRunStepListParams struct { // ending with obj_foo, your subsequent call can include before=obj_foo in order to // fetch the previous page of the list. Before param.Field[string] `query:"before"` + // A list of additional fields to include in the response. Currently the only + // supported value is `step_details.tool_calls[*].file_search.results[*].content` + // to fetch the file search result content. + // + // See the + // [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search/customizing-file-search-settings) + // for more information. + Include param.Field[[]RunStepInclude] `query:"include"` // A limit on the number of objects to be returned. Limit can range between 1 and // 100, and the default is 20. Limit param.Field[int64] `query:"limit"` diff --git a/betathreadrunstep_test.go b/betathreadrunstep_test.go index 74a0601b..cbae8446 100644 --- a/betathreadrunstep_test.go +++ b/betathreadrunstep_test.go @@ -13,7 +13,7 @@ import ( "github.com/openai/openai-go/option" ) -func TestBetaThreadRunStepGet(t *testing.T) { +func TestBetaThreadRunStepGetWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -30,6 +30,9 @@ func TestBetaThreadRunStepGet(t *testing.T) { "thread_id", "run_id", "step_id", + openai.BetaThreadRunStepGetParams{ + Include: openai.F([]openai.RunStepInclude{openai.RunStepIncludeStepDetailsToolCallsFileSearchResultsContent}), + }, ) if err != nil { var apierr *openai.Error @@ -57,10 +60,11 @@ func TestBetaThreadRunStepListWithOptionalParams(t *testing.T) { "thread_id", "run_id", openai.BetaThreadRunStepListParams{ - After: openai.F("after"), - Before: openai.F("before"), - Limit: openai.F(int64(0)), - Order: openai.F(openai.BetaThreadRunStepListParamsOrderAsc), + After: openai.F("after"), + Before: openai.F("before"), + Include: openai.F([]openai.RunStepInclude{openai.RunStepIncludeStepDetailsToolCallsFileSearchResultsContent}), + Limit: openai.F(int64(0)), + Order: openai.F(openai.BetaThreadRunStepListParamsOrderAsc), }, ) if err != nil {