Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: 0.1.0-alpha.13 #33

Merged
merged 2 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.12"
".": "0.1.0-alpha.13"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.1.0-alpha.13 (2024-08-29)

Full Changelog: [v0.1.0-alpha.12...v0.1.0-alpha.13](https://github.com/openai/openai-go/compare/v0.1.0-alpha.12...v0.1.0-alpha.13)

### Features

* **api:** add file search result details to run steps ([#32](https://github.com/openai/openai-go/issues/32)) ([f6a1f12](https://github.com/openai/openai-go/commit/f6a1f12acbaf158af8009debcc2019d1b9e19104))

## 0.1.0-alpha.12 (2024-08-23)

Full Changelog: [v0.1.0-alpha.11...v0.1.0-alpha.12](https://github.com/openai/openai-go/compare/v0.1.0-alpha.11...v0.1.0-alpha.12)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Or to pin the version:
<!-- x-release-please-start-version -->

```sh
go get -u 'github.com/openai/openai-go@v0.1.0-alpha.12'
go get -u 'github.com/openai/openai-go@v0.1.0-alpha.13'
```

<!-- x-release-please-end -->
Expand Down
8 changes: 6 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ Response Types:

Methods:

- <code title="post /threads/{thread_id}/runs">client.Beta.Threads.Runs.<a href="https://pkg.go.dev/github.com/openai/openai-go#BetaThreadRunService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, threadID <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#BetaThreadRunNewParams">BetaThreadRunNewParams</a>) (<a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#Run">Run</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="post /threads/{thread_id}/runs">client.Beta.Threads.Runs.<a href="https://pkg.go.dev/github.com/openai/openai-go#BetaThreadRunService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, threadID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#BetaThreadRunNewParams">BetaThreadRunNewParams</a>) (<a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#Run">Run</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /threads/{thread_id}/runs/{run_id}">client.Beta.Threads.Runs.<a href="https://pkg.go.dev/github.com/openai/openai-go#BetaThreadRunService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, threadID <a href="https://pkg.go.dev/builtin#string">string</a>, runID <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#Run">Run</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="post /threads/{thread_id}/runs/{run_id}">client.Beta.Threads.Runs.<a href="https://pkg.go.dev/github.com/openai/openai-go#BetaThreadRunService.Update">Update</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, threadID <a href="https://pkg.go.dev/builtin#string">string</a>, runID <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#BetaThreadRunUpdateParams">BetaThreadRunUpdateParams</a>) (<a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#Run">Run</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /threads/{thread_id}/runs">client.Beta.Threads.Runs.<a href="https://pkg.go.dev/github.com/openai/openai-go#BetaThreadRunService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, threadID <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#BetaThreadRunListParams">BetaThreadRunListParams</a>) (<a href="https://pkg.go.dev/github.com/openai/openai-go/internal/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/internal/pagination#CursorPage">CursorPage</a>[<a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#Run">Run</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
Expand All @@ -317,6 +317,10 @@ Methods:

#### Steps

Params Types:

- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#RunStepInclude">RunStepInclude</a>

Response Types:

- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#CodeInterpreterLogs">CodeInterpreterLogs</a>
Expand All @@ -339,7 +343,7 @@ Response Types:

Methods:

- <code title="get /threads/{thread_id}/runs/{run_id}/steps/{step_id}">client.Beta.Threads.Runs.Steps.<a href="https://pkg.go.dev/github.com/openai/openai-go#BetaThreadRunStepService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, threadID <a href="https://pkg.go.dev/builtin#string">string</a>, runID <a href="https://pkg.go.dev/builtin#string">string</a>, stepID <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#RunStep">RunStep</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /threads/{thread_id}/runs/{run_id}/steps/{step_id}">client.Beta.Threads.Runs.Steps.<a href="https://pkg.go.dev/github.com/openai/openai-go#BetaThreadRunStepService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, threadID <a href="https://pkg.go.dev/builtin#string">string</a>, runID <a href="https://pkg.go.dev/builtin#string">string</a>, stepID <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#BetaThreadRunStepGetParams">BetaThreadRunStepGetParams</a>) (<a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#RunStep">RunStep</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /threads/{thread_id}/runs/{run_id}/steps">client.Beta.Threads.Runs.Steps.<a href="https://pkg.go.dev/github.com/openai/openai-go#BetaThreadRunStepService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, threadID <a href="https://pkg.go.dev/builtin#string">string</a>, runID <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#BetaThreadRunStepListParams">BetaThreadRunStepListParams</a>) (<a href="https://pkg.go.dev/github.com/openai/openai-go/internal/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/internal/pagination#CursorPage">CursorPage</a>[<a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#RunStep">RunStep</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

### Messages
Expand Down
116 changes: 98 additions & 18 deletions betaassistant.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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"`
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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"`
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand All @@ -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"`
Expand All @@ -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`
Expand Down
24 changes: 20 additions & 4 deletions betathreadrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
Loading
Loading