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

feat(vector store): improve chunking strategy type names #40

Merged
merged 1 commit into from
Sep 5, 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 .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-1dbac0e95bdb5a89a0dd3d93265475a378214551b7d8c22862928e0d87ace94b.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-85a85e0c08de456441431c0ae4e9c078cc8f9748c29430b9a9058340db6389ee.yml
11 changes: 11 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,19 @@ Methods:

## VectorStores

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#AutoFileChunkingStrategyParam">AutoFileChunkingStrategyParam</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#FileChunkingStrategyParamUnion">FileChunkingStrategyParamUnion</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#StaticFileChunkingStrategyParam">StaticFileChunkingStrategyParam</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#StaticFileChunkingStrategyParam">StaticFileChunkingStrategyParam</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#FileChunkingStrategy">FileChunkingStrategy</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#OtherFileChunkingStrategyObject">OtherFileChunkingStrategyObject</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#StaticFileChunkingStrategy">StaticFileChunkingStrategy</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#StaticFileChunkingStrategyObject">StaticFileChunkingStrategyObject</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#VectorStore">VectorStore</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#VectorStoreDeleted">VectorStoreDeleted</a>

Expand Down
117 changes: 2 additions & 115 deletions betaassistant.go
Original file line number Diff line number Diff line change
Expand Up @@ -2132,8 +2132,8 @@ func (r BetaAssistantNewParamsToolResourcesFileSearch) MarshalJSON() (data []byt

type BetaAssistantNewParamsToolResourcesFileSearchVectorStore struct {
// The chunking strategy used to chunk the file(s). If not set, will use the `auto`
// strategy.
ChunkingStrategy param.Field[BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyUnion] `json:"chunking_strategy"`
// strategy. Only applicable if `file_ids` is non-empty.
ChunkingStrategy param.Field[FileChunkingStrategyParamUnion] `json:"chunking_strategy"`
// A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
// add to the vector store. There can be a maximum of 10000 files in a vector
// store.
Expand All @@ -2149,119 +2149,6 @@ func (r BetaAssistantNewParamsToolResourcesFileSearchVectorStore) MarshalJSON()
return apijson.MarshalRoot(r)
}

// The chunking strategy used to chunk the file(s). If not set, will use the `auto`
// strategy.
type BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategy struct {
// Always `auto`.
Type param.Field[BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyType] `json:"type,required"`
Static param.Field[interface{}] `json:"static,required"`
}

func (r BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategy) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

func (r BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategy) implementsBetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyUnion() {
}

// The chunking strategy used to chunk the file(s). If not set, will use the `auto`
// strategy.
//
// Satisfied by
// [BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyAuto],
// [BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyStatic],
// [BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategy].
type BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyUnion interface {
implementsBetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyUnion()
}

// The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
// `800` and `chunk_overlap_tokens` of `400`.
type BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyAuto struct {
// Always `auto`.
Type param.Field[BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyAutoType] `json:"type,required"`
}

func (r BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyAuto) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

func (r BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyAuto) implementsBetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyUnion() {
}

// Always `auto`.
type BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyAutoType string

const (
BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyAutoTypeAuto BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyAutoType = "auto"
)

func (r BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyAutoType) IsKnown() bool {
switch r {
case BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyAutoTypeAuto:
return true
}
return false
}

type BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyStatic struct {
Static param.Field[BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyStaticStatic] `json:"static,required"`
// Always `static`.
Type param.Field[BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyStaticType] `json:"type,required"`
}

func (r BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyStatic) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

func (r BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyStatic) implementsBetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyUnion() {
}

type BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyStaticStatic struct {
// The number of tokens that overlap between chunks. The default value is `400`.
//
// Note that the overlap must not exceed half of `max_chunk_size_tokens`.
ChunkOverlapTokens param.Field[int64] `json:"chunk_overlap_tokens,required"`
// The maximum number of tokens in each chunk. The default value is `800`. The
// minimum value is `100` and the maximum value is `4096`.
MaxChunkSizeTokens param.Field[int64] `json:"max_chunk_size_tokens,required"`
}

func (r BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyStaticStatic) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

// Always `static`.
type BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyStaticType string

const (
BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyStaticTypeStatic BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyStaticType = "static"
)

func (r BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyStaticType) IsKnown() bool {
switch r {
case BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyStaticTypeStatic:
return true
}
return false
}

// Always `auto`.
type BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyType string

const (
BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyTypeAuto BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyType = "auto"
BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyTypeStatic BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyType = "static"
)

func (r BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyType) IsKnown() bool {
switch r {
case BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyTypeAuto, BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyTypeStatic:
return true
}
return false
}

type BetaAssistantUpdateParams struct {
// The description of the assistant. The maximum length is 512 characters.
Description param.Field[string] `json:"description"`
Expand Down
4 changes: 2 additions & 2 deletions betaassistant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func TestBetaAssistantNewWithOptionalParams(t *testing.T) {
FileSearch: openai.F(openai.BetaAssistantNewParamsToolResourcesFileSearch{
VectorStoreIDs: openai.F([]string{"string"}),
VectorStores: openai.F([]openai.BetaAssistantNewParamsToolResourcesFileSearchVectorStore{{
ChunkingStrategy: openai.F[openai.BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyUnion](openai.BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyAuto{
Type: openai.F(openai.BetaAssistantNewParamsToolResourcesFileSearchVectorStoresChunkingStrategyAutoTypeAuto),
ChunkingStrategy: openai.F[openai.FileChunkingStrategyParamUnion](openai.AutoFileChunkingStrategyParam{
Type: openai.F(openai.AutoFileChunkingStrategyParamTypeAuto),
}),
FileIDs: openai.F([]string{"string", "string", "string"}),
Metadata: openai.F[any](map[string]interface{}{}),
Expand Down
Loading