From c7fafed933890ba05c37e6ab54cd5163d00801fc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Nov 2025 23:54:34 +0000 Subject: [PATCH 1/7] chore: use Pydantic to generate OpenAPI schema --- .stats.yml | 8 +- README.md | 10 +- alphabenchmark.go | 141 +- alphabenchmark_test.go | 27 +- alphaeval.go | 369 +- alphaeval_test.go | 96 +- alphainference.go | 95 +- alphaposttraining.go | 688 ++- alphaposttraining_test.go | 45 +- alphaposttrainingjob.go | 176 +- api.md | 47 +- batch.go | 917 ++++ batch_test.go | 115 + betadataset.go | 779 +--- betadataset_test.go | 22 +- chat.go | 129 +- chatcompletion.go | 4084 ++++++++---------- chatcompletion_test.go | 23 +- client.go | 2 + client_test.go | 10 + completion.go | 174 +- completion_test.go | 6 +- conversation.go | 886 ++-- conversation_test.go | 3 +- conversationitem.go | 3745 +++++++++------- conversationitem_test.go | 30 +- embedding.go | 80 +- file.go | 113 +- file_test.go | 2 +- inspect.go | 139 +- model.go | 291 +- model_test.go | 6 +- moderation.go | 98 +- prompt.go | 58 +- prompt_test.go | 2 +- promptversion.go | 4 +- provider.go | 9 +- response.go | 7862 +++++++++++++++++----------------- response_test.go | 13 +- responseinputitem.go | 856 ++-- route.go | 15 +- safety.go | 483 +-- safety_test.go | 7 +- scoring.go | 379 +- scoring_test.go | 26 +- scoringfunction.go | 452 +- scoringfunction_test.go | 42 +- shared.go | 1046 ++--- shared/constant/constants.go | 388 +- shield.go | 113 +- shield_test.go | 6 +- tool.go | 2 - toolgroup.go | 129 +- toolgroup_test.go | 6 +- toolruntime.go | 445 +- toolruntime_test.go | 6 +- toolruntimeragtool.go | 32 - usage_test.go | 6 +- vectorio.go | 1012 ++++- vectorio_test.go | 18 +- vectorstore.go | 614 +-- vectorstore_test.go | 34 +- vectorstorefile.go | 399 +- vectorstorefile_test.go | 16 +- vectorstorefilebatch.go | 167 +- vectorstorefilebatch_test.go | 10 +- 66 files changed, 13807 insertions(+), 14206 deletions(-) create mode 100644 batch.go create mode 100644 batch_test.go delete mode 100644 toolruntimeragtool.go diff --git a/.stats.yml b/.stats.yml index c4e4ef9..253e4ba 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 96 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-602ce64aa309cc15fa09388d99c9f298795686fc37605237cbc03c39d29aabf6.yml -openapi_spec_hash: fc6995247b2555e8660bc9291eb10415 -config_hash: e8a35d9d37cb4774b4b0fe1b167dc156 +configured_endpoints: 103 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-2b99a80543f8bc8fa164167693c214651ac8e710f4726fb5869183b4d6c71a03.yml +openapi_spec_hash: a5632057f5e4d956a71c20a79c0d879c +config_hash: 0017f6c419cbbf7b949f9b2842917a79 diff --git a/README.md b/README.md index b5c682f..04f3789 100644 --- a/README.md +++ b/README.md @@ -53,13 +53,11 @@ import ( func main() { client := llamastackclient.NewClient() - response, err := client.Models.Register(context.TODO(), llamastackclient.ModelRegisterParams{ - ModelID: "model_id", - }) + models, err := client.Models.List(context.TODO()) if err != nil { panic(err.Error()) } - fmt.Printf("%+v\n", response.Identifier) + fmt.Printf("%+v\n", models) } ``` @@ -302,6 +300,7 @@ _, err := client.Chat.Completions.New(context.TODO(), llamastackclient.ChatCompl Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, + Role: "user", }, }}, Model: "model", @@ -338,6 +337,7 @@ client.Chat.Completions.New( Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, + Role: "user", }, }}, Model: "model", @@ -404,6 +404,7 @@ client.Chat.Completions.New( Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, + Role: "user", }, }}, Model: "model", @@ -428,6 +429,7 @@ completion, err := client.Chat.Completions.New( Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, + Role: "user", }, }}, Model: "model", diff --git a/alphabenchmark.go b/alphabenchmark.go index 6f433bd..33d0cfc 100644 --- a/alphabenchmark.go +++ b/alphabenchmark.go @@ -10,7 +10,6 @@ package llamastackclient import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -21,7 +20,6 @@ import ( "github.com/llamastack/llama-stack-client-go/option" "github.com/llamastack/llama-stack-client-go/packages/param" "github.com/llamastack/llama-stack-client-go/packages/respjson" - "github.com/llamastack/llama-stack-client-go/shared/constant" ) // AlphaBenchmarkService contains methods and other services that help with @@ -79,28 +77,44 @@ func (r *AlphaBenchmarkService) Register(ctx context.Context, body AlphaBenchmar return } +// Unregister a benchmark. +// +// Deprecated: deprecated +func (r *AlphaBenchmarkService) Unregister(ctx context.Context, benchmarkID string, opts ...option.RequestOption) (err error) { + opts = slices.Concat(r.Options, opts) + opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + if benchmarkID == "" { + err = errors.New("missing required benchmark_id parameter") + return + } + path := fmt.Sprintf("v1alpha/eval/benchmarks/%s", benchmarkID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...) + return +} + // A benchmark resource for evaluating model performance. type Benchmark struct { - // Identifier of the dataset to use for the benchmark evaluation - DatasetID string `json:"dataset_id,required"` + DatasetID string `json:"dataset_id,required"` + // Unique identifier for this resource in llama stack Identifier string `json:"identifier,required"` - // Metadata for this evaluation task - Metadata map[string]BenchmarkMetadataUnion `json:"metadata,required"` - ProviderID string `json:"provider_id,required"` - // List of scoring function identifiers to apply during evaluation + // ID of the provider that owns this resource + ProviderID string `json:"provider_id,required"` ScoringFunctions []string `json:"scoring_functions,required"` - // The resource type, always benchmark - Type constant.Benchmark `json:"type,required"` - ProviderResourceID string `json:"provider_resource_id"` + // Metadata for this evaluation task + Metadata map[string]any `json:"metadata"` + // Unique identifier for this resource in the provider + ProviderResourceID string `json:"provider_resource_id,nullable"` + // Any of "benchmark". + Type BenchmarkType `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { DatasetID respjson.Field Identifier respjson.Field - Metadata respjson.Field ProviderID respjson.Field ScoringFunctions respjson.Field - Type respjson.Field + Metadata respjson.Field ProviderResourceID respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -112,57 +126,11 @@ func (r *Benchmark) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// BenchmarkMetadataUnion contains all possible properties and values from [bool], -// [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type BenchmarkMetadataUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u BenchmarkMetadataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u BenchmarkMetadataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u BenchmarkMetadataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} +type BenchmarkType string -func (u BenchmarkMetadataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u BenchmarkMetadataUnion) RawJSON() string { return u.JSON.raw } - -func (r *BenchmarkMetadataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} +const ( + BenchmarkTypeBenchmark BenchmarkType = "benchmark" +) type ListBenchmarksResponse struct { Data []Benchmark `json:"data,required"` @@ -181,18 +149,12 @@ func (r *ListBenchmarksResponse) UnmarshalJSON(data []byte) error { } type AlphaBenchmarkRegisterParams struct { - // The ID of the benchmark to register. - BenchmarkID string `json:"benchmark_id,required"` - // The ID of the dataset to use for the benchmark. - DatasetID string `json:"dataset_id,required"` - // The scoring functions to use for the benchmark. - ScoringFunctions []string `json:"scoring_functions,omitzero,required"` - // The ID of the provider benchmark to use for the benchmark. + BenchmarkID string `json:"benchmark_id,required"` + DatasetID string `json:"dataset_id,required"` + ScoringFunctions []string `json:"scoring_functions,omitzero,required"` ProviderBenchmarkID param.Opt[string] `json:"provider_benchmark_id,omitzero"` - // The ID of the provider to use for the benchmark. - ProviderID param.Opt[string] `json:"provider_id,omitzero"` - // The metadata to use for the benchmark. - Metadata map[string]AlphaBenchmarkRegisterParamsMetadataUnion `json:"metadata,omitzero"` + ProviderID param.Opt[string] `json:"provider_id,omitzero"` + Metadata map[string]any `json:"metadata,omitzero"` paramObj } @@ -203,34 +165,3 @@ func (r AlphaBenchmarkRegisterParams) MarshalJSON() (data []byte, err error) { func (r *AlphaBenchmarkRegisterParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type AlphaBenchmarkRegisterParamsMetadataUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u AlphaBenchmarkRegisterParamsMetadataUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *AlphaBenchmarkRegisterParamsMetadataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *AlphaBenchmarkRegisterParamsMetadataUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} diff --git a/alphabenchmark_test.go b/alphabenchmark_test.go index 4602eae..1a2ed1a 100644 --- a/alphabenchmark_test.go +++ b/alphabenchmark_test.go @@ -76,10 +76,8 @@ func TestAlphaBenchmarkRegisterWithOptionalParams(t *testing.T) { BenchmarkID: "benchmark_id", DatasetID: "dataset_id", ScoringFunctions: []string{"string"}, - Metadata: map[string]llamastackclient.AlphaBenchmarkRegisterParamsMetadataUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + Metadata: map[string]any{ + "foo": "bar", }, ProviderBenchmarkID: llamastackclient.String("provider_benchmark_id"), ProviderID: llamastackclient.String("provider_id"), @@ -92,3 +90,24 @@ func TestAlphaBenchmarkRegisterWithOptionalParams(t *testing.T) { t.Fatalf("err should be nil: %s", err.Error()) } } + +func TestAlphaBenchmarkUnregister(t *testing.T) { + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := llamastackclient.NewClient( + option.WithBaseURL(baseURL), + ) + err := client.Alpha.Benchmarks.Unregister(context.TODO(), "benchmark_id") + if err != nil { + var apierr *llamastackclient.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} diff --git a/alphaeval.go b/alphaeval.go index ba5de6c..0a40f86 100644 --- a/alphaeval.go +++ b/alphaeval.go @@ -17,11 +17,11 @@ import ( "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" + shimjson "github.com/llamastack/llama-stack-client-go/internal/encoding/json" "github.com/llamastack/llama-stack-client-go/internal/requestconfig" "github.com/llamastack/llama-stack-client-go/option" "github.com/llamastack/llama-stack-client-go/packages/param" "github.com/llamastack/llama-stack-client-go/packages/respjson" - "github.com/llamastack/llama-stack-client-go/shared/constant" ) // AlphaEvalService contains methods and other services that help with interacting @@ -95,16 +95,16 @@ func (r *AlphaEvalService) RunEvalAlpha(ctx context.Context, benchmarkID string, // A benchmark configuration for evaluation. // -// The properties EvalCandidate, ScoringParams are required. +// The property EvalCandidate is required. type BenchmarkConfigParam struct { - // The candidate to evaluate. + // A model candidate for evaluation. EvalCandidate BenchmarkConfigEvalCandidateParam `json:"eval_candidate,omitzero,required"` + // Number of examples to evaluate (useful for testing), if not provided, all + // examples in the dataset will be evaluated + NumExamples param.Opt[int64] `json:"num_examples,omitzero"` // Map between scoring function id and parameters for each scoring function you // want to run - ScoringParams map[string]ScoringFnParamsUnion `json:"scoring_params,omitzero,required"` - // (Optional) The number of examples to evaluate. If not provided, all examples in - // the dataset will be evaluated - NumExamples param.Opt[int64] `json:"num_examples,omitzero"` + ScoringParams map[string]BenchmarkConfigScoringParamUnionParam `json:"scoring_params,omitzero"` paramObj } @@ -116,18 +116,17 @@ func (r *BenchmarkConfigParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// The candidate to evaluate. +// A model candidate for evaluation. // -// The properties Model, SamplingParams, Type are required. +// The properties Model, SamplingParams are required. type BenchmarkConfigEvalCandidateParam struct { - // The model ID to evaluate. Model string `json:"model,required"` - // The sampling parameters for the model. + // Sampling parameters. SamplingParams SamplingParams `json:"sampling_params,omitzero,required"` - // (Optional) The system message providing instructions or context to the model. + // A system message providing instructions or context to the model. SystemMessage SystemMessageParam `json:"system_message,omitzero"` - // This field can be elided, and will marshal its zero value as "model". - Type constant.Model `json:"type,required"` + // Any of "model". + Type string `json:"type,omitzero"` paramObj } @@ -139,84 +138,212 @@ func (r *BenchmarkConfigEvalCandidateParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// The response from an evaluation. -type EvaluateResponse struct { - // The generations from the evaluation. - Generations []map[string]EvaluateResponseGenerationUnion `json:"generations,required"` - // The scores from the evaluation. - Scores map[string]ScoringResult `json:"scores,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Generations respjson.Field - Scores respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` +func init() { + apijson.RegisterFieldValidator[BenchmarkConfigEvalCandidateParam]( + "type", "model", + ) } -// Returns the unmodified JSON received from the API -func (r EvaluateResponse) RawJSON() string { return r.JSON.raw } -func (r *EvaluateResponse) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) +// Only one field can be non-zero. +// +// Use [param.IsOmitted] to confirm if a field is set. +type BenchmarkConfigScoringParamUnionParam struct { + OfLlmAsJudge *BenchmarkConfigScoringParamLlmAsJudgeParam `json:",omitzero,inline"` + OfRegexParser *BenchmarkConfigScoringParamRegexParserParam `json:",omitzero,inline"` + OfBasic *BenchmarkConfigScoringParamBasicParam `json:",omitzero,inline"` + paramUnion } -// EvaluateResponseGenerationUnion contains all possible properties and values from -// [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. +func (u BenchmarkConfigScoringParamUnionParam) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfLlmAsJudge, u.OfRegexParser, u.OfBasic) +} +func (u *BenchmarkConfigScoringParamUnionParam) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *BenchmarkConfigScoringParamUnionParam) asAny() any { + if !param.IsOmitted(u.OfLlmAsJudge) { + return u.OfLlmAsJudge + } else if !param.IsOmitted(u.OfRegexParser) { + return u.OfRegexParser + } else if !param.IsOmitted(u.OfBasic) { + return u.OfBasic + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u BenchmarkConfigScoringParamUnionParam) GetJudgeModel() *string { + if vt := u.OfLlmAsJudge; vt != nil { + return &vt.JudgeModel + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u BenchmarkConfigScoringParamUnionParam) GetJudgeScoreRegexes() []string { + if vt := u.OfLlmAsJudge; vt != nil { + return vt.JudgeScoreRegexes + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u BenchmarkConfigScoringParamUnionParam) GetPromptTemplate() *string { + if vt := u.OfLlmAsJudge; vt != nil && vt.PromptTemplate.Valid() { + return &vt.PromptTemplate.Value + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u BenchmarkConfigScoringParamUnionParam) GetParsingRegexes() []string { + if vt := u.OfRegexParser; vt != nil { + return vt.ParsingRegexes + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u BenchmarkConfigScoringParamUnionParam) GetType() *string { + if vt := u.OfLlmAsJudge; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfRegexParser; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfBasic; vt != nil { + return (*string)(&vt.Type) + } + return nil +} + +// Returns a pointer to the underlying variant's AggregationFunctions property, if +// present. +func (u BenchmarkConfigScoringParamUnionParam) GetAggregationFunctions() []string { + if vt := u.OfLlmAsJudge; vt != nil { + return vt.AggregationFunctions + } else if vt := u.OfRegexParser; vt != nil { + return vt.AggregationFunctions + } else if vt := u.OfBasic; vt != nil { + return vt.AggregationFunctions + } + return nil +} + +func init() { + apijson.RegisterUnion[BenchmarkConfigScoringParamUnionParam]( + "type", + apijson.Discriminator[BenchmarkConfigScoringParamLlmAsJudgeParam]("llm_as_judge"), + apijson.Discriminator[BenchmarkConfigScoringParamRegexParserParam]("regex_parser"), + apijson.Discriminator[BenchmarkConfigScoringParamBasicParam]("basic"), + ) +} + +// Parameters for LLM-as-judge scoring function configuration. // -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type EvaluateResponseGenerationUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` +// The property JudgeModel is required. +type BenchmarkConfigScoringParamLlmAsJudgeParam struct { + JudgeModel string `json:"judge_model,required"` + PromptTemplate param.Opt[string] `json:"prompt_template,omitzero"` + // Aggregation functions to apply to the scores of each row + // + // Any of "average", "weighted_average", "median", "categorical_count", "accuracy". + AggregationFunctions []string `json:"aggregation_functions,omitzero"` + // Regexes to extract the answer from generated response + JudgeScoreRegexes []string `json:"judge_score_regexes,omitzero"` + // Any of "llm_as_judge". + Type string `json:"type,omitzero"` + paramObj } -func (u EvaluateResponseGenerationUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +func (r BenchmarkConfigScoringParamLlmAsJudgeParam) MarshalJSON() (data []byte, err error) { + type shadow BenchmarkConfigScoringParamLlmAsJudgeParam + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *BenchmarkConfigScoringParamLlmAsJudgeParam) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u EvaluateResponseGenerationUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +func init() { + apijson.RegisterFieldValidator[BenchmarkConfigScoringParamLlmAsJudgeParam]( + "type", "llm_as_judge", + ) } -func (u EvaluateResponseGenerationUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Parameters for regex parser scoring function configuration. +type BenchmarkConfigScoringParamRegexParserParam struct { + // Aggregation functions to apply to the scores of each row + // + // Any of "average", "weighted_average", "median", "categorical_count", "accuracy". + AggregationFunctions []string `json:"aggregation_functions,omitzero"` + // Regex to extract the answer from generated response + ParsingRegexes []string `json:"parsing_regexes,omitzero"` + // Any of "regex_parser". + Type string `json:"type,omitzero"` + paramObj } -func (u EvaluateResponseGenerationUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +func (r BenchmarkConfigScoringParamRegexParserParam) MarshalJSON() (data []byte, err error) { + type shadow BenchmarkConfigScoringParamRegexParserParam + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *BenchmarkConfigScoringParamRegexParserParam) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -// Returns the unmodified JSON received from the API -func (u EvaluateResponseGenerationUnion) RawJSON() string { return u.JSON.raw } +func init() { + apijson.RegisterFieldValidator[BenchmarkConfigScoringParamRegexParserParam]( + "type", "regex_parser", + ) +} + +// Parameters for basic scoring function configuration. +type BenchmarkConfigScoringParamBasicParam struct { + // Aggregation functions to apply to the scores of each row + // + // Any of "average", "weighted_average", "median", "categorical_count", "accuracy". + AggregationFunctions []string `json:"aggregation_functions,omitzero"` + // Any of "basic". + Type string `json:"type,omitzero"` + paramObj +} + +func (r BenchmarkConfigScoringParamBasicParam) MarshalJSON() (data []byte, err error) { + type shadow BenchmarkConfigScoringParamBasicParam + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *BenchmarkConfigScoringParamBasicParam) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} -func (r *EvaluateResponseGenerationUnion) UnmarshalJSON(data []byte) error { +func init() { + apijson.RegisterFieldValidator[BenchmarkConfigScoringParamBasicParam]( + "type", "basic", + ) +} + +// The response from an evaluation. +type EvaluateResponse struct { + Generations []map[string]any `json:"generations,required"` + Scores map[string]ScoringResult `json:"scores,required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Generations respjson.Field + Scores respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r EvaluateResponse) RawJSON() string { return r.JSON.raw } +func (r *EvaluateResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A job execution instance with status tracking. type Job struct { - // Unique identifier for the job JobID string `json:"job_id,required"` - // Current execution status of the job + // Status of a job execution. // // Any of "completed", "in_progress", "failed", "scheduled", "cancelled". Status JobStatus `json:"status,required"` @@ -235,7 +362,7 @@ func (r *Job) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Current execution status of the job +// Status of a job execution. type JobStatus string const ( @@ -247,12 +374,10 @@ const ( ) type AlphaEvalEvaluateRowsParams struct { - // The configuration for the benchmark. - BenchmarkConfig BenchmarkConfigParam `json:"benchmark_config,omitzero,required"` - // The rows to evaluate. - InputRows []map[string]AlphaEvalEvaluateRowsParamsInputRowUnion `json:"input_rows,omitzero,required"` - // The scoring functions to use for the evaluation. - ScoringFunctions []string `json:"scoring_functions,omitzero,required"` + // A benchmark configuration for evaluation. + BenchmarkConfig BenchmarkConfigParam `json:"benchmark_config,omitzero,required"` + InputRows []map[string]any `json:"input_rows,omitzero,required"` + ScoringFunctions []string `json:"scoring_functions,omitzero,required"` paramObj } @@ -264,44 +389,11 @@ func (r *AlphaEvalEvaluateRowsParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type AlphaEvalEvaluateRowsParamsInputRowUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u AlphaEvalEvaluateRowsParamsInputRowUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *AlphaEvalEvaluateRowsParamsInputRowUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *AlphaEvalEvaluateRowsParamsInputRowUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - type AlphaEvalEvaluateRowsAlphaParams struct { - // The configuration for the benchmark. - BenchmarkConfig BenchmarkConfigParam `json:"benchmark_config,omitzero,required"` - // The rows to evaluate. - InputRows []map[string]AlphaEvalEvaluateRowsAlphaParamsInputRowUnion `json:"input_rows,omitzero,required"` - // The scoring functions to use for the evaluation. - ScoringFunctions []string `json:"scoring_functions,omitzero,required"` + // A benchmark configuration for evaluation. + BenchmarkConfig BenchmarkConfigParam `json:"benchmark_config,omitzero,required"` + InputRows []map[string]any `json:"input_rows,omitzero,required"` + ScoringFunctions []string `json:"scoring_functions,omitzero,required"` paramObj } @@ -313,61 +405,28 @@ func (r *AlphaEvalEvaluateRowsAlphaParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type AlphaEvalEvaluateRowsAlphaParamsInputRowUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u AlphaEvalEvaluateRowsAlphaParamsInputRowUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *AlphaEvalEvaluateRowsAlphaParamsInputRowUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *AlphaEvalEvaluateRowsAlphaParamsInputRowUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - type AlphaEvalRunEvalParams struct { - // The configuration for the benchmark. - BenchmarkConfig BenchmarkConfigParam `json:"benchmark_config,omitzero,required"` + // A benchmark configuration for evaluation. + BenchmarkConfig BenchmarkConfigParam paramObj } func (r AlphaEvalRunEvalParams) MarshalJSON() (data []byte, err error) { - type shadow AlphaEvalRunEvalParams - return param.MarshalObject(r, (*shadow)(&r)) + return shimjson.Marshal(r.BenchmarkConfig) } func (r *AlphaEvalRunEvalParams) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) + return json.Unmarshal(data, &r.BenchmarkConfig) } type AlphaEvalRunEvalAlphaParams struct { - // The configuration for the benchmark. - BenchmarkConfig BenchmarkConfigParam `json:"benchmark_config,omitzero,required"` + // A benchmark configuration for evaluation. + BenchmarkConfig BenchmarkConfigParam paramObj } func (r AlphaEvalRunEvalAlphaParams) MarshalJSON() (data []byte, err error) { - type shadow AlphaEvalRunEvalAlphaParams - return param.MarshalObject(r, (*shadow)(&r)) + return shimjson.Marshal(r.BenchmarkConfig) } func (r *AlphaEvalRunEvalAlphaParams) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) + return json.Unmarshal(data, &r.BenchmarkConfig) } diff --git a/alphaeval_test.go b/alphaeval_test.go index ccb533b..9f65654 100644 --- a/alphaeval_test.go +++ b/alphaeval_test.go @@ -38,35 +38,38 @@ func TestAlphaEvalEvaluateRowsWithOptionalParams(t *testing.T) { EvalCandidate: llamastackclient.BenchmarkConfigEvalCandidateParam{ Model: "model", SamplingParams: llamastackclient.SamplingParams{ - Strategy: llamastackclient.SamplingParamsStrategyUnion{ - OfGreedy: &llamastackclient.SamplingParamsStrategyGreedy{}, - }, MaxTokens: llamastackclient.Int(0), RepetitionPenalty: llamastackclient.Float(0), Stop: []string{"string"}, + Strategy: llamastackclient.SamplingParamsStrategyUnion{ + OfGreedy: &llamastackclient.SamplingParamsStrategyGreedy{ + Type: "greedy", + }, + }, }, SystemMessage: llamastackclient.SystemMessageParam{ - Content: llamastackclient.InterleavedContentUnionParam{ + Content: llamastackclient.SystemMessageContentUnionParam{ OfString: llamastackclient.String("string"), }, + Role: llamastackclient.SystemMessageRoleSystem, }, + Type: "model", }, - ScoringParams: map[string]llamastackclient.ScoringFnParamsUnion{ + NumExamples: llamastackclient.Int(0), + ScoringParams: map[string]llamastackclient.BenchmarkConfigScoringParamUnionParam{ "foo": { - OfLlmAsJudge: &llamastackclient.ScoringFnParamsLlmAsJudge{ - AggregationFunctions: []string{"average"}, + OfLlmAsJudge: &llamastackclient.BenchmarkConfigScoringParamLlmAsJudgeParam{ JudgeModel: "judge_model", + AggregationFunctions: []string{"average"}, JudgeScoreRegexes: []string{"string"}, PromptTemplate: llamastackclient.String("prompt_template"), + Type: "llm_as_judge", }, }, }, - NumExamples: llamastackclient.Int(0), }, - InputRows: []map[string]llamastackclient.AlphaEvalEvaluateRowsParamsInputRowUnion{{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + InputRows: []map[string]any{{ + "foo": "bar", }}, ScoringFunctions: []string{"string"}, }, @@ -99,35 +102,38 @@ func TestAlphaEvalEvaluateRowsAlphaWithOptionalParams(t *testing.T) { EvalCandidate: llamastackclient.BenchmarkConfigEvalCandidateParam{ Model: "model", SamplingParams: llamastackclient.SamplingParams{ - Strategy: llamastackclient.SamplingParamsStrategyUnion{ - OfGreedy: &llamastackclient.SamplingParamsStrategyGreedy{}, - }, MaxTokens: llamastackclient.Int(0), RepetitionPenalty: llamastackclient.Float(0), Stop: []string{"string"}, + Strategy: llamastackclient.SamplingParamsStrategyUnion{ + OfGreedy: &llamastackclient.SamplingParamsStrategyGreedy{ + Type: "greedy", + }, + }, }, SystemMessage: llamastackclient.SystemMessageParam{ - Content: llamastackclient.InterleavedContentUnionParam{ + Content: llamastackclient.SystemMessageContentUnionParam{ OfString: llamastackclient.String("string"), }, + Role: llamastackclient.SystemMessageRoleSystem, }, + Type: "model", }, - ScoringParams: map[string]llamastackclient.ScoringFnParamsUnion{ + NumExamples: llamastackclient.Int(0), + ScoringParams: map[string]llamastackclient.BenchmarkConfigScoringParamUnionParam{ "foo": { - OfLlmAsJudge: &llamastackclient.ScoringFnParamsLlmAsJudge{ - AggregationFunctions: []string{"average"}, + OfLlmAsJudge: &llamastackclient.BenchmarkConfigScoringParamLlmAsJudgeParam{ JudgeModel: "judge_model", + AggregationFunctions: []string{"average"}, JudgeScoreRegexes: []string{"string"}, PromptTemplate: llamastackclient.String("prompt_template"), + Type: "llm_as_judge", }, }, }, - NumExamples: llamastackclient.Int(0), }, - InputRows: []map[string]llamastackclient.AlphaEvalEvaluateRowsAlphaParamsInputRowUnion{{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + InputRows: []map[string]any{{ + "foo": "bar", }}, ScoringFunctions: []string{"string"}, }, @@ -160,30 +166,35 @@ func TestAlphaEvalRunEvalWithOptionalParams(t *testing.T) { EvalCandidate: llamastackclient.BenchmarkConfigEvalCandidateParam{ Model: "model", SamplingParams: llamastackclient.SamplingParams{ - Strategy: llamastackclient.SamplingParamsStrategyUnion{ - OfGreedy: &llamastackclient.SamplingParamsStrategyGreedy{}, - }, MaxTokens: llamastackclient.Int(0), RepetitionPenalty: llamastackclient.Float(0), Stop: []string{"string"}, + Strategy: llamastackclient.SamplingParamsStrategyUnion{ + OfGreedy: &llamastackclient.SamplingParamsStrategyGreedy{ + Type: "greedy", + }, + }, }, SystemMessage: llamastackclient.SystemMessageParam{ - Content: llamastackclient.InterleavedContentUnionParam{ + Content: llamastackclient.SystemMessageContentUnionParam{ OfString: llamastackclient.String("string"), }, + Role: llamastackclient.SystemMessageRoleSystem, }, + Type: "model", }, - ScoringParams: map[string]llamastackclient.ScoringFnParamsUnion{ + NumExamples: llamastackclient.Int(0), + ScoringParams: map[string]llamastackclient.BenchmarkConfigScoringParamUnionParam{ "foo": { - OfLlmAsJudge: &llamastackclient.ScoringFnParamsLlmAsJudge{ - AggregationFunctions: []string{"average"}, + OfLlmAsJudge: &llamastackclient.BenchmarkConfigScoringParamLlmAsJudgeParam{ JudgeModel: "judge_model", + AggregationFunctions: []string{"average"}, JudgeScoreRegexes: []string{"string"}, PromptTemplate: llamastackclient.String("prompt_template"), + Type: "llm_as_judge", }, }, }, - NumExamples: llamastackclient.Int(0), }, }, ) @@ -215,30 +226,35 @@ func TestAlphaEvalRunEvalAlphaWithOptionalParams(t *testing.T) { EvalCandidate: llamastackclient.BenchmarkConfigEvalCandidateParam{ Model: "model", SamplingParams: llamastackclient.SamplingParams{ - Strategy: llamastackclient.SamplingParamsStrategyUnion{ - OfGreedy: &llamastackclient.SamplingParamsStrategyGreedy{}, - }, MaxTokens: llamastackclient.Int(0), RepetitionPenalty: llamastackclient.Float(0), Stop: []string{"string"}, + Strategy: llamastackclient.SamplingParamsStrategyUnion{ + OfGreedy: &llamastackclient.SamplingParamsStrategyGreedy{ + Type: "greedy", + }, + }, }, SystemMessage: llamastackclient.SystemMessageParam{ - Content: llamastackclient.InterleavedContentUnionParam{ + Content: llamastackclient.SystemMessageContentUnionParam{ OfString: llamastackclient.String("string"), }, + Role: llamastackclient.SystemMessageRoleSystem, }, + Type: "model", }, - ScoringParams: map[string]llamastackclient.ScoringFnParamsUnion{ + NumExamples: llamastackclient.Int(0), + ScoringParams: map[string]llamastackclient.BenchmarkConfigScoringParamUnionParam{ "foo": { - OfLlmAsJudge: &llamastackclient.ScoringFnParamsLlmAsJudge{ - AggregationFunctions: []string{"average"}, + OfLlmAsJudge: &llamastackclient.BenchmarkConfigScoringParamLlmAsJudgeParam{ JudgeModel: "judge_model", + AggregationFunctions: []string{"average"}, JudgeScoreRegexes: []string{"string"}, PromptTemplate: llamastackclient.String("prompt_template"), + Type: "llm_as_judge", }, }, }, - NumExamples: llamastackclient.Int(0), }, }, ) diff --git a/alphainference.go b/alphainference.go index d7d0918..34117ce 100644 --- a/alphainference.go +++ b/alphainference.go @@ -18,7 +18,6 @@ import ( "github.com/llamastack/llama-stack-client-go/option" "github.com/llamastack/llama-stack-client-go/packages/param" "github.com/llamastack/llama-stack-client-go/packages/respjson" - "github.com/llamastack/llama-stack-client-go/shared/constant" ) // AlphaInferenceService contains methods and other services that help with @@ -55,10 +54,7 @@ func (r *AlphaInferenceService) Rerank(ctx context.Context, body AlphaInferenceR // A single rerank result from a reranking response. type AlphaInferenceRerankResponse struct { - // The original index of the document in the input list - Index int64 `json:"index,required"` - // The relevance score from the model output. Values are inverted when applicable - // so that higher scores indicate greater relevance. + Index int64 `json:"index,required"` RelevanceScore float64 `json:"relevance_score,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { @@ -76,17 +72,11 @@ func (r *AlphaInferenceRerankResponse) UnmarshalJSON(data []byte) error { } type AlphaInferenceRerankParams struct { - // List of items to rerank. Each item can be a string, text content part, or image - // content part. Each input must not exceed the model's max input token length. Items []AlphaInferenceRerankParamsItemUnion `json:"items,omitzero,required"` - // The identifier of the reranking model to use. - Model string `json:"model,required"` - // The search query to rank items against. Can be a string, text content part, or - // image content part. The input must not exceed the model's max input token - // length. - Query AlphaInferenceRerankParamsQueryUnion `json:"query,omitzero,required"` - // (Optional) Maximum number of results to return. Default: returns all. - MaxNumResults param.Opt[int64] `json:"max_num_results,omitzero"` + Model string `json:"model,required"` + // Text content part for OpenAI-compatible chat completion messages. + Query AlphaInferenceRerankParamsQueryUnion `json:"query,omitzero,required"` + MaxNumResults param.Opt[int64] `json:"max_num_results,omitzero"` paramObj } @@ -154,14 +144,11 @@ func (u AlphaInferenceRerankParamsItemUnion) GetType() *string { // Text content part for OpenAI-compatible chat completion messages. // -// The properties Text, Type are required. +// The property Text is required. type AlphaInferenceRerankParamsItemOpenAIChatCompletionContentPartTextParam struct { - // The text content of the message Text string `json:"text,required"` - // Must be "text" to identify this as text content - // - // This field can be elided, and will marshal its zero value as "text". - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type,omitzero"` paramObj } @@ -173,16 +160,20 @@ func (r *AlphaInferenceRerankParamsItemOpenAIChatCompletionContentPartTextParam) return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[AlphaInferenceRerankParamsItemOpenAIChatCompletionContentPartTextParam]( + "type", "text", + ) +} + // Image content part for OpenAI-compatible chat completion messages. // -// The properties ImageURL, Type are required. +// The property ImageURL is required. type AlphaInferenceRerankParamsItemOpenAIChatCompletionContentPartImageParam struct { - // Image URL specification and processing details + // Image URL specification for OpenAI-compatible chat completion messages. ImageURL AlphaInferenceRerankParamsItemOpenAIChatCompletionContentPartImageParamImageURL `json:"image_url,omitzero,required"` - // Must be "image_url" to identify this as image content - // - // This field can be elided, and will marshal its zero value as "image_url". - Type constant.ImageURL `json:"type,required"` + // Any of "image_url". + Type string `json:"type,omitzero"` paramObj } @@ -194,13 +185,17 @@ func (r *AlphaInferenceRerankParamsItemOpenAIChatCompletionContentPartImageParam return apijson.UnmarshalRoot(data, r) } -// Image URL specification and processing details +func init() { + apijson.RegisterFieldValidator[AlphaInferenceRerankParamsItemOpenAIChatCompletionContentPartImageParam]( + "type", "image_url", + ) +} + +// Image URL specification for OpenAI-compatible chat completion messages. // // The property URL is required. type AlphaInferenceRerankParamsItemOpenAIChatCompletionContentPartImageParamImageURL struct { - // URL of the image to include in the message - URL string `json:"url,required"` - // (Optional) Level of detail for image processing. Can be "low", "high", or "auto" + URL string `json:"url,required"` Detail param.Opt[string] `json:"detail,omitzero"` paramObj } @@ -269,14 +264,11 @@ func (u AlphaInferenceRerankParamsQueryUnion) GetType() *string { // Text content part for OpenAI-compatible chat completion messages. // -// The properties Text, Type are required. +// The property Text is required. type AlphaInferenceRerankParamsQueryOpenAIChatCompletionContentPartTextParam struct { - // The text content of the message Text string `json:"text,required"` - // Must be "text" to identify this as text content - // - // This field can be elided, and will marshal its zero value as "text". - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type,omitzero"` paramObj } @@ -288,16 +280,20 @@ func (r *AlphaInferenceRerankParamsQueryOpenAIChatCompletionContentPartTextParam return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[AlphaInferenceRerankParamsQueryOpenAIChatCompletionContentPartTextParam]( + "type", "text", + ) +} + // Image content part for OpenAI-compatible chat completion messages. // -// The properties ImageURL, Type are required. +// The property ImageURL is required. type AlphaInferenceRerankParamsQueryOpenAIChatCompletionContentPartImageParam struct { - // Image URL specification and processing details + // Image URL specification for OpenAI-compatible chat completion messages. ImageURL AlphaInferenceRerankParamsQueryOpenAIChatCompletionContentPartImageParamImageURL `json:"image_url,omitzero,required"` - // Must be "image_url" to identify this as image content - // - // This field can be elided, and will marshal its zero value as "image_url". - Type constant.ImageURL `json:"type,required"` + // Any of "image_url". + Type string `json:"type,omitzero"` paramObj } @@ -309,13 +305,17 @@ func (r *AlphaInferenceRerankParamsQueryOpenAIChatCompletionContentPartImagePara return apijson.UnmarshalRoot(data, r) } -// Image URL specification and processing details +func init() { + apijson.RegisterFieldValidator[AlphaInferenceRerankParamsQueryOpenAIChatCompletionContentPartImageParam]( + "type", "image_url", + ) +} + +// Image URL specification for OpenAI-compatible chat completion messages. // // The property URL is required. type AlphaInferenceRerankParamsQueryOpenAIChatCompletionContentPartImageParamImageURL struct { - // URL of the image to include in the message - URL string `json:"url,required"` - // (Optional) Level of detail for image processing. Can be "low", "high", or "auto" + URL string `json:"url,required"` Detail param.Opt[string] `json:"detail,omitzero"` paramObj } @@ -330,7 +330,6 @@ func (r *AlphaInferenceRerankParamsQueryOpenAIChatCompletionContentPartImagePara // Response from a reranking request. type AlphaInferenceRerankResponseEnvelope struct { - // List of rerank result objects, sorted by relevance score (descending) Data []AlphaInferenceRerankResponse `json:"data,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { diff --git a/alphaposttraining.go b/alphaposttraining.go index d3c655b..227227a 100644 --- a/alphaposttraining.go +++ b/alphaposttraining.go @@ -18,7 +18,6 @@ import ( "github.com/llamastack/llama-stack-client-go/option" "github.com/llamastack/llama-stack-client-go/packages/param" "github.com/llamastack/llama-stack-client-go/packages/respjson" - "github.com/llamastack/llama-stack-client-go/shared/constant" ) // AlphaPostTrainingService contains methods and other services that help with @@ -58,187 +57,8 @@ func (r *AlphaPostTrainingService) SupervisedFineTune(ctx context.Context, body return } -func AlgorithmConfigParamOfQat(groupSize int64, quantizerName string) AlgorithmConfigUnionParam { - var qat AlgorithmConfigQatParam - qat.GroupSize = groupSize - qat.QuantizerName = quantizerName - return AlgorithmConfigUnionParam{OfQat: &qat} -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type AlgorithmConfigUnionParam struct { - OfLoRa *AlgorithmConfigLoRaParam `json:",omitzero,inline"` - OfQat *AlgorithmConfigQatParam `json:",omitzero,inline"` - paramUnion -} - -func (u AlgorithmConfigUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfLoRa, u.OfQat) -} -func (u *AlgorithmConfigUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *AlgorithmConfigUnionParam) asAny() any { - if !param.IsOmitted(u.OfLoRa) { - return u.OfLoRa - } else if !param.IsOmitted(u.OfQat) { - return u.OfQat - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u AlgorithmConfigUnionParam) GetAlpha() *int64 { - if vt := u.OfLoRa; vt != nil { - return &vt.Alpha - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u AlgorithmConfigUnionParam) GetApplyLoraToMlp() *bool { - if vt := u.OfLoRa; vt != nil { - return &vt.ApplyLoraToMlp - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u AlgorithmConfigUnionParam) GetApplyLoraToOutput() *bool { - if vt := u.OfLoRa; vt != nil { - return &vt.ApplyLoraToOutput - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u AlgorithmConfigUnionParam) GetLoraAttnModules() []string { - if vt := u.OfLoRa; vt != nil { - return vt.LoraAttnModules - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u AlgorithmConfigUnionParam) GetRank() *int64 { - if vt := u.OfLoRa; vt != nil { - return &vt.Rank - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u AlgorithmConfigUnionParam) GetQuantizeBase() *bool { - if vt := u.OfLoRa; vt != nil && vt.QuantizeBase.Valid() { - return &vt.QuantizeBase.Value - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u AlgorithmConfigUnionParam) GetUseDora() *bool { - if vt := u.OfLoRa; vt != nil && vt.UseDora.Valid() { - return &vt.UseDora.Value - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u AlgorithmConfigUnionParam) GetGroupSize() *int64 { - if vt := u.OfQat; vt != nil { - return &vt.GroupSize - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u AlgorithmConfigUnionParam) GetQuantizerName() *string { - if vt := u.OfQat; vt != nil { - return &vt.QuantizerName - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u AlgorithmConfigUnionParam) GetType() *string { - if vt := u.OfLoRa; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfQat; vt != nil { - return (*string)(&vt.Type) - } - return nil -} - -func init() { - apijson.RegisterUnion[AlgorithmConfigUnionParam]( - "type", - apijson.Discriminator[AlgorithmConfigLoRaParam]("LoRA"), - apijson.Discriminator[AlgorithmConfigQatParam]("QAT"), - ) -} - -// Configuration for Low-Rank Adaptation (LoRA) fine-tuning. -// -// The properties Alpha, ApplyLoraToMlp, ApplyLoraToOutput, LoraAttnModules, Rank, -// Type are required. -type AlgorithmConfigLoRaParam struct { - // LoRA scaling parameter that controls adaptation strength - Alpha int64 `json:"alpha,required"` - // Whether to apply LoRA to MLP layers - ApplyLoraToMlp bool `json:"apply_lora_to_mlp,required"` - // Whether to apply LoRA to output projection layers - ApplyLoraToOutput bool `json:"apply_lora_to_output,required"` - // List of attention module names to apply LoRA to - LoraAttnModules []string `json:"lora_attn_modules,omitzero,required"` - // Rank of the LoRA adaptation (lower rank = fewer parameters) - Rank int64 `json:"rank,required"` - // (Optional) Whether to quantize the base model weights - QuantizeBase param.Opt[bool] `json:"quantize_base,omitzero"` - // (Optional) Whether to use DoRA (Weight-Decomposed Low-Rank Adaptation) - UseDora param.Opt[bool] `json:"use_dora,omitzero"` - // Algorithm type identifier, always "LoRA" - // - // This field can be elided, and will marshal its zero value as "LoRA". - Type constant.LoRa `json:"type,required"` - paramObj -} - -func (r AlgorithmConfigLoRaParam) MarshalJSON() (data []byte, err error) { - type shadow AlgorithmConfigLoRaParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *AlgorithmConfigLoRaParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Configuration for Quantization-Aware Training (QAT) fine-tuning. -// -// The properties GroupSize, QuantizerName, Type are required. -type AlgorithmConfigQatParam struct { - // Size of groups for grouped quantization - GroupSize int64 `json:"group_size,required"` - // Name of the quantization algorithm to use - QuantizerName string `json:"quantizer_name,required"` - // Algorithm type identifier, always "QAT" - // - // This field can be elided, and will marshal its zero value as "QAT". - Type constant.Qat `json:"type,required"` - paramObj -} - -func (r AlgorithmConfigQatParam) MarshalJSON() (data []byte, err error) { - type shadow AlgorithmConfigQatParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *AlgorithmConfigQatParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - type ListPostTrainingJobsResponse struct { - Data []ListPostTrainingJobsResponseData `json:"data,required"` + Data []PostTrainingJob `json:"data,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Data respjson.Field @@ -253,22 +73,6 @@ func (r *ListPostTrainingJobsResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ListPostTrainingJobsResponseData struct { - JobUuid string `json:"job_uuid,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - JobUuid respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ListPostTrainingJobsResponseData) RawJSON() string { return r.JSON.raw } -func (r *ListPostTrainingJobsResponseData) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - type PostTrainingJob struct { JobUuid string `json:"job_uuid,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. @@ -286,17 +90,13 @@ func (r *PostTrainingJob) UnmarshalJSON(data []byte) error { } type AlphaPostTrainingPreferenceOptimizeParams struct { - // The algorithm configuration. - AlgorithmConfig AlphaPostTrainingPreferenceOptimizeParamsAlgorithmConfig `json:"algorithm_config,omitzero,required"` - // The model to fine-tune. - FinetunedModel string `json:"finetuned_model,required"` - // The hyperparam search configuration. - HyperparamSearchConfig map[string]AlphaPostTrainingPreferenceOptimizeParamsHyperparamSearchConfigUnion `json:"hyperparam_search_config,omitzero,required"` - // The UUID of the job to create. - JobUuid string `json:"job_uuid,required"` - // The logger configuration. - LoggerConfig map[string]AlphaPostTrainingPreferenceOptimizeParamsLoggerConfigUnion `json:"logger_config,omitzero,required"` - // The training configuration. + // Configuration for Direct Preference Optimization (DPO) alignment. + AlgorithmConfig AlphaPostTrainingPreferenceOptimizeParamsAlgorithmConfig `json:"algorithm_config,omitzero,required"` + FinetunedModel string `json:"finetuned_model,required"` + HyperparamSearchConfig map[string]any `json:"hyperparam_search_config,omitzero,required"` + JobUuid string `json:"job_uuid,required"` + LoggerConfig map[string]any `json:"logger_config,omitzero,required"` + // Comprehensive configuration for the training process. TrainingConfig AlphaPostTrainingPreferenceOptimizeParamsTrainingConfig `json:"training_config,omitzero,required"` paramObj } @@ -309,16 +109,13 @@ func (r *AlphaPostTrainingPreferenceOptimizeParams) UnmarshalJSON(data []byte) e return apijson.UnmarshalRoot(data, r) } -// The algorithm configuration. +// Configuration for Direct Preference Optimization (DPO) alignment. // -// The properties Beta, LossType are required. +// The property Beta is required. type AlphaPostTrainingPreferenceOptimizeParamsAlgorithmConfig struct { - // Temperature parameter for the DPO loss Beta float64 `json:"beta,required"` - // The type of loss function to use for DPO - // // Any of "sigmoid", "hinge", "ipo", "kto_pair". - LossType string `json:"loss_type,omitzero,required"` + LossType string `json:"loss_type,omitzero"` paramObj } @@ -336,88 +133,20 @@ func init() { ) } -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type AlphaPostTrainingPreferenceOptimizeParamsHyperparamSearchConfigUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u AlphaPostTrainingPreferenceOptimizeParamsHyperparamSearchConfigUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *AlphaPostTrainingPreferenceOptimizeParamsHyperparamSearchConfigUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *AlphaPostTrainingPreferenceOptimizeParamsHyperparamSearchConfigUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type AlphaPostTrainingPreferenceOptimizeParamsLoggerConfigUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u AlphaPostTrainingPreferenceOptimizeParamsLoggerConfigUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *AlphaPostTrainingPreferenceOptimizeParamsLoggerConfigUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *AlphaPostTrainingPreferenceOptimizeParamsLoggerConfigUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - -// The training configuration. +// Comprehensive configuration for the training process. // -// The properties GradientAccumulationSteps, MaxStepsPerEpoch, NEpochs are -// required. +// The property NEpochs is required. type AlphaPostTrainingPreferenceOptimizeParamsTrainingConfig struct { - // Number of steps to accumulate gradients before updating - GradientAccumulationSteps int64 `json:"gradient_accumulation_steps,required"` - // Maximum number of steps to run per epoch - MaxStepsPerEpoch int64 `json:"max_steps_per_epoch,required"` - // Number of training epochs to run - NEpochs int64 `json:"n_epochs,required"` - // (Optional) Data type for model parameters (bf16, fp16, fp32) - Dtype param.Opt[string] `json:"dtype,omitzero"` - // (Optional) Maximum number of validation steps per epoch - MaxValidationSteps param.Opt[int64] `json:"max_validation_steps,omitzero"` - // (Optional) Configuration for data loading and formatting + NEpochs int64 `json:"n_epochs,required"` + Dtype param.Opt[string] `json:"dtype,omitzero"` + MaxValidationSteps param.Opt[int64] `json:"max_validation_steps,omitzero"` + GradientAccumulationSteps param.Opt[int64] `json:"gradient_accumulation_steps,omitzero"` + MaxStepsPerEpoch param.Opt[int64] `json:"max_steps_per_epoch,omitzero"` + // Configuration for training data and data loading. DataConfig AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigDataConfig `json:"data_config,omitzero"` - // (Optional) Configuration for memory and compute optimizations + // Configuration for memory and compute efficiency optimizations. EfficiencyConfig AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigEfficiencyConfig `json:"efficiency_config,omitzero"` - // (Optional) Configuration for the optimization algorithm + // Configuration parameters for the optimization algorithm. OptimizerConfig AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigOptimizerConfig `json:"optimizer_config,omitzero"` paramObj } @@ -430,26 +159,19 @@ func (r *AlphaPostTrainingPreferenceOptimizeParamsTrainingConfig) UnmarshalJSON( return apijson.UnmarshalRoot(data, r) } -// (Optional) Configuration for data loading and formatting +// Configuration for training data and data loading. // // The properties BatchSize, DataFormat, DatasetID, Shuffle are required. type AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigDataConfig struct { - // Number of samples per training batch BatchSize int64 `json:"batch_size,required"` - // Format of the dataset (instruct or dialog) + // Format of the training dataset. // // Any of "instruct", "dialog". - DataFormat string `json:"data_format,omitzero,required"` - // Unique identifier for the training dataset - DatasetID string `json:"dataset_id,required"` - // Whether to shuffle the dataset during training - Shuffle bool `json:"shuffle,required"` - // (Optional) Whether to pack multiple samples into a single sequence for - // efficiency - Packed param.Opt[bool] `json:"packed,omitzero"` - // (Optional) Whether to compute loss on input tokens as well as output tokens - TrainOnInput param.Opt[bool] `json:"train_on_input,omitzero"` - // (Optional) Unique identifier for the validation dataset + DataFormat string `json:"data_format,omitzero,required"` + DatasetID string `json:"dataset_id,required"` + Shuffle bool `json:"shuffle,required"` + Packed param.Opt[bool] `json:"packed,omitzero"` + TrainOnInput param.Opt[bool] `json:"train_on_input,omitzero"` ValidationDatasetID param.Opt[string] `json:"validation_dataset_id,omitzero"` paramObj } @@ -468,16 +190,12 @@ func init() { ) } -// (Optional) Configuration for memory and compute optimizations +// Configuration for memory and compute efficiency optimizations. type AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigEfficiencyConfig struct { - // (Optional) Whether to use activation checkpointing to reduce memory usage EnableActivationCheckpointing param.Opt[bool] `json:"enable_activation_checkpointing,omitzero"` - // (Optional) Whether to offload activations to CPU to save GPU memory - EnableActivationOffloading param.Opt[bool] `json:"enable_activation_offloading,omitzero"` - // (Optional) Whether to offload FSDP parameters to CPU - FsdpCPUOffload param.Opt[bool] `json:"fsdp_cpu_offload,omitzero"` - // (Optional) Whether to use memory-efficient FSDP wrapping - MemoryEfficientFsdpWrap param.Opt[bool] `json:"memory_efficient_fsdp_wrap,omitzero"` + EnableActivationOffloading param.Opt[bool] `json:"enable_activation_offloading,omitzero"` + FsdpCPUOffload param.Opt[bool] `json:"fsdp_cpu_offload,omitzero"` + MemoryEfficientFsdpWrap param.Opt[bool] `json:"memory_efficient_fsdp_wrap,omitzero"` paramObj } @@ -489,20 +207,17 @@ func (r *AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigEfficiencyConfig return apijson.UnmarshalRoot(data, r) } -// (Optional) Configuration for the optimization algorithm +// Configuration parameters for the optimization algorithm. // // The properties Lr, NumWarmupSteps, OptimizerType, WeightDecay are required. type AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigOptimizerConfig struct { - // Learning rate for the optimizer - Lr float64 `json:"lr,required"` - // Number of steps for learning rate warmup - NumWarmupSteps int64 `json:"num_warmup_steps,required"` - // Type of optimizer to use (adam, adamw, or sgd) + Lr float64 `json:"lr,required"` + NumWarmupSteps int64 `json:"num_warmup_steps,required"` + // Available optimizer algorithms for training. // // Any of "adam", "adamw", "sgd". - OptimizerType string `json:"optimizer_type,omitzero,required"` - // Weight decay coefficient for regularization - WeightDecay float64 `json:"weight_decay,required"` + OptimizerType string `json:"optimizer_type,omitzero,required"` + WeightDecay float64 `json:"weight_decay,required"` paramObj } @@ -521,20 +236,16 @@ func init() { } type AlphaPostTrainingSupervisedFineTuneParams struct { - // The hyperparam search configuration. - HyperparamSearchConfig map[string]AlphaPostTrainingSupervisedFineTuneParamsHyperparamSearchConfigUnion `json:"hyperparam_search_config,omitzero,required"` - // The UUID of the job to create. - JobUuid string `json:"job_uuid,required"` - // The logger configuration. - LoggerConfig map[string]AlphaPostTrainingSupervisedFineTuneParamsLoggerConfigUnion `json:"logger_config,omitzero,required"` - // The training configuration. + HyperparamSearchConfig map[string]any `json:"hyperparam_search_config,omitzero,required"` + JobUuid string `json:"job_uuid,required"` + LoggerConfig map[string]any `json:"logger_config,omitzero,required"` + // Comprehensive configuration for the training process. TrainingConfig AlphaPostTrainingSupervisedFineTuneParamsTrainingConfig `json:"training_config,omitzero,required"` - // The directory to save checkpoint(s) to. - CheckpointDir param.Opt[string] `json:"checkpoint_dir,omitzero"` - // The model to fine-tune. + CheckpointDir param.Opt[string] `json:"checkpoint_dir,omitzero"` + // Model descriptor for training if not in provider config` Model param.Opt[string] `json:"model,omitzero"` - // The algorithm configuration. - AlgorithmConfig AlgorithmConfigUnionParam `json:"algorithm_config,omitzero"` + // Configuration for Low-Rank Adaptation (LoRA) fine-tuning. + AlgorithmConfig AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigUnion `json:"algorithm_config,omitzero"` paramObj } @@ -546,88 +257,20 @@ func (r *AlphaPostTrainingSupervisedFineTuneParams) UnmarshalJSON(data []byte) e return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type AlphaPostTrainingSupervisedFineTuneParamsHyperparamSearchConfigUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u AlphaPostTrainingSupervisedFineTuneParamsHyperparamSearchConfigUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *AlphaPostTrainingSupervisedFineTuneParamsHyperparamSearchConfigUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *AlphaPostTrainingSupervisedFineTuneParamsHyperparamSearchConfigUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type AlphaPostTrainingSupervisedFineTuneParamsLoggerConfigUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u AlphaPostTrainingSupervisedFineTuneParamsLoggerConfigUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *AlphaPostTrainingSupervisedFineTuneParamsLoggerConfigUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *AlphaPostTrainingSupervisedFineTuneParamsLoggerConfigUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - -// The training configuration. +// Comprehensive configuration for the training process. // -// The properties GradientAccumulationSteps, MaxStepsPerEpoch, NEpochs are -// required. +// The property NEpochs is required. type AlphaPostTrainingSupervisedFineTuneParamsTrainingConfig struct { - // Number of steps to accumulate gradients before updating - GradientAccumulationSteps int64 `json:"gradient_accumulation_steps,required"` - // Maximum number of steps to run per epoch - MaxStepsPerEpoch int64 `json:"max_steps_per_epoch,required"` - // Number of training epochs to run - NEpochs int64 `json:"n_epochs,required"` - // (Optional) Data type for model parameters (bf16, fp16, fp32) - Dtype param.Opt[string] `json:"dtype,omitzero"` - // (Optional) Maximum number of validation steps per epoch - MaxValidationSteps param.Opt[int64] `json:"max_validation_steps,omitzero"` - // (Optional) Configuration for data loading and formatting + NEpochs int64 `json:"n_epochs,required"` + Dtype param.Opt[string] `json:"dtype,omitzero"` + MaxValidationSteps param.Opt[int64] `json:"max_validation_steps,omitzero"` + GradientAccumulationSteps param.Opt[int64] `json:"gradient_accumulation_steps,omitzero"` + MaxStepsPerEpoch param.Opt[int64] `json:"max_steps_per_epoch,omitzero"` + // Configuration for training data and data loading. DataConfig AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigDataConfig `json:"data_config,omitzero"` - // (Optional) Configuration for memory and compute optimizations + // Configuration for memory and compute efficiency optimizations. EfficiencyConfig AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigEfficiencyConfig `json:"efficiency_config,omitzero"` - // (Optional) Configuration for the optimization algorithm + // Configuration parameters for the optimization algorithm. OptimizerConfig AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigOptimizerConfig `json:"optimizer_config,omitzero"` paramObj } @@ -640,26 +283,19 @@ func (r *AlphaPostTrainingSupervisedFineTuneParamsTrainingConfig) UnmarshalJSON( return apijson.UnmarshalRoot(data, r) } -// (Optional) Configuration for data loading and formatting +// Configuration for training data and data loading. // // The properties BatchSize, DataFormat, DatasetID, Shuffle are required. type AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigDataConfig struct { - // Number of samples per training batch BatchSize int64 `json:"batch_size,required"` - // Format of the dataset (instruct or dialog) + // Format of the training dataset. // // Any of "instruct", "dialog". - DataFormat string `json:"data_format,omitzero,required"` - // Unique identifier for the training dataset - DatasetID string `json:"dataset_id,required"` - // Whether to shuffle the dataset during training - Shuffle bool `json:"shuffle,required"` - // (Optional) Whether to pack multiple samples into a single sequence for - // efficiency - Packed param.Opt[bool] `json:"packed,omitzero"` - // (Optional) Whether to compute loss on input tokens as well as output tokens - TrainOnInput param.Opt[bool] `json:"train_on_input,omitzero"` - // (Optional) Unique identifier for the validation dataset + DataFormat string `json:"data_format,omitzero,required"` + DatasetID string `json:"dataset_id,required"` + Shuffle bool `json:"shuffle,required"` + Packed param.Opt[bool] `json:"packed,omitzero"` + TrainOnInput param.Opt[bool] `json:"train_on_input,omitzero"` ValidationDatasetID param.Opt[string] `json:"validation_dataset_id,omitzero"` paramObj } @@ -678,16 +314,12 @@ func init() { ) } -// (Optional) Configuration for memory and compute optimizations +// Configuration for memory and compute efficiency optimizations. type AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigEfficiencyConfig struct { - // (Optional) Whether to use activation checkpointing to reduce memory usage EnableActivationCheckpointing param.Opt[bool] `json:"enable_activation_checkpointing,omitzero"` - // (Optional) Whether to offload activations to CPU to save GPU memory - EnableActivationOffloading param.Opt[bool] `json:"enable_activation_offloading,omitzero"` - // (Optional) Whether to offload FSDP parameters to CPU - FsdpCPUOffload param.Opt[bool] `json:"fsdp_cpu_offload,omitzero"` - // (Optional) Whether to use memory-efficient FSDP wrapping - MemoryEfficientFsdpWrap param.Opt[bool] `json:"memory_efficient_fsdp_wrap,omitzero"` + EnableActivationOffloading param.Opt[bool] `json:"enable_activation_offloading,omitzero"` + FsdpCPUOffload param.Opt[bool] `json:"fsdp_cpu_offload,omitzero"` + MemoryEfficientFsdpWrap param.Opt[bool] `json:"memory_efficient_fsdp_wrap,omitzero"` paramObj } @@ -699,20 +331,17 @@ func (r *AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigEfficiencyConfig return apijson.UnmarshalRoot(data, r) } -// (Optional) Configuration for the optimization algorithm +// Configuration parameters for the optimization algorithm. // // The properties Lr, NumWarmupSteps, OptimizerType, WeightDecay are required. type AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigOptimizerConfig struct { - // Learning rate for the optimizer - Lr float64 `json:"lr,required"` - // Number of steps for learning rate warmup - NumWarmupSteps int64 `json:"num_warmup_steps,required"` - // Type of optimizer to use (adam, adamw, or sgd) + Lr float64 `json:"lr,required"` + NumWarmupSteps int64 `json:"num_warmup_steps,required"` + // Available optimizer algorithms for training. // // Any of "adam", "adamw", "sgd". - OptimizerType string `json:"optimizer_type,omitzero,required"` - // Weight decay coefficient for regularization - WeightDecay float64 `json:"weight_decay,required"` + OptimizerType string `json:"optimizer_type,omitzero,required"` + WeightDecay float64 `json:"weight_decay,required"` paramObj } @@ -729,3 +358,174 @@ func init() { "optimizer_type", "adam", "adamw", "sgd", ) } + +// Only one field can be non-zero. +// +// Use [param.IsOmitted] to confirm if a field is set. +type AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigUnion struct { + OfLoRa *AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigLoRa `json:",omitzero,inline"` + OfQat *AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigQat `json:",omitzero,inline"` + paramUnion +} + +func (u AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfLoRa, u.OfQat) +} +func (u *AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigUnion) asAny() any { + if !param.IsOmitted(u.OfLoRa) { + return u.OfLoRa + } else if !param.IsOmitted(u.OfQat) { + return u.OfQat + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigUnion) GetAlpha() *int64 { + if vt := u.OfLoRa; vt != nil { + return &vt.Alpha + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigUnion) GetApplyLoraToMlp() *bool { + if vt := u.OfLoRa; vt != nil { + return &vt.ApplyLoraToMlp + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigUnion) GetApplyLoraToOutput() *bool { + if vt := u.OfLoRa; vt != nil { + return &vt.ApplyLoraToOutput + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigUnion) GetLoraAttnModules() []string { + if vt := u.OfLoRa; vt != nil { + return vt.LoraAttnModules + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigUnion) GetRank() *int64 { + if vt := u.OfLoRa; vt != nil { + return &vt.Rank + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigUnion) GetQuantizeBase() *bool { + if vt := u.OfLoRa; vt != nil && vt.QuantizeBase.Valid() { + return &vt.QuantizeBase.Value + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigUnion) GetUseDora() *bool { + if vt := u.OfLoRa; vt != nil && vt.UseDora.Valid() { + return &vt.UseDora.Value + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigUnion) GetGroupSize() *int64 { + if vt := u.OfQat; vt != nil { + return &vt.GroupSize + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigUnion) GetQuantizerName() *string { + if vt := u.OfQat; vt != nil { + return &vt.QuantizerName + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigUnion) GetType() *string { + if vt := u.OfLoRa; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfQat; vt != nil { + return (*string)(&vt.Type) + } + return nil +} + +func init() { + apijson.RegisterUnion[AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigUnion]( + "type", + apijson.Discriminator[AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigLoRa]("LoRA"), + apijson.Discriminator[AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigQat]("QAT"), + ) +} + +// Configuration for Low-Rank Adaptation (LoRA) fine-tuning. +// +// The properties Alpha, ApplyLoraToMlp, ApplyLoraToOutput, LoraAttnModules, Rank +// are required. +type AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigLoRa struct { + Alpha int64 `json:"alpha,required"` + ApplyLoraToMlp bool `json:"apply_lora_to_mlp,required"` + ApplyLoraToOutput bool `json:"apply_lora_to_output,required"` + LoraAttnModules []string `json:"lora_attn_modules,omitzero,required"` + Rank int64 `json:"rank,required"` + QuantizeBase param.Opt[bool] `json:"quantize_base,omitzero"` + UseDora param.Opt[bool] `json:"use_dora,omitzero"` + // Any of "LoRA". + Type string `json:"type,omitzero"` + paramObj +} + +func (r AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigLoRa) MarshalJSON() (data []byte, err error) { + type shadow AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigLoRa + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigLoRa) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigLoRa]( + "type", "LoRA", + ) +} + +// Configuration for Quantization-Aware Training (QAT) fine-tuning. +// +// The properties GroupSize, QuantizerName are required. +type AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigQat struct { + GroupSize int64 `json:"group_size,required"` + QuantizerName string `json:"quantizer_name,required"` + // Any of "QAT". + Type string `json:"type,omitzero"` + paramObj +} + +func (r AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigQat) MarshalJSON() (data []byte, err error) { + type shadow AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigQat + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigQat) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigQat]( + "type", "QAT", + ) +} diff --git a/alphaposttraining_test.go b/alphaposttraining_test.go index c297d87..5bd0b4d 100644 --- a/alphaposttraining_test.go +++ b/alphaposttraining_test.go @@ -36,21 +36,15 @@ func TestAlphaPostTrainingPreferenceOptimizeWithOptionalParams(t *testing.T) { LossType: "sigmoid", }, FinetunedModel: "finetuned_model", - HyperparamSearchConfig: map[string]llamastackclient.AlphaPostTrainingPreferenceOptimizeParamsHyperparamSearchConfigUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + HyperparamSearchConfig: map[string]any{ + "foo": "bar", }, JobUuid: "job_uuid", - LoggerConfig: map[string]llamastackclient.AlphaPostTrainingPreferenceOptimizeParamsLoggerConfigUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + LoggerConfig: map[string]any{ + "foo": "bar", }, TrainingConfig: llamastackclient.AlphaPostTrainingPreferenceOptimizeParamsTrainingConfig{ - GradientAccumulationSteps: 0, - MaxStepsPerEpoch: 0, - NEpochs: 0, + NEpochs: 0, DataConfig: llamastackclient.AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigDataConfig{ BatchSize: 0, DataFormat: "instruct", @@ -67,7 +61,9 @@ func TestAlphaPostTrainingPreferenceOptimizeWithOptionalParams(t *testing.T) { FsdpCPUOffload: llamastackclient.Bool(true), MemoryEfficientFsdpWrap: llamastackclient.Bool(true), }, - MaxValidationSteps: llamastackclient.Int(0), + GradientAccumulationSteps: llamastackclient.Int(0), + MaxStepsPerEpoch: llamastackclient.Int(0), + MaxValidationSteps: llamastackclient.Int(0), OptimizerConfig: llamastackclient.AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigOptimizerConfig{ Lr: 0, NumWarmupSteps: 0, @@ -97,21 +93,15 @@ func TestAlphaPostTrainingSupervisedFineTuneWithOptionalParams(t *testing.T) { option.WithBaseURL(baseURL), ) _, err := client.Alpha.PostTraining.SupervisedFineTune(context.TODO(), llamastackclient.AlphaPostTrainingSupervisedFineTuneParams{ - HyperparamSearchConfig: map[string]llamastackclient.AlphaPostTrainingSupervisedFineTuneParamsHyperparamSearchConfigUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + HyperparamSearchConfig: map[string]any{ + "foo": "bar", }, JobUuid: "job_uuid", - LoggerConfig: map[string]llamastackclient.AlphaPostTrainingSupervisedFineTuneParamsLoggerConfigUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + LoggerConfig: map[string]any{ + "foo": "bar", }, TrainingConfig: llamastackclient.AlphaPostTrainingSupervisedFineTuneParamsTrainingConfig{ - GradientAccumulationSteps: 0, - MaxStepsPerEpoch: 0, - NEpochs: 0, + NEpochs: 0, DataConfig: llamastackclient.AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigDataConfig{ BatchSize: 0, DataFormat: "instruct", @@ -128,7 +118,9 @@ func TestAlphaPostTrainingSupervisedFineTuneWithOptionalParams(t *testing.T) { FsdpCPUOffload: llamastackclient.Bool(true), MemoryEfficientFsdpWrap: llamastackclient.Bool(true), }, - MaxValidationSteps: llamastackclient.Int(0), + GradientAccumulationSteps: llamastackclient.Int(0), + MaxStepsPerEpoch: llamastackclient.Int(0), + MaxValidationSteps: llamastackclient.Int(0), OptimizerConfig: llamastackclient.AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigOptimizerConfig{ Lr: 0, NumWarmupSteps: 0, @@ -136,14 +128,15 @@ func TestAlphaPostTrainingSupervisedFineTuneWithOptionalParams(t *testing.T) { WeightDecay: 0, }, }, - AlgorithmConfig: llamastackclient.AlgorithmConfigUnionParam{ - OfLoRa: &llamastackclient.AlgorithmConfigLoRaParam{ + AlgorithmConfig: llamastackclient.AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigUnion{ + OfLoRa: &llamastackclient.AlphaPostTrainingSupervisedFineTuneParamsAlgorithmConfigLoRa{ Alpha: 0, ApplyLoraToMlp: true, ApplyLoraToOutput: true, LoraAttnModules: []string{"string"}, Rank: 0, QuantizeBase: llamastackclient.Bool(true), + Type: "LoRA", UseDora: llamastackclient.Bool(true), }, }, diff --git a/alphaposttrainingjob.go b/alphaposttrainingjob.go index 7c85e31..cb7b730 100644 --- a/alphaposttrainingjob.go +++ b/alphaposttrainingjob.go @@ -10,7 +10,6 @@ package llamastackclient import ( "context" - "encoding/json" "net/http" "net/url" "slices" @@ -44,7 +43,7 @@ func NewAlphaPostTrainingJobService(opts ...option.RequestOption) (r AlphaPostTr } // Get all training jobs. -func (r *AlphaPostTrainingJobService) List(ctx context.Context, opts ...option.RequestOption) (res *[]ListPostTrainingJobsResponseData, err error) { +func (r *AlphaPostTrainingJobService) List(ctx context.Context, opts ...option.RequestOption) (res *[]PostTrainingJob, err error) { var env ListPostTrainingJobsResponse opts = slices.Concat(r.Options, opts) path := "v1alpha/post-training/jobs" @@ -83,14 +82,12 @@ func (r *AlphaPostTrainingJobService) Status(ctx context.Context, query AlphaPos // Artifacts of a finetuning job. type AlphaPostTrainingJobArtifactsResponse struct { - // List of model checkpoints created during training - Checkpoints []AlphaPostTrainingJobArtifactsResponseCheckpoint `json:"checkpoints,required"` - // Unique identifier for the training job - JobUuid string `json:"job_uuid,required"` + JobUuid string `json:"job_uuid,required"` + Checkpoints []AlphaPostTrainingJobArtifactsResponseCheckpoint `json:"checkpoints"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Checkpoints respjson.Field JobUuid respjson.Field + Checkpoints respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -104,18 +101,13 @@ func (r *AlphaPostTrainingJobArtifactsResponse) UnmarshalJSON(data []byte) error // Checkpoint created during training runs. type AlphaPostTrainingJobArtifactsResponseCheckpoint struct { - // Timestamp when the checkpoint was created - CreatedAt time.Time `json:"created_at,required" format:"date-time"` - // Training epoch when the checkpoint was saved - Epoch int64 `json:"epoch,required"` - // Unique identifier for the checkpoint - Identifier string `json:"identifier,required"` - // File system path where the checkpoint is stored - Path string `json:"path,required"` - // Identifier of the training job that created this checkpoint - PostTrainingJobID string `json:"post_training_job_id,required"` - // (Optional) Training metrics associated with this checkpoint - TrainingMetrics AlphaPostTrainingJobArtifactsResponseCheckpointTrainingMetrics `json:"training_metrics"` + CreatedAt time.Time `json:"created_at,required" format:"date-time"` + Epoch int64 `json:"epoch,required"` + Identifier string `json:"identifier,required"` + Path string `json:"path,required"` + PostTrainingJobID string `json:"post_training_job_id,required"` + // Training metrics captured during post-training jobs. + TrainingMetrics AlphaPostTrainingJobArtifactsResponseCheckpointTrainingMetrics `json:"training_metrics,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { CreatedAt respjson.Field @@ -135,15 +127,11 @@ func (r *AlphaPostTrainingJobArtifactsResponseCheckpoint) UnmarshalJSON(data []b return apijson.UnmarshalRoot(data, r) } -// (Optional) Training metrics associated with this checkpoint +// Training metrics captured during post-training jobs. type AlphaPostTrainingJobArtifactsResponseCheckpointTrainingMetrics struct { - // Training epoch number - Epoch int64 `json:"epoch,required"` - // Perplexity metric indicating model confidence - Perplexity float64 `json:"perplexity,required"` - // Loss value on the training dataset - TrainLoss float64 `json:"train_loss,required"` - // Loss value on the validation dataset + Epoch int64 `json:"epoch,required"` + Perplexity float64 `json:"perplexity,required"` + TrainLoss float64 `json:"train_loss,required"` ValidationLoss float64 `json:"validation_loss,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { @@ -166,27 +154,21 @@ func (r *AlphaPostTrainingJobArtifactsResponseCheckpointTrainingMetrics) Unmarsh // Status of a finetuning job. type AlphaPostTrainingJobStatusResponse struct { - // List of model checkpoints created during training - Checkpoints []AlphaPostTrainingJobStatusResponseCheckpoint `json:"checkpoints,required"` - // Unique identifier for the training job JobUuid string `json:"job_uuid,required"` - // Current status of the training job + // Status of a job execution. // // Any of "completed", "in_progress", "failed", "scheduled", "cancelled". - Status AlphaPostTrainingJobStatusResponseStatus `json:"status,required"` - // (Optional) Timestamp when the job finished, if completed - CompletedAt time.Time `json:"completed_at" format:"date-time"` - // (Optional) Information about computational resources allocated to the job - ResourcesAllocated map[string]AlphaPostTrainingJobStatusResponseResourcesAllocatedUnion `json:"resources_allocated"` - // (Optional) Timestamp when the job was scheduled - ScheduledAt time.Time `json:"scheduled_at" format:"date-time"` - // (Optional) Timestamp when the job execution began - StartedAt time.Time `json:"started_at" format:"date-time"` + Status AlphaPostTrainingJobStatusResponseStatus `json:"status,required"` + Checkpoints []AlphaPostTrainingJobStatusResponseCheckpoint `json:"checkpoints"` + CompletedAt time.Time `json:"completed_at,nullable" format:"date-time"` + ResourcesAllocated map[string]any `json:"resources_allocated,nullable"` + ScheduledAt time.Time `json:"scheduled_at,nullable" format:"date-time"` + StartedAt time.Time `json:"started_at,nullable" format:"date-time"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Checkpoints respjson.Field JobUuid respjson.Field Status respjson.Field + Checkpoints respjson.Field CompletedAt respjson.Field ResourcesAllocated respjson.Field ScheduledAt respjson.Field @@ -202,20 +184,26 @@ func (r *AlphaPostTrainingJobStatusResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +// Status of a job execution. +type AlphaPostTrainingJobStatusResponseStatus string + +const ( + AlphaPostTrainingJobStatusResponseStatusCompleted AlphaPostTrainingJobStatusResponseStatus = "completed" + AlphaPostTrainingJobStatusResponseStatusInProgress AlphaPostTrainingJobStatusResponseStatus = "in_progress" + AlphaPostTrainingJobStatusResponseStatusFailed AlphaPostTrainingJobStatusResponseStatus = "failed" + AlphaPostTrainingJobStatusResponseStatusScheduled AlphaPostTrainingJobStatusResponseStatus = "scheduled" + AlphaPostTrainingJobStatusResponseStatusCancelled AlphaPostTrainingJobStatusResponseStatus = "cancelled" +) + // Checkpoint created during training runs. type AlphaPostTrainingJobStatusResponseCheckpoint struct { - // Timestamp when the checkpoint was created - CreatedAt time.Time `json:"created_at,required" format:"date-time"` - // Training epoch when the checkpoint was saved - Epoch int64 `json:"epoch,required"` - // Unique identifier for the checkpoint - Identifier string `json:"identifier,required"` - // File system path where the checkpoint is stored - Path string `json:"path,required"` - // Identifier of the training job that created this checkpoint - PostTrainingJobID string `json:"post_training_job_id,required"` - // (Optional) Training metrics associated with this checkpoint - TrainingMetrics AlphaPostTrainingJobStatusResponseCheckpointTrainingMetrics `json:"training_metrics"` + CreatedAt time.Time `json:"created_at,required" format:"date-time"` + Epoch int64 `json:"epoch,required"` + Identifier string `json:"identifier,required"` + Path string `json:"path,required"` + PostTrainingJobID string `json:"post_training_job_id,required"` + // Training metrics captured during post-training jobs. + TrainingMetrics AlphaPostTrainingJobStatusResponseCheckpointTrainingMetrics `json:"training_metrics,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { CreatedAt respjson.Field @@ -235,15 +223,11 @@ func (r *AlphaPostTrainingJobStatusResponseCheckpoint) UnmarshalJSON(data []byte return apijson.UnmarshalRoot(data, r) } -// (Optional) Training metrics associated with this checkpoint +// Training metrics captured during post-training jobs. type AlphaPostTrainingJobStatusResponseCheckpointTrainingMetrics struct { - // Training epoch number - Epoch int64 `json:"epoch,required"` - // Perplexity metric indicating model confidence - Perplexity float64 `json:"perplexity,required"` - // Loss value on the training dataset - TrainLoss float64 `json:"train_loss,required"` - // Loss value on the validation dataset + Epoch int64 `json:"epoch,required"` + Perplexity float64 `json:"perplexity,required"` + TrainLoss float64 `json:"train_loss,required"` ValidationLoss float64 `json:"validation_loss,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { @@ -264,73 +248,23 @@ func (r *AlphaPostTrainingJobStatusResponseCheckpointTrainingMetrics) UnmarshalJ return apijson.UnmarshalRoot(data, r) } -// Current status of the training job -type AlphaPostTrainingJobStatusResponseStatus string - -const ( - AlphaPostTrainingJobStatusResponseStatusCompleted AlphaPostTrainingJobStatusResponseStatus = "completed" - AlphaPostTrainingJobStatusResponseStatusInProgress AlphaPostTrainingJobStatusResponseStatus = "in_progress" - AlphaPostTrainingJobStatusResponseStatusFailed AlphaPostTrainingJobStatusResponseStatus = "failed" - AlphaPostTrainingJobStatusResponseStatusScheduled AlphaPostTrainingJobStatusResponseStatus = "scheduled" - AlphaPostTrainingJobStatusResponseStatusCancelled AlphaPostTrainingJobStatusResponseStatus = "cancelled" -) - -// AlphaPostTrainingJobStatusResponseResourcesAllocatedUnion contains all possible -// properties and values from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type AlphaPostTrainingJobStatusResponseResourcesAllocatedUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string +type ListPostTrainingJobsResponse struct { + Data []PostTrainingJob `json:"data,required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Data respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } -func (u AlphaPostTrainingJobStatusResponseResourcesAllocatedUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u AlphaPostTrainingJobStatusResponseResourcesAllocatedUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u AlphaPostTrainingJobStatusResponseResourcesAllocatedUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u AlphaPostTrainingJobStatusResponseResourcesAllocatedUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - // Returns the unmodified JSON received from the API -func (u AlphaPostTrainingJobStatusResponseResourcesAllocatedUnion) RawJSON() string { - return u.JSON.raw -} - -func (r *AlphaPostTrainingJobStatusResponseResourcesAllocatedUnion) UnmarshalJSON(data []byte) error { +func (r ListPostTrainingJobsResponse) RawJSON() string { return r.JSON.raw } +func (r *ListPostTrainingJobsResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } type AlphaPostTrainingJobArtifactsParams struct { - // The UUID of the job to get the artifacts of. JobUuid string `query:"job_uuid,required" json:"-"` paramObj } @@ -345,7 +279,6 @@ func (r AlphaPostTrainingJobArtifactsParams) URLQuery() (v url.Values, err error } type AlphaPostTrainingJobCancelParams struct { - // The UUID of the job to cancel. JobUuid string `json:"job_uuid,required"` paramObj } @@ -359,7 +292,6 @@ func (r *AlphaPostTrainingJobCancelParams) UnmarshalJSON(data []byte) error { } type AlphaPostTrainingJobStatusParams struct { - // The UUID of the job to get the status of. JobUuid string `query:"job_uuid,required" json:"-"` paramObj } diff --git a/api.md b/api.md index dcfb0cb..0a13b46 100644 --- a/api.md +++ b/api.md @@ -1,14 +1,10 @@ # Shared Params Types -- llamastackclient.InterleavedContentUnionParam -- llamastackclient.InterleavedContentItemUnionParam - llamastackclient.SamplingParams - llamastackclient.SystemMessageParam # Shared Response Types -- llamastackclient.InterleavedContentUnion -- llamastackclient.InterleavedContentItemUnion - llamastackclient.SafetyViolation - llamastackclient.ScoringResult @@ -45,8 +41,6 @@ Methods: - client.ToolRuntime.InvokeTool(ctx context.Context, body llamastackclient.ToolRuntimeInvokeToolParams) (llamastackclient.ToolInvocationResult, error) - client.ToolRuntime.ListTools(ctx context.Context, query llamastackclient.ToolRuntimeListToolsParams) ([]llamastackclient.ToolDef, error) -## RagTool - # Responses Response Types: @@ -115,13 +109,15 @@ Response Types: - llamastackclient.ConversationItemNewResponse - llamastackclient.ConversationItemListResponseUnion -- llamastackclient.ConversationItemGetResponseUnion +- llamastackclient.ConversationItemDeleteResponse +- llamastackclient.ConversationItemGetResponse Methods: - client.Conversations.Items.New(ctx context.Context, conversationID string, body llamastackclient.ConversationItemNewParams) (llamastackclient.ConversationItemNewResponse, error) - client.Conversations.Items.List(ctx context.Context, conversationID string, query llamastackclient.ConversationItemListParams) (pagination.OpenAICursorPage[llamastackclient.ConversationItemListResponseUnion], error) -- client.Conversations.Items.Get(ctx context.Context, itemID string, query llamastackclient.ConversationItemGetParams) (llamastackclient.ConversationItemGetResponseUnion, error) +- client.Conversations.Items.Delete(ctx context.Context, itemID string, body llamastackclient.ConversationItemDeleteParams) (llamastackclient.ConversationItemDeleteResponse, error) +- client.Conversations.Items.Get(ctx context.Context, itemID string, query llamastackclient.ConversationItemGetParams) (llamastackclient.ConversationItemGetResponse, error) # Inspect @@ -157,15 +153,15 @@ Response Types: Response Types: -- llamastackclient.ChatCompletionNewResponseUnion +- llamastackclient.ChatCompletionNewResponse - llamastackclient.ChatCompletionGetResponse - llamastackclient.ChatCompletionListResponse Methods: -- client.Chat.Completions.New(ctx context.Context, body llamastackclient.ChatCompletionNewParams) (llamastackclient.ChatCompletionNewResponseUnion, error) +- client.Chat.Completions.New(ctx context.Context, body llamastackclient.ChatCompletionNewParams) (llamastackclient.ChatCompletionNewResponse, error) - client.Chat.Completions.Get(ctx context.Context, completionID string) (llamastackclient.ChatCompletionGetResponse, error) -- client.Chat.Completions.List(ctx context.Context, query llamastackclient.ChatCompletionListParams) (pagination.OpenAICursorPage[llamastackclient.ChatCompletionListResponse], error) +- client.Chat.Completions.List(ctx context.Context, query llamastackclient.ChatCompletionListParams) (llamastackclient.ChatCompletionListResponse, error) # Completions @@ -328,21 +324,17 @@ Methods: # ScoringFunctions -Params Types: - -- llamastackclient.ScoringFnParamsUnion - Response Types: - llamastackclient.ListScoringFunctionsResponse - llamastackclient.ScoringFn -- llamastackclient.ScoringFnParamsUnionResp Methods: - client.ScoringFunctions.Get(ctx context.Context, scoringFnID string) (llamastackclient.ScoringFn, error) - client.ScoringFunctions.List(ctx context.Context) ([]llamastackclient.ScoringFn, error) - client.ScoringFunctions.Register(ctx context.Context, body llamastackclient.ScoringFunctionRegisterParams) error +- client.ScoringFunctions.Unregister(ctx context.Context, scoringFnID string) error # Files @@ -361,6 +353,22 @@ Methods: - client.Files.Delete(ctx context.Context, fileID string) (llamastackclient.DeleteFileResponse, error) - client.Files.Content(ctx context.Context, fileID string) (llamastackclient.FileContentResponse, error) +# Batches + +Response Types: + +- llamastackclient.BatchNewResponse +- llamastackclient.BatchGetResponse +- llamastackclient.BatchListResponse +- llamastackclient.BatchCancelResponse + +Methods: + +- client.Batches.New(ctx context.Context, body llamastackclient.BatchNewParams) (llamastackclient.BatchNewResponse, error) +- client.Batches.Get(ctx context.Context, batchID string) (llamastackclient.BatchGetResponse, error) +- client.Batches.List(ctx context.Context, query llamastackclient.BatchListParams) (pagination.OpenAICursorPage[llamastackclient.BatchListResponse], error) +- client.Batches.Cancel(ctx context.Context, batchID string) (llamastackclient.BatchCancelResponse, error) + # Alpha ## Inference @@ -375,10 +383,6 @@ Methods: ## PostTraining -Params Types: - -- llamastackclient.AlgorithmConfigUnionParam - Response Types: - llamastackclient.ListPostTrainingJobsResponse @@ -398,7 +402,7 @@ Response Types: Methods: -- client.Alpha.PostTraining.Job.List(ctx context.Context) ([]llamastackclient.ListPostTrainingJobsResponseData, error) +- client.Alpha.PostTraining.Job.List(ctx context.Context) ([]llamastackclient.PostTrainingJob, error) - client.Alpha.PostTraining.Job.Artifacts(ctx context.Context, query llamastackclient.AlphaPostTrainingJobArtifactsParams) (llamastackclient.AlphaPostTrainingJobArtifactsResponse, error) - client.Alpha.PostTraining.Job.Cancel(ctx context.Context, body llamastackclient.AlphaPostTrainingJobCancelParams) error - client.Alpha.PostTraining.Job.Status(ctx context.Context, query llamastackclient.AlphaPostTrainingJobStatusParams) (llamastackclient.AlphaPostTrainingJobStatusResponse, error) @@ -415,6 +419,7 @@ Methods: - client.Alpha.Benchmarks.Get(ctx context.Context, benchmarkID string) (llamastackclient.Benchmark, error) - client.Alpha.Benchmarks.List(ctx context.Context) ([]llamastackclient.Benchmark, error) - client.Alpha.Benchmarks.Register(ctx context.Context, body llamastackclient.AlphaBenchmarkRegisterParams) error +- client.Alpha.Benchmarks.Unregister(ctx context.Context, benchmarkID string) error ## Eval diff --git a/batch.go b/batch.go new file mode 100644 index 0000000..4eeba79 --- /dev/null +++ b/batch.go @@ -0,0 +1,917 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the terms described in the LICENSE file in +// the root directory of this source tree. +// +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package llamastackclient + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "slices" + + "github.com/llamastack/llama-stack-client-go/internal/apijson" + "github.com/llamastack/llama-stack-client-go/internal/apiquery" + "github.com/llamastack/llama-stack-client-go/internal/requestconfig" + "github.com/llamastack/llama-stack-client-go/option" + "github.com/llamastack/llama-stack-client-go/packages/pagination" + "github.com/llamastack/llama-stack-client-go/packages/param" + "github.com/llamastack/llama-stack-client-go/packages/respjson" + "github.com/llamastack/llama-stack-client-go/shared/constant" +) + +// BatchService contains methods and other services that help with interacting with +// the llama-stack-client API. +// +// Note, unlike clients, this service does not read variables from the environment +// automatically. You should not instantiate this service directly, and instead use +// the [NewBatchService] method instead. +type BatchService struct { + Options []option.RequestOption +} + +// NewBatchService generates a new service that applies the given options to each +// request. These options are applied after the parent client's options (if there +// is one), and before any request-specific options. +func NewBatchService(opts ...option.RequestOption) (r BatchService) { + r = BatchService{} + r.Options = opts + return +} + +// Create a new batch for processing multiple API requests. +func (r *BatchService) New(ctx context.Context, body BatchNewParams, opts ...option.RequestOption) (res *BatchNewResponse, err error) { + opts = slices.Concat(r.Options, opts) + path := "v1/batches" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return +} + +// Retrieve information about a specific batch. +func (r *BatchService) Get(ctx context.Context, batchID string, opts ...option.RequestOption) (res *BatchGetResponse, err error) { + opts = slices.Concat(r.Options, opts) + if batchID == "" { + err = errors.New("missing required batch_id parameter") + return + } + path := fmt.Sprintf("v1/batches/%s", batchID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return +} + +// List all batches for the current user. +func (r *BatchService) List(ctx context.Context, query BatchListParams, opts ...option.RequestOption) (res *pagination.OpenAICursorPage[BatchListResponse], err error) { + var raw *http.Response + opts = slices.Concat(r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := "v1/batches" + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// List all batches for the current user. +func (r *BatchService) ListAutoPaging(ctx context.Context, query BatchListParams, opts ...option.RequestOption) *pagination.OpenAICursorPageAutoPager[BatchListResponse] { + return pagination.NewOpenAICursorPageAutoPager(r.List(ctx, query, opts...)) +} + +// Cancel a batch that is in progress. +func (r *BatchService) Cancel(ctx context.Context, batchID string, opts ...option.RequestOption) (res *BatchCancelResponse, err error) { + opts = slices.Concat(r.Options, opts) + if batchID == "" { + err = errors.New("missing required batch_id parameter") + return + } + path := fmt.Sprintf("v1/batches/%s/cancel", batchID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...) + return +} + +type BatchNewResponse struct { + ID string `json:"id,required"` + CompletionWindow string `json:"completion_window,required"` + CreatedAt int64 `json:"created_at,required"` + Endpoint string `json:"endpoint,required"` + InputFileID string `json:"input_file_id,required"` + Object constant.Batch `json:"object,required"` + // Any of "validating", "failed", "in_progress", "finalizing", "completed", + // "expired", "cancelling", "cancelled". + Status BatchNewResponseStatus `json:"status,required"` + CancelledAt int64 `json:"cancelled_at,nullable"` + CancellingAt int64 `json:"cancelling_at,nullable"` + CompletedAt int64 `json:"completed_at,nullable"` + ErrorFileID string `json:"error_file_id,nullable"` + Errors BatchNewResponseErrors `json:"errors,nullable"` + ExpiredAt int64 `json:"expired_at,nullable"` + ExpiresAt int64 `json:"expires_at,nullable"` + FailedAt int64 `json:"failed_at,nullable"` + FinalizingAt int64 `json:"finalizing_at,nullable"` + InProgressAt int64 `json:"in_progress_at,nullable"` + Metadata map[string]string `json:"metadata,nullable"` + Model string `json:"model,nullable"` + OutputFileID string `json:"output_file_id,nullable"` + RequestCounts BatchNewResponseRequestCounts `json:"request_counts,nullable"` + Usage BatchNewResponseUsage `json:"usage,nullable"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + CompletionWindow respjson.Field + CreatedAt respjson.Field + Endpoint respjson.Field + InputFileID respjson.Field + Object respjson.Field + Status respjson.Field + CancelledAt respjson.Field + CancellingAt respjson.Field + CompletedAt respjson.Field + ErrorFileID respjson.Field + Errors respjson.Field + ExpiredAt respjson.Field + ExpiresAt respjson.Field + FailedAt respjson.Field + FinalizingAt respjson.Field + InProgressAt respjson.Field + Metadata respjson.Field + Model respjson.Field + OutputFileID respjson.Field + RequestCounts respjson.Field + Usage respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchNewResponse) RawJSON() string { return r.JSON.raw } +func (r *BatchNewResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchNewResponseStatus string + +const ( + BatchNewResponseStatusValidating BatchNewResponseStatus = "validating" + BatchNewResponseStatusFailed BatchNewResponseStatus = "failed" + BatchNewResponseStatusInProgress BatchNewResponseStatus = "in_progress" + BatchNewResponseStatusFinalizing BatchNewResponseStatus = "finalizing" + BatchNewResponseStatusCompleted BatchNewResponseStatus = "completed" + BatchNewResponseStatusExpired BatchNewResponseStatus = "expired" + BatchNewResponseStatusCancelling BatchNewResponseStatus = "cancelling" + BatchNewResponseStatusCancelled BatchNewResponseStatus = "cancelled" +) + +type BatchNewResponseErrors struct { + Data []BatchNewResponseErrorsData `json:"data,nullable"` + Object string `json:"object,nullable"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Data respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchNewResponseErrors) RawJSON() string { return r.JSON.raw } +func (r *BatchNewResponseErrors) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchNewResponseErrorsData struct { + Code string `json:"code,nullable"` + Line int64 `json:"line,nullable"` + Message string `json:"message,nullable"` + Param string `json:"param,nullable"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Code respjson.Field + Line respjson.Field + Message respjson.Field + Param respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchNewResponseErrorsData) RawJSON() string { return r.JSON.raw } +func (r *BatchNewResponseErrorsData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchNewResponseRequestCounts struct { + Completed int64 `json:"completed,required"` + Failed int64 `json:"failed,required"` + Total int64 `json:"total,required"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Completed respjson.Field + Failed respjson.Field + Total respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchNewResponseRequestCounts) RawJSON() string { return r.JSON.raw } +func (r *BatchNewResponseRequestCounts) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchNewResponseUsage struct { + InputTokens int64 `json:"input_tokens,required"` + InputTokensDetails BatchNewResponseUsageInputTokensDetails `json:"input_tokens_details,required"` + OutputTokens int64 `json:"output_tokens,required"` + OutputTokensDetails BatchNewResponseUsageOutputTokensDetails `json:"output_tokens_details,required"` + TotalTokens int64 `json:"total_tokens,required"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + InputTokensDetails respjson.Field + OutputTokens respjson.Field + OutputTokensDetails respjson.Field + TotalTokens respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchNewResponseUsage) RawJSON() string { return r.JSON.raw } +func (r *BatchNewResponseUsage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchNewResponseUsageInputTokensDetails struct { + CachedTokens int64 `json:"cached_tokens,required"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + CachedTokens respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchNewResponseUsageInputTokensDetails) RawJSON() string { return r.JSON.raw } +func (r *BatchNewResponseUsageInputTokensDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchNewResponseUsageOutputTokensDetails struct { + ReasoningTokens int64 `json:"reasoning_tokens,required"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ReasoningTokens respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchNewResponseUsageOutputTokensDetails) RawJSON() string { return r.JSON.raw } +func (r *BatchNewResponseUsageOutputTokensDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchGetResponse struct { + ID string `json:"id,required"` + CompletionWindow string `json:"completion_window,required"` + CreatedAt int64 `json:"created_at,required"` + Endpoint string `json:"endpoint,required"` + InputFileID string `json:"input_file_id,required"` + Object constant.Batch `json:"object,required"` + // Any of "validating", "failed", "in_progress", "finalizing", "completed", + // "expired", "cancelling", "cancelled". + Status BatchGetResponseStatus `json:"status,required"` + CancelledAt int64 `json:"cancelled_at,nullable"` + CancellingAt int64 `json:"cancelling_at,nullable"` + CompletedAt int64 `json:"completed_at,nullable"` + ErrorFileID string `json:"error_file_id,nullable"` + Errors BatchGetResponseErrors `json:"errors,nullable"` + ExpiredAt int64 `json:"expired_at,nullable"` + ExpiresAt int64 `json:"expires_at,nullable"` + FailedAt int64 `json:"failed_at,nullable"` + FinalizingAt int64 `json:"finalizing_at,nullable"` + InProgressAt int64 `json:"in_progress_at,nullable"` + Metadata map[string]string `json:"metadata,nullable"` + Model string `json:"model,nullable"` + OutputFileID string `json:"output_file_id,nullable"` + RequestCounts BatchGetResponseRequestCounts `json:"request_counts,nullable"` + Usage BatchGetResponseUsage `json:"usage,nullable"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + CompletionWindow respjson.Field + CreatedAt respjson.Field + Endpoint respjson.Field + InputFileID respjson.Field + Object respjson.Field + Status respjson.Field + CancelledAt respjson.Field + CancellingAt respjson.Field + CompletedAt respjson.Field + ErrorFileID respjson.Field + Errors respjson.Field + ExpiredAt respjson.Field + ExpiresAt respjson.Field + FailedAt respjson.Field + FinalizingAt respjson.Field + InProgressAt respjson.Field + Metadata respjson.Field + Model respjson.Field + OutputFileID respjson.Field + RequestCounts respjson.Field + Usage respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchGetResponse) RawJSON() string { return r.JSON.raw } +func (r *BatchGetResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchGetResponseStatus string + +const ( + BatchGetResponseStatusValidating BatchGetResponseStatus = "validating" + BatchGetResponseStatusFailed BatchGetResponseStatus = "failed" + BatchGetResponseStatusInProgress BatchGetResponseStatus = "in_progress" + BatchGetResponseStatusFinalizing BatchGetResponseStatus = "finalizing" + BatchGetResponseStatusCompleted BatchGetResponseStatus = "completed" + BatchGetResponseStatusExpired BatchGetResponseStatus = "expired" + BatchGetResponseStatusCancelling BatchGetResponseStatus = "cancelling" + BatchGetResponseStatusCancelled BatchGetResponseStatus = "cancelled" +) + +type BatchGetResponseErrors struct { + Data []BatchGetResponseErrorsData `json:"data,nullable"` + Object string `json:"object,nullable"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Data respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchGetResponseErrors) RawJSON() string { return r.JSON.raw } +func (r *BatchGetResponseErrors) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchGetResponseErrorsData struct { + Code string `json:"code,nullable"` + Line int64 `json:"line,nullable"` + Message string `json:"message,nullable"` + Param string `json:"param,nullable"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Code respjson.Field + Line respjson.Field + Message respjson.Field + Param respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchGetResponseErrorsData) RawJSON() string { return r.JSON.raw } +func (r *BatchGetResponseErrorsData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchGetResponseRequestCounts struct { + Completed int64 `json:"completed,required"` + Failed int64 `json:"failed,required"` + Total int64 `json:"total,required"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Completed respjson.Field + Failed respjson.Field + Total respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchGetResponseRequestCounts) RawJSON() string { return r.JSON.raw } +func (r *BatchGetResponseRequestCounts) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchGetResponseUsage struct { + InputTokens int64 `json:"input_tokens,required"` + InputTokensDetails BatchGetResponseUsageInputTokensDetails `json:"input_tokens_details,required"` + OutputTokens int64 `json:"output_tokens,required"` + OutputTokensDetails BatchGetResponseUsageOutputTokensDetails `json:"output_tokens_details,required"` + TotalTokens int64 `json:"total_tokens,required"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + InputTokensDetails respjson.Field + OutputTokens respjson.Field + OutputTokensDetails respjson.Field + TotalTokens respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchGetResponseUsage) RawJSON() string { return r.JSON.raw } +func (r *BatchGetResponseUsage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchGetResponseUsageInputTokensDetails struct { + CachedTokens int64 `json:"cached_tokens,required"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + CachedTokens respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchGetResponseUsageInputTokensDetails) RawJSON() string { return r.JSON.raw } +func (r *BatchGetResponseUsageInputTokensDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchGetResponseUsageOutputTokensDetails struct { + ReasoningTokens int64 `json:"reasoning_tokens,required"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ReasoningTokens respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchGetResponseUsageOutputTokensDetails) RawJSON() string { return r.JSON.raw } +func (r *BatchGetResponseUsageOutputTokensDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchListResponse struct { + ID string `json:"id,required"` + CompletionWindow string `json:"completion_window,required"` + CreatedAt int64 `json:"created_at,required"` + Endpoint string `json:"endpoint,required"` + InputFileID string `json:"input_file_id,required"` + Object constant.Batch `json:"object,required"` + // Any of "validating", "failed", "in_progress", "finalizing", "completed", + // "expired", "cancelling", "cancelled". + Status BatchListResponseStatus `json:"status,required"` + CancelledAt int64 `json:"cancelled_at,nullable"` + CancellingAt int64 `json:"cancelling_at,nullable"` + CompletedAt int64 `json:"completed_at,nullable"` + ErrorFileID string `json:"error_file_id,nullable"` + Errors BatchListResponseErrors `json:"errors,nullable"` + ExpiredAt int64 `json:"expired_at,nullable"` + ExpiresAt int64 `json:"expires_at,nullable"` + FailedAt int64 `json:"failed_at,nullable"` + FinalizingAt int64 `json:"finalizing_at,nullable"` + InProgressAt int64 `json:"in_progress_at,nullable"` + Metadata map[string]string `json:"metadata,nullable"` + Model string `json:"model,nullable"` + OutputFileID string `json:"output_file_id,nullable"` + RequestCounts BatchListResponseRequestCounts `json:"request_counts,nullable"` + Usage BatchListResponseUsage `json:"usage,nullable"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + CompletionWindow respjson.Field + CreatedAt respjson.Field + Endpoint respjson.Field + InputFileID respjson.Field + Object respjson.Field + Status respjson.Field + CancelledAt respjson.Field + CancellingAt respjson.Field + CompletedAt respjson.Field + ErrorFileID respjson.Field + Errors respjson.Field + ExpiredAt respjson.Field + ExpiresAt respjson.Field + FailedAt respjson.Field + FinalizingAt respjson.Field + InProgressAt respjson.Field + Metadata respjson.Field + Model respjson.Field + OutputFileID respjson.Field + RequestCounts respjson.Field + Usage respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchListResponse) RawJSON() string { return r.JSON.raw } +func (r *BatchListResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchListResponseStatus string + +const ( + BatchListResponseStatusValidating BatchListResponseStatus = "validating" + BatchListResponseStatusFailed BatchListResponseStatus = "failed" + BatchListResponseStatusInProgress BatchListResponseStatus = "in_progress" + BatchListResponseStatusFinalizing BatchListResponseStatus = "finalizing" + BatchListResponseStatusCompleted BatchListResponseStatus = "completed" + BatchListResponseStatusExpired BatchListResponseStatus = "expired" + BatchListResponseStatusCancelling BatchListResponseStatus = "cancelling" + BatchListResponseStatusCancelled BatchListResponseStatus = "cancelled" +) + +type BatchListResponseErrors struct { + Data []BatchListResponseErrorsData `json:"data,nullable"` + Object string `json:"object,nullable"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Data respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchListResponseErrors) RawJSON() string { return r.JSON.raw } +func (r *BatchListResponseErrors) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchListResponseErrorsData struct { + Code string `json:"code,nullable"` + Line int64 `json:"line,nullable"` + Message string `json:"message,nullable"` + Param string `json:"param,nullable"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Code respjson.Field + Line respjson.Field + Message respjson.Field + Param respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchListResponseErrorsData) RawJSON() string { return r.JSON.raw } +func (r *BatchListResponseErrorsData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchListResponseRequestCounts struct { + Completed int64 `json:"completed,required"` + Failed int64 `json:"failed,required"` + Total int64 `json:"total,required"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Completed respjson.Field + Failed respjson.Field + Total respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchListResponseRequestCounts) RawJSON() string { return r.JSON.raw } +func (r *BatchListResponseRequestCounts) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchListResponseUsage struct { + InputTokens int64 `json:"input_tokens,required"` + InputTokensDetails BatchListResponseUsageInputTokensDetails `json:"input_tokens_details,required"` + OutputTokens int64 `json:"output_tokens,required"` + OutputTokensDetails BatchListResponseUsageOutputTokensDetails `json:"output_tokens_details,required"` + TotalTokens int64 `json:"total_tokens,required"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + InputTokensDetails respjson.Field + OutputTokens respjson.Field + OutputTokensDetails respjson.Field + TotalTokens respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchListResponseUsage) RawJSON() string { return r.JSON.raw } +func (r *BatchListResponseUsage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchListResponseUsageInputTokensDetails struct { + CachedTokens int64 `json:"cached_tokens,required"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + CachedTokens respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchListResponseUsageInputTokensDetails) RawJSON() string { return r.JSON.raw } +func (r *BatchListResponseUsageInputTokensDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchListResponseUsageOutputTokensDetails struct { + ReasoningTokens int64 `json:"reasoning_tokens,required"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ReasoningTokens respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchListResponseUsageOutputTokensDetails) RawJSON() string { return r.JSON.raw } +func (r *BatchListResponseUsageOutputTokensDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchCancelResponse struct { + ID string `json:"id,required"` + CompletionWindow string `json:"completion_window,required"` + CreatedAt int64 `json:"created_at,required"` + Endpoint string `json:"endpoint,required"` + InputFileID string `json:"input_file_id,required"` + Object constant.Batch `json:"object,required"` + // Any of "validating", "failed", "in_progress", "finalizing", "completed", + // "expired", "cancelling", "cancelled". + Status BatchCancelResponseStatus `json:"status,required"` + CancelledAt int64 `json:"cancelled_at,nullable"` + CancellingAt int64 `json:"cancelling_at,nullable"` + CompletedAt int64 `json:"completed_at,nullable"` + ErrorFileID string `json:"error_file_id,nullable"` + Errors BatchCancelResponseErrors `json:"errors,nullable"` + ExpiredAt int64 `json:"expired_at,nullable"` + ExpiresAt int64 `json:"expires_at,nullable"` + FailedAt int64 `json:"failed_at,nullable"` + FinalizingAt int64 `json:"finalizing_at,nullable"` + InProgressAt int64 `json:"in_progress_at,nullable"` + Metadata map[string]string `json:"metadata,nullable"` + Model string `json:"model,nullable"` + OutputFileID string `json:"output_file_id,nullable"` + RequestCounts BatchCancelResponseRequestCounts `json:"request_counts,nullable"` + Usage BatchCancelResponseUsage `json:"usage,nullable"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + CompletionWindow respjson.Field + CreatedAt respjson.Field + Endpoint respjson.Field + InputFileID respjson.Field + Object respjson.Field + Status respjson.Field + CancelledAt respjson.Field + CancellingAt respjson.Field + CompletedAt respjson.Field + ErrorFileID respjson.Field + Errors respjson.Field + ExpiredAt respjson.Field + ExpiresAt respjson.Field + FailedAt respjson.Field + FinalizingAt respjson.Field + InProgressAt respjson.Field + Metadata respjson.Field + Model respjson.Field + OutputFileID respjson.Field + RequestCounts respjson.Field + Usage respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchCancelResponse) RawJSON() string { return r.JSON.raw } +func (r *BatchCancelResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchCancelResponseStatus string + +const ( + BatchCancelResponseStatusValidating BatchCancelResponseStatus = "validating" + BatchCancelResponseStatusFailed BatchCancelResponseStatus = "failed" + BatchCancelResponseStatusInProgress BatchCancelResponseStatus = "in_progress" + BatchCancelResponseStatusFinalizing BatchCancelResponseStatus = "finalizing" + BatchCancelResponseStatusCompleted BatchCancelResponseStatus = "completed" + BatchCancelResponseStatusExpired BatchCancelResponseStatus = "expired" + BatchCancelResponseStatusCancelling BatchCancelResponseStatus = "cancelling" + BatchCancelResponseStatusCancelled BatchCancelResponseStatus = "cancelled" +) + +type BatchCancelResponseErrors struct { + Data []BatchCancelResponseErrorsData `json:"data,nullable"` + Object string `json:"object,nullable"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Data respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchCancelResponseErrors) RawJSON() string { return r.JSON.raw } +func (r *BatchCancelResponseErrors) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchCancelResponseErrorsData struct { + Code string `json:"code,nullable"` + Line int64 `json:"line,nullable"` + Message string `json:"message,nullable"` + Param string `json:"param,nullable"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Code respjson.Field + Line respjson.Field + Message respjson.Field + Param respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchCancelResponseErrorsData) RawJSON() string { return r.JSON.raw } +func (r *BatchCancelResponseErrorsData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchCancelResponseRequestCounts struct { + Completed int64 `json:"completed,required"` + Failed int64 `json:"failed,required"` + Total int64 `json:"total,required"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Completed respjson.Field + Failed respjson.Field + Total respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchCancelResponseRequestCounts) RawJSON() string { return r.JSON.raw } +func (r *BatchCancelResponseRequestCounts) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchCancelResponseUsage struct { + InputTokens int64 `json:"input_tokens,required"` + InputTokensDetails BatchCancelResponseUsageInputTokensDetails `json:"input_tokens_details,required"` + OutputTokens int64 `json:"output_tokens,required"` + OutputTokensDetails BatchCancelResponseUsageOutputTokensDetails `json:"output_tokens_details,required"` + TotalTokens int64 `json:"total_tokens,required"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + InputTokensDetails respjson.Field + OutputTokens respjson.Field + OutputTokensDetails respjson.Field + TotalTokens respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchCancelResponseUsage) RawJSON() string { return r.JSON.raw } +func (r *BatchCancelResponseUsage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchCancelResponseUsageInputTokensDetails struct { + CachedTokens int64 `json:"cached_tokens,required"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + CachedTokens respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchCancelResponseUsageInputTokensDetails) RawJSON() string { return r.JSON.raw } +func (r *BatchCancelResponseUsageInputTokensDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchCancelResponseUsageOutputTokensDetails struct { + ReasoningTokens int64 `json:"reasoning_tokens,required"` + ExtraFields map[string]any `json:",extras"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ReasoningTokens respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BatchCancelResponseUsageOutputTokensDetails) RawJSON() string { return r.JSON.raw } +func (r *BatchCancelResponseUsageOutputTokensDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchNewParams struct { + Endpoint string `json:"endpoint,required"` + InputFileID string `json:"input_file_id,required"` + IdempotencyKey param.Opt[string] `json:"idempotency_key,omitzero"` + Metadata map[string]string `json:"metadata,omitzero"` + // This field can be elided, and will marshal its zero value as "24h". + CompletionWindow constant.String24h `json:"completion_window,required"` + paramObj +} + +func (r BatchNewParams) MarshalJSON() (data []byte, err error) { + type shadow BatchNewParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *BatchNewParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type BatchListParams struct { + After param.Opt[string] `query:"after,omitzero" json:"-"` + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [BatchListParams]'s query parameters as `url.Values`. +func (r BatchListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} diff --git a/batch_test.go b/batch_test.go new file mode 100644 index 0000000..815f75b --- /dev/null +++ b/batch_test.go @@ -0,0 +1,115 @@ +// Copyright (c) Meta Platforms, Inc. and affiliates. +// All rights reserved. +// +// This source code is licensed under the terms described in the LICENSE file in +// the root directory of this source tree. +// +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package llamastackclient_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/llamastack/llama-stack-client-go" + "github.com/llamastack/llama-stack-client-go/internal/testutil" + "github.com/llamastack/llama-stack-client-go/option" +) + +func TestBatchNewWithOptionalParams(t *testing.T) { + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := llamastackclient.NewClient( + option.WithBaseURL(baseURL), + ) + _, err := client.Batches.New(context.TODO(), llamastackclient.BatchNewParams{ + CompletionWindow: "24h", + Endpoint: "endpoint", + InputFileID: "input_file_id", + IdempotencyKey: llamastackclient.String("idempotency_key"), + Metadata: map[string]string{ + "foo": "string", + }, + }) + if err != nil { + var apierr *llamastackclient.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} + +func TestBatchGet(t *testing.T) { + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := llamastackclient.NewClient( + option.WithBaseURL(baseURL), + ) + _, err := client.Batches.Get(context.TODO(), "batch_id") + if err != nil { + var apierr *llamastackclient.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} + +func TestBatchListWithOptionalParams(t *testing.T) { + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := llamastackclient.NewClient( + option.WithBaseURL(baseURL), + ) + _, err := client.Batches.List(context.TODO(), llamastackclient.BatchListParams{ + After: llamastackclient.String("after"), + Limit: llamastackclient.Int(0), + }) + if err != nil { + var apierr *llamastackclient.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} + +func TestBatchCancel(t *testing.T) { + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := llamastackclient.NewClient( + option.WithBaseURL(baseURL), + ) + _, err := client.Batches.Cancel(context.TODO(), "batch_id") + if err != nil { + var apierr *llamastackclient.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} diff --git a/betadataset.go b/betadataset.go index 8568bf0..6c6a986 100644 --- a/betadataset.go +++ b/betadataset.go @@ -23,7 +23,6 @@ import ( "github.com/llamastack/llama-stack-client-go/option" "github.com/llamastack/llama-stack-client-go/packages/param" "github.com/llamastack/llama-stack-client-go/packages/respjson" - "github.com/llamastack/llama-stack-client-go/shared/constant" ) // BetaDatasetService contains methods and other services that help with @@ -83,7 +82,9 @@ func (r *BetaDatasetService) Appendrows(ctx context.Context, datasetID string, b return } -// Get a paginated list of rows from a dataset. Uses offset-based pagination where: +// Get a paginated list of rows from a dataset. +// +// Uses offset-based pagination where: // // - start_index: The starting index (0-based). If None, starts from beginning. // - limit: Number of items to return. If None or -1, returns all items. @@ -130,7 +131,6 @@ func (r *BetaDatasetService) Unregister(ctx context.Context, datasetID string, o // Response from listing datasets. type ListDatasetsResponse struct { - // List of datasets Data []ListDatasetsResponseData `json:"data,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { @@ -148,28 +148,31 @@ func (r *ListDatasetsResponse) UnmarshalJSON(data []byte) error { // Dataset resource for storing and accessing training or evaluation data. type ListDatasetsResponseData struct { + // Unique identifier for this resource in llama stack Identifier string `json:"identifier,required"` - // Additional metadata for the dataset - Metadata map[string]ListDatasetsResponseDataMetadataUnion `json:"metadata,required"` - ProviderID string `json:"provider_id,required"` - // Purpose of the dataset indicating its intended use + // ID of the provider that owns this resource + ProviderID string `json:"provider_id,required"` + // Purpose of the dataset. Each purpose has a required input data schema. // // Any of "post-training/messages", "eval/question-answer", "eval/messages-answer". Purpose string `json:"purpose,required"` - // Data source configuration for the dataset + // A dataset that can be obtained from a URI. Source ListDatasetsResponseDataSourceUnion `json:"source,required"` - // Type of resource, always 'dataset' for datasets - Type constant.Dataset `json:"type,required"` - ProviderResourceID string `json:"provider_resource_id"` + // Any additional metadata for this dataset + Metadata map[string]any `json:"metadata"` + // Unique identifier for this resource in the provider + ProviderResourceID string `json:"provider_resource_id,nullable"` + // Any of "dataset". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Identifier respjson.Field - Metadata respjson.Field ProviderID respjson.Field Purpose respjson.Field Source respjson.Field - Type respjson.Field + Metadata respjson.Field ProviderResourceID respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -181,58 +184,6 @@ func (r *ListDatasetsResponseData) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ListDatasetsResponseDataMetadataUnion contains all possible properties and -// values from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ListDatasetsResponseDataMetadataUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ListDatasetsResponseDataMetadataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ListDatasetsResponseDataMetadataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ListDatasetsResponseDataMetadataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ListDatasetsResponseDataMetadataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ListDatasetsResponseDataMetadataUnion) RawJSON() string { return u.JSON.raw } - -func (r *ListDatasetsResponseDataMetadataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - // ListDatasetsResponseDataSourceUnion contains all possible properties and values // from [ListDatasetsResponseDataSourceUri], [ListDatasetsResponseDataSourceRows]. // @@ -241,15 +192,15 @@ func (r *ListDatasetsResponseDataMetadataUnion) UnmarshalJSON(data []byte) error // // Use the methods beginning with 'As' to cast the union to one of its variants. type ListDatasetsResponseDataSourceUnion struct { - // Any of "uri", "rows". - Type string `json:"type"` // This field is from variant [ListDatasetsResponseDataSourceUri]. Uri string `json:"uri"` + // Any of "uri", "rows". + Type string `json:"type"` // This field is from variant [ListDatasetsResponseDataSourceRows]. - Rows []map[string]ListDatasetsResponseDataSourceRowsRowUnion `json:"rows"` + Rows []map[string]any `json:"rows"` JSON struct { - Type respjson.Field Uri respjson.Field + Type respjson.Field Rows respjson.Field raw string } `json:"-"` @@ -302,15 +253,13 @@ func (r *ListDatasetsResponseDataSourceUnion) UnmarshalJSON(data []byte) error { // A dataset that can be obtained from a URI. type ListDatasetsResponseDataSourceUri struct { - Type constant.Uri `json:"type,required"` - // The dataset can be obtained from a URI. E.g. - - // "https://mywebsite.com/mydata.jsonl" - "lsfs://mydata.jsonl" - - // "data:csv;base64,{base64_content}" Uri string `json:"uri,required"` + // Any of "uri". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field Uri respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -324,11 +273,9 @@ func (r *ListDatasetsResponseDataSourceUri) UnmarshalJSON(data []byte) error { // A dataset stored in rows. type ListDatasetsResponseDataSourceRows struct { - // The dataset is stored in rows. E.g. - [ {"messages": [{"role": "user", - // "content": "Hello, world!"}, {"role": "assistant", "content": "Hello, world!"}]} - // ] - Rows []map[string]ListDatasetsResponseDataSourceRowsRowUnion `json:"rows,required"` - Type constant.Rows `json:"type,required"` + Rows []map[string]any `json:"rows,required"` + // Any of "rows". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Rows respjson.Field @@ -344,82 +291,33 @@ func (r *ListDatasetsResponseDataSourceRows) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ListDatasetsResponseDataSourceRowsRowUnion contains all possible properties and -// values from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ListDatasetsResponseDataSourceRowsRowUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ListDatasetsResponseDataSourceRowsRowUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ListDatasetsResponseDataSourceRowsRowUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ListDatasetsResponseDataSourceRowsRowUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ListDatasetsResponseDataSourceRowsRowUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ListDatasetsResponseDataSourceRowsRowUnion) RawJSON() string { return u.JSON.raw } - -func (r *ListDatasetsResponseDataSourceRowsRowUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - // Dataset resource for storing and accessing training or evaluation data. type BetaDatasetGetResponse struct { + // Unique identifier for this resource in llama stack Identifier string `json:"identifier,required"` - // Additional metadata for the dataset - Metadata map[string]BetaDatasetGetResponseMetadataUnion `json:"metadata,required"` - ProviderID string `json:"provider_id,required"` - // Purpose of the dataset indicating its intended use + // ID of the provider that owns this resource + ProviderID string `json:"provider_id,required"` + // Purpose of the dataset. Each purpose has a required input data schema. // // Any of "post-training/messages", "eval/question-answer", "eval/messages-answer". Purpose BetaDatasetGetResponsePurpose `json:"purpose,required"` - // Data source configuration for the dataset + // A dataset that can be obtained from a URI. Source BetaDatasetGetResponseSourceUnion `json:"source,required"` - // Type of resource, always 'dataset' for datasets - Type constant.Dataset `json:"type,required"` - ProviderResourceID string `json:"provider_resource_id"` + // Any additional metadata for this dataset + Metadata map[string]any `json:"metadata"` + // Unique identifier for this resource in the provider + ProviderResourceID string `json:"provider_resource_id,nullable"` + // Any of "dataset". + Type BetaDatasetGetResponseType `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Identifier respjson.Field - Metadata respjson.Field ProviderID respjson.Field Purpose respjson.Field Source respjson.Field - Type respjson.Field + Metadata respjson.Field ProviderResourceID respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -431,59 +329,7 @@ func (r *BetaDatasetGetResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// BetaDatasetGetResponseMetadataUnion contains all possible properties and values -// from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type BetaDatasetGetResponseMetadataUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u BetaDatasetGetResponseMetadataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u BetaDatasetGetResponseMetadataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u BetaDatasetGetResponseMetadataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u BetaDatasetGetResponseMetadataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u BetaDatasetGetResponseMetadataUnion) RawJSON() string { return u.JSON.raw } - -func (r *BetaDatasetGetResponseMetadataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Purpose of the dataset indicating its intended use +// Purpose of the dataset. Each purpose has a required input data schema. type BetaDatasetGetResponsePurpose string const ( @@ -500,15 +346,15 @@ const ( // // Use the methods beginning with 'As' to cast the union to one of its variants. type BetaDatasetGetResponseSourceUnion struct { - // Any of "uri", "rows". - Type string `json:"type"` // This field is from variant [BetaDatasetGetResponseSourceUri]. Uri string `json:"uri"` + // Any of "uri", "rows". + Type string `json:"type"` // This field is from variant [BetaDatasetGetResponseSourceRows]. - Rows []map[string]BetaDatasetGetResponseSourceRowsRowUnion `json:"rows"` + Rows []map[string]any `json:"rows"` JSON struct { - Type respjson.Field Uri respjson.Field + Type respjson.Field Rows respjson.Field raw string } `json:"-"` @@ -561,15 +407,13 @@ func (r *BetaDatasetGetResponseSourceUnion) UnmarshalJSON(data []byte) error { // A dataset that can be obtained from a URI. type BetaDatasetGetResponseSourceUri struct { - Type constant.Uri `json:"type,required"` - // The dataset can be obtained from a URI. E.g. - - // "https://mywebsite.com/mydata.jsonl" - "lsfs://mydata.jsonl" - - // "data:csv;base64,{base64_content}" Uri string `json:"uri,required"` + // Any of "uri". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field Uri respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -583,11 +427,9 @@ func (r *BetaDatasetGetResponseSourceUri) UnmarshalJSON(data []byte) error { // A dataset stored in rows. type BetaDatasetGetResponseSourceRows struct { - // The dataset is stored in rows. E.g. - [ {"messages": [{"role": "user", - // "content": "Hello, world!"}, {"role": "assistant", "content": "Hello, world!"}]} - // ] - Rows []map[string]BetaDatasetGetResponseSourceRowsRowUnion `json:"rows,required"` - Type constant.Rows `json:"type,required"` + Rows []map[string]any `json:"rows,required"` + // Any of "rows". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Rows respjson.Field @@ -603,66 +445,17 @@ func (r *BetaDatasetGetResponseSourceRows) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// BetaDatasetGetResponseSourceRowsRowUnion contains all possible properties and -// values from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type BetaDatasetGetResponseSourceRowsRowUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u BetaDatasetGetResponseSourceRowsRowUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u BetaDatasetGetResponseSourceRowsRowUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u BetaDatasetGetResponseSourceRowsRowUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u BetaDatasetGetResponseSourceRowsRowUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u BetaDatasetGetResponseSourceRowsRowUnion) RawJSON() string { return u.JSON.raw } +type BetaDatasetGetResponseType string -func (r *BetaDatasetGetResponseSourceRowsRowUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} +const ( + BetaDatasetGetResponseTypeDataset BetaDatasetGetResponseType = "dataset" +) // A generic paginated response that follows a simple format. type BetaDatasetIterrowsResponse struct { - // The list of items for the current page - Data []map[string]BetaDatasetIterrowsResponseDataUnion `json:"data,required"` - // Whether there are more items available after this set - HasMore bool `json:"has_more,required"` - // The URL for accessing this list - URL string `json:"url"` + Data []map[string]any `json:"data,required"` + HasMore bool `json:"has_more,required"` + URL string `json:"url,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Data respjson.Field @@ -679,82 +472,33 @@ func (r *BetaDatasetIterrowsResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// BetaDatasetIterrowsResponseDataUnion contains all possible properties and values -// from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type BetaDatasetIterrowsResponseDataUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u BetaDatasetIterrowsResponseDataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u BetaDatasetIterrowsResponseDataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u BetaDatasetIterrowsResponseDataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u BetaDatasetIterrowsResponseDataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u BetaDatasetIterrowsResponseDataUnion) RawJSON() string { return u.JSON.raw } - -func (r *BetaDatasetIterrowsResponseDataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - // Dataset resource for storing and accessing training or evaluation data. type BetaDatasetRegisterResponse struct { + // Unique identifier for this resource in llama stack Identifier string `json:"identifier,required"` - // Additional metadata for the dataset - Metadata map[string]BetaDatasetRegisterResponseMetadataUnion `json:"metadata,required"` - ProviderID string `json:"provider_id,required"` - // Purpose of the dataset indicating its intended use + // ID of the provider that owns this resource + ProviderID string `json:"provider_id,required"` + // Purpose of the dataset. Each purpose has a required input data schema. // // Any of "post-training/messages", "eval/question-answer", "eval/messages-answer". Purpose BetaDatasetRegisterResponsePurpose `json:"purpose,required"` - // Data source configuration for the dataset + // A dataset that can be obtained from a URI. Source BetaDatasetRegisterResponseSourceUnion `json:"source,required"` - // Type of resource, always 'dataset' for datasets - Type constant.Dataset `json:"type,required"` - ProviderResourceID string `json:"provider_resource_id"` + // Any additional metadata for this dataset + Metadata map[string]any `json:"metadata"` + // Unique identifier for this resource in the provider + ProviderResourceID string `json:"provider_resource_id,nullable"` + // Any of "dataset". + Type BetaDatasetRegisterResponseType `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Identifier respjson.Field - Metadata respjson.Field ProviderID respjson.Field Purpose respjson.Field Source respjson.Field - Type respjson.Field + Metadata respjson.Field ProviderResourceID respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -766,59 +510,7 @@ func (r *BetaDatasetRegisterResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// BetaDatasetRegisterResponseMetadataUnion contains all possible properties and -// values from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type BetaDatasetRegisterResponseMetadataUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u BetaDatasetRegisterResponseMetadataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u BetaDatasetRegisterResponseMetadataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u BetaDatasetRegisterResponseMetadataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u BetaDatasetRegisterResponseMetadataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u BetaDatasetRegisterResponseMetadataUnion) RawJSON() string { return u.JSON.raw } - -func (r *BetaDatasetRegisterResponseMetadataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Purpose of the dataset indicating its intended use +// Purpose of the dataset. Each purpose has a required input data schema. type BetaDatasetRegisterResponsePurpose string const ( @@ -836,15 +528,15 @@ const ( // // Use the methods beginning with 'As' to cast the union to one of its variants. type BetaDatasetRegisterResponseSourceUnion struct { - // Any of "uri", "rows". - Type string `json:"type"` // This field is from variant [BetaDatasetRegisterResponseSourceUri]. Uri string `json:"uri"` + // Any of "uri", "rows". + Type string `json:"type"` // This field is from variant [BetaDatasetRegisterResponseSourceRows]. - Rows []map[string]BetaDatasetRegisterResponseSourceRowsRowUnion `json:"rows"` + Rows []map[string]any `json:"rows"` JSON struct { - Type respjson.Field Uri respjson.Field + Type respjson.Field Rows respjson.Field raw string } `json:"-"` @@ -897,15 +589,13 @@ func (r *BetaDatasetRegisterResponseSourceUnion) UnmarshalJSON(data []byte) erro // A dataset that can be obtained from a URI. type BetaDatasetRegisterResponseSourceUri struct { - Type constant.Uri `json:"type,required"` - // The dataset can be obtained from a URI. E.g. - - // "https://mywebsite.com/mydata.jsonl" - "lsfs://mydata.jsonl" - - // "data:csv;base64,{base64_content}" Uri string `json:"uri,required"` + // Any of "uri". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field Uri respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -919,11 +609,9 @@ func (r *BetaDatasetRegisterResponseSourceUri) UnmarshalJSON(data []byte) error // A dataset stored in rows. type BetaDatasetRegisterResponseSourceRows struct { - // The dataset is stored in rows. E.g. - [ {"messages": [{"role": "user", - // "content": "Hello, world!"}, {"role": "assistant", "content": "Hello, world!"}]} - // ] - Rows []map[string]BetaDatasetRegisterResponseSourceRowsRowUnion `json:"rows,required"` - Type constant.Rows `json:"type,required"` + Rows []map[string]any `json:"rows,required"` + // Any of "rows". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Rows respjson.Field @@ -939,61 +627,14 @@ func (r *BetaDatasetRegisterResponseSourceRows) UnmarshalJSON(data []byte) error return apijson.UnmarshalRoot(data, r) } -// BetaDatasetRegisterResponseSourceRowsRowUnion contains all possible properties -// and values from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type BetaDatasetRegisterResponseSourceRowsRowUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u BetaDatasetRegisterResponseSourceRowsRowUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} +type BetaDatasetRegisterResponseType string -func (u BetaDatasetRegisterResponseSourceRowsRowUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u BetaDatasetRegisterResponseSourceRowsRowUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u BetaDatasetRegisterResponseSourceRowsRowUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u BetaDatasetRegisterResponseSourceRowsRowUnion) RawJSON() string { return u.JSON.raw } - -func (r *BetaDatasetRegisterResponseSourceRowsRowUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} +const ( + BetaDatasetRegisterResponseTypeDataset BetaDatasetRegisterResponseType = "dataset" +) type BetaDatasetAppendrowsParams struct { - // The rows to append to the dataset. - Rows []map[string]BetaDatasetAppendrowsParamsRowUnion `json:"rows,omitzero,required"` + Rows []map[string]any `json:"rows,omitzero,required"` paramObj } @@ -1005,41 +646,8 @@ func (r *BetaDatasetAppendrowsParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type BetaDatasetAppendrowsParamsRowUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u BetaDatasetAppendrowsParamsRowUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *BetaDatasetAppendrowsParamsRowUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *BetaDatasetAppendrowsParamsRowUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - type BetaDatasetIterrowsParams struct { - // The number of rows to get. - Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` - // Index into dataset for the first row to get. Get all rows if None. + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` StartIndex param.Opt[int64] `query:"start_index,omitzero" json:"-"` paramObj } @@ -1054,33 +662,10 @@ func (r BetaDatasetIterrowsParams) URLQuery() (v url.Values, err error) { } type BetaDatasetRegisterParams struct { - // The purpose of the dataset. One of: - "post-training/messages": The dataset - // contains a messages column with list of messages for post-training. { - // "messages": [ {"role": "user", "content": "Hello, world!"}, {"role": - // "assistant", "content": "Hello, world!"}, ] } - "eval/question-answer": The - // dataset contains a question column and an answer column for evaluation. { - // "question": "What is the capital of France?", "answer": "Paris" } - - // "eval/messages-answer": The dataset contains a messages column with list of - // messages and an answer column for evaluation. { "messages": [ {"role": "user", - // "content": "Hello, my name is John Doe."}, {"role": "assistant", "content": - // "Hello, John Doe. How can I help you today?"}, {"role": "user", "content": - // "What's my name?"}, ], "answer": "John Doe" } - // - // Any of "post-training/messages", "eval/question-answer", "eval/messages-answer". - Purpose BetaDatasetRegisterParamsPurpose `json:"purpose,omitzero,required"` - // The data source of the dataset. Ensure that the data source schema is compatible - // with the purpose of the dataset. Examples: - { "type": "uri", "uri": - // "https://mywebsite.com/mydata.jsonl" } - { "type": "uri", "uri": - // "lsfs://mydata.jsonl" } - { "type": "uri", "uri": - // "data:csv;base64,{base64_content}" } - { "type": "uri", "uri": - // "huggingface://llamastack/simpleqa?split=train" } - { "type": "rows", "rows": [ - // { "messages": [ {"role": "user", "content": "Hello, world!"}, {"role": - // "assistant", "content": "Hello, world!"}, ] } ] } - Source BetaDatasetRegisterParamsSourceUnion `json:"source,omitzero,required"` - // The ID of the dataset. If not provided, an ID will be generated. - DatasetID param.Opt[string] `json:"dataset_id,omitzero"` - // The metadata for the dataset. - E.g. {"description": "My dataset"}. - Metadata map[string]BetaDatasetRegisterParamsMetadataUnion `json:"metadata,omitzero"` + Purpose any `json:"purpose,omitzero,required"` + Source any `json:"source,omitzero,required"` + DatasetID any `json:"dataset_id,omitzero"` + Metadata any `json:"metadata,omitzero"` paramObj } @@ -1091,185 +676,3 @@ func (r BetaDatasetRegisterParams) MarshalJSON() (data []byte, err error) { func (r *BetaDatasetRegisterParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } - -// The purpose of the dataset. One of: - "post-training/messages": The dataset -// contains a messages column with list of messages for post-training. { -// "messages": [ {"role": "user", "content": "Hello, world!"}, {"role": -// "assistant", "content": "Hello, world!"}, ] } - "eval/question-answer": The -// dataset contains a question column and an answer column for evaluation. { -// "question": "What is the capital of France?", "answer": "Paris" } - -// "eval/messages-answer": The dataset contains a messages column with list of -// messages and an answer column for evaluation. { "messages": [ {"role": "user", -// "content": "Hello, my name is John Doe."}, {"role": "assistant", "content": -// "Hello, John Doe. How can I help you today?"}, {"role": "user", "content": -// "What's my name?"}, ], "answer": "John Doe" } -type BetaDatasetRegisterParamsPurpose string - -const ( - BetaDatasetRegisterParamsPurposePostTrainingMessages BetaDatasetRegisterParamsPurpose = "post-training/messages" - BetaDatasetRegisterParamsPurposeEvalQuestionAnswer BetaDatasetRegisterParamsPurpose = "eval/question-answer" - BetaDatasetRegisterParamsPurposeEvalMessagesAnswer BetaDatasetRegisterParamsPurpose = "eval/messages-answer" -) - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type BetaDatasetRegisterParamsSourceUnion struct { - OfUri *BetaDatasetRegisterParamsSourceUri `json:",omitzero,inline"` - OfRows *BetaDatasetRegisterParamsSourceRows `json:",omitzero,inline"` - paramUnion -} - -func (u BetaDatasetRegisterParamsSourceUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfUri, u.OfRows) -} -func (u *BetaDatasetRegisterParamsSourceUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *BetaDatasetRegisterParamsSourceUnion) asAny() any { - if !param.IsOmitted(u.OfUri) { - return u.OfUri - } else if !param.IsOmitted(u.OfRows) { - return u.OfRows - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u BetaDatasetRegisterParamsSourceUnion) GetUri() *string { - if vt := u.OfUri; vt != nil { - return &vt.Uri - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u BetaDatasetRegisterParamsSourceUnion) GetRows() []map[string]BetaDatasetRegisterParamsSourceRowsRowUnion { - if vt := u.OfRows; vt != nil { - return vt.Rows - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u BetaDatasetRegisterParamsSourceUnion) GetType() *string { - if vt := u.OfUri; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfRows; vt != nil { - return (*string)(&vt.Type) - } - return nil -} - -func init() { - apijson.RegisterUnion[BetaDatasetRegisterParamsSourceUnion]( - "type", - apijson.Discriminator[BetaDatasetRegisterParamsSourceUri]("uri"), - apijson.Discriminator[BetaDatasetRegisterParamsSourceRows]("rows"), - ) -} - -// A dataset that can be obtained from a URI. -// -// The properties Type, Uri are required. -type BetaDatasetRegisterParamsSourceUri struct { - // The dataset can be obtained from a URI. E.g. - - // "https://mywebsite.com/mydata.jsonl" - "lsfs://mydata.jsonl" - - // "data:csv;base64,{base64_content}" - Uri string `json:"uri,required"` - // This field can be elided, and will marshal its zero value as "uri". - Type constant.Uri `json:"type,required"` - paramObj -} - -func (r BetaDatasetRegisterParamsSourceUri) MarshalJSON() (data []byte, err error) { - type shadow BetaDatasetRegisterParamsSourceUri - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *BetaDatasetRegisterParamsSourceUri) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A dataset stored in rows. -// -// The properties Rows, Type are required. -type BetaDatasetRegisterParamsSourceRows struct { - // The dataset is stored in rows. E.g. - [ {"messages": [{"role": "user", - // "content": "Hello, world!"}, {"role": "assistant", "content": "Hello, world!"}]} - // ] - Rows []map[string]BetaDatasetRegisterParamsSourceRowsRowUnion `json:"rows,omitzero,required"` - // This field can be elided, and will marshal its zero value as "rows". - Type constant.Rows `json:"type,required"` - paramObj -} - -func (r BetaDatasetRegisterParamsSourceRows) MarshalJSON() (data []byte, err error) { - type shadow BetaDatasetRegisterParamsSourceRows - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *BetaDatasetRegisterParamsSourceRows) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type BetaDatasetRegisterParamsSourceRowsRowUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u BetaDatasetRegisterParamsSourceRowsRowUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *BetaDatasetRegisterParamsSourceRowsRowUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *BetaDatasetRegisterParamsSourceRowsRowUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type BetaDatasetRegisterParamsMetadataUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u BetaDatasetRegisterParamsMetadataUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *BetaDatasetRegisterParamsMetadataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *BetaDatasetRegisterParamsMetadataUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} diff --git a/betadataset_test.go b/betadataset_test.go index 4143ec6..1b1d119 100644 --- a/betadataset_test.go +++ b/betadataset_test.go @@ -76,10 +76,8 @@ func TestBetaDatasetAppendrows(t *testing.T) { context.TODO(), "dataset_id", llamastackclient.BetaDatasetAppendrowsParams{ - Rows: []map[string]llamastackclient.BetaDatasetAppendrowsParamsRowUnion{{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + Rows: []map[string]any{{ + "foo": "bar", }}, }, ) @@ -132,18 +130,10 @@ func TestBetaDatasetRegisterWithOptionalParams(t *testing.T) { option.WithBaseURL(baseURL), ) _, err := client.Beta.Datasets.Register(context.TODO(), llamastackclient.BetaDatasetRegisterParams{ - Purpose: llamastackclient.BetaDatasetRegisterParamsPurposePostTrainingMessages, - Source: llamastackclient.BetaDatasetRegisterParamsSourceUnion{ - OfUri: &llamastackclient.BetaDatasetRegisterParamsSourceUri{ - Uri: "uri", - }, - }, - DatasetID: llamastackclient.String("dataset_id"), - Metadata: map[string]llamastackclient.BetaDatasetRegisterParamsMetadataUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, - }, + Purpose: map[string]interface{}{}, + Source: map[string]interface{}{}, + DatasetID: map[string]interface{}{}, + Metadata: map[string]interface{}{}, }) if err != nil { var apierr *llamastackclient.Error diff --git a/chat.go b/chat.go index 519c9ac..e18da87 100644 --- a/chat.go +++ b/chat.go @@ -12,7 +12,6 @@ import ( "github.com/llamastack/llama-stack-client-go/internal/apijson" "github.com/llamastack/llama-stack-client-go/option" "github.com/llamastack/llama-stack-client-go/packages/respjson" - "github.com/llamastack/llama-stack-client-go/shared/constant" ) // ChatService contains methods and other services that help with interacting with @@ -38,18 +37,14 @@ func NewChatService(opts ...option.RequestOption) (r ChatService) { // Chunk from a streaming response to an OpenAI-compatible chat completion request. type ChatCompletionChunk struct { - // The ID of the chat completion - ID string `json:"id,required"` - // List of choices + ID string `json:"id,required"` Choices []ChatCompletionChunkChoice `json:"choices,required"` - // The Unix timestamp in seconds when the chat completion was created - Created int64 `json:"created,required"` - // The model that was used to generate the chat completion - Model string `json:"model,required"` - // The object type, which will be "chat.completion.chunk" - Object constant.ChatCompletionChunk `json:"object,required"` - // Token usage information (typically included in final chunk with stream_options) - Usage ChatCompletionChunkUsage `json:"usage"` + Created int64 `json:"created,required"` + Model string `json:"model,required"` + // Any of "chat.completion.chunk". + Object ChatCompletionChunkObject `json:"object"` + // Usage information for OpenAI chat completion. + Usage ChatCompletionChunkUsage `json:"usage,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -71,14 +66,13 @@ func (r *ChatCompletionChunk) UnmarshalJSON(data []byte) error { // A chunk choice from an OpenAI-compatible chat completion streaming response. type ChatCompletionChunkChoice struct { - // The delta from the chunk - Delta ChatCompletionChunkChoiceDelta `json:"delta,required"` - // The reason the model stopped generating - FinishReason string `json:"finish_reason,required"` - // The index of the choice - Index int64 `json:"index,required"` - // (Optional) The log probabilities for the tokens in the message - Logprobs ChatCompletionChunkChoiceLogprobs `json:"logprobs"` + // A delta from an OpenAI-compatible chat completion streaming response. + Delta ChatCompletionChunkChoiceDelta `json:"delta,required"` + FinishReason string `json:"finish_reason,required"` + Index int64 `json:"index,required"` + // The log probabilities for the tokens in the message from an OpenAI-compatible + // chat completion response. + Logprobs ChatCompletionChunkChoiceLogprobs `json:"logprobs,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Delta respjson.Field @@ -96,18 +90,13 @@ func (r *ChatCompletionChunkChoice) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// The delta from the chunk +// A delta from an OpenAI-compatible chat completion streaming response. type ChatCompletionChunkChoiceDelta struct { - // (Optional) The content of the delta - Content string `json:"content"` - // (Optional) The reasoning content from the model (non-standard, for o1/o3 models) - ReasoningContent string `json:"reasoning_content"` - // (Optional) The refusal of the delta - Refusal string `json:"refusal"` - // (Optional) The role of the delta - Role string `json:"role"` - // (Optional) The tool calls of the delta - ToolCalls []ChatCompletionChunkChoiceDeltaToolCall `json:"tool_calls"` + Content string `json:"content,nullable"` + ReasoningContent string `json:"reasoning_content,nullable"` + Refusal string `json:"refusal,nullable"` + Role string `json:"role,nullable"` + ToolCalls []ChatCompletionChunkChoiceDeltaToolCall `json:"tool_calls,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field @@ -128,20 +117,18 @@ func (r *ChatCompletionChunkChoiceDelta) UnmarshalJSON(data []byte) error { // Tool call specification for OpenAI-compatible chat completion responses. type ChatCompletionChunkChoiceDeltaToolCall struct { - // Must be "function" to identify this as a function call - Type constant.Function `json:"type,required"` - // (Optional) Unique identifier for the tool call - ID string `json:"id"` - // (Optional) Function call details - Function ChatCompletionChunkChoiceDeltaToolCallFunction `json:"function"` - // (Optional) Index of the tool call in the list - Index int64 `json:"index"` + ID string `json:"id,nullable"` + // Function call details for OpenAI-compatible tool calls. + Function ChatCompletionChunkChoiceDeltaToolCallFunction `json:"function,nullable"` + Index int64 `json:"index,nullable"` + // Any of "function". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field ID respjson.Field Function respjson.Field Index respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -153,12 +140,10 @@ func (r *ChatCompletionChunkChoiceDeltaToolCall) UnmarshalJSON(data []byte) erro return apijson.UnmarshalRoot(data, r) } -// (Optional) Function call details +// Function call details for OpenAI-compatible tool calls. type ChatCompletionChunkChoiceDeltaToolCallFunction struct { - // (Optional) Arguments to pass to the function as a JSON string - Arguments string `json:"arguments"` - // (Optional) Name of the function to call - Name string `json:"name"` + Arguments string `json:"arguments,nullable"` + Name string `json:"name,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Arguments respjson.Field @@ -174,12 +159,11 @@ func (r *ChatCompletionChunkChoiceDeltaToolCallFunction) UnmarshalJSON(data []by return apijson.UnmarshalRoot(data, r) } -// (Optional) The log probabilities for the tokens in the message +// The log probabilities for the tokens in the message from an OpenAI-compatible +// chat completion response. type ChatCompletionChunkChoiceLogprobs struct { - // (Optional) The log probabilities for the tokens in the message - Content []ChatCompletionChunkChoiceLogprobsContent `json:"content"` - // (Optional) The log probabilities for the tokens in the message - Refusal []ChatCompletionChunkChoiceLogprobsRefusal `json:"refusal"` + Content []ChatCompletionChunkChoiceLogprobsContent `json:"content,nullable"` + Refusal []ChatCompletionChunkChoiceLogprobsRefusal `json:"refusal,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field @@ -197,11 +181,14 @@ func (r *ChatCompletionChunkChoiceLogprobs) UnmarshalJSON(data []byte) error { // The log probability for a token from an OpenAI-compatible chat completion // response. +// +// :token: The token :bytes: (Optional) The bytes for the token :logprob: The log +// probability of the token :top_logprobs: The top log probabilities for the token type ChatCompletionChunkChoiceLogprobsContent struct { Token string `json:"token,required"` Logprob float64 `json:"logprob,required"` TopLogprobs []ChatCompletionChunkChoiceLogprobsContentTopLogprob `json:"top_logprobs,required"` - Bytes []int64 `json:"bytes"` + Bytes []int64 `json:"bytes,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Token respjson.Field @@ -221,10 +208,13 @@ func (r *ChatCompletionChunkChoiceLogprobsContent) UnmarshalJSON(data []byte) er // The top log probability for a token from an OpenAI-compatible chat completion // response. +// +// :token: The token :bytes: (Optional) The bytes for the token :logprob: The log +// probability of the token type ChatCompletionChunkChoiceLogprobsContentTopLogprob struct { Token string `json:"token,required"` Logprob float64 `json:"logprob,required"` - Bytes []int64 `json:"bytes"` + Bytes []int64 `json:"bytes,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Token respjson.Field @@ -243,11 +233,14 @@ func (r *ChatCompletionChunkChoiceLogprobsContentTopLogprob) UnmarshalJSON(data // The log probability for a token from an OpenAI-compatible chat completion // response. +// +// :token: The token :bytes: (Optional) The bytes for the token :logprob: The log +// probability of the token :top_logprobs: The top log probabilities for the token type ChatCompletionChunkChoiceLogprobsRefusal struct { Token string `json:"token,required"` Logprob float64 `json:"logprob,required"` TopLogprobs []ChatCompletionChunkChoiceLogprobsRefusalTopLogprob `json:"top_logprobs,required"` - Bytes []int64 `json:"bytes"` + Bytes []int64 `json:"bytes,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Token respjson.Field @@ -267,10 +260,13 @@ func (r *ChatCompletionChunkChoiceLogprobsRefusal) UnmarshalJSON(data []byte) er // The top log probability for a token from an OpenAI-compatible chat completion // response. +// +// :token: The token :bytes: (Optional) The bytes for the token :logprob: The log +// probability of the token type ChatCompletionChunkChoiceLogprobsRefusalTopLogprob struct { Token string `json:"token,required"` Logprob float64 `json:"logprob,required"` - Bytes []int64 `json:"bytes"` + Bytes []int64 `json:"bytes,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Token respjson.Field @@ -287,18 +283,21 @@ func (r *ChatCompletionChunkChoiceLogprobsRefusalTopLogprob) UnmarshalJSON(data return apijson.UnmarshalRoot(data, r) } -// Token usage information (typically included in final chunk with stream_options) +type ChatCompletionChunkObject string + +const ( + ChatCompletionChunkObjectChatCompletionChunk ChatCompletionChunkObject = "chat.completion.chunk" +) + +// Usage information for OpenAI chat completion. type ChatCompletionChunkUsage struct { - // Number of tokens in the completion CompletionTokens int64 `json:"completion_tokens,required"` - // Number of tokens in the prompt - PromptTokens int64 `json:"prompt_tokens,required"` - // Total tokens used (prompt + completion) - TotalTokens int64 `json:"total_tokens,required"` + PromptTokens int64 `json:"prompt_tokens,required"` + TotalTokens int64 `json:"total_tokens,required"` // Token details for output tokens in OpenAI chat completion usage. - CompletionTokensDetails ChatCompletionChunkUsageCompletionTokensDetails `json:"completion_tokens_details"` + CompletionTokensDetails ChatCompletionChunkUsageCompletionTokensDetails `json:"completion_tokens_details,nullable"` // Token details for prompt tokens in OpenAI chat completion usage. - PromptTokensDetails ChatCompletionChunkUsagePromptTokensDetails `json:"prompt_tokens_details"` + PromptTokensDetails ChatCompletionChunkUsagePromptTokensDetails `json:"prompt_tokens_details,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { CompletionTokens respjson.Field @@ -319,8 +318,7 @@ func (r *ChatCompletionChunkUsage) UnmarshalJSON(data []byte) error { // Token details for output tokens in OpenAI chat completion usage. type ChatCompletionChunkUsageCompletionTokensDetails struct { - // Number of tokens used for reasoning (o1/o3 models) - ReasoningTokens int64 `json:"reasoning_tokens"` + ReasoningTokens int64 `json:"reasoning_tokens,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ReasoningTokens respjson.Field @@ -337,8 +335,7 @@ func (r *ChatCompletionChunkUsageCompletionTokensDetails) UnmarshalJSON(data []b // Token details for prompt tokens in OpenAI chat completion usage. type ChatCompletionChunkUsagePromptTokensDetails struct { - // Number of tokens retrieved from cache - CachedTokens int64 `json:"cached_tokens"` + CachedTokens int64 `json:"cached_tokens,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { CachedTokens respjson.Field diff --git a/chatcompletion.go b/chatcompletion.go index add4bd1..7e8a4c9 100644 --- a/chatcompletion.go +++ b/chatcompletion.go @@ -21,11 +21,9 @@ import ( "github.com/llamastack/llama-stack-client-go/internal/apiquery" "github.com/llamastack/llama-stack-client-go/internal/requestconfig" "github.com/llamastack/llama-stack-client-go/option" - "github.com/llamastack/llama-stack-client-go/packages/pagination" "github.com/llamastack/llama-stack-client-go/packages/param" "github.com/llamastack/llama-stack-client-go/packages/respjson" "github.com/llamastack/llama-stack-client-go/packages/ssestream" - "github.com/llamastack/llama-stack-client-go/shared/constant" ) // ChatCompletionService contains methods and other services that help with @@ -47,17 +45,21 @@ func NewChatCompletionService(opts ...option.RequestOption) (r ChatCompletionSer return } -// Create chat completions. Generate an OpenAI-compatible chat completion for the -// given messages using the specified model. -func (r *ChatCompletionService) New(ctx context.Context, body ChatCompletionNewParams, opts ...option.RequestOption) (res *ChatCompletionNewResponseUnion, err error) { +// Create chat completions. +// +// Generate an OpenAI-compatible chat completion for the given messages using the +// specified model. +func (r *ChatCompletionService) New(ctx context.Context, body ChatCompletionNewParams, opts ...option.RequestOption) (res *ChatCompletionNewResponse, err error) { opts = slices.Concat(r.Options, opts) path := "v1/chat/completions" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return } -// Create chat completions. Generate an OpenAI-compatible chat completion for the -// given messages using the specified model. +// Create chat completions. +// +// Generate an OpenAI-compatible chat completion for the given messages using the +// specified model. func (r *ChatCompletionService) NewStreaming(ctx context.Context, body ChatCompletionNewParams, opts ...option.RequestOption) (stream *ssestream.Stream[ChatCompletionChunk]) { var ( raw *http.Response @@ -70,7 +72,9 @@ func (r *ChatCompletionService) NewStreaming(ctx context.Context, body ChatCompl return ssestream.NewStream[ChatCompletionChunk](ssestream.NewDecoder(raw), err) } -// Get chat completion. Describe a chat completion by its ID. +// Get chat completion. +// +// Describe a chat completion by its ID. func (r *ChatCompletionService) Get(ctx context.Context, completionID string, opts ...option.RequestOption) (res *ChatCompletionGetResponse, err error) { opts = slices.Concat(r.Options, opts) if completionID == "" { @@ -83,184 +87,23 @@ func (r *ChatCompletionService) Get(ctx context.Context, completionID string, op } // List chat completions. -func (r *ChatCompletionService) List(ctx context.Context, query ChatCompletionListParams, opts ...option.RequestOption) (res *pagination.OpenAICursorPage[ChatCompletionListResponse], err error) { - var raw *http.Response +func (r *ChatCompletionService) List(ctx context.Context, query ChatCompletionListParams, opts ...option.RequestOption) (res *ChatCompletionListResponse, err error) { opts = slices.Concat(r.Options, opts) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) path := "v1/chat/completions" - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// List chat completions. -func (r *ChatCompletionService) ListAutoPaging(ctx context.Context, query ChatCompletionListParams, opts ...option.RequestOption) *pagination.OpenAICursorPageAutoPager[ChatCompletionListResponse] { - return pagination.NewOpenAICursorPageAutoPager(r.List(ctx, query, opts...)) -} - -// ChatCompletionNewResponseUnion contains all possible properties and values from -// [ChatCompletionNewResponseOpenAIChatCompletion], [ChatCompletionChunk]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -type ChatCompletionNewResponseUnion struct { - ID string `json:"id"` - // This field is a union of - // [[]ChatCompletionNewResponseOpenAIChatCompletionChoice], - // [[]ChatCompletionChunkChoice] - Choices ChatCompletionNewResponseUnionChoices `json:"choices"` - Created int64 `json:"created"` - Model string `json:"model"` - Object string `json:"object"` - // This field is a union of [ChatCompletionNewResponseOpenAIChatCompletionUsage], - // [ChatCompletionChunkUsage] - Usage ChatCompletionNewResponseUnionUsage `json:"usage"` - JSON struct { - ID respjson.Field - Choices respjson.Field - Created respjson.Field - Model respjson.Field - Object respjson.Field - Usage respjson.Field - raw string - } `json:"-"` -} - -func (u ChatCompletionNewResponseUnion) AsOpenAIChatCompletion() (v ChatCompletionNewResponseOpenAIChatCompletion) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ChatCompletionNewResponseUnion) AsOpenAIChatCompletionChunk() (v ChatCompletionChunk) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) return } -// Returns the unmodified JSON received from the API -func (u ChatCompletionNewResponseUnion) RawJSON() string { return u.JSON.raw } - -func (r *ChatCompletionNewResponseUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ChatCompletionNewResponseUnionChoices is an implicit subunion of -// [ChatCompletionNewResponseUnion]. ChatCompletionNewResponseUnionChoices provides -// convenient access to the sub-properties of the union. -// -// For type safety it is recommended to directly use a variant of the -// [ChatCompletionNewResponseUnion]. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfChatCompletionNewResponseOpenAIChatCompletionChoices -// OfChatCompletionChunkChoices] -type ChatCompletionNewResponseUnionChoices struct { - // This field will be present if the value is a - // [[]ChatCompletionNewResponseOpenAIChatCompletionChoice] instead of an object. - OfChatCompletionNewResponseOpenAIChatCompletionChoices []ChatCompletionNewResponseOpenAIChatCompletionChoice `json:",inline"` - // This field will be present if the value is a [[]ChatCompletionChunkChoice] - // instead of an object. - OfChatCompletionChunkChoices []ChatCompletionChunkChoice `json:",inline"` - JSON struct { - OfChatCompletionNewResponseOpenAIChatCompletionChoices respjson.Field - OfChatCompletionChunkChoices respjson.Field - raw string - } `json:"-"` -} - -func (r *ChatCompletionNewResponseUnionChoices) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ChatCompletionNewResponseUnionUsage is an implicit subunion of -// [ChatCompletionNewResponseUnion]. ChatCompletionNewResponseUnionUsage provides -// convenient access to the sub-properties of the union. -// -// For type safety it is recommended to directly use a variant of the -// [ChatCompletionNewResponseUnion]. -type ChatCompletionNewResponseUnionUsage struct { - CompletionTokens int64 `json:"completion_tokens"` - PromptTokens int64 `json:"prompt_tokens"` - TotalTokens int64 `json:"total_tokens"` - // This field is a union of - // [ChatCompletionNewResponseOpenAIChatCompletionUsageCompletionTokensDetails], - // [ChatCompletionChunkUsageCompletionTokensDetails] - CompletionTokensDetails ChatCompletionNewResponseUnionUsageCompletionTokensDetails `json:"completion_tokens_details"` - // This field is a union of - // [ChatCompletionNewResponseOpenAIChatCompletionUsagePromptTokensDetails], - // [ChatCompletionChunkUsagePromptTokensDetails] - PromptTokensDetails ChatCompletionNewResponseUnionUsagePromptTokensDetails `json:"prompt_tokens_details"` - JSON struct { - CompletionTokens respjson.Field - PromptTokens respjson.Field - TotalTokens respjson.Field - CompletionTokensDetails respjson.Field - PromptTokensDetails respjson.Field - raw string - } `json:"-"` -} - -func (r *ChatCompletionNewResponseUnionUsage) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ChatCompletionNewResponseUnionUsageCompletionTokensDetails is an implicit -// subunion of [ChatCompletionNewResponseUnion]. -// ChatCompletionNewResponseUnionUsageCompletionTokensDetails provides convenient -// access to the sub-properties of the union. -// -// For type safety it is recommended to directly use a variant of the -// [ChatCompletionNewResponseUnion]. -type ChatCompletionNewResponseUnionUsageCompletionTokensDetails struct { - ReasoningTokens int64 `json:"reasoning_tokens"` - JSON struct { - ReasoningTokens respjson.Field - raw string - } `json:"-"` -} - -func (r *ChatCompletionNewResponseUnionUsageCompletionTokensDetails) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ChatCompletionNewResponseUnionUsagePromptTokensDetails is an implicit subunion -// of [ChatCompletionNewResponseUnion]. -// ChatCompletionNewResponseUnionUsagePromptTokensDetails provides convenient -// access to the sub-properties of the union. -// -// For type safety it is recommended to directly use a variant of the -// [ChatCompletionNewResponseUnion]. -type ChatCompletionNewResponseUnionUsagePromptTokensDetails struct { - CachedTokens int64 `json:"cached_tokens"` - JSON struct { - CachedTokens respjson.Field - raw string - } `json:"-"` -} - -func (r *ChatCompletionNewResponseUnionUsagePromptTokensDetails) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - // Response from an OpenAI-compatible chat completion request. -type ChatCompletionNewResponseOpenAIChatCompletion struct { - // The ID of the chat completion - ID string `json:"id,required"` - // List of choices - Choices []ChatCompletionNewResponseOpenAIChatCompletionChoice `json:"choices,required"` - // The Unix timestamp in seconds when the chat completion was created - Created int64 `json:"created,required"` - // The model that was used to generate the chat completion - Model string `json:"model,required"` - // The object type, which will be "chat.completion" - Object constant.ChatCompletion `json:"object,required"` - // Token usage information for the completion - Usage ChatCompletionNewResponseOpenAIChatCompletionUsage `json:"usage"` +type ChatCompletionNewResponse struct { + ID string `json:"id,required"` + Choices []ChatCompletionNewResponseChoice `json:"choices,required"` + Created int64 `json:"created,required"` + Model string `json:"model,required"` + // Any of "chat.completion". + Object ChatCompletionNewResponseObject `json:"object"` + // Usage information for OpenAI chat completion. + Usage ChatCompletionNewResponseUsage `json:"usage,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -275,21 +118,20 @@ type ChatCompletionNewResponseOpenAIChatCompletion struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletion) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionNewResponseOpenAIChatCompletion) UnmarshalJSON(data []byte) error { +func (r ChatCompletionNewResponse) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionNewResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A choice from an OpenAI-compatible chat completion response. -type ChatCompletionNewResponseOpenAIChatCompletionChoice struct { - // The reason the model stopped generating +type ChatCompletionNewResponseChoice struct { FinishReason string `json:"finish_reason,required"` - // The index of the choice - Index int64 `json:"index,required"` - // The message from the model - Message ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion `json:"message,required"` - // (Optional) The log probabilities for the tokens in the message - Logprobs ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobs `json:"logprobs"` + Index int64 `json:"index,required"` + // A message from the user in an OpenAI-compatible chat completion request. + Message ChatCompletionNewResponseChoiceMessageUnion `json:"message,required"` + // The log probabilities for the tokens in the message from an OpenAI-compatible + // chat completion response. + Logprobs ChatCompletionNewResponseChoiceLogprobs `json:"logprobs,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { FinishReason respjson.Field @@ -302,82 +144,75 @@ type ChatCompletionNewResponseOpenAIChatCompletionChoice struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionChoice) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoice) UnmarshalJSON(data []byte) error { +func (r ChatCompletionNewResponseChoice) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionNewResponseChoice) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion contains all -// possible properties and values from -// [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUser], -// [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystem], -// [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistant], -// [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageTool], -// [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloper]. +// ChatCompletionNewResponseChoiceMessageUnion contains all possible properties and +// values from [ChatCompletionNewResponseChoiceMessageUser], +// [ChatCompletionNewResponseChoiceMessageSystem], +// [ChatCompletionNewResponseChoiceMessageAssistant], +// [ChatCompletionNewResponseChoiceMessageTool], +// [ChatCompletionNewResponseChoiceMessageDeveloper]. // -// Use the [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion.AsAny] -// method to switch on the variant. +// Use the [ChatCompletionNewResponseChoiceMessageUnion.AsAny] method to switch on +// the variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion struct { +type ChatCompletionNewResponseChoiceMessageUnion struct { // This field is a union of - // [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentUnion], - // [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentUnion], - // [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentUnion], - // [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentUnion], - // [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentUnion] - Content ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnionContent `json:"content"` + // [ChatCompletionNewResponseChoiceMessageUserContentUnion], + // [ChatCompletionNewResponseChoiceMessageSystemContentUnion], + // [ChatCompletionNewResponseChoiceMessageAssistantContentUnion], + // [ChatCompletionNewResponseChoiceMessageToolContentUnion], + // [ChatCompletionNewResponseChoiceMessageDeveloperContentUnion] + Content ChatCompletionNewResponseChoiceMessageUnionContent `json:"content"` + Name string `json:"name"` // Any of "user", "system", "assistant", "tool", "developer". Role string `json:"role"` - Name string `json:"name"` - // This field is from variant - // [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistant]. - ToolCalls []ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantToolCall `json:"tool_calls"` - // This field is from variant - // [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageTool]. + // This field is from variant [ChatCompletionNewResponseChoiceMessageAssistant]. + ToolCalls []ChatCompletionNewResponseChoiceMessageAssistantToolCall `json:"tool_calls"` + // This field is from variant [ChatCompletionNewResponseChoiceMessageTool]. ToolCallID string `json:"tool_call_id"` JSON struct { Content respjson.Field - Role respjson.Field Name respjson.Field + Role respjson.Field ToolCalls respjson.Field ToolCallID respjson.Field raw string } `json:"-"` } -// anyChatCompletionNewResponseOpenAIChatCompletionChoiceMessage is implemented by -// each variant of -// [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion] to add type -// safety for the return type of -// [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion.AsAny] -type anyChatCompletionNewResponseOpenAIChatCompletionChoiceMessage interface { - implChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion() +// anyChatCompletionNewResponseChoiceMessage is implemented by each variant of +// [ChatCompletionNewResponseChoiceMessageUnion] to add type safety for the return +// type of [ChatCompletionNewResponseChoiceMessageUnion.AsAny] +type anyChatCompletionNewResponseChoiceMessage interface { + implChatCompletionNewResponseChoiceMessageUnion() } -func (ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUser) implChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion() { -} -func (ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystem) implChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion() { +func (ChatCompletionNewResponseChoiceMessageUser) implChatCompletionNewResponseChoiceMessageUnion() {} +func (ChatCompletionNewResponseChoiceMessageSystem) implChatCompletionNewResponseChoiceMessageUnion() { } -func (ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistant) implChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion() { +func (ChatCompletionNewResponseChoiceMessageAssistant) implChatCompletionNewResponseChoiceMessageUnion() { } -func (ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageTool) implChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion() { -} -func (ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloper) implChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion() { +func (ChatCompletionNewResponseChoiceMessageTool) implChatCompletionNewResponseChoiceMessageUnion() {} +func (ChatCompletionNewResponseChoiceMessageDeveloper) implChatCompletionNewResponseChoiceMessageUnion() { } // Use the following switch statement to find the correct variant // -// switch variant := ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion.AsAny().(type) { -// case llamastackclient.ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUser: -// case llamastackclient.ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystem: -// case llamastackclient.ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistant: -// case llamastackclient.ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageTool: -// case llamastackclient.ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloper: +// switch variant := ChatCompletionNewResponseChoiceMessageUnion.AsAny().(type) { +// case llamastackclient.ChatCompletionNewResponseChoiceMessageUser: +// case llamastackclient.ChatCompletionNewResponseChoiceMessageSystem: +// case llamastackclient.ChatCompletionNewResponseChoiceMessageAssistant: +// case llamastackclient.ChatCompletionNewResponseChoiceMessageTool: +// case llamastackclient.ChatCompletionNewResponseChoiceMessageDeveloper: // default: // fmt.Errorf("no variant present") // } -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion) AsAny() anyChatCompletionNewResponseOpenAIChatCompletionChoiceMessage { +func (u ChatCompletionNewResponseChoiceMessageUnion) AsAny() anyChatCompletionNewResponseChoiceMessage { switch u.Role { case "user": return u.AsUser() @@ -393,185 +228,158 @@ func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion) AsAny() return nil } -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion) AsUser() (v ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUser) { +func (u ChatCompletionNewResponseChoiceMessageUnion) AsUser() (v ChatCompletionNewResponseChoiceMessageUser) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion) AsSystem() (v ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystem) { +func (u ChatCompletionNewResponseChoiceMessageUnion) AsSystem() (v ChatCompletionNewResponseChoiceMessageSystem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion) AsAssistant() (v ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistant) { +func (u ChatCompletionNewResponseChoiceMessageUnion) AsAssistant() (v ChatCompletionNewResponseChoiceMessageAssistant) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion) AsTool() (v ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageTool) { +func (u ChatCompletionNewResponseChoiceMessageUnion) AsTool() (v ChatCompletionNewResponseChoiceMessageTool) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion) AsDeveloper() (v ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloper) { +func (u ChatCompletionNewResponseChoiceMessageUnion) AsDeveloper() (v ChatCompletionNewResponseChoiceMessageDeveloper) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion) RawJSON() string { - return u.JSON.raw -} +func (u ChatCompletionNewResponseChoiceMessageUnion) RawJSON() string { return u.JSON.raw } -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewResponseChoiceMessageUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnionContent is an -// implicit subunion of -// [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion]. -// ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnionContent provides -// convenient access to the sub-properties of the union. +// ChatCompletionNewResponseChoiceMessageUnionContent is an implicit subunion of +// [ChatCompletionNewResponseChoiceMessageUnion]. +// ChatCompletionNewResponseChoiceMessageUnionContent provides convenient access to +// the sub-properties of the union. // // For type safety it is recommended to directly use a variant of the -// [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnion]. +// [ChatCompletionNewResponseChoiceMessageUnion]. // // If the underlying value is not a json object, one of the following properties // will be valid: OfString -// OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArray -// OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentArray -// OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentArray -// OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentArray -// OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentArray] -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnionContent struct { +// OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile +// OfListOpenAIChatCompletionContentPartText] +type ChatCompletionNewResponseChoiceMessageUnionContent struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemUnion] - // instead of an object. - OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArray []ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemUnion `json:",inline"` - // This field will be present if the value is a - // [[]ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentArrayItem] - // instead of an object. - OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentArray []ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentArrayItem `json:",inline"` - // This field will be present if the value is a - // [[]ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentArrayItem] + // [[]ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion] // instead of an object. - OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentArray []ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentArrayItem `json:",inline"` + OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile []ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentArrayItem] + // [[]ChatCompletionNewResponseChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem] // instead of an object. - OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentArray []ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentArrayItem `json:",inline"` - // This field will be present if the value is a - // [[]ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentArrayItem] - // instead of an object. - OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentArray []ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArray respjson.Field - OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentArray respjson.Field - OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentArray respjson.Field - OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentArray respjson.Field - OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentArray respjson.Field - raw string + OfListOpenAIChatCompletionContentPartText []ChatCompletionNewResponseChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUnionContent) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewResponseChoiceMessageUnionContent) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A message from the user in an OpenAI-compatible chat completion request. -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUser struct { - // The content of the message, which can include text and other media - Content ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentUnion `json:"content,required"` - // Must be "user" to identify this as a user message - Role constant.User `json:"role,required"` - // (Optional) The name of the user message participant. - Name string `json:"name"` +type ChatCompletionNewResponseChoiceMessageUser struct { + Content ChatCompletionNewResponseChoiceMessageUserContentUnion `json:"content,required"` + Name string `json:"name,nullable"` + // Any of "user". + Role string `json:"role"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field - Role respjson.Field Name respjson.Field + Role respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUser) RawJSON() string { - return r.JSON.raw -} -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUser) UnmarshalJSON(data []byte) error { +func (r ChatCompletionNewResponseChoiceMessageUser) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionNewResponseChoiceMessageUser) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentUnion -// contains all possible properties and values from [string], -// [[]ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemUnion]. +// ChatCompletionNewResponseChoiceMessageUserContentUnion contains all possible +// properties and values from [string], +// [[]ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties // will be valid: OfString -// OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArray] -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentUnion struct { +// OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile] +type ChatCompletionNewResponseChoiceMessageUserContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemUnion] + // [[]ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion] // instead of an object. - OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArray []ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemUnion `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArray respjson.Field - raw string + OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile []ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile respjson.Field + raw string } `json:"-"` } -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentUnion) AsString() (v string) { +func (u ChatCompletionNewResponseChoiceMessageUserContentUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentUnion) AsChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArray() (v []ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemUnion) { +func (u ChatCompletionNewResponseChoiceMessageUserContentUnion) AsListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFile() (v []ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentUnion) RawJSON() string { - return u.JSON.raw -} +func (u ChatCompletionNewResponseChoiceMessageUserContentUnion) RawJSON() string { return u.JSON.raw } -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentUnion) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewResponseChoiceMessageUserContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemUnion +// ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion // contains all possible properties and values from -// [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemText], -// [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemImageURL], -// [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemFile]. +// [ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText], +// [ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL], +// [ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile]. // // Use the -// [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemUnion.AsAny] +// [ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion.AsAny] // method to switch on the variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemUnion struct { +type ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion struct { // This field is from variant - // [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemText]. + // [ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText]. Text string `json:"text"` // Any of "text", "image_url", "file". Type string `json:"type"` // This field is from variant - // [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemImageURL]. - ImageURL ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemImageURLImageURL `json:"image_url"` + // [ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL]. + ImageURL ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL `json:"image_url"` // This field is from variant - // [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemFile]. - File ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemFileFile `json:"file"` + // [ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile]. + File ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile `json:"file"` JSON struct { Text respjson.Field Type respjson.Field @@ -581,32 +389,32 @@ type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayI } `json:"-"` } -// anyChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItem +// anyChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItem // is implemented by each variant of -// [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemUnion] +// [ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion] // to add type safety for the return type of -// [ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemUnion.AsAny] -type anyChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItem interface { - implChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemUnion() +// [ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion.AsAny] +type anyChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItem interface { + implChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion() } -func (ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemText) implChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemUnion() { +func (ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) implChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion() { } -func (ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemImageURL) implChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemUnion() { +func (ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) implChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion() { } -func (ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemFile) implChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemUnion() { +func (ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) implChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion() { } // Use the following switch statement to find the correct variant // -// switch variant := ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemUnion.AsAny().(type) { -// case llamastackclient.ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemText: -// case llamastackclient.ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemImageURL: -// case llamastackclient.ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemFile: +// switch variant := ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion.AsAny().(type) { +// case llamastackclient.ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText: +// case llamastackclient.ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL: +// case llamastackclient.ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile: // default: // fmt.Errorf("no variant present") // } -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemUnion) AsAny() anyChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItem { +func (u ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) AsAny() anyChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItem { switch u.Type { case "text": return u.AsText() @@ -618,36 +426,35 @@ func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArr return nil } -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemUnion) AsText() (v ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemText) { +func (u ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) AsText() (v ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemUnion) AsImageURL() (v ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemImageURL) { +func (u ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) AsImageURL() (v ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemUnion) AsFile() (v ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemFile) { +func (u ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) AsFile() (v ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemUnion) RawJSON() string { +func (u ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) RawJSON() string { return u.JSON.raw } -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemUnion) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemText struct { - // The text content of the message +type ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -658,19 +465,19 @@ type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayI } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemText) RawJSON() string { +func (r ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemText) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Image content part for OpenAI-compatible chat completion messages. -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemImageURL struct { - // Image URL specification and processing details - ImageURL ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemImageURLImageURL `json:"image_url,required"` - // Must be "image_url" to identify this as image content - Type constant.ImageURL `json:"type,required"` +type ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL struct { + // Image URL specification for OpenAI-compatible chat completion messages. + ImageURL ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL `json:"image_url,required"` + // Any of "image_url". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ImageURL respjson.Field @@ -681,19 +488,17 @@ type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayI } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemImageURL) RawJSON() string { +func (r ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemImageURL) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Image URL specification and processing details -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemImageURLImageURL struct { - // URL of the image to include in the message - URL string `json:"url,required"` - // (Optional) Level of detail for image processing. Can be "low", "high", or "auto" - Detail string `json:"detail"` +// Image URL specification for OpenAI-compatible chat completion messages. +type ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL struct { + URL string `json:"url,required"` + Detail string `json:"detail,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { URL respjson.Field @@ -704,16 +509,17 @@ type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayI } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemImageURLImageURL) RawJSON() string { +func (r ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemImageURLImageURL) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemFile struct { - File ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemFileFile `json:"file,required"` - Type constant.File `json:"type,required"` +type ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile struct { + File ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile `json:"file,required"` + // Any of "file". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { File respjson.Field @@ -724,17 +530,17 @@ type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayI } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemFile) RawJSON() string { +func (r ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemFile) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemFileFile struct { - FileData string `json:"file_data"` - FileID string `json:"file_id"` - Filename string `json:"filename"` +type ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile struct { + FileData string `json:"file_data,nullable"` + FileID string `json:"file_id,nullable"` + Filename string `json:"filename,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { FileData respjson.Field @@ -746,89 +552,79 @@ type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayI } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemFileFile) RawJSON() string { +func (r ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageUserContentArrayItemFileFile) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A system message providing instructions or context to the model. -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystem struct { - // The content of the "system prompt". If multiple system messages are provided, - // they are concatenated. The underlying Llama Stack code may also add other system - // messages (for example, for formatting tool definitions). - Content ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentUnion `json:"content,required"` - // Must be "system" to identify this as a system message - Role constant.System `json:"role,required"` - // (Optional) The name of the system message participant. - Name string `json:"name"` +type ChatCompletionNewResponseChoiceMessageSystem struct { + Content ChatCompletionNewResponseChoiceMessageSystemContentUnion `json:"content,required"` + Name string `json:"name,nullable"` + // Any of "system". + Role string `json:"role"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field - Role respjson.Field Name respjson.Field + Role respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystem) RawJSON() string { - return r.JSON.raw -} -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystem) UnmarshalJSON(data []byte) error { +func (r ChatCompletionNewResponseChoiceMessageSystem) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionNewResponseChoiceMessageSystem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentUnion -// contains all possible properties and values from [string], -// [[]ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentArrayItem]. +// ChatCompletionNewResponseChoiceMessageSystemContentUnion contains all possible +// properties and values from [string], +// [[]ChatCompletionNewResponseChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString -// OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentArray] -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentUnion struct { +// will be valid: OfString OfListOpenAIChatCompletionContentPartText] +type ChatCompletionNewResponseChoiceMessageSystemContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentArrayItem] + // [[]ChatCompletionNewResponseChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem] // instead of an object. - OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentArray []ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentArray respjson.Field - raw string + OfListOpenAIChatCompletionContentPartText []ChatCompletionNewResponseChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentUnion) AsString() (v string) { +func (u ChatCompletionNewResponseChoiceMessageSystemContentUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentUnion) AsChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentArray() (v []ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentArrayItem) { +func (u ChatCompletionNewResponseChoiceMessageSystemContentUnion) AsListOpenAIChatCompletionContentPartTextParam() (v []ChatCompletionNewResponseChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentUnion) RawJSON() string { - return u.JSON.raw -} +func (u ChatCompletionNewResponseChoiceMessageSystemContentUnion) RawJSON() string { return u.JSON.raw } -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentUnion) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewResponseChoiceMessageSystemContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentArrayItem struct { - // The text content of the message +type ChatCompletionNewResponseChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -839,29 +635,26 @@ type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentArra } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentArrayItem) RawJSON() string { +func (r ChatCompletionNewResponseChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageSystemContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewResponseChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A message containing the model's (assistant) response in an OpenAI-compatible // chat completion request. -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistant struct { - // Must be "assistant" to identify this as the model's response - Role constant.Assistant `json:"role,required"` - // The content of the model's response - Content ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentUnion `json:"content"` - // (Optional) The name of the assistant message participant. - Name string `json:"name"` - // List of tool calls. Each tool call is an OpenAIChatCompletionToolCall object. - ToolCalls []ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantToolCall `json:"tool_calls"` +type ChatCompletionNewResponseChoiceMessageAssistant struct { + Content ChatCompletionNewResponseChoiceMessageAssistantContentUnion `json:"content,nullable"` + Name string `json:"name,nullable"` + // Any of "assistant". + Role string `json:"role"` + ToolCalls []ChatCompletionNewResponseChoiceMessageAssistantToolCall `json:"tool_calls,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Role respjson.Field Content respjson.Field Name respjson.Field + Role respjson.Field ToolCalls respjson.Field ExtraFields map[string]respjson.Field raw string @@ -869,61 +662,57 @@ type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistant struct } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistant) RawJSON() string { - return r.JSON.raw -} -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistant) UnmarshalJSON(data []byte) error { +func (r ChatCompletionNewResponseChoiceMessageAssistant) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionNewResponseChoiceMessageAssistant) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentUnion -// contains all possible properties and values from [string], -// [[]ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentArrayItem]. +// ChatCompletionNewResponseChoiceMessageAssistantContentUnion contains all +// possible properties and values from [string], +// [[]ChatCompletionNewResponseChoiceMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString -// OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentArray] -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentUnion struct { +// will be valid: OfString OfListOpenAIChatCompletionContentPartText] +type ChatCompletionNewResponseChoiceMessageAssistantContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentArrayItem] + // [[]ChatCompletionNewResponseChoiceMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem] // instead of an object. - OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentArray []ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentArray respjson.Field - raw string + OfListOpenAIChatCompletionContentPartText []ChatCompletionNewResponseChoiceMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentUnion) AsString() (v string) { +func (u ChatCompletionNewResponseChoiceMessageAssistantContentUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentUnion) AsChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentArray() (v []ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentArrayItem) { +func (u ChatCompletionNewResponseChoiceMessageAssistantContentUnion) AsListOpenAIChatCompletionContentPartTextParam() (v []ChatCompletionNewResponseChoiceMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentUnion) RawJSON() string { +func (u ChatCompletionNewResponseChoiceMessageAssistantContentUnion) RawJSON() string { return u.JSON.raw } -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentUnion) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewResponseChoiceMessageAssistantContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentArrayItem struct { - // The text content of the message +type ChatCompletionNewResponseChoiceMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -934,48 +723,42 @@ type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentA } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentArrayItem) RawJSON() string { +func (r ChatCompletionNewResponseChoiceMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewResponseChoiceMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Tool call specification for OpenAI-compatible chat completion responses. -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantToolCall struct { - // Must be "function" to identify this as a function call - Type constant.Function `json:"type,required"` - // (Optional) Unique identifier for the tool call - ID string `json:"id"` - // (Optional) Function call details - Function ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantToolCallFunction `json:"function"` - // (Optional) Index of the tool call in the list - Index int64 `json:"index"` +type ChatCompletionNewResponseChoiceMessageAssistantToolCall struct { + ID string `json:"id,nullable"` + // Function call details for OpenAI-compatible tool calls. + Function ChatCompletionNewResponseChoiceMessageAssistantToolCallFunction `json:"function,nullable"` + Index int64 `json:"index,nullable"` + // Any of "function". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field ID respjson.Field Function respjson.Field Index respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantToolCall) RawJSON() string { - return r.JSON.raw -} -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantToolCall) UnmarshalJSON(data []byte) error { +func (r ChatCompletionNewResponseChoiceMessageAssistantToolCall) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionNewResponseChoiceMessageAssistantToolCall) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// (Optional) Function call details -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantToolCallFunction struct { - // (Optional) Arguments to pass to the function as a JSON string - Arguments string `json:"arguments"` - // (Optional) Name of the function to call - Name string `json:"name"` +// Function call details for OpenAI-compatible tool calls. +type ChatCompletionNewResponseChoiceMessageAssistantToolCallFunction struct { + Arguments string `json:"arguments,nullable"` + Name string `json:"name,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Arguments respjson.Field @@ -986,88 +769,80 @@ type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantToolCall } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantToolCallFunction) RawJSON() string { +func (r ChatCompletionNewResponseChoiceMessageAssistantToolCallFunction) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageAssistantToolCallFunction) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewResponseChoiceMessageAssistantToolCallFunction) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A message representing the result of a tool invocation in an OpenAI-compatible // chat completion request. -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageTool struct { - // The response content from the tool - Content ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentUnion `json:"content,required"` - // Must be "tool" to identify this as a tool response - Role constant.Tool `json:"role,required"` - // Unique identifier for the tool call this response is for - ToolCallID string `json:"tool_call_id,required"` +type ChatCompletionNewResponseChoiceMessageTool struct { + Content ChatCompletionNewResponseChoiceMessageToolContentUnion `json:"content,required"` + ToolCallID string `json:"tool_call_id,required"` + // Any of "tool". + Role string `json:"role"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field - Role respjson.Field ToolCallID respjson.Field + Role respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageTool) RawJSON() string { - return r.JSON.raw -} -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageTool) UnmarshalJSON(data []byte) error { +func (r ChatCompletionNewResponseChoiceMessageTool) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionNewResponseChoiceMessageTool) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentUnion -// contains all possible properties and values from [string], -// [[]ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentArrayItem]. +// ChatCompletionNewResponseChoiceMessageToolContentUnion contains all possible +// properties and values from [string], +// [[]ChatCompletionNewResponseChoiceMessageToolContentListOpenAIChatCompletionContentPartTextParamItem]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString -// OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentArray] -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentUnion struct { +// will be valid: OfString OfListOpenAIChatCompletionContentPartText] +type ChatCompletionNewResponseChoiceMessageToolContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentArrayItem] + // [[]ChatCompletionNewResponseChoiceMessageToolContentListOpenAIChatCompletionContentPartTextParamItem] // instead of an object. - OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentArray []ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentArray respjson.Field - raw string + OfListOpenAIChatCompletionContentPartText []ChatCompletionNewResponseChoiceMessageToolContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentUnion) AsString() (v string) { +func (u ChatCompletionNewResponseChoiceMessageToolContentUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentUnion) AsChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentArray() (v []ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentArrayItem) { +func (u ChatCompletionNewResponseChoiceMessageToolContentUnion) AsListOpenAIChatCompletionContentPartTextParam() (v []ChatCompletionNewResponseChoiceMessageToolContentListOpenAIChatCompletionContentPartTextParamItem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentUnion) RawJSON() string { - return u.JSON.raw -} +func (u ChatCompletionNewResponseChoiceMessageToolContentUnion) RawJSON() string { return u.JSON.raw } -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentUnion) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewResponseChoiceMessageToolContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentArrayItem struct { - // The text content of the message +type ChatCompletionNewResponseChoiceMessageToolContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -1078,87 +853,81 @@ type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentArrayI } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentArrayItem) RawJSON() string { +func (r ChatCompletionNewResponseChoiceMessageToolContentListOpenAIChatCompletionContentPartTextParamItem) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageToolContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewResponseChoiceMessageToolContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A message from the developer in an OpenAI-compatible chat completion request. -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloper struct { - // The content of the developer message - Content ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentUnion `json:"content,required"` - // Must be "developer" to identify this as a developer message - Role constant.Developer `json:"role,required"` - // (Optional) The name of the developer message participant. - Name string `json:"name"` +type ChatCompletionNewResponseChoiceMessageDeveloper struct { + Content ChatCompletionNewResponseChoiceMessageDeveloperContentUnion `json:"content,required"` + Name string `json:"name,nullable"` + // Any of "developer". + Role string `json:"role"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field - Role respjson.Field Name respjson.Field + Role respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloper) RawJSON() string { - return r.JSON.raw -} -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloper) UnmarshalJSON(data []byte) error { +func (r ChatCompletionNewResponseChoiceMessageDeveloper) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionNewResponseChoiceMessageDeveloper) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentUnion -// contains all possible properties and values from [string], -// [[]ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentArrayItem]. +// ChatCompletionNewResponseChoiceMessageDeveloperContentUnion contains all +// possible properties and values from [string], +// [[]ChatCompletionNewResponseChoiceMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString -// OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentArray] -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentUnion struct { +// will be valid: OfString OfListOpenAIChatCompletionContentPartText] +type ChatCompletionNewResponseChoiceMessageDeveloperContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentArrayItem] + // [[]ChatCompletionNewResponseChoiceMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem] // instead of an object. - OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentArray []ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentArray respjson.Field - raw string + OfListOpenAIChatCompletionContentPartText []ChatCompletionNewResponseChoiceMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentUnion) AsString() (v string) { +func (u ChatCompletionNewResponseChoiceMessageDeveloperContentUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentUnion) AsChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentArray() (v []ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentArrayItem) { +func (u ChatCompletionNewResponseChoiceMessageDeveloperContentUnion) AsListOpenAIChatCompletionContentPartTextParam() (v []ChatCompletionNewResponseChoiceMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentUnion) RawJSON() string { +func (u ChatCompletionNewResponseChoiceMessageDeveloperContentUnion) RawJSON() string { return u.JSON.raw } -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentUnion) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewResponseChoiceMessageDeveloperContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentArrayItem struct { - // The text content of the message +type ChatCompletionNewResponseChoiceMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -1169,19 +938,18 @@ type ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentA } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentArrayItem) RawJSON() string { +func (r ChatCompletionNewResponseChoiceMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceMessageDeveloperContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewResponseChoiceMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// (Optional) The log probabilities for the tokens in the message -type ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobs struct { - // (Optional) The log probabilities for the tokens in the message - Content []ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobsContent `json:"content"` - // (Optional) The log probabilities for the tokens in the message - Refusal []ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobsRefusal `json:"refusal"` +// The log probabilities for the tokens in the message from an OpenAI-compatible +// chat completion response. +type ChatCompletionNewResponseChoiceLogprobs struct { + Content []ChatCompletionNewResponseChoiceLogprobsContent `json:"content,nullable"` + Refusal []ChatCompletionNewResponseChoiceLogprobsRefusal `json:"refusal,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field @@ -1192,20 +960,21 @@ type ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobs struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobs) RawJSON() string { - return r.JSON.raw -} -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobs) UnmarshalJSON(data []byte) error { +func (r ChatCompletionNewResponseChoiceLogprobs) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionNewResponseChoiceLogprobs) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // The log probability for a token from an OpenAI-compatible chat completion // response. -type ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobsContent struct { - Token string `json:"token,required"` - Logprob float64 `json:"logprob,required"` - TopLogprobs []ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobsContentTopLogprob `json:"top_logprobs,required"` - Bytes []int64 `json:"bytes"` +// +// :token: The token :bytes: (Optional) The bytes for the token :logprob: The log +// probability of the token :top_logprobs: The top log probabilities for the token +type ChatCompletionNewResponseChoiceLogprobsContent struct { + Token string `json:"token,required"` + Logprob float64 `json:"logprob,required"` + TopLogprobs []ChatCompletionNewResponseChoiceLogprobsContentTopLogprob `json:"top_logprobs,required"` + Bytes []int64 `json:"bytes,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Token respjson.Field @@ -1218,19 +987,20 @@ type ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobsContent struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobsContent) RawJSON() string { - return r.JSON.raw -} -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobsContent) UnmarshalJSON(data []byte) error { +func (r ChatCompletionNewResponseChoiceLogprobsContent) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionNewResponseChoiceLogprobsContent) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // The top log probability for a token from an OpenAI-compatible chat completion // response. -type ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobsContentTopLogprob struct { +// +// :token: The token :bytes: (Optional) The bytes for the token :logprob: The log +// probability of the token +type ChatCompletionNewResponseChoiceLogprobsContentTopLogprob struct { Token string `json:"token,required"` Logprob float64 `json:"logprob,required"` - Bytes []int64 `json:"bytes"` + Bytes []int64 `json:"bytes,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Token respjson.Field @@ -1242,20 +1012,21 @@ type ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobsContentTopLogpro } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobsContentTopLogprob) RawJSON() string { - return r.JSON.raw -} -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobsContentTopLogprob) UnmarshalJSON(data []byte) error { +func (r ChatCompletionNewResponseChoiceLogprobsContentTopLogprob) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionNewResponseChoiceLogprobsContentTopLogprob) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // The log probability for a token from an OpenAI-compatible chat completion // response. -type ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobsRefusal struct { - Token string `json:"token,required"` - Logprob float64 `json:"logprob,required"` - TopLogprobs []ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobsRefusalTopLogprob `json:"top_logprobs,required"` - Bytes []int64 `json:"bytes"` +// +// :token: The token :bytes: (Optional) The bytes for the token :logprob: The log +// probability of the token :top_logprobs: The top log probabilities for the token +type ChatCompletionNewResponseChoiceLogprobsRefusal struct { + Token string `json:"token,required"` + Logprob float64 `json:"logprob,required"` + TopLogprobs []ChatCompletionNewResponseChoiceLogprobsRefusalTopLogprob `json:"top_logprobs,required"` + Bytes []int64 `json:"bytes,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Token respjson.Field @@ -1268,19 +1039,20 @@ type ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobsRefusal struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobsRefusal) RawJSON() string { - return r.JSON.raw -} -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobsRefusal) UnmarshalJSON(data []byte) error { +func (r ChatCompletionNewResponseChoiceLogprobsRefusal) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionNewResponseChoiceLogprobsRefusal) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // The top log probability for a token from an OpenAI-compatible chat completion // response. -type ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobsRefusalTopLogprob struct { +// +// :token: The token :bytes: (Optional) The bytes for the token :logprob: The log +// probability of the token +type ChatCompletionNewResponseChoiceLogprobsRefusalTopLogprob struct { Token string `json:"token,required"` Logprob float64 `json:"logprob,required"` - Bytes []int64 `json:"bytes"` + Bytes []int64 `json:"bytes,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Token respjson.Field @@ -1292,25 +1064,26 @@ type ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobsRefusalTopLogpro } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobsRefusalTopLogprob) RawJSON() string { - return r.JSON.raw -} -func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobsRefusalTopLogprob) UnmarshalJSON(data []byte) error { +func (r ChatCompletionNewResponseChoiceLogprobsRefusalTopLogprob) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionNewResponseChoiceLogprobsRefusalTopLogprob) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Token usage information for the completion -type ChatCompletionNewResponseOpenAIChatCompletionUsage struct { - // Number of tokens in the completion +type ChatCompletionNewResponseObject string + +const ( + ChatCompletionNewResponseObjectChatCompletion ChatCompletionNewResponseObject = "chat.completion" +) + +// Usage information for OpenAI chat completion. +type ChatCompletionNewResponseUsage struct { CompletionTokens int64 `json:"completion_tokens,required"` - // Number of tokens in the prompt - PromptTokens int64 `json:"prompt_tokens,required"` - // Total tokens used (prompt + completion) - TotalTokens int64 `json:"total_tokens,required"` + PromptTokens int64 `json:"prompt_tokens,required"` + TotalTokens int64 `json:"total_tokens,required"` // Token details for output tokens in OpenAI chat completion usage. - CompletionTokensDetails ChatCompletionNewResponseOpenAIChatCompletionUsageCompletionTokensDetails `json:"completion_tokens_details"` + CompletionTokensDetails ChatCompletionNewResponseUsageCompletionTokensDetails `json:"completion_tokens_details,nullable"` // Token details for prompt tokens in OpenAI chat completion usage. - PromptTokensDetails ChatCompletionNewResponseOpenAIChatCompletionUsagePromptTokensDetails `json:"prompt_tokens_details"` + PromptTokensDetails ChatCompletionNewResponseUsagePromptTokensDetails `json:"prompt_tokens_details,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { CompletionTokens respjson.Field @@ -1324,15 +1097,14 @@ type ChatCompletionNewResponseOpenAIChatCompletionUsage struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionUsage) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionNewResponseOpenAIChatCompletionUsage) UnmarshalJSON(data []byte) error { +func (r ChatCompletionNewResponseUsage) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionNewResponseUsage) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Token details for output tokens in OpenAI chat completion usage. -type ChatCompletionNewResponseOpenAIChatCompletionUsageCompletionTokensDetails struct { - // Number of tokens used for reasoning (o1/o3 models) - ReasoningTokens int64 `json:"reasoning_tokens"` +type ChatCompletionNewResponseUsageCompletionTokensDetails struct { + ReasoningTokens int64 `json:"reasoning_tokens,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ReasoningTokens respjson.Field @@ -1342,17 +1114,14 @@ type ChatCompletionNewResponseOpenAIChatCompletionUsageCompletionTokensDetails s } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionUsageCompletionTokensDetails) RawJSON() string { - return r.JSON.raw -} -func (r *ChatCompletionNewResponseOpenAIChatCompletionUsageCompletionTokensDetails) UnmarshalJSON(data []byte) error { +func (r ChatCompletionNewResponseUsageCompletionTokensDetails) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionNewResponseUsageCompletionTokensDetails) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Token details for prompt tokens in OpenAI chat completion usage. -type ChatCompletionNewResponseOpenAIChatCompletionUsagePromptTokensDetails struct { - // Number of tokens retrieved from cache - CachedTokens int64 `json:"cached_tokens"` +type ChatCompletionNewResponseUsagePromptTokensDetails struct { + CachedTokens int64 `json:"cached_tokens,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { CachedTokens respjson.Field @@ -1362,27 +1131,21 @@ type ChatCompletionNewResponseOpenAIChatCompletionUsagePromptTokensDetails struc } // Returns the unmodified JSON received from the API -func (r ChatCompletionNewResponseOpenAIChatCompletionUsagePromptTokensDetails) RawJSON() string { - return r.JSON.raw -} -func (r *ChatCompletionNewResponseOpenAIChatCompletionUsagePromptTokensDetails) UnmarshalJSON(data []byte) error { +func (r ChatCompletionNewResponseUsagePromptTokensDetails) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionNewResponseUsagePromptTokensDetails) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } type ChatCompletionGetResponse struct { - // The ID of the chat completion - ID string `json:"id,required"` - // List of choices - Choices []ChatCompletionGetResponseChoice `json:"choices,required"` - // The Unix timestamp in seconds when the chat completion was created + ID string `json:"id,required"` + Choices []ChatCompletionGetResponseChoice `json:"choices,required"` Created int64 `json:"created,required"` InputMessages []ChatCompletionGetResponseInputMessageUnion `json:"input_messages,required"` - // The model that was used to generate the chat completion - Model string `json:"model,required"` - // The object type, which will be "chat.completion" - Object constant.ChatCompletion `json:"object,required"` - // Token usage information for the completion - Usage ChatCompletionGetResponseUsage `json:"usage"` + Model string `json:"model,required"` + // Any of "chat.completion". + Object ChatCompletionGetResponseObject `json:"object"` + // Usage information for OpenAI chat completion. + Usage ChatCompletionGetResponseUsage `json:"usage,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -1405,14 +1168,13 @@ func (r *ChatCompletionGetResponse) UnmarshalJSON(data []byte) error { // A choice from an OpenAI-compatible chat completion response. type ChatCompletionGetResponseChoice struct { - // The reason the model stopped generating FinishReason string `json:"finish_reason,required"` - // The index of the choice - Index int64 `json:"index,required"` - // The message from the model + Index int64 `json:"index,required"` + // A message from the user in an OpenAI-compatible chat completion request. Message ChatCompletionGetResponseChoiceMessageUnion `json:"message,required"` - // (Optional) The log probabilities for the tokens in the message - Logprobs ChatCompletionGetResponseChoiceLogprobs `json:"logprobs"` + // The log probabilities for the tokens in the message from an OpenAI-compatible + // chat completion response. + Logprobs ChatCompletionGetResponseChoiceLogprobs `json:"logprobs,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { FinishReason respjson.Field @@ -1449,17 +1211,17 @@ type ChatCompletionGetResponseChoiceMessageUnion struct { // [ChatCompletionGetResponseChoiceMessageToolContentUnion], // [ChatCompletionGetResponseChoiceMessageDeveloperContentUnion] Content ChatCompletionGetResponseChoiceMessageUnionContent `json:"content"` + Name string `json:"name"` // Any of "user", "system", "assistant", "tool", "developer". Role string `json:"role"` - Name string `json:"name"` // This field is from variant [ChatCompletionGetResponseChoiceMessageAssistant]. ToolCalls []ChatCompletionGetResponseChoiceMessageAssistantToolCall `json:"tool_calls"` // This field is from variant [ChatCompletionGetResponseChoiceMessageTool]. ToolCallID string `json:"tool_call_id"` JSON struct { Content respjson.Field - Role respjson.Field Name respjson.Field + Role respjson.Field ToolCalls respjson.Field ToolCallID respjson.Field raw string @@ -1550,42 +1312,25 @@ func (r *ChatCompletionGetResponseChoiceMessageUnion) UnmarshalJSON(data []byte) // [ChatCompletionGetResponseChoiceMessageUnion]. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString OfChatCompletionGetResponseChoiceMessageUserContentArray -// OfChatCompletionGetResponseChoiceMessageSystemContentArray -// OfChatCompletionGetResponseChoiceMessageAssistantContentArray -// OfChatCompletionGetResponseChoiceMessageToolContentArray -// OfChatCompletionGetResponseChoiceMessageDeveloperContentArray] +// will be valid: OfString +// OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile +// OfListOpenAIChatCompletionContentPartText] type ChatCompletionGetResponseChoiceMessageUnionContent struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion] instead of - // an object. - OfChatCompletionGetResponseChoiceMessageUserContentArray []ChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion `json:",inline"` - // This field will be present if the value is a - // [[]ChatCompletionGetResponseChoiceMessageSystemContentArrayItem] instead of an - // object. - OfChatCompletionGetResponseChoiceMessageSystemContentArray []ChatCompletionGetResponseChoiceMessageSystemContentArrayItem `json:",inline"` - // This field will be present if the value is a - // [[]ChatCompletionGetResponseChoiceMessageAssistantContentArrayItem] instead of - // an object. - OfChatCompletionGetResponseChoiceMessageAssistantContentArray []ChatCompletionGetResponseChoiceMessageAssistantContentArrayItem `json:",inline"` - // This field will be present if the value is a - // [[]ChatCompletionGetResponseChoiceMessageToolContentArrayItem] instead of an - // object. - OfChatCompletionGetResponseChoiceMessageToolContentArray []ChatCompletionGetResponseChoiceMessageToolContentArrayItem `json:",inline"` + // [[]ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion] + // instead of an object. + OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile []ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionGetResponseChoiceMessageDeveloperContentArrayItem] instead of - // an object. - OfChatCompletionGetResponseChoiceMessageDeveloperContentArray []ChatCompletionGetResponseChoiceMessageDeveloperContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionGetResponseChoiceMessageUserContentArray respjson.Field - OfChatCompletionGetResponseChoiceMessageSystemContentArray respjson.Field - OfChatCompletionGetResponseChoiceMessageAssistantContentArray respjson.Field - OfChatCompletionGetResponseChoiceMessageToolContentArray respjson.Field - OfChatCompletionGetResponseChoiceMessageDeveloperContentArray respjson.Field - raw string + // [[]ChatCompletionGetResponseChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem] + // instead of an object. + OfListOpenAIChatCompletionContentPartText []ChatCompletionGetResponseChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } @@ -1595,17 +1340,15 @@ func (r *ChatCompletionGetResponseChoiceMessageUnionContent) UnmarshalJSON(data // A message from the user in an OpenAI-compatible chat completion request. type ChatCompletionGetResponseChoiceMessageUser struct { - // The content of the message, which can include text and other media Content ChatCompletionGetResponseChoiceMessageUserContentUnion `json:"content,required"` - // Must be "user" to identify this as a user message - Role constant.User `json:"role,required"` - // (Optional) The name of the user message participant. - Name string `json:"name"` + Name string `json:"name,nullable"` + // Any of "user". + Role string `json:"role"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field - Role respjson.Field Name respjson.Field + Role respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -1619,24 +1362,24 @@ func (r *ChatCompletionGetResponseChoiceMessageUser) UnmarshalJSON(data []byte) // ChatCompletionGetResponseChoiceMessageUserContentUnion contains all possible // properties and values from [string], -// [[]ChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion]. +// [[]ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties // will be valid: OfString -// OfChatCompletionGetResponseChoiceMessageUserContentArray] +// OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile] type ChatCompletionGetResponseChoiceMessageUserContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion] instead of - // an object. - OfChatCompletionGetResponseChoiceMessageUserContentArray []ChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionGetResponseChoiceMessageUserContentArray respjson.Field - raw string + // [[]ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion] + // instead of an object. + OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile []ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile respjson.Field + raw string } `json:"-"` } @@ -1645,7 +1388,7 @@ func (u ChatCompletionGetResponseChoiceMessageUserContentUnion) AsString() (v st return } -func (u ChatCompletionGetResponseChoiceMessageUserContentUnion) AsChatCompletionGetResponseChoiceMessageUserContentArray() (v []ChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion) { +func (u ChatCompletionGetResponseChoiceMessageUserContentUnion) AsListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFile() (v []ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -1657,28 +1400,29 @@ func (r *ChatCompletionGetResponseChoiceMessageUserContentUnion) UnmarshalJSON(d return apijson.UnmarshalRoot(data, r) } -// ChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion contains all -// possible properties and values from -// [ChatCompletionGetResponseChoiceMessageUserContentArrayItemText], -// [ChatCompletionGetResponseChoiceMessageUserContentArrayItemImageURL], -// [ChatCompletionGetResponseChoiceMessageUserContentArrayItemFile]. +// ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion +// contains all possible properties and values from +// [ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText], +// [ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL], +// [ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile]. // -// Use the [ChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion.AsAny] +// Use the +// [ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion.AsAny] // method to switch on the variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type ChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion struct { +type ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion struct { // This field is from variant - // [ChatCompletionGetResponseChoiceMessageUserContentArrayItemText]. + // [ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText]. Text string `json:"text"` // Any of "text", "image_url", "file". Type string `json:"type"` // This field is from variant - // [ChatCompletionGetResponseChoiceMessageUserContentArrayItemImageURL]. - ImageURL ChatCompletionGetResponseChoiceMessageUserContentArrayItemImageURLImageURL `json:"image_url"` + // [ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL]. + ImageURL ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL `json:"image_url"` // This field is from variant - // [ChatCompletionGetResponseChoiceMessageUserContentArrayItemFile]. - File ChatCompletionGetResponseChoiceMessageUserContentArrayItemFileFile `json:"file"` + // [ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile]. + File ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile `json:"file"` JSON struct { Text respjson.Field Type respjson.Field @@ -1688,32 +1432,32 @@ type ChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion struct { } `json:"-"` } -// anyChatCompletionGetResponseChoiceMessageUserContentArrayItem is implemented by -// each variant of -// [ChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion] to add type -// safety for the return type of -// [ChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion.AsAny] -type anyChatCompletionGetResponseChoiceMessageUserContentArrayItem interface { - implChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion() +// anyChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItem +// is implemented by each variant of +// [ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion] +// to add type safety for the return type of +// [ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion.AsAny] +type anyChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItem interface { + implChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion() } -func (ChatCompletionGetResponseChoiceMessageUserContentArrayItemText) implChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion() { +func (ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) implChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion() { } -func (ChatCompletionGetResponseChoiceMessageUserContentArrayItemImageURL) implChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion() { +func (ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) implChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion() { } -func (ChatCompletionGetResponseChoiceMessageUserContentArrayItemFile) implChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion() { +func (ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) implChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion() { } // Use the following switch statement to find the correct variant // -// switch variant := ChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion.AsAny().(type) { -// case llamastackclient.ChatCompletionGetResponseChoiceMessageUserContentArrayItemText: -// case llamastackclient.ChatCompletionGetResponseChoiceMessageUserContentArrayItemImageURL: -// case llamastackclient.ChatCompletionGetResponseChoiceMessageUserContentArrayItemFile: +// switch variant := ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion.AsAny().(type) { +// case llamastackclient.ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText: +// case llamastackclient.ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL: +// case llamastackclient.ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile: // default: // fmt.Errorf("no variant present") // } -func (u ChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion) AsAny() anyChatCompletionGetResponseChoiceMessageUserContentArrayItem { +func (u ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) AsAny() anyChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItem { switch u.Type { case "text": return u.AsText() @@ -1725,36 +1469,35 @@ func (u ChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion) AsAny() return nil } -func (u ChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion) AsText() (v ChatCompletionGetResponseChoiceMessageUserContentArrayItemText) { +func (u ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) AsText() (v ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion) AsImageURL() (v ChatCompletionGetResponseChoiceMessageUserContentArrayItemImageURL) { +func (u ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) AsImageURL() (v ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion) AsFile() (v ChatCompletionGetResponseChoiceMessageUserContentArrayItemFile) { +func (u ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) AsFile() (v ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion) RawJSON() string { +func (u ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) RawJSON() string { return u.JSON.raw } -func (r *ChatCompletionGetResponseChoiceMessageUserContentArrayItemUnion) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionGetResponseChoiceMessageUserContentArrayItemText struct { - // The text content of the message +type ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -1765,19 +1508,19 @@ type ChatCompletionGetResponseChoiceMessageUserContentArrayItemText struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionGetResponseChoiceMessageUserContentArrayItemText) RawJSON() string { +func (r ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionGetResponseChoiceMessageUserContentArrayItemText) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Image content part for OpenAI-compatible chat completion messages. -type ChatCompletionGetResponseChoiceMessageUserContentArrayItemImageURL struct { - // Image URL specification and processing details - ImageURL ChatCompletionGetResponseChoiceMessageUserContentArrayItemImageURLImageURL `json:"image_url,required"` - // Must be "image_url" to identify this as image content - Type constant.ImageURL `json:"type,required"` +type ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL struct { + // Image URL specification for OpenAI-compatible chat completion messages. + ImageURL ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL `json:"image_url,required"` + // Any of "image_url". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ImageURL respjson.Field @@ -1788,19 +1531,17 @@ type ChatCompletionGetResponseChoiceMessageUserContentArrayItemImageURL struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionGetResponseChoiceMessageUserContentArrayItemImageURL) RawJSON() string { +func (r ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionGetResponseChoiceMessageUserContentArrayItemImageURL) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Image URL specification and processing details -type ChatCompletionGetResponseChoiceMessageUserContentArrayItemImageURLImageURL struct { - // URL of the image to include in the message - URL string `json:"url,required"` - // (Optional) Level of detail for image processing. Can be "low", "high", or "auto" - Detail string `json:"detail"` +// Image URL specification for OpenAI-compatible chat completion messages. +type ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL struct { + URL string `json:"url,required"` + Detail string `json:"detail,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { URL respjson.Field @@ -1811,16 +1552,17 @@ type ChatCompletionGetResponseChoiceMessageUserContentArrayItemImageURLImageURL } // Returns the unmodified JSON received from the API -func (r ChatCompletionGetResponseChoiceMessageUserContentArrayItemImageURLImageURL) RawJSON() string { +func (r ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionGetResponseChoiceMessageUserContentArrayItemImageURLImageURL) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ChatCompletionGetResponseChoiceMessageUserContentArrayItemFile struct { - File ChatCompletionGetResponseChoiceMessageUserContentArrayItemFileFile `json:"file,required"` - Type constant.File `json:"type,required"` +type ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile struct { + File ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile `json:"file,required"` + // Any of "file". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { File respjson.Field @@ -1831,17 +1573,17 @@ type ChatCompletionGetResponseChoiceMessageUserContentArrayItemFile struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionGetResponseChoiceMessageUserContentArrayItemFile) RawJSON() string { +func (r ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionGetResponseChoiceMessageUserContentArrayItemFile) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ChatCompletionGetResponseChoiceMessageUserContentArrayItemFileFile struct { - FileData string `json:"file_data"` - FileID string `json:"file_id"` - Filename string `json:"filename"` +type ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile struct { + FileData string `json:"file_data,nullable"` + FileID string `json:"file_id,nullable"` + Filename string `json:"filename,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { FileData respjson.Field @@ -1853,28 +1595,24 @@ type ChatCompletionGetResponseChoiceMessageUserContentArrayItemFileFile struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionGetResponseChoiceMessageUserContentArrayItemFileFile) RawJSON() string { +func (r ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionGetResponseChoiceMessageUserContentArrayItemFileFile) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionGetResponseChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A system message providing instructions or context to the model. type ChatCompletionGetResponseChoiceMessageSystem struct { - // The content of the "system prompt". If multiple system messages are provided, - // they are concatenated. The underlying Llama Stack code may also add other system - // messages (for example, for formatting tool definitions). Content ChatCompletionGetResponseChoiceMessageSystemContentUnion `json:"content,required"` - // Must be "system" to identify this as a system message - Role constant.System `json:"role,required"` - // (Optional) The name of the system message participant. - Name string `json:"name"` + Name string `json:"name,nullable"` + // Any of "system". + Role string `json:"role"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field - Role respjson.Field Name respjson.Field + Role respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -1888,24 +1626,23 @@ func (r *ChatCompletionGetResponseChoiceMessageSystem) UnmarshalJSON(data []byte // ChatCompletionGetResponseChoiceMessageSystemContentUnion contains all possible // properties and values from [string], -// [[]ChatCompletionGetResponseChoiceMessageSystemContentArrayItem]. +// [[]ChatCompletionGetResponseChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString -// OfChatCompletionGetResponseChoiceMessageSystemContentArray] +// will be valid: OfString OfListOpenAIChatCompletionContentPartText] type ChatCompletionGetResponseChoiceMessageSystemContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionGetResponseChoiceMessageSystemContentArrayItem] instead of an - // object. - OfChatCompletionGetResponseChoiceMessageSystemContentArray []ChatCompletionGetResponseChoiceMessageSystemContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionGetResponseChoiceMessageSystemContentArray respjson.Field - raw string + // [[]ChatCompletionGetResponseChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem] + // instead of an object. + OfListOpenAIChatCompletionContentPartText []ChatCompletionGetResponseChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } @@ -1914,7 +1651,7 @@ func (u ChatCompletionGetResponseChoiceMessageSystemContentUnion) AsString() (v return } -func (u ChatCompletionGetResponseChoiceMessageSystemContentUnion) AsChatCompletionGetResponseChoiceMessageSystemContentArray() (v []ChatCompletionGetResponseChoiceMessageSystemContentArrayItem) { +func (u ChatCompletionGetResponseChoiceMessageSystemContentUnion) AsListOpenAIChatCompletionContentPartTextParam() (v []ChatCompletionGetResponseChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -1927,11 +1664,10 @@ func (r *ChatCompletionGetResponseChoiceMessageSystemContentUnion) UnmarshalJSON } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionGetResponseChoiceMessageSystemContentArrayItem struct { - // The text content of the message +type ChatCompletionGetResponseChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -1942,29 +1678,26 @@ type ChatCompletionGetResponseChoiceMessageSystemContentArrayItem struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionGetResponseChoiceMessageSystemContentArrayItem) RawJSON() string { +func (r ChatCompletionGetResponseChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionGetResponseChoiceMessageSystemContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionGetResponseChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A message containing the model's (assistant) response in an OpenAI-compatible // chat completion request. type ChatCompletionGetResponseChoiceMessageAssistant struct { - // Must be "assistant" to identify this as the model's response - Role constant.Assistant `json:"role,required"` - // The content of the model's response - Content ChatCompletionGetResponseChoiceMessageAssistantContentUnion `json:"content"` - // (Optional) The name of the assistant message participant. - Name string `json:"name"` - // List of tool calls. Each tool call is an OpenAIChatCompletionToolCall object. - ToolCalls []ChatCompletionGetResponseChoiceMessageAssistantToolCall `json:"tool_calls"` + Content ChatCompletionGetResponseChoiceMessageAssistantContentUnion `json:"content,nullable"` + Name string `json:"name,nullable"` + // Any of "assistant". + Role string `json:"role"` + ToolCalls []ChatCompletionGetResponseChoiceMessageAssistantToolCall `json:"tool_calls,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Role respjson.Field Content respjson.Field Name respjson.Field + Role respjson.Field ToolCalls respjson.Field ExtraFields map[string]respjson.Field raw string @@ -1979,24 +1712,23 @@ func (r *ChatCompletionGetResponseChoiceMessageAssistant) UnmarshalJSON(data []b // ChatCompletionGetResponseChoiceMessageAssistantContentUnion contains all // possible properties and values from [string], -// [[]ChatCompletionGetResponseChoiceMessageAssistantContentArrayItem]. +// [[]ChatCompletionGetResponseChoiceMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString -// OfChatCompletionGetResponseChoiceMessageAssistantContentArray] +// will be valid: OfString OfListOpenAIChatCompletionContentPartText] type ChatCompletionGetResponseChoiceMessageAssistantContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionGetResponseChoiceMessageAssistantContentArrayItem] instead of - // an object. - OfChatCompletionGetResponseChoiceMessageAssistantContentArray []ChatCompletionGetResponseChoiceMessageAssistantContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionGetResponseChoiceMessageAssistantContentArray respjson.Field - raw string + // [[]ChatCompletionGetResponseChoiceMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem] + // instead of an object. + OfListOpenAIChatCompletionContentPartText []ChatCompletionGetResponseChoiceMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } @@ -2005,7 +1737,7 @@ func (u ChatCompletionGetResponseChoiceMessageAssistantContentUnion) AsString() return } -func (u ChatCompletionGetResponseChoiceMessageAssistantContentUnion) AsChatCompletionGetResponseChoiceMessageAssistantContentArray() (v []ChatCompletionGetResponseChoiceMessageAssistantContentArrayItem) { +func (u ChatCompletionGetResponseChoiceMessageAssistantContentUnion) AsListOpenAIChatCompletionContentPartTextParam() (v []ChatCompletionGetResponseChoiceMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -2020,11 +1752,10 @@ func (r *ChatCompletionGetResponseChoiceMessageAssistantContentUnion) UnmarshalJ } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionGetResponseChoiceMessageAssistantContentArrayItem struct { - // The text content of the message +type ChatCompletionGetResponseChoiceMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -2035,29 +1766,27 @@ type ChatCompletionGetResponseChoiceMessageAssistantContentArrayItem struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionGetResponseChoiceMessageAssistantContentArrayItem) RawJSON() string { +func (r ChatCompletionGetResponseChoiceMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionGetResponseChoiceMessageAssistantContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionGetResponseChoiceMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Tool call specification for OpenAI-compatible chat completion responses. type ChatCompletionGetResponseChoiceMessageAssistantToolCall struct { - // Must be "function" to identify this as a function call - Type constant.Function `json:"type,required"` - // (Optional) Unique identifier for the tool call - ID string `json:"id"` - // (Optional) Function call details - Function ChatCompletionGetResponseChoiceMessageAssistantToolCallFunction `json:"function"` - // (Optional) Index of the tool call in the list - Index int64 `json:"index"` + ID string `json:"id,nullable"` + // Function call details for OpenAI-compatible tool calls. + Function ChatCompletionGetResponseChoiceMessageAssistantToolCallFunction `json:"function,nullable"` + Index int64 `json:"index,nullable"` + // Any of "function". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field ID respjson.Field Function respjson.Field Index respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -2069,12 +1798,10 @@ func (r *ChatCompletionGetResponseChoiceMessageAssistantToolCall) UnmarshalJSON( return apijson.UnmarshalRoot(data, r) } -// (Optional) Function call details +// Function call details for OpenAI-compatible tool calls. type ChatCompletionGetResponseChoiceMessageAssistantToolCallFunction struct { - // (Optional) Arguments to pass to the function as a JSON string - Arguments string `json:"arguments"` - // (Optional) Name of the function to call - Name string `json:"name"` + Arguments string `json:"arguments,nullable"` + Name string `json:"name,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Arguments respjson.Field @@ -2095,17 +1822,15 @@ func (r *ChatCompletionGetResponseChoiceMessageAssistantToolCallFunction) Unmars // A message representing the result of a tool invocation in an OpenAI-compatible // chat completion request. type ChatCompletionGetResponseChoiceMessageTool struct { - // The response content from the tool - Content ChatCompletionGetResponseChoiceMessageToolContentUnion `json:"content,required"` - // Must be "tool" to identify this as a tool response - Role constant.Tool `json:"role,required"` - // Unique identifier for the tool call this response is for - ToolCallID string `json:"tool_call_id,required"` + Content ChatCompletionGetResponseChoiceMessageToolContentUnion `json:"content,required"` + ToolCallID string `json:"tool_call_id,required"` + // Any of "tool". + Role string `json:"role"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field - Role respjson.Field ToolCallID respjson.Field + Role respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -2119,24 +1844,23 @@ func (r *ChatCompletionGetResponseChoiceMessageTool) UnmarshalJSON(data []byte) // ChatCompletionGetResponseChoiceMessageToolContentUnion contains all possible // properties and values from [string], -// [[]ChatCompletionGetResponseChoiceMessageToolContentArrayItem]. +// [[]ChatCompletionGetResponseChoiceMessageToolContentListOpenAIChatCompletionContentPartTextParamItem]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString -// OfChatCompletionGetResponseChoiceMessageToolContentArray] +// will be valid: OfString OfListOpenAIChatCompletionContentPartText] type ChatCompletionGetResponseChoiceMessageToolContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionGetResponseChoiceMessageToolContentArrayItem] instead of an - // object. - OfChatCompletionGetResponseChoiceMessageToolContentArray []ChatCompletionGetResponseChoiceMessageToolContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionGetResponseChoiceMessageToolContentArray respjson.Field - raw string + // [[]ChatCompletionGetResponseChoiceMessageToolContentListOpenAIChatCompletionContentPartTextParamItem] + // instead of an object. + OfListOpenAIChatCompletionContentPartText []ChatCompletionGetResponseChoiceMessageToolContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } @@ -2145,7 +1869,7 @@ func (u ChatCompletionGetResponseChoiceMessageToolContentUnion) AsString() (v st return } -func (u ChatCompletionGetResponseChoiceMessageToolContentUnion) AsChatCompletionGetResponseChoiceMessageToolContentArray() (v []ChatCompletionGetResponseChoiceMessageToolContentArrayItem) { +func (u ChatCompletionGetResponseChoiceMessageToolContentUnion) AsListOpenAIChatCompletionContentPartTextParam() (v []ChatCompletionGetResponseChoiceMessageToolContentListOpenAIChatCompletionContentPartTextParamItem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -2158,11 +1882,10 @@ func (r *ChatCompletionGetResponseChoiceMessageToolContentUnion) UnmarshalJSON(d } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionGetResponseChoiceMessageToolContentArrayItem struct { - // The text content of the message +type ChatCompletionGetResponseChoiceMessageToolContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -2173,26 +1896,24 @@ type ChatCompletionGetResponseChoiceMessageToolContentArrayItem struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionGetResponseChoiceMessageToolContentArrayItem) RawJSON() string { +func (r ChatCompletionGetResponseChoiceMessageToolContentListOpenAIChatCompletionContentPartTextParamItem) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionGetResponseChoiceMessageToolContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionGetResponseChoiceMessageToolContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A message from the developer in an OpenAI-compatible chat completion request. type ChatCompletionGetResponseChoiceMessageDeveloper struct { - // The content of the developer message Content ChatCompletionGetResponseChoiceMessageDeveloperContentUnion `json:"content,required"` - // Must be "developer" to identify this as a developer message - Role constant.Developer `json:"role,required"` - // (Optional) The name of the developer message participant. - Name string `json:"name"` + Name string `json:"name,nullable"` + // Any of "developer". + Role string `json:"role"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field - Role respjson.Field Name respjson.Field + Role respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -2206,24 +1927,23 @@ func (r *ChatCompletionGetResponseChoiceMessageDeveloper) UnmarshalJSON(data []b // ChatCompletionGetResponseChoiceMessageDeveloperContentUnion contains all // possible properties and values from [string], -// [[]ChatCompletionGetResponseChoiceMessageDeveloperContentArrayItem]. +// [[]ChatCompletionGetResponseChoiceMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString -// OfChatCompletionGetResponseChoiceMessageDeveloperContentArray] +// will be valid: OfString OfListOpenAIChatCompletionContentPartText] type ChatCompletionGetResponseChoiceMessageDeveloperContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionGetResponseChoiceMessageDeveloperContentArrayItem] instead of - // an object. - OfChatCompletionGetResponseChoiceMessageDeveloperContentArray []ChatCompletionGetResponseChoiceMessageDeveloperContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionGetResponseChoiceMessageDeveloperContentArray respjson.Field - raw string + // [[]ChatCompletionGetResponseChoiceMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem] + // instead of an object. + OfListOpenAIChatCompletionContentPartText []ChatCompletionGetResponseChoiceMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } @@ -2232,7 +1952,7 @@ func (u ChatCompletionGetResponseChoiceMessageDeveloperContentUnion) AsString() return } -func (u ChatCompletionGetResponseChoiceMessageDeveloperContentUnion) AsChatCompletionGetResponseChoiceMessageDeveloperContentArray() (v []ChatCompletionGetResponseChoiceMessageDeveloperContentArrayItem) { +func (u ChatCompletionGetResponseChoiceMessageDeveloperContentUnion) AsListOpenAIChatCompletionContentPartTextParam() (v []ChatCompletionGetResponseChoiceMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -2247,11 +1967,10 @@ func (r *ChatCompletionGetResponseChoiceMessageDeveloperContentUnion) UnmarshalJ } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionGetResponseChoiceMessageDeveloperContentArrayItem struct { - // The text content of the message +type ChatCompletionGetResponseChoiceMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -2262,19 +1981,18 @@ type ChatCompletionGetResponseChoiceMessageDeveloperContentArrayItem struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionGetResponseChoiceMessageDeveloperContentArrayItem) RawJSON() string { +func (r ChatCompletionGetResponseChoiceMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionGetResponseChoiceMessageDeveloperContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionGetResponseChoiceMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// (Optional) The log probabilities for the tokens in the message +// The log probabilities for the tokens in the message from an OpenAI-compatible +// chat completion response. type ChatCompletionGetResponseChoiceLogprobs struct { - // (Optional) The log probabilities for the tokens in the message - Content []ChatCompletionGetResponseChoiceLogprobsContent `json:"content"` - // (Optional) The log probabilities for the tokens in the message - Refusal []ChatCompletionGetResponseChoiceLogprobsRefusal `json:"refusal"` + Content []ChatCompletionGetResponseChoiceLogprobsContent `json:"content,nullable"` + Refusal []ChatCompletionGetResponseChoiceLogprobsRefusal `json:"refusal,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field @@ -2292,11 +2010,14 @@ func (r *ChatCompletionGetResponseChoiceLogprobs) UnmarshalJSON(data []byte) err // The log probability for a token from an OpenAI-compatible chat completion // response. +// +// :token: The token :bytes: (Optional) The bytes for the token :logprob: The log +// probability of the token :top_logprobs: The top log probabilities for the token type ChatCompletionGetResponseChoiceLogprobsContent struct { Token string `json:"token,required"` Logprob float64 `json:"logprob,required"` TopLogprobs []ChatCompletionGetResponseChoiceLogprobsContentTopLogprob `json:"top_logprobs,required"` - Bytes []int64 `json:"bytes"` + Bytes []int64 `json:"bytes,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Token respjson.Field @@ -2316,10 +2037,13 @@ func (r *ChatCompletionGetResponseChoiceLogprobsContent) UnmarshalJSON(data []by // The top log probability for a token from an OpenAI-compatible chat completion // response. +// +// :token: The token :bytes: (Optional) The bytes for the token :logprob: The log +// probability of the token type ChatCompletionGetResponseChoiceLogprobsContentTopLogprob struct { Token string `json:"token,required"` Logprob float64 `json:"logprob,required"` - Bytes []int64 `json:"bytes"` + Bytes []int64 `json:"bytes,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Token respjson.Field @@ -2338,11 +2062,14 @@ func (r *ChatCompletionGetResponseChoiceLogprobsContentTopLogprob) UnmarshalJSON // The log probability for a token from an OpenAI-compatible chat completion // response. +// +// :token: The token :bytes: (Optional) The bytes for the token :logprob: The log +// probability of the token :top_logprobs: The top log probabilities for the token type ChatCompletionGetResponseChoiceLogprobsRefusal struct { Token string `json:"token,required"` Logprob float64 `json:"logprob,required"` TopLogprobs []ChatCompletionGetResponseChoiceLogprobsRefusalTopLogprob `json:"top_logprobs,required"` - Bytes []int64 `json:"bytes"` + Bytes []int64 `json:"bytes,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Token respjson.Field @@ -2362,10 +2089,13 @@ func (r *ChatCompletionGetResponseChoiceLogprobsRefusal) UnmarshalJSON(data []by // The top log probability for a token from an OpenAI-compatible chat completion // response. +// +// :token: The token :bytes: (Optional) The bytes for the token :logprob: The log +// probability of the token type ChatCompletionGetResponseChoiceLogprobsRefusalTopLogprob struct { Token string `json:"token,required"` Logprob float64 `json:"logprob,required"` - Bytes []int64 `json:"bytes"` + Bytes []int64 `json:"bytes,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Token respjson.Field @@ -2401,17 +2131,17 @@ type ChatCompletionGetResponseInputMessageUnion struct { // [ChatCompletionGetResponseInputMessageToolContentUnion], // [ChatCompletionGetResponseInputMessageDeveloperContentUnion] Content ChatCompletionGetResponseInputMessageUnionContent `json:"content"` + Name string `json:"name"` // Any of "user", "system", "assistant", "tool", "developer". Role string `json:"role"` - Name string `json:"name"` // This field is from variant [ChatCompletionGetResponseInputMessageAssistant]. ToolCalls []ChatCompletionGetResponseInputMessageAssistantToolCall `json:"tool_calls"` // This field is from variant [ChatCompletionGetResponseInputMessageTool]. ToolCallID string `json:"tool_call_id"` JSON struct { Content respjson.Field - Role respjson.Field Name respjson.Field + Role respjson.Field ToolCalls respjson.Field ToolCallID respjson.Field raw string @@ -2501,42 +2231,25 @@ func (r *ChatCompletionGetResponseInputMessageUnion) UnmarshalJSON(data []byte) // [ChatCompletionGetResponseInputMessageUnion]. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString OfChatCompletionGetResponseInputMessageUserContentArray -// OfChatCompletionGetResponseInputMessageSystemContentArray -// OfChatCompletionGetResponseInputMessageAssistantContentArray -// OfChatCompletionGetResponseInputMessageToolContentArray -// OfChatCompletionGetResponseInputMessageDeveloperContentArray] +// will be valid: OfString +// OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile +// OfListOpenAIChatCompletionContentPartText] type ChatCompletionGetResponseInputMessageUnionContent struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionGetResponseInputMessageUserContentArrayItemUnion] instead of an - // object. - OfChatCompletionGetResponseInputMessageUserContentArray []ChatCompletionGetResponseInputMessageUserContentArrayItemUnion `json:",inline"` - // This field will be present if the value is a - // [[]ChatCompletionGetResponseInputMessageSystemContentArrayItem] instead of an - // object. - OfChatCompletionGetResponseInputMessageSystemContentArray []ChatCompletionGetResponseInputMessageSystemContentArrayItem `json:",inline"` - // This field will be present if the value is a - // [[]ChatCompletionGetResponseInputMessageAssistantContentArrayItem] instead of an - // object. - OfChatCompletionGetResponseInputMessageAssistantContentArray []ChatCompletionGetResponseInputMessageAssistantContentArrayItem `json:",inline"` - // This field will be present if the value is a - // [[]ChatCompletionGetResponseInputMessageToolContentArrayItem] instead of an - // object. - OfChatCompletionGetResponseInputMessageToolContentArray []ChatCompletionGetResponseInputMessageToolContentArrayItem `json:",inline"` + // [[]ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion] + // instead of an object. + OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile []ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionGetResponseInputMessageDeveloperContentArrayItem] instead of an - // object. - OfChatCompletionGetResponseInputMessageDeveloperContentArray []ChatCompletionGetResponseInputMessageDeveloperContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionGetResponseInputMessageUserContentArray respjson.Field - OfChatCompletionGetResponseInputMessageSystemContentArray respjson.Field - OfChatCompletionGetResponseInputMessageAssistantContentArray respjson.Field - OfChatCompletionGetResponseInputMessageToolContentArray respjson.Field - OfChatCompletionGetResponseInputMessageDeveloperContentArray respjson.Field - raw string + // [[]ChatCompletionGetResponseInputMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem] + // instead of an object. + OfListOpenAIChatCompletionContentPartText []ChatCompletionGetResponseInputMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } @@ -2546,17 +2259,15 @@ func (r *ChatCompletionGetResponseInputMessageUnionContent) UnmarshalJSON(data [ // A message from the user in an OpenAI-compatible chat completion request. type ChatCompletionGetResponseInputMessageUser struct { - // The content of the message, which can include text and other media Content ChatCompletionGetResponseInputMessageUserContentUnion `json:"content,required"` - // Must be "user" to identify this as a user message - Role constant.User `json:"role,required"` - // (Optional) The name of the user message participant. - Name string `json:"name"` + Name string `json:"name,nullable"` + // Any of "user". + Role string `json:"role"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field - Role respjson.Field Name respjson.Field + Role respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -2570,23 +2281,24 @@ func (r *ChatCompletionGetResponseInputMessageUser) UnmarshalJSON(data []byte) e // ChatCompletionGetResponseInputMessageUserContentUnion contains all possible // properties and values from [string], -// [[]ChatCompletionGetResponseInputMessageUserContentArrayItemUnion]. +// [[]ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString OfChatCompletionGetResponseInputMessageUserContentArray] +// will be valid: OfString +// OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile] type ChatCompletionGetResponseInputMessageUserContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionGetResponseInputMessageUserContentArrayItemUnion] instead of an - // object. - OfChatCompletionGetResponseInputMessageUserContentArray []ChatCompletionGetResponseInputMessageUserContentArrayItemUnion `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionGetResponseInputMessageUserContentArray respjson.Field - raw string + // [[]ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion] + // instead of an object. + OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile []ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile respjson.Field + raw string } `json:"-"` } @@ -2595,7 +2307,7 @@ func (u ChatCompletionGetResponseInputMessageUserContentUnion) AsString() (v str return } -func (u ChatCompletionGetResponseInputMessageUserContentUnion) AsChatCompletionGetResponseInputMessageUserContentArray() (v []ChatCompletionGetResponseInputMessageUserContentArrayItemUnion) { +func (u ChatCompletionGetResponseInputMessageUserContentUnion) AsListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFile() (v []ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -2607,28 +2319,29 @@ func (r *ChatCompletionGetResponseInputMessageUserContentUnion) UnmarshalJSON(da return apijson.UnmarshalRoot(data, r) } -// ChatCompletionGetResponseInputMessageUserContentArrayItemUnion contains all -// possible properties and values from -// [ChatCompletionGetResponseInputMessageUserContentArrayItemText], -// [ChatCompletionGetResponseInputMessageUserContentArrayItemImageURL], -// [ChatCompletionGetResponseInputMessageUserContentArrayItemFile]. +// ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion +// contains all possible properties and values from +// [ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText], +// [ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL], +// [ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile]. // -// Use the [ChatCompletionGetResponseInputMessageUserContentArrayItemUnion.AsAny] +// Use the +// [ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion.AsAny] // method to switch on the variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type ChatCompletionGetResponseInputMessageUserContentArrayItemUnion struct { +type ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion struct { // This field is from variant - // [ChatCompletionGetResponseInputMessageUserContentArrayItemText]. + // [ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText]. Text string `json:"text"` // Any of "text", "image_url", "file". Type string `json:"type"` // This field is from variant - // [ChatCompletionGetResponseInputMessageUserContentArrayItemImageURL]. - ImageURL ChatCompletionGetResponseInputMessageUserContentArrayItemImageURLImageURL `json:"image_url"` + // [ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL]. + ImageURL ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL `json:"image_url"` // This field is from variant - // [ChatCompletionGetResponseInputMessageUserContentArrayItemFile]. - File ChatCompletionGetResponseInputMessageUserContentArrayItemFileFile `json:"file"` + // [ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile]. + File ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile `json:"file"` JSON struct { Text respjson.Field Type respjson.Field @@ -2638,31 +2351,32 @@ type ChatCompletionGetResponseInputMessageUserContentArrayItemUnion struct { } `json:"-"` } -// anyChatCompletionGetResponseInputMessageUserContentArrayItem is implemented by -// each variant of [ChatCompletionGetResponseInputMessageUserContentArrayItemUnion] +// anyChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItem +// is implemented by each variant of +// [ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion] // to add type safety for the return type of -// [ChatCompletionGetResponseInputMessageUserContentArrayItemUnion.AsAny] -type anyChatCompletionGetResponseInputMessageUserContentArrayItem interface { - implChatCompletionGetResponseInputMessageUserContentArrayItemUnion() +// [ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion.AsAny] +type anyChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItem interface { + implChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion() } -func (ChatCompletionGetResponseInputMessageUserContentArrayItemText) implChatCompletionGetResponseInputMessageUserContentArrayItemUnion() { +func (ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) implChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion() { } -func (ChatCompletionGetResponseInputMessageUserContentArrayItemImageURL) implChatCompletionGetResponseInputMessageUserContentArrayItemUnion() { +func (ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) implChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion() { } -func (ChatCompletionGetResponseInputMessageUserContentArrayItemFile) implChatCompletionGetResponseInputMessageUserContentArrayItemUnion() { +func (ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) implChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion() { } // Use the following switch statement to find the correct variant // -// switch variant := ChatCompletionGetResponseInputMessageUserContentArrayItemUnion.AsAny().(type) { -// case llamastackclient.ChatCompletionGetResponseInputMessageUserContentArrayItemText: -// case llamastackclient.ChatCompletionGetResponseInputMessageUserContentArrayItemImageURL: -// case llamastackclient.ChatCompletionGetResponseInputMessageUserContentArrayItemFile: +// switch variant := ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion.AsAny().(type) { +// case llamastackclient.ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText: +// case llamastackclient.ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL: +// case llamastackclient.ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile: // default: // fmt.Errorf("no variant present") // } -func (u ChatCompletionGetResponseInputMessageUserContentArrayItemUnion) AsAny() anyChatCompletionGetResponseInputMessageUserContentArrayItem { +func (u ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) AsAny() anyChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItem { switch u.Type { case "text": return u.AsText() @@ -2674,36 +2388,35 @@ func (u ChatCompletionGetResponseInputMessageUserContentArrayItemUnion) AsAny() return nil } -func (u ChatCompletionGetResponseInputMessageUserContentArrayItemUnion) AsText() (v ChatCompletionGetResponseInputMessageUserContentArrayItemText) { +func (u ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) AsText() (v ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionGetResponseInputMessageUserContentArrayItemUnion) AsImageURL() (v ChatCompletionGetResponseInputMessageUserContentArrayItemImageURL) { +func (u ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) AsImageURL() (v ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionGetResponseInputMessageUserContentArrayItemUnion) AsFile() (v ChatCompletionGetResponseInputMessageUserContentArrayItemFile) { +func (u ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) AsFile() (v ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ChatCompletionGetResponseInputMessageUserContentArrayItemUnion) RawJSON() string { +func (u ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) RawJSON() string { return u.JSON.raw } -func (r *ChatCompletionGetResponseInputMessageUserContentArrayItemUnion) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionGetResponseInputMessageUserContentArrayItemText struct { - // The text content of the message +type ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -2714,19 +2427,19 @@ type ChatCompletionGetResponseInputMessageUserContentArrayItemText struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionGetResponseInputMessageUserContentArrayItemText) RawJSON() string { +func (r ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionGetResponseInputMessageUserContentArrayItemText) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Image content part for OpenAI-compatible chat completion messages. -type ChatCompletionGetResponseInputMessageUserContentArrayItemImageURL struct { - // Image URL specification and processing details - ImageURL ChatCompletionGetResponseInputMessageUserContentArrayItemImageURLImageURL `json:"image_url,required"` - // Must be "image_url" to identify this as image content - Type constant.ImageURL `json:"type,required"` +type ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL struct { + // Image URL specification for OpenAI-compatible chat completion messages. + ImageURL ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL `json:"image_url,required"` + // Any of "image_url". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ImageURL respjson.Field @@ -2737,19 +2450,17 @@ type ChatCompletionGetResponseInputMessageUserContentArrayItemImageURL struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionGetResponseInputMessageUserContentArrayItemImageURL) RawJSON() string { +func (r ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionGetResponseInputMessageUserContentArrayItemImageURL) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Image URL specification and processing details -type ChatCompletionGetResponseInputMessageUserContentArrayItemImageURLImageURL struct { - // URL of the image to include in the message - URL string `json:"url,required"` - // (Optional) Level of detail for image processing. Can be "low", "high", or "auto" - Detail string `json:"detail"` +// Image URL specification for OpenAI-compatible chat completion messages. +type ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL struct { + URL string `json:"url,required"` + Detail string `json:"detail,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { URL respjson.Field @@ -2760,16 +2471,17 @@ type ChatCompletionGetResponseInputMessageUserContentArrayItemImageURLImageURL s } // Returns the unmodified JSON received from the API -func (r ChatCompletionGetResponseInputMessageUserContentArrayItemImageURLImageURL) RawJSON() string { +func (r ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionGetResponseInputMessageUserContentArrayItemImageURLImageURL) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ChatCompletionGetResponseInputMessageUserContentArrayItemFile struct { - File ChatCompletionGetResponseInputMessageUserContentArrayItemFileFile `json:"file,required"` - Type constant.File `json:"type,required"` +type ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile struct { + File ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile `json:"file,required"` + // Any of "file". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { File respjson.Field @@ -2780,17 +2492,17 @@ type ChatCompletionGetResponseInputMessageUserContentArrayItemFile struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionGetResponseInputMessageUserContentArrayItemFile) RawJSON() string { +func (r ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionGetResponseInputMessageUserContentArrayItemFile) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ChatCompletionGetResponseInputMessageUserContentArrayItemFileFile struct { - FileData string `json:"file_data"` - FileID string `json:"file_id"` - Filename string `json:"filename"` +type ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile struct { + FileData string `json:"file_data,nullable"` + FileID string `json:"file_id,nullable"` + Filename string `json:"filename,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { FileData respjson.Field @@ -2802,28 +2514,24 @@ type ChatCompletionGetResponseInputMessageUserContentArrayItemFileFile struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionGetResponseInputMessageUserContentArrayItemFileFile) RawJSON() string { +func (r ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionGetResponseInputMessageUserContentArrayItemFileFile) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionGetResponseInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A system message providing instructions or context to the model. type ChatCompletionGetResponseInputMessageSystem struct { - // The content of the "system prompt". If multiple system messages are provided, - // they are concatenated. The underlying Llama Stack code may also add other system - // messages (for example, for formatting tool definitions). Content ChatCompletionGetResponseInputMessageSystemContentUnion `json:"content,required"` - // Must be "system" to identify this as a system message - Role constant.System `json:"role,required"` - // (Optional) The name of the system message participant. - Name string `json:"name"` + Name string `json:"name,nullable"` + // Any of "system". + Role string `json:"role"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field - Role respjson.Field Name respjson.Field + Role respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -2837,24 +2545,23 @@ func (r *ChatCompletionGetResponseInputMessageSystem) UnmarshalJSON(data []byte) // ChatCompletionGetResponseInputMessageSystemContentUnion contains all possible // properties and values from [string], -// [[]ChatCompletionGetResponseInputMessageSystemContentArrayItem]. +// [[]ChatCompletionGetResponseInputMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString -// OfChatCompletionGetResponseInputMessageSystemContentArray] +// will be valid: OfString OfListOpenAIChatCompletionContentPartText] type ChatCompletionGetResponseInputMessageSystemContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionGetResponseInputMessageSystemContentArrayItem] instead of an - // object. - OfChatCompletionGetResponseInputMessageSystemContentArray []ChatCompletionGetResponseInputMessageSystemContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionGetResponseInputMessageSystemContentArray respjson.Field - raw string + // [[]ChatCompletionGetResponseInputMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem] + // instead of an object. + OfListOpenAIChatCompletionContentPartText []ChatCompletionGetResponseInputMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } @@ -2863,7 +2570,7 @@ func (u ChatCompletionGetResponseInputMessageSystemContentUnion) AsString() (v s return } -func (u ChatCompletionGetResponseInputMessageSystemContentUnion) AsChatCompletionGetResponseInputMessageSystemContentArray() (v []ChatCompletionGetResponseInputMessageSystemContentArrayItem) { +func (u ChatCompletionGetResponseInputMessageSystemContentUnion) AsListOpenAIChatCompletionContentPartTextParam() (v []ChatCompletionGetResponseInputMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -2876,11 +2583,10 @@ func (r *ChatCompletionGetResponseInputMessageSystemContentUnion) UnmarshalJSON( } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionGetResponseInputMessageSystemContentArrayItem struct { - // The text content of the message +type ChatCompletionGetResponseInputMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -2891,29 +2597,26 @@ type ChatCompletionGetResponseInputMessageSystemContentArrayItem struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionGetResponseInputMessageSystemContentArrayItem) RawJSON() string { +func (r ChatCompletionGetResponseInputMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionGetResponseInputMessageSystemContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionGetResponseInputMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A message containing the model's (assistant) response in an OpenAI-compatible // chat completion request. type ChatCompletionGetResponseInputMessageAssistant struct { - // Must be "assistant" to identify this as the model's response - Role constant.Assistant `json:"role,required"` - // The content of the model's response - Content ChatCompletionGetResponseInputMessageAssistantContentUnion `json:"content"` - // (Optional) The name of the assistant message participant. - Name string `json:"name"` - // List of tool calls. Each tool call is an OpenAIChatCompletionToolCall object. - ToolCalls []ChatCompletionGetResponseInputMessageAssistantToolCall `json:"tool_calls"` + Content ChatCompletionGetResponseInputMessageAssistantContentUnion `json:"content,nullable"` + Name string `json:"name,nullable"` + // Any of "assistant". + Role string `json:"role"` + ToolCalls []ChatCompletionGetResponseInputMessageAssistantToolCall `json:"tool_calls,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Role respjson.Field Content respjson.Field Name respjson.Field + Role respjson.Field ToolCalls respjson.Field ExtraFields map[string]respjson.Field raw string @@ -2928,24 +2631,23 @@ func (r *ChatCompletionGetResponseInputMessageAssistant) UnmarshalJSON(data []by // ChatCompletionGetResponseInputMessageAssistantContentUnion contains all possible // properties and values from [string], -// [[]ChatCompletionGetResponseInputMessageAssistantContentArrayItem]. +// [[]ChatCompletionGetResponseInputMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString -// OfChatCompletionGetResponseInputMessageAssistantContentArray] +// will be valid: OfString OfListOpenAIChatCompletionContentPartText] type ChatCompletionGetResponseInputMessageAssistantContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionGetResponseInputMessageAssistantContentArrayItem] instead of an - // object. - OfChatCompletionGetResponseInputMessageAssistantContentArray []ChatCompletionGetResponseInputMessageAssistantContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionGetResponseInputMessageAssistantContentArray respjson.Field - raw string + // [[]ChatCompletionGetResponseInputMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem] + // instead of an object. + OfListOpenAIChatCompletionContentPartText []ChatCompletionGetResponseInputMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } @@ -2954,7 +2656,7 @@ func (u ChatCompletionGetResponseInputMessageAssistantContentUnion) AsString() ( return } -func (u ChatCompletionGetResponseInputMessageAssistantContentUnion) AsChatCompletionGetResponseInputMessageAssistantContentArray() (v []ChatCompletionGetResponseInputMessageAssistantContentArrayItem) { +func (u ChatCompletionGetResponseInputMessageAssistantContentUnion) AsListOpenAIChatCompletionContentPartTextParam() (v []ChatCompletionGetResponseInputMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -2969,11 +2671,10 @@ func (r *ChatCompletionGetResponseInputMessageAssistantContentUnion) UnmarshalJS } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionGetResponseInputMessageAssistantContentArrayItem struct { - // The text content of the message +type ChatCompletionGetResponseInputMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -2984,29 +2685,27 @@ type ChatCompletionGetResponseInputMessageAssistantContentArrayItem struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionGetResponseInputMessageAssistantContentArrayItem) RawJSON() string { +func (r ChatCompletionGetResponseInputMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionGetResponseInputMessageAssistantContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionGetResponseInputMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Tool call specification for OpenAI-compatible chat completion responses. type ChatCompletionGetResponseInputMessageAssistantToolCall struct { - // Must be "function" to identify this as a function call - Type constant.Function `json:"type,required"` - // (Optional) Unique identifier for the tool call - ID string `json:"id"` - // (Optional) Function call details - Function ChatCompletionGetResponseInputMessageAssistantToolCallFunction `json:"function"` - // (Optional) Index of the tool call in the list - Index int64 `json:"index"` + ID string `json:"id,nullable"` + // Function call details for OpenAI-compatible tool calls. + Function ChatCompletionGetResponseInputMessageAssistantToolCallFunction `json:"function,nullable"` + Index int64 `json:"index,nullable"` + // Any of "function". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field ID respjson.Field Function respjson.Field Index respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -3018,12 +2717,10 @@ func (r *ChatCompletionGetResponseInputMessageAssistantToolCall) UnmarshalJSON(d return apijson.UnmarshalRoot(data, r) } -// (Optional) Function call details +// Function call details for OpenAI-compatible tool calls. type ChatCompletionGetResponseInputMessageAssistantToolCallFunction struct { - // (Optional) Arguments to pass to the function as a JSON string - Arguments string `json:"arguments"` - // (Optional) Name of the function to call - Name string `json:"name"` + Arguments string `json:"arguments,nullable"` + Name string `json:"name,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Arguments respjson.Field @@ -3044,17 +2741,15 @@ func (r *ChatCompletionGetResponseInputMessageAssistantToolCallFunction) Unmarsh // A message representing the result of a tool invocation in an OpenAI-compatible // chat completion request. type ChatCompletionGetResponseInputMessageTool struct { - // The response content from the tool - Content ChatCompletionGetResponseInputMessageToolContentUnion `json:"content,required"` - // Must be "tool" to identify this as a tool response - Role constant.Tool `json:"role,required"` - // Unique identifier for the tool call this response is for - ToolCallID string `json:"tool_call_id,required"` + Content ChatCompletionGetResponseInputMessageToolContentUnion `json:"content,required"` + ToolCallID string `json:"tool_call_id,required"` + // Any of "tool". + Role string `json:"role"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field - Role respjson.Field ToolCallID respjson.Field + Role respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -3068,23 +2763,23 @@ func (r *ChatCompletionGetResponseInputMessageTool) UnmarshalJSON(data []byte) e // ChatCompletionGetResponseInputMessageToolContentUnion contains all possible // properties and values from [string], -// [[]ChatCompletionGetResponseInputMessageToolContentArrayItem]. +// [[]ChatCompletionGetResponseInputMessageToolContentListOpenAIChatCompletionContentPartTextParamItem]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString OfChatCompletionGetResponseInputMessageToolContentArray] +// will be valid: OfString OfListOpenAIChatCompletionContentPartText] type ChatCompletionGetResponseInputMessageToolContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionGetResponseInputMessageToolContentArrayItem] instead of an - // object. - OfChatCompletionGetResponseInputMessageToolContentArray []ChatCompletionGetResponseInputMessageToolContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionGetResponseInputMessageToolContentArray respjson.Field - raw string + // [[]ChatCompletionGetResponseInputMessageToolContentListOpenAIChatCompletionContentPartTextParamItem] + // instead of an object. + OfListOpenAIChatCompletionContentPartText []ChatCompletionGetResponseInputMessageToolContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } @@ -3093,7 +2788,7 @@ func (u ChatCompletionGetResponseInputMessageToolContentUnion) AsString() (v str return } -func (u ChatCompletionGetResponseInputMessageToolContentUnion) AsChatCompletionGetResponseInputMessageToolContentArray() (v []ChatCompletionGetResponseInputMessageToolContentArrayItem) { +func (u ChatCompletionGetResponseInputMessageToolContentUnion) AsListOpenAIChatCompletionContentPartTextParam() (v []ChatCompletionGetResponseInputMessageToolContentListOpenAIChatCompletionContentPartTextParamItem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -3106,11 +2801,10 @@ func (r *ChatCompletionGetResponseInputMessageToolContentUnion) UnmarshalJSON(da } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionGetResponseInputMessageToolContentArrayItem struct { - // The text content of the message +type ChatCompletionGetResponseInputMessageToolContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -3121,26 +2815,24 @@ type ChatCompletionGetResponseInputMessageToolContentArrayItem struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionGetResponseInputMessageToolContentArrayItem) RawJSON() string { +func (r ChatCompletionGetResponseInputMessageToolContentListOpenAIChatCompletionContentPartTextParamItem) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionGetResponseInputMessageToolContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionGetResponseInputMessageToolContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A message from the developer in an OpenAI-compatible chat completion request. type ChatCompletionGetResponseInputMessageDeveloper struct { - // The content of the developer message Content ChatCompletionGetResponseInputMessageDeveloperContentUnion `json:"content,required"` - // Must be "developer" to identify this as a developer message - Role constant.Developer `json:"role,required"` - // (Optional) The name of the developer message participant. - Name string `json:"name"` + Name string `json:"name,nullable"` + // Any of "developer". + Role string `json:"role"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field - Role respjson.Field Name respjson.Field + Role respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -3154,24 +2846,23 @@ func (r *ChatCompletionGetResponseInputMessageDeveloper) UnmarshalJSON(data []by // ChatCompletionGetResponseInputMessageDeveloperContentUnion contains all possible // properties and values from [string], -// [[]ChatCompletionGetResponseInputMessageDeveloperContentArrayItem]. +// [[]ChatCompletionGetResponseInputMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString -// OfChatCompletionGetResponseInputMessageDeveloperContentArray] +// will be valid: OfString OfListOpenAIChatCompletionContentPartText] type ChatCompletionGetResponseInputMessageDeveloperContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionGetResponseInputMessageDeveloperContentArrayItem] instead of an - // object. - OfChatCompletionGetResponseInputMessageDeveloperContentArray []ChatCompletionGetResponseInputMessageDeveloperContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionGetResponseInputMessageDeveloperContentArray respjson.Field - raw string + // [[]ChatCompletionGetResponseInputMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem] + // instead of an object. + OfListOpenAIChatCompletionContentPartText []ChatCompletionGetResponseInputMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } @@ -3180,7 +2871,7 @@ func (u ChatCompletionGetResponseInputMessageDeveloperContentUnion) AsString() ( return } -func (u ChatCompletionGetResponseInputMessageDeveloperContentUnion) AsChatCompletionGetResponseInputMessageDeveloperContentArray() (v []ChatCompletionGetResponseInputMessageDeveloperContentArrayItem) { +func (u ChatCompletionGetResponseInputMessageDeveloperContentUnion) AsListOpenAIChatCompletionContentPartTextParam() (v []ChatCompletionGetResponseInputMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -3195,11 +2886,10 @@ func (r *ChatCompletionGetResponseInputMessageDeveloperContentUnion) UnmarshalJS } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionGetResponseInputMessageDeveloperContentArrayItem struct { - // The text content of the message +type ChatCompletionGetResponseInputMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -3210,25 +2900,28 @@ type ChatCompletionGetResponseInputMessageDeveloperContentArrayItem struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionGetResponseInputMessageDeveloperContentArrayItem) RawJSON() string { +func (r ChatCompletionGetResponseInputMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionGetResponseInputMessageDeveloperContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionGetResponseInputMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Token usage information for the completion +type ChatCompletionGetResponseObject string + +const ( + ChatCompletionGetResponseObjectChatCompletion ChatCompletionGetResponseObject = "chat.completion" +) + +// Usage information for OpenAI chat completion. type ChatCompletionGetResponseUsage struct { - // Number of tokens in the completion CompletionTokens int64 `json:"completion_tokens,required"` - // Number of tokens in the prompt - PromptTokens int64 `json:"prompt_tokens,required"` - // Total tokens used (prompt + completion) - TotalTokens int64 `json:"total_tokens,required"` + PromptTokens int64 `json:"prompt_tokens,required"` + TotalTokens int64 `json:"total_tokens,required"` // Token details for output tokens in OpenAI chat completion usage. - CompletionTokensDetails ChatCompletionGetResponseUsageCompletionTokensDetails `json:"completion_tokens_details"` + CompletionTokensDetails ChatCompletionGetResponseUsageCompletionTokensDetails `json:"completion_tokens_details,nullable"` // Token details for prompt tokens in OpenAI chat completion usage. - PromptTokensDetails ChatCompletionGetResponseUsagePromptTokensDetails `json:"prompt_tokens_details"` + PromptTokensDetails ChatCompletionGetResponseUsagePromptTokensDetails `json:"prompt_tokens_details,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { CompletionTokens respjson.Field @@ -3249,8 +2942,7 @@ func (r *ChatCompletionGetResponseUsage) UnmarshalJSON(data []byte) error { // Token details for output tokens in OpenAI chat completion usage. type ChatCompletionGetResponseUsageCompletionTokensDetails struct { - // Number of tokens used for reasoning (o1/o3 models) - ReasoningTokens int64 `json:"reasoning_tokens"` + ReasoningTokens int64 `json:"reasoning_tokens,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ReasoningTokens respjson.Field @@ -3267,8 +2959,7 @@ func (r *ChatCompletionGetResponseUsageCompletionTokensDetails) UnmarshalJSON(da // Token details for prompt tokens in OpenAI chat completion usage. type ChatCompletionGetResponseUsagePromptTokensDetails struct { - // Number of tokens retrieved from cache - CachedTokens int64 `json:"cached_tokens"` + CachedTokens int64 `json:"cached_tokens,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { CachedTokens respjson.Field @@ -3283,20 +2974,42 @@ func (r *ChatCompletionGetResponseUsagePromptTokensDetails) UnmarshalJSON(data [ return apijson.UnmarshalRoot(data, r) } +// Response from listing OpenAI-compatible chat completions. type ChatCompletionListResponse struct { - // The ID of the chat completion - ID string `json:"id,required"` - // List of choices - Choices []ChatCompletionListResponseChoice `json:"choices,required"` - // The Unix timestamp in seconds when the chat completion was created - Created int64 `json:"created,required"` - InputMessages []ChatCompletionListResponseInputMessageUnion `json:"input_messages,required"` - // The model that was used to generate the chat completion - Model string `json:"model,required"` - // The object type, which will be "chat.completion" - Object constant.ChatCompletion `json:"object,required"` - // Token usage information for the completion - Usage ChatCompletionListResponseUsage `json:"usage"` + Data []ChatCompletionListResponseData `json:"data,required"` + FirstID string `json:"first_id,required"` + HasMore bool `json:"has_more,required"` + LastID string `json:"last_id,required"` + // Any of "list". + Object ChatCompletionListResponseObject `json:"object"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Data respjson.Field + FirstID respjson.Field + HasMore respjson.Field + LastID respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ChatCompletionListResponse) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionListResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type ChatCompletionListResponseData struct { + ID string `json:"id,required"` + Choices []ChatCompletionListResponseDataChoice `json:"choices,required"` + Created int64 `json:"created,required"` + InputMessages []ChatCompletionListResponseDataInputMessageUnion `json:"input_messages,required"` + Model string `json:"model,required"` + // Any of "chat.completion". + Object string `json:"object"` + // Usage information for OpenAI chat completion. + Usage ChatCompletionListResponseDataUsage `json:"usage,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -3312,21 +3025,20 @@ type ChatCompletionListResponse struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponse) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponse) UnmarshalJSON(data []byte) error { +func (r ChatCompletionListResponseData) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionListResponseData) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A choice from an OpenAI-compatible chat completion response. -type ChatCompletionListResponseChoice struct { - // The reason the model stopped generating +type ChatCompletionListResponseDataChoice struct { FinishReason string `json:"finish_reason,required"` - // The index of the choice - Index int64 `json:"index,required"` - // The message from the model - Message ChatCompletionListResponseChoiceMessageUnion `json:"message,required"` - // (Optional) The log probabilities for the tokens in the message - Logprobs ChatCompletionListResponseChoiceLogprobs `json:"logprobs"` + Index int64 `json:"index,required"` + // A message from the user in an OpenAI-compatible chat completion request. + Message ChatCompletionListResponseDataChoiceMessageUnion `json:"message,required"` + // The log probabilities for the tokens in the message from an OpenAI-compatible + // chat completion response. + Logprobs ChatCompletionListResponseDataChoiceLogprobs `json:"logprobs,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { FinishReason respjson.Field @@ -3339,77 +3051,78 @@ type ChatCompletionListResponseChoice struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseChoice) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseChoice) UnmarshalJSON(data []byte) error { +func (r ChatCompletionListResponseDataChoice) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionListResponseDataChoice) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionListResponseChoiceMessageUnion contains all possible properties -// and values from [ChatCompletionListResponseChoiceMessageUser], -// [ChatCompletionListResponseChoiceMessageSystem], -// [ChatCompletionListResponseChoiceMessageAssistant], -// [ChatCompletionListResponseChoiceMessageTool], -// [ChatCompletionListResponseChoiceMessageDeveloper]. +// ChatCompletionListResponseDataChoiceMessageUnion contains all possible +// properties and values from [ChatCompletionListResponseDataChoiceMessageUser], +// [ChatCompletionListResponseDataChoiceMessageSystem], +// [ChatCompletionListResponseDataChoiceMessageAssistant], +// [ChatCompletionListResponseDataChoiceMessageTool], +// [ChatCompletionListResponseDataChoiceMessageDeveloper]. // -// Use the [ChatCompletionListResponseChoiceMessageUnion.AsAny] method to switch on -// the variant. +// Use the [ChatCompletionListResponseDataChoiceMessageUnion.AsAny] method to +// switch on the variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type ChatCompletionListResponseChoiceMessageUnion struct { +type ChatCompletionListResponseDataChoiceMessageUnion struct { // This field is a union of - // [ChatCompletionListResponseChoiceMessageUserContentUnion], - // [ChatCompletionListResponseChoiceMessageSystemContentUnion], - // [ChatCompletionListResponseChoiceMessageAssistantContentUnion], - // [ChatCompletionListResponseChoiceMessageToolContentUnion], - // [ChatCompletionListResponseChoiceMessageDeveloperContentUnion] - Content ChatCompletionListResponseChoiceMessageUnionContent `json:"content"` + // [ChatCompletionListResponseDataChoiceMessageUserContentUnion], + // [ChatCompletionListResponseDataChoiceMessageSystemContentUnion], + // [ChatCompletionListResponseDataChoiceMessageAssistantContentUnion], + // [ChatCompletionListResponseDataChoiceMessageToolContentUnion], + // [ChatCompletionListResponseDataChoiceMessageDeveloperContentUnion] + Content ChatCompletionListResponseDataChoiceMessageUnionContent `json:"content"` + Name string `json:"name"` // Any of "user", "system", "assistant", "tool", "developer". Role string `json:"role"` - Name string `json:"name"` - // This field is from variant [ChatCompletionListResponseChoiceMessageAssistant]. - ToolCalls []ChatCompletionListResponseChoiceMessageAssistantToolCall `json:"tool_calls"` - // This field is from variant [ChatCompletionListResponseChoiceMessageTool]. + // This field is from variant + // [ChatCompletionListResponseDataChoiceMessageAssistant]. + ToolCalls []ChatCompletionListResponseDataChoiceMessageAssistantToolCall `json:"tool_calls"` + // This field is from variant [ChatCompletionListResponseDataChoiceMessageTool]. ToolCallID string `json:"tool_call_id"` JSON struct { Content respjson.Field - Role respjson.Field Name respjson.Field + Role respjson.Field ToolCalls respjson.Field ToolCallID respjson.Field raw string } `json:"-"` } -// anyChatCompletionListResponseChoiceMessage is implemented by each variant of -// [ChatCompletionListResponseChoiceMessageUnion] to add type safety for the return -// type of [ChatCompletionListResponseChoiceMessageUnion.AsAny] -type anyChatCompletionListResponseChoiceMessage interface { - implChatCompletionListResponseChoiceMessageUnion() +// anyChatCompletionListResponseDataChoiceMessage is implemented by each variant of +// [ChatCompletionListResponseDataChoiceMessageUnion] to add type safety for the +// return type of [ChatCompletionListResponseDataChoiceMessageUnion.AsAny] +type anyChatCompletionListResponseDataChoiceMessage interface { + implChatCompletionListResponseDataChoiceMessageUnion() } -func (ChatCompletionListResponseChoiceMessageUser) implChatCompletionListResponseChoiceMessageUnion() { +func (ChatCompletionListResponseDataChoiceMessageUser) implChatCompletionListResponseDataChoiceMessageUnion() { } -func (ChatCompletionListResponseChoiceMessageSystem) implChatCompletionListResponseChoiceMessageUnion() { +func (ChatCompletionListResponseDataChoiceMessageSystem) implChatCompletionListResponseDataChoiceMessageUnion() { } -func (ChatCompletionListResponseChoiceMessageAssistant) implChatCompletionListResponseChoiceMessageUnion() { +func (ChatCompletionListResponseDataChoiceMessageAssistant) implChatCompletionListResponseDataChoiceMessageUnion() { } -func (ChatCompletionListResponseChoiceMessageTool) implChatCompletionListResponseChoiceMessageUnion() { +func (ChatCompletionListResponseDataChoiceMessageTool) implChatCompletionListResponseDataChoiceMessageUnion() { } -func (ChatCompletionListResponseChoiceMessageDeveloper) implChatCompletionListResponseChoiceMessageUnion() { +func (ChatCompletionListResponseDataChoiceMessageDeveloper) implChatCompletionListResponseDataChoiceMessageUnion() { } // Use the following switch statement to find the correct variant // -// switch variant := ChatCompletionListResponseChoiceMessageUnion.AsAny().(type) { -// case llamastackclient.ChatCompletionListResponseChoiceMessageUser: -// case llamastackclient.ChatCompletionListResponseChoiceMessageSystem: -// case llamastackclient.ChatCompletionListResponseChoiceMessageAssistant: -// case llamastackclient.ChatCompletionListResponseChoiceMessageTool: -// case llamastackclient.ChatCompletionListResponseChoiceMessageDeveloper: +// switch variant := ChatCompletionListResponseDataChoiceMessageUnion.AsAny().(type) { +// case llamastackclient.ChatCompletionListResponseDataChoiceMessageUser: +// case llamastackclient.ChatCompletionListResponseDataChoiceMessageSystem: +// case llamastackclient.ChatCompletionListResponseDataChoiceMessageAssistant: +// case llamastackclient.ChatCompletionListResponseDataChoiceMessageTool: +// case llamastackclient.ChatCompletionListResponseDataChoiceMessageDeveloper: // default: // fmt.Errorf("no variant present") // } -func (u ChatCompletionListResponseChoiceMessageUnion) AsAny() anyChatCompletionListResponseChoiceMessage { +func (u ChatCompletionListResponseDataChoiceMessageUnion) AsAny() anyChatCompletionListResponseDataChoiceMessage { switch u.Role { case "user": return u.AsUser() @@ -3425,177 +3138,160 @@ func (u ChatCompletionListResponseChoiceMessageUnion) AsAny() anyChatCompletionL return nil } -func (u ChatCompletionListResponseChoiceMessageUnion) AsUser() (v ChatCompletionListResponseChoiceMessageUser) { +func (u ChatCompletionListResponseDataChoiceMessageUnion) AsUser() (v ChatCompletionListResponseDataChoiceMessageUser) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionListResponseChoiceMessageUnion) AsSystem() (v ChatCompletionListResponseChoiceMessageSystem) { +func (u ChatCompletionListResponseDataChoiceMessageUnion) AsSystem() (v ChatCompletionListResponseDataChoiceMessageSystem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionListResponseChoiceMessageUnion) AsAssistant() (v ChatCompletionListResponseChoiceMessageAssistant) { +func (u ChatCompletionListResponseDataChoiceMessageUnion) AsAssistant() (v ChatCompletionListResponseDataChoiceMessageAssistant) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionListResponseChoiceMessageUnion) AsTool() (v ChatCompletionListResponseChoiceMessageTool) { +func (u ChatCompletionListResponseDataChoiceMessageUnion) AsTool() (v ChatCompletionListResponseDataChoiceMessageTool) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionListResponseChoiceMessageUnion) AsDeveloper() (v ChatCompletionListResponseChoiceMessageDeveloper) { +func (u ChatCompletionListResponseDataChoiceMessageUnion) AsDeveloper() (v ChatCompletionListResponseDataChoiceMessageDeveloper) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ChatCompletionListResponseChoiceMessageUnion) RawJSON() string { return u.JSON.raw } +func (u ChatCompletionListResponseDataChoiceMessageUnion) RawJSON() string { return u.JSON.raw } -func (r *ChatCompletionListResponseChoiceMessageUnion) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataChoiceMessageUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionListResponseChoiceMessageUnionContent is an implicit subunion of -// [ChatCompletionListResponseChoiceMessageUnion]. -// ChatCompletionListResponseChoiceMessageUnionContent provides convenient access -// to the sub-properties of the union. +// ChatCompletionListResponseDataChoiceMessageUnionContent is an implicit subunion +// of [ChatCompletionListResponseDataChoiceMessageUnion]. +// ChatCompletionListResponseDataChoiceMessageUnionContent provides convenient +// access to the sub-properties of the union. // // For type safety it is recommended to directly use a variant of the -// [ChatCompletionListResponseChoiceMessageUnion]. +// [ChatCompletionListResponseDataChoiceMessageUnion]. // // If the underlying value is not a json object, one of the following properties // will be valid: OfString -// OfChatCompletionListResponseChoiceMessageUserContentArray -// OfChatCompletionListResponseChoiceMessageSystemContentArray -// OfChatCompletionListResponseChoiceMessageAssistantContentArray -// OfChatCompletionListResponseChoiceMessageToolContentArray -// OfChatCompletionListResponseChoiceMessageDeveloperContentArray] -type ChatCompletionListResponseChoiceMessageUnionContent struct { +// OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile +// OfListOpenAIChatCompletionContentPartText] +type ChatCompletionListResponseDataChoiceMessageUnionContent struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionListResponseChoiceMessageUserContentArrayItemUnion] instead of - // an object. - OfChatCompletionListResponseChoiceMessageUserContentArray []ChatCompletionListResponseChoiceMessageUserContentArrayItemUnion `json:",inline"` - // This field will be present if the value is a - // [[]ChatCompletionListResponseChoiceMessageSystemContentArrayItem] instead of an - // object. - OfChatCompletionListResponseChoiceMessageSystemContentArray []ChatCompletionListResponseChoiceMessageSystemContentArrayItem `json:",inline"` - // This field will be present if the value is a - // [[]ChatCompletionListResponseChoiceMessageAssistantContentArrayItem] instead of - // an object. - OfChatCompletionListResponseChoiceMessageAssistantContentArray []ChatCompletionListResponseChoiceMessageAssistantContentArrayItem `json:",inline"` - // This field will be present if the value is a - // [[]ChatCompletionListResponseChoiceMessageToolContentArrayItem] instead of an - // object. - OfChatCompletionListResponseChoiceMessageToolContentArray []ChatCompletionListResponseChoiceMessageToolContentArrayItem `json:",inline"` + // [[]ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion] + // instead of an object. + OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile []ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionListResponseChoiceMessageDeveloperContentArrayItem] instead of - // an object. - OfChatCompletionListResponseChoiceMessageDeveloperContentArray []ChatCompletionListResponseChoiceMessageDeveloperContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionListResponseChoiceMessageUserContentArray respjson.Field - OfChatCompletionListResponseChoiceMessageSystemContentArray respjson.Field - OfChatCompletionListResponseChoiceMessageAssistantContentArray respjson.Field - OfChatCompletionListResponseChoiceMessageToolContentArray respjson.Field - OfChatCompletionListResponseChoiceMessageDeveloperContentArray respjson.Field - raw string + // [[]ChatCompletionListResponseDataChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem] + // instead of an object. + OfListOpenAIChatCompletionContentPartText []ChatCompletionListResponseDataChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } -func (r *ChatCompletionListResponseChoiceMessageUnionContent) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataChoiceMessageUnionContent) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A message from the user in an OpenAI-compatible chat completion request. -type ChatCompletionListResponseChoiceMessageUser struct { - // The content of the message, which can include text and other media - Content ChatCompletionListResponseChoiceMessageUserContentUnion `json:"content,required"` - // Must be "user" to identify this as a user message - Role constant.User `json:"role,required"` - // (Optional) The name of the user message participant. - Name string `json:"name"` +type ChatCompletionListResponseDataChoiceMessageUser struct { + Content ChatCompletionListResponseDataChoiceMessageUserContentUnion `json:"content,required"` + Name string `json:"name,nullable"` + // Any of "user". + Role string `json:"role"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field - Role respjson.Field Name respjson.Field + Role respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseChoiceMessageUser) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseChoiceMessageUser) UnmarshalJSON(data []byte) error { +func (r ChatCompletionListResponseDataChoiceMessageUser) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionListResponseDataChoiceMessageUser) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionListResponseChoiceMessageUserContentUnion contains all possible -// properties and values from [string], -// [[]ChatCompletionListResponseChoiceMessageUserContentArrayItemUnion]. +// ChatCompletionListResponseDataChoiceMessageUserContentUnion contains all +// possible properties and values from [string], +// [[]ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties // will be valid: OfString -// OfChatCompletionListResponseChoiceMessageUserContentArray] -type ChatCompletionListResponseChoiceMessageUserContentUnion struct { +// OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile] +type ChatCompletionListResponseDataChoiceMessageUserContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionListResponseChoiceMessageUserContentArrayItemUnion] instead of - // an object. - OfChatCompletionListResponseChoiceMessageUserContentArray []ChatCompletionListResponseChoiceMessageUserContentArrayItemUnion `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionListResponseChoiceMessageUserContentArray respjson.Field - raw string + // [[]ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion] + // instead of an object. + OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile []ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile respjson.Field + raw string } `json:"-"` } -func (u ChatCompletionListResponseChoiceMessageUserContentUnion) AsString() (v string) { +func (u ChatCompletionListResponseDataChoiceMessageUserContentUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionListResponseChoiceMessageUserContentUnion) AsChatCompletionListResponseChoiceMessageUserContentArray() (v []ChatCompletionListResponseChoiceMessageUserContentArrayItemUnion) { +func (u ChatCompletionListResponseDataChoiceMessageUserContentUnion) AsListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFile() (v []ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ChatCompletionListResponseChoiceMessageUserContentUnion) RawJSON() string { return u.JSON.raw } +func (u ChatCompletionListResponseDataChoiceMessageUserContentUnion) RawJSON() string { + return u.JSON.raw +} -func (r *ChatCompletionListResponseChoiceMessageUserContentUnion) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataChoiceMessageUserContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionListResponseChoiceMessageUserContentArrayItemUnion contains all -// possible properties and values from -// [ChatCompletionListResponseChoiceMessageUserContentArrayItemText], -// [ChatCompletionListResponseChoiceMessageUserContentArrayItemImageURL], -// [ChatCompletionListResponseChoiceMessageUserContentArrayItemFile]. +// ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion +// contains all possible properties and values from +// [ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText], +// [ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL], +// [ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile]. // -// Use the [ChatCompletionListResponseChoiceMessageUserContentArrayItemUnion.AsAny] +// Use the +// [ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion.AsAny] // method to switch on the variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type ChatCompletionListResponseChoiceMessageUserContentArrayItemUnion struct { +type ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion struct { // This field is from variant - // [ChatCompletionListResponseChoiceMessageUserContentArrayItemText]. + // [ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText]. Text string `json:"text"` // Any of "text", "image_url", "file". Type string `json:"type"` // This field is from variant - // [ChatCompletionListResponseChoiceMessageUserContentArrayItemImageURL]. - ImageURL ChatCompletionListResponseChoiceMessageUserContentArrayItemImageURLImageURL `json:"image_url"` + // [ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL]. + ImageURL ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL `json:"image_url"` // This field is from variant - // [ChatCompletionListResponseChoiceMessageUserContentArrayItemFile]. - File ChatCompletionListResponseChoiceMessageUserContentArrayItemFileFile `json:"file"` + // [ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile]. + File ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile `json:"file"` JSON struct { Text respjson.Field Type respjson.Field @@ -3605,32 +3301,32 @@ type ChatCompletionListResponseChoiceMessageUserContentArrayItemUnion struct { } `json:"-"` } -// anyChatCompletionListResponseChoiceMessageUserContentArrayItem is implemented by -// each variant of -// [ChatCompletionListResponseChoiceMessageUserContentArrayItemUnion] to add type -// safety for the return type of -// [ChatCompletionListResponseChoiceMessageUserContentArrayItemUnion.AsAny] -type anyChatCompletionListResponseChoiceMessageUserContentArrayItem interface { - implChatCompletionListResponseChoiceMessageUserContentArrayItemUnion() +// anyChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItem +// is implemented by each variant of +// [ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion] +// to add type safety for the return type of +// [ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion.AsAny] +type anyChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItem interface { + implChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion() } -func (ChatCompletionListResponseChoiceMessageUserContentArrayItemText) implChatCompletionListResponseChoiceMessageUserContentArrayItemUnion() { +func (ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) implChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion() { } -func (ChatCompletionListResponseChoiceMessageUserContentArrayItemImageURL) implChatCompletionListResponseChoiceMessageUserContentArrayItemUnion() { +func (ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) implChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion() { } -func (ChatCompletionListResponseChoiceMessageUserContentArrayItemFile) implChatCompletionListResponseChoiceMessageUserContentArrayItemUnion() { +func (ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) implChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion() { } // Use the following switch statement to find the correct variant // -// switch variant := ChatCompletionListResponseChoiceMessageUserContentArrayItemUnion.AsAny().(type) { -// case llamastackclient.ChatCompletionListResponseChoiceMessageUserContentArrayItemText: -// case llamastackclient.ChatCompletionListResponseChoiceMessageUserContentArrayItemImageURL: -// case llamastackclient.ChatCompletionListResponseChoiceMessageUserContentArrayItemFile: +// switch variant := ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion.AsAny().(type) { +// case llamastackclient.ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText: +// case llamastackclient.ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL: +// case llamastackclient.ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile: // default: // fmt.Errorf("no variant present") // } -func (u ChatCompletionListResponseChoiceMessageUserContentArrayItemUnion) AsAny() anyChatCompletionListResponseChoiceMessageUserContentArrayItem { +func (u ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) AsAny() anyChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItem { switch u.Type { case "text": return u.AsText() @@ -3642,36 +3338,35 @@ func (u ChatCompletionListResponseChoiceMessageUserContentArrayItemUnion) AsAny( return nil } -func (u ChatCompletionListResponseChoiceMessageUserContentArrayItemUnion) AsText() (v ChatCompletionListResponseChoiceMessageUserContentArrayItemText) { +func (u ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) AsText() (v ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionListResponseChoiceMessageUserContentArrayItemUnion) AsImageURL() (v ChatCompletionListResponseChoiceMessageUserContentArrayItemImageURL) { +func (u ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) AsImageURL() (v ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionListResponseChoiceMessageUserContentArrayItemUnion) AsFile() (v ChatCompletionListResponseChoiceMessageUserContentArrayItemFile) { +func (u ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) AsFile() (v ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ChatCompletionListResponseChoiceMessageUserContentArrayItemUnion) RawJSON() string { +func (u ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) RawJSON() string { return u.JSON.raw } -func (r *ChatCompletionListResponseChoiceMessageUserContentArrayItemUnion) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionListResponseChoiceMessageUserContentArrayItemText struct { - // The text content of the message +type ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -3682,19 +3377,19 @@ type ChatCompletionListResponseChoiceMessageUserContentArrayItemText struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseChoiceMessageUserContentArrayItemText) RawJSON() string { +func (r ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseChoiceMessageUserContentArrayItemText) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Image content part for OpenAI-compatible chat completion messages. -type ChatCompletionListResponseChoiceMessageUserContentArrayItemImageURL struct { - // Image URL specification and processing details - ImageURL ChatCompletionListResponseChoiceMessageUserContentArrayItemImageURLImageURL `json:"image_url,required"` - // Must be "image_url" to identify this as image content - Type constant.ImageURL `json:"type,required"` +type ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL struct { + // Image URL specification for OpenAI-compatible chat completion messages. + ImageURL ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL `json:"image_url,required"` + // Any of "image_url". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ImageURL respjson.Field @@ -3705,19 +3400,17 @@ type ChatCompletionListResponseChoiceMessageUserContentArrayItemImageURL struct } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseChoiceMessageUserContentArrayItemImageURL) RawJSON() string { +func (r ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseChoiceMessageUserContentArrayItemImageURL) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Image URL specification and processing details -type ChatCompletionListResponseChoiceMessageUserContentArrayItemImageURLImageURL struct { - // URL of the image to include in the message - URL string `json:"url,required"` - // (Optional) Level of detail for image processing. Can be "low", "high", or "auto" - Detail string `json:"detail"` +// Image URL specification for OpenAI-compatible chat completion messages. +type ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL struct { + URL string `json:"url,required"` + Detail string `json:"detail,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { URL respjson.Field @@ -3728,16 +3421,17 @@ type ChatCompletionListResponseChoiceMessageUserContentArrayItemImageURLImageURL } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseChoiceMessageUserContentArrayItemImageURLImageURL) RawJSON() string { +func (r ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseChoiceMessageUserContentArrayItemImageURLImageURL) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ChatCompletionListResponseChoiceMessageUserContentArrayItemFile struct { - File ChatCompletionListResponseChoiceMessageUserContentArrayItemFileFile `json:"file,required"` - Type constant.File `json:"type,required"` +type ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile struct { + File ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile `json:"file,required"` + // Any of "file". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { File respjson.Field @@ -3748,17 +3442,17 @@ type ChatCompletionListResponseChoiceMessageUserContentArrayItemFile struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseChoiceMessageUserContentArrayItemFile) RawJSON() string { +func (r ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseChoiceMessageUserContentArrayItemFile) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ChatCompletionListResponseChoiceMessageUserContentArrayItemFileFile struct { - FileData string `json:"file_data"` - FileID string `json:"file_id"` - Filename string `json:"filename"` +type ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile struct { + FileData string `json:"file_data,nullable"` + FileID string `json:"file_id,nullable"` + Filename string `json:"filename,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { FileData respjson.Field @@ -3770,87 +3464,81 @@ type ChatCompletionListResponseChoiceMessageUserContentArrayItemFileFile struct } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseChoiceMessageUserContentArrayItemFileFile) RawJSON() string { +func (r ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseChoiceMessageUserContentArrayItemFileFile) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataChoiceMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A system message providing instructions or context to the model. -type ChatCompletionListResponseChoiceMessageSystem struct { - // The content of the "system prompt". If multiple system messages are provided, - // they are concatenated. The underlying Llama Stack code may also add other system - // messages (for example, for formatting tool definitions). - Content ChatCompletionListResponseChoiceMessageSystemContentUnion `json:"content,required"` - // Must be "system" to identify this as a system message - Role constant.System `json:"role,required"` - // (Optional) The name of the system message participant. - Name string `json:"name"` +type ChatCompletionListResponseDataChoiceMessageSystem struct { + Content ChatCompletionListResponseDataChoiceMessageSystemContentUnion `json:"content,required"` + Name string `json:"name,nullable"` + // Any of "system". + Role string `json:"role"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field - Role respjson.Field Name respjson.Field + Role respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseChoiceMessageSystem) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseChoiceMessageSystem) UnmarshalJSON(data []byte) error { +func (r ChatCompletionListResponseDataChoiceMessageSystem) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionListResponseDataChoiceMessageSystem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionListResponseChoiceMessageSystemContentUnion contains all possible -// properties and values from [string], -// [[]ChatCompletionListResponseChoiceMessageSystemContentArrayItem]. +// ChatCompletionListResponseDataChoiceMessageSystemContentUnion contains all +// possible properties and values from [string], +// [[]ChatCompletionListResponseDataChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString -// OfChatCompletionListResponseChoiceMessageSystemContentArray] -type ChatCompletionListResponseChoiceMessageSystemContentUnion struct { +// will be valid: OfString OfListOpenAIChatCompletionContentPartText] +type ChatCompletionListResponseDataChoiceMessageSystemContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionListResponseChoiceMessageSystemContentArrayItem] instead of an - // object. - OfChatCompletionListResponseChoiceMessageSystemContentArray []ChatCompletionListResponseChoiceMessageSystemContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionListResponseChoiceMessageSystemContentArray respjson.Field - raw string + // [[]ChatCompletionListResponseDataChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem] + // instead of an object. + OfListOpenAIChatCompletionContentPartText []ChatCompletionListResponseDataChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } -func (u ChatCompletionListResponseChoiceMessageSystemContentUnion) AsString() (v string) { +func (u ChatCompletionListResponseDataChoiceMessageSystemContentUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionListResponseChoiceMessageSystemContentUnion) AsChatCompletionListResponseChoiceMessageSystemContentArray() (v []ChatCompletionListResponseChoiceMessageSystemContentArrayItem) { +func (u ChatCompletionListResponseDataChoiceMessageSystemContentUnion) AsListOpenAIChatCompletionContentPartTextParam() (v []ChatCompletionListResponseDataChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ChatCompletionListResponseChoiceMessageSystemContentUnion) RawJSON() string { +func (u ChatCompletionListResponseDataChoiceMessageSystemContentUnion) RawJSON() string { return u.JSON.raw } -func (r *ChatCompletionListResponseChoiceMessageSystemContentUnion) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataChoiceMessageSystemContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionListResponseChoiceMessageSystemContentArrayItem struct { - // The text content of the message +type ChatCompletionListResponseDataChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -3861,29 +3549,26 @@ type ChatCompletionListResponseChoiceMessageSystemContentArrayItem struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseChoiceMessageSystemContentArrayItem) RawJSON() string { +func (r ChatCompletionListResponseDataChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseChoiceMessageSystemContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataChoiceMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A message containing the model's (assistant) response in an OpenAI-compatible // chat completion request. -type ChatCompletionListResponseChoiceMessageAssistant struct { - // Must be "assistant" to identify this as the model's response - Role constant.Assistant `json:"role,required"` - // The content of the model's response - Content ChatCompletionListResponseChoiceMessageAssistantContentUnion `json:"content"` - // (Optional) The name of the assistant message participant. - Name string `json:"name"` - // List of tool calls. Each tool call is an OpenAIChatCompletionToolCall object. - ToolCalls []ChatCompletionListResponseChoiceMessageAssistantToolCall `json:"tool_calls"` +type ChatCompletionListResponseDataChoiceMessageAssistant struct { + Content ChatCompletionListResponseDataChoiceMessageAssistantContentUnion `json:"content,nullable"` + Name string `json:"name,nullable"` + // Any of "assistant". + Role string `json:"role"` + ToolCalls []ChatCompletionListResponseDataChoiceMessageAssistantToolCall `json:"tool_calls,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Role respjson.Field Content respjson.Field Name respjson.Field + Role respjson.Field ToolCalls respjson.Field ExtraFields map[string]respjson.Field raw string @@ -3891,59 +3576,57 @@ type ChatCompletionListResponseChoiceMessageAssistant struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseChoiceMessageAssistant) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseChoiceMessageAssistant) UnmarshalJSON(data []byte) error { +func (r ChatCompletionListResponseDataChoiceMessageAssistant) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionListResponseDataChoiceMessageAssistant) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionListResponseChoiceMessageAssistantContentUnion contains all +// ChatCompletionListResponseDataChoiceMessageAssistantContentUnion contains all // possible properties and values from [string], -// [[]ChatCompletionListResponseChoiceMessageAssistantContentArrayItem]. +// [[]ChatCompletionListResponseDataChoiceMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString -// OfChatCompletionListResponseChoiceMessageAssistantContentArray] -type ChatCompletionListResponseChoiceMessageAssistantContentUnion struct { +// will be valid: OfString OfListOpenAIChatCompletionContentPartText] +type ChatCompletionListResponseDataChoiceMessageAssistantContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionListResponseChoiceMessageAssistantContentArrayItem] instead of - // an object. - OfChatCompletionListResponseChoiceMessageAssistantContentArray []ChatCompletionListResponseChoiceMessageAssistantContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionListResponseChoiceMessageAssistantContentArray respjson.Field - raw string + // [[]ChatCompletionListResponseDataChoiceMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem] + // instead of an object. + OfListOpenAIChatCompletionContentPartText []ChatCompletionListResponseDataChoiceMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } -func (u ChatCompletionListResponseChoiceMessageAssistantContentUnion) AsString() (v string) { +func (u ChatCompletionListResponseDataChoiceMessageAssistantContentUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionListResponseChoiceMessageAssistantContentUnion) AsChatCompletionListResponseChoiceMessageAssistantContentArray() (v []ChatCompletionListResponseChoiceMessageAssistantContentArrayItem) { +func (u ChatCompletionListResponseDataChoiceMessageAssistantContentUnion) AsListOpenAIChatCompletionContentPartTextParam() (v []ChatCompletionListResponseDataChoiceMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ChatCompletionListResponseChoiceMessageAssistantContentUnion) RawJSON() string { +func (u ChatCompletionListResponseDataChoiceMessageAssistantContentUnion) RawJSON() string { return u.JSON.raw } -func (r *ChatCompletionListResponseChoiceMessageAssistantContentUnion) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataChoiceMessageAssistantContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionListResponseChoiceMessageAssistantContentArrayItem struct { - // The text content of the message +type ChatCompletionListResponseDataChoiceMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -3954,46 +3637,44 @@ type ChatCompletionListResponseChoiceMessageAssistantContentArrayItem struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseChoiceMessageAssistantContentArrayItem) RawJSON() string { +func (r ChatCompletionListResponseDataChoiceMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseChoiceMessageAssistantContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataChoiceMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Tool call specification for OpenAI-compatible chat completion responses. -type ChatCompletionListResponseChoiceMessageAssistantToolCall struct { - // Must be "function" to identify this as a function call - Type constant.Function `json:"type,required"` - // (Optional) Unique identifier for the tool call - ID string `json:"id"` - // (Optional) Function call details - Function ChatCompletionListResponseChoiceMessageAssistantToolCallFunction `json:"function"` - // (Optional) Index of the tool call in the list - Index int64 `json:"index"` +type ChatCompletionListResponseDataChoiceMessageAssistantToolCall struct { + ID string `json:"id,nullable"` + // Function call details for OpenAI-compatible tool calls. + Function ChatCompletionListResponseDataChoiceMessageAssistantToolCallFunction `json:"function,nullable"` + Index int64 `json:"index,nullable"` + // Any of "function". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field ID respjson.Field Function respjson.Field Index respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseChoiceMessageAssistantToolCall) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseChoiceMessageAssistantToolCall) UnmarshalJSON(data []byte) error { +func (r ChatCompletionListResponseDataChoiceMessageAssistantToolCall) RawJSON() string { + return r.JSON.raw +} +func (r *ChatCompletionListResponseDataChoiceMessageAssistantToolCall) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// (Optional) Function call details -type ChatCompletionListResponseChoiceMessageAssistantToolCallFunction struct { - // (Optional) Arguments to pass to the function as a JSON string - Arguments string `json:"arguments"` - // (Optional) Name of the function to call - Name string `json:"name"` +// Function call details for OpenAI-compatible tool calls. +type ChatCompletionListResponseDataChoiceMessageAssistantToolCallFunction struct { + Arguments string `json:"arguments,nullable"` + Name string `json:"name,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Arguments respjson.Field @@ -4004,84 +3685,82 @@ type ChatCompletionListResponseChoiceMessageAssistantToolCallFunction struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseChoiceMessageAssistantToolCallFunction) RawJSON() string { +func (r ChatCompletionListResponseDataChoiceMessageAssistantToolCallFunction) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseChoiceMessageAssistantToolCallFunction) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataChoiceMessageAssistantToolCallFunction) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A message representing the result of a tool invocation in an OpenAI-compatible // chat completion request. -type ChatCompletionListResponseChoiceMessageTool struct { - // The response content from the tool - Content ChatCompletionListResponseChoiceMessageToolContentUnion `json:"content,required"` - // Must be "tool" to identify this as a tool response - Role constant.Tool `json:"role,required"` - // Unique identifier for the tool call this response is for - ToolCallID string `json:"tool_call_id,required"` +type ChatCompletionListResponseDataChoiceMessageTool struct { + Content ChatCompletionListResponseDataChoiceMessageToolContentUnion `json:"content,required"` + ToolCallID string `json:"tool_call_id,required"` + // Any of "tool". + Role string `json:"role"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field - Role respjson.Field ToolCallID respjson.Field + Role respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseChoiceMessageTool) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseChoiceMessageTool) UnmarshalJSON(data []byte) error { +func (r ChatCompletionListResponseDataChoiceMessageTool) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionListResponseDataChoiceMessageTool) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionListResponseChoiceMessageToolContentUnion contains all possible -// properties and values from [string], -// [[]ChatCompletionListResponseChoiceMessageToolContentArrayItem]. +// ChatCompletionListResponseDataChoiceMessageToolContentUnion contains all +// possible properties and values from [string], +// [[]ChatCompletionListResponseDataChoiceMessageToolContentListOpenAIChatCompletionContentPartTextParamItem]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString -// OfChatCompletionListResponseChoiceMessageToolContentArray] -type ChatCompletionListResponseChoiceMessageToolContentUnion struct { +// will be valid: OfString OfListOpenAIChatCompletionContentPartText] +type ChatCompletionListResponseDataChoiceMessageToolContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionListResponseChoiceMessageToolContentArrayItem] instead of an - // object. - OfChatCompletionListResponseChoiceMessageToolContentArray []ChatCompletionListResponseChoiceMessageToolContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionListResponseChoiceMessageToolContentArray respjson.Field - raw string + // [[]ChatCompletionListResponseDataChoiceMessageToolContentListOpenAIChatCompletionContentPartTextParamItem] + // instead of an object. + OfListOpenAIChatCompletionContentPartText []ChatCompletionListResponseDataChoiceMessageToolContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } -func (u ChatCompletionListResponseChoiceMessageToolContentUnion) AsString() (v string) { +func (u ChatCompletionListResponseDataChoiceMessageToolContentUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionListResponseChoiceMessageToolContentUnion) AsChatCompletionListResponseChoiceMessageToolContentArray() (v []ChatCompletionListResponseChoiceMessageToolContentArrayItem) { +func (u ChatCompletionListResponseDataChoiceMessageToolContentUnion) AsListOpenAIChatCompletionContentPartTextParam() (v []ChatCompletionListResponseDataChoiceMessageToolContentListOpenAIChatCompletionContentPartTextParamItem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ChatCompletionListResponseChoiceMessageToolContentUnion) RawJSON() string { return u.JSON.raw } +func (u ChatCompletionListResponseDataChoiceMessageToolContentUnion) RawJSON() string { + return u.JSON.raw +} -func (r *ChatCompletionListResponseChoiceMessageToolContentUnion) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataChoiceMessageToolContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionListResponseChoiceMessageToolContentArrayItem struct { - // The text content of the message +type ChatCompletionListResponseDataChoiceMessageToolContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -4092,85 +3771,81 @@ type ChatCompletionListResponseChoiceMessageToolContentArrayItem struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseChoiceMessageToolContentArrayItem) RawJSON() string { +func (r ChatCompletionListResponseDataChoiceMessageToolContentListOpenAIChatCompletionContentPartTextParamItem) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseChoiceMessageToolContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataChoiceMessageToolContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A message from the developer in an OpenAI-compatible chat completion request. -type ChatCompletionListResponseChoiceMessageDeveloper struct { - // The content of the developer message - Content ChatCompletionListResponseChoiceMessageDeveloperContentUnion `json:"content,required"` - // Must be "developer" to identify this as a developer message - Role constant.Developer `json:"role,required"` - // (Optional) The name of the developer message participant. - Name string `json:"name"` +type ChatCompletionListResponseDataChoiceMessageDeveloper struct { + Content ChatCompletionListResponseDataChoiceMessageDeveloperContentUnion `json:"content,required"` + Name string `json:"name,nullable"` + // Any of "developer". + Role string `json:"role"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field - Role respjson.Field Name respjson.Field + Role respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseChoiceMessageDeveloper) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseChoiceMessageDeveloper) UnmarshalJSON(data []byte) error { +func (r ChatCompletionListResponseDataChoiceMessageDeveloper) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionListResponseDataChoiceMessageDeveloper) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionListResponseChoiceMessageDeveloperContentUnion contains all +// ChatCompletionListResponseDataChoiceMessageDeveloperContentUnion contains all // possible properties and values from [string], -// [[]ChatCompletionListResponseChoiceMessageDeveloperContentArrayItem]. +// [[]ChatCompletionListResponseDataChoiceMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString -// OfChatCompletionListResponseChoiceMessageDeveloperContentArray] -type ChatCompletionListResponseChoiceMessageDeveloperContentUnion struct { +// will be valid: OfString OfListOpenAIChatCompletionContentPartText] +type ChatCompletionListResponseDataChoiceMessageDeveloperContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionListResponseChoiceMessageDeveloperContentArrayItem] instead of - // an object. - OfChatCompletionListResponseChoiceMessageDeveloperContentArray []ChatCompletionListResponseChoiceMessageDeveloperContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionListResponseChoiceMessageDeveloperContentArray respjson.Field - raw string + // [[]ChatCompletionListResponseDataChoiceMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem] + // instead of an object. + OfListOpenAIChatCompletionContentPartText []ChatCompletionListResponseDataChoiceMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } -func (u ChatCompletionListResponseChoiceMessageDeveloperContentUnion) AsString() (v string) { +func (u ChatCompletionListResponseDataChoiceMessageDeveloperContentUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionListResponseChoiceMessageDeveloperContentUnion) AsChatCompletionListResponseChoiceMessageDeveloperContentArray() (v []ChatCompletionListResponseChoiceMessageDeveloperContentArrayItem) { +func (u ChatCompletionListResponseDataChoiceMessageDeveloperContentUnion) AsListOpenAIChatCompletionContentPartTextParam() (v []ChatCompletionListResponseDataChoiceMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ChatCompletionListResponseChoiceMessageDeveloperContentUnion) RawJSON() string { +func (u ChatCompletionListResponseDataChoiceMessageDeveloperContentUnion) RawJSON() string { return u.JSON.raw } -func (r *ChatCompletionListResponseChoiceMessageDeveloperContentUnion) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataChoiceMessageDeveloperContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionListResponseChoiceMessageDeveloperContentArrayItem struct { - // The text content of the message +type ChatCompletionListResponseDataChoiceMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -4181,19 +3856,18 @@ type ChatCompletionListResponseChoiceMessageDeveloperContentArrayItem struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseChoiceMessageDeveloperContentArrayItem) RawJSON() string { +func (r ChatCompletionListResponseDataChoiceMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseChoiceMessageDeveloperContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataChoiceMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// (Optional) The log probabilities for the tokens in the message -type ChatCompletionListResponseChoiceLogprobs struct { - // (Optional) The log probabilities for the tokens in the message - Content []ChatCompletionListResponseChoiceLogprobsContent `json:"content"` - // (Optional) The log probabilities for the tokens in the message - Refusal []ChatCompletionListResponseChoiceLogprobsRefusal `json:"refusal"` +// The log probabilities for the tokens in the message from an OpenAI-compatible +// chat completion response. +type ChatCompletionListResponseDataChoiceLogprobs struct { + Content []ChatCompletionListResponseDataChoiceLogprobsContent `json:"content,nullable"` + Refusal []ChatCompletionListResponseDataChoiceLogprobsRefusal `json:"refusal,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field @@ -4204,18 +3878,21 @@ type ChatCompletionListResponseChoiceLogprobs struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseChoiceLogprobs) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseChoiceLogprobs) UnmarshalJSON(data []byte) error { +func (r ChatCompletionListResponseDataChoiceLogprobs) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionListResponseDataChoiceLogprobs) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // The log probability for a token from an OpenAI-compatible chat completion // response. -type ChatCompletionListResponseChoiceLogprobsContent struct { - Token string `json:"token,required"` - Logprob float64 `json:"logprob,required"` - TopLogprobs []ChatCompletionListResponseChoiceLogprobsContentTopLogprob `json:"top_logprobs,required"` - Bytes []int64 `json:"bytes"` +// +// :token: The token :bytes: (Optional) The bytes for the token :logprob: The log +// probability of the token :top_logprobs: The top log probabilities for the token +type ChatCompletionListResponseDataChoiceLogprobsContent struct { + Token string `json:"token,required"` + Logprob float64 `json:"logprob,required"` + TopLogprobs []ChatCompletionListResponseDataChoiceLogprobsContentTopLogprob `json:"top_logprobs,required"` + Bytes []int64 `json:"bytes,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Token respjson.Field @@ -4228,17 +3905,20 @@ type ChatCompletionListResponseChoiceLogprobsContent struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseChoiceLogprobsContent) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseChoiceLogprobsContent) UnmarshalJSON(data []byte) error { +func (r ChatCompletionListResponseDataChoiceLogprobsContent) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionListResponseDataChoiceLogprobsContent) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // The top log probability for a token from an OpenAI-compatible chat completion // response. -type ChatCompletionListResponseChoiceLogprobsContentTopLogprob struct { +// +// :token: The token :bytes: (Optional) The bytes for the token :logprob: The log +// probability of the token +type ChatCompletionListResponseDataChoiceLogprobsContentTopLogprob struct { Token string `json:"token,required"` Logprob float64 `json:"logprob,required"` - Bytes []int64 `json:"bytes"` + Bytes []int64 `json:"bytes,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Token respjson.Field @@ -4250,20 +3930,23 @@ type ChatCompletionListResponseChoiceLogprobsContentTopLogprob struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseChoiceLogprobsContentTopLogprob) RawJSON() string { +func (r ChatCompletionListResponseDataChoiceLogprobsContentTopLogprob) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseChoiceLogprobsContentTopLogprob) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataChoiceLogprobsContentTopLogprob) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // The log probability for a token from an OpenAI-compatible chat completion // response. -type ChatCompletionListResponseChoiceLogprobsRefusal struct { - Token string `json:"token,required"` - Logprob float64 `json:"logprob,required"` - TopLogprobs []ChatCompletionListResponseChoiceLogprobsRefusalTopLogprob `json:"top_logprobs,required"` - Bytes []int64 `json:"bytes"` +// +// :token: The token :bytes: (Optional) The bytes for the token :logprob: The log +// probability of the token :top_logprobs: The top log probabilities for the token +type ChatCompletionListResponseDataChoiceLogprobsRefusal struct { + Token string `json:"token,required"` + Logprob float64 `json:"logprob,required"` + TopLogprobs []ChatCompletionListResponseDataChoiceLogprobsRefusalTopLogprob `json:"top_logprobs,required"` + Bytes []int64 `json:"bytes,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Token respjson.Field @@ -4276,17 +3959,20 @@ type ChatCompletionListResponseChoiceLogprobsRefusal struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseChoiceLogprobsRefusal) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseChoiceLogprobsRefusal) UnmarshalJSON(data []byte) error { +func (r ChatCompletionListResponseDataChoiceLogprobsRefusal) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionListResponseDataChoiceLogprobsRefusal) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // The top log probability for a token from an OpenAI-compatible chat completion // response. -type ChatCompletionListResponseChoiceLogprobsRefusalTopLogprob struct { +// +// :token: The token :bytes: (Optional) The bytes for the token :logprob: The log +// probability of the token +type ChatCompletionListResponseDataChoiceLogprobsRefusalTopLogprob struct { Token string `json:"token,required"` Logprob float64 `json:"logprob,required"` - Bytes []int64 `json:"bytes"` + Bytes []int64 `json:"bytes,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Token respjson.Field @@ -4298,77 +3984,80 @@ type ChatCompletionListResponseChoiceLogprobsRefusalTopLogprob struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseChoiceLogprobsRefusalTopLogprob) RawJSON() string { +func (r ChatCompletionListResponseDataChoiceLogprobsRefusalTopLogprob) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseChoiceLogprobsRefusalTopLogprob) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataChoiceLogprobsRefusalTopLogprob) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionListResponseInputMessageUnion contains all possible properties and -// values from [ChatCompletionListResponseInputMessageUser], -// [ChatCompletionListResponseInputMessageSystem], -// [ChatCompletionListResponseInputMessageAssistant], -// [ChatCompletionListResponseInputMessageTool], -// [ChatCompletionListResponseInputMessageDeveloper]. +// ChatCompletionListResponseDataInputMessageUnion contains all possible properties +// and values from [ChatCompletionListResponseDataInputMessageUser], +// [ChatCompletionListResponseDataInputMessageSystem], +// [ChatCompletionListResponseDataInputMessageAssistant], +// [ChatCompletionListResponseDataInputMessageTool], +// [ChatCompletionListResponseDataInputMessageDeveloper]. // -// Use the [ChatCompletionListResponseInputMessageUnion.AsAny] method to switch on -// the variant. +// Use the [ChatCompletionListResponseDataInputMessageUnion.AsAny] method to switch +// on the variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type ChatCompletionListResponseInputMessageUnion struct { +type ChatCompletionListResponseDataInputMessageUnion struct { // This field is a union of - // [ChatCompletionListResponseInputMessageUserContentUnion], - // [ChatCompletionListResponseInputMessageSystemContentUnion], - // [ChatCompletionListResponseInputMessageAssistantContentUnion], - // [ChatCompletionListResponseInputMessageToolContentUnion], - // [ChatCompletionListResponseInputMessageDeveloperContentUnion] - Content ChatCompletionListResponseInputMessageUnionContent `json:"content"` + // [ChatCompletionListResponseDataInputMessageUserContentUnion], + // [ChatCompletionListResponseDataInputMessageSystemContentUnion], + // [ChatCompletionListResponseDataInputMessageAssistantContentUnion], + // [ChatCompletionListResponseDataInputMessageToolContentUnion], + // [ChatCompletionListResponseDataInputMessageDeveloperContentUnion] + Content ChatCompletionListResponseDataInputMessageUnionContent `json:"content"` + Name string `json:"name"` // Any of "user", "system", "assistant", "tool", "developer". Role string `json:"role"` - Name string `json:"name"` - // This field is from variant [ChatCompletionListResponseInputMessageAssistant]. - ToolCalls []ChatCompletionListResponseInputMessageAssistantToolCall `json:"tool_calls"` - // This field is from variant [ChatCompletionListResponseInputMessageTool]. + // This field is from variant + // [ChatCompletionListResponseDataInputMessageAssistant]. + ToolCalls []ChatCompletionListResponseDataInputMessageAssistantToolCall `json:"tool_calls"` + // This field is from variant [ChatCompletionListResponseDataInputMessageTool]. ToolCallID string `json:"tool_call_id"` JSON struct { Content respjson.Field - Role respjson.Field Name respjson.Field + Role respjson.Field ToolCalls respjson.Field ToolCallID respjson.Field raw string } `json:"-"` } -// anyChatCompletionListResponseInputMessage is implemented by each variant of -// [ChatCompletionListResponseInputMessageUnion] to add type safety for the return -// type of [ChatCompletionListResponseInputMessageUnion.AsAny] -type anyChatCompletionListResponseInputMessage interface { - implChatCompletionListResponseInputMessageUnion() +// anyChatCompletionListResponseDataInputMessage is implemented by each variant of +// [ChatCompletionListResponseDataInputMessageUnion] to add type safety for the +// return type of [ChatCompletionListResponseDataInputMessageUnion.AsAny] +type anyChatCompletionListResponseDataInputMessage interface { + implChatCompletionListResponseDataInputMessageUnion() } -func (ChatCompletionListResponseInputMessageUser) implChatCompletionListResponseInputMessageUnion() {} -func (ChatCompletionListResponseInputMessageSystem) implChatCompletionListResponseInputMessageUnion() { +func (ChatCompletionListResponseDataInputMessageUser) implChatCompletionListResponseDataInputMessageUnion() { +} +func (ChatCompletionListResponseDataInputMessageSystem) implChatCompletionListResponseDataInputMessageUnion() { } -func (ChatCompletionListResponseInputMessageAssistant) implChatCompletionListResponseInputMessageUnion() { +func (ChatCompletionListResponseDataInputMessageAssistant) implChatCompletionListResponseDataInputMessageUnion() { } -func (ChatCompletionListResponseInputMessageTool) implChatCompletionListResponseInputMessageUnion() {} -func (ChatCompletionListResponseInputMessageDeveloper) implChatCompletionListResponseInputMessageUnion() { +func (ChatCompletionListResponseDataInputMessageTool) implChatCompletionListResponseDataInputMessageUnion() { +} +func (ChatCompletionListResponseDataInputMessageDeveloper) implChatCompletionListResponseDataInputMessageUnion() { } // Use the following switch statement to find the correct variant // -// switch variant := ChatCompletionListResponseInputMessageUnion.AsAny().(type) { -// case llamastackclient.ChatCompletionListResponseInputMessageUser: -// case llamastackclient.ChatCompletionListResponseInputMessageSystem: -// case llamastackclient.ChatCompletionListResponseInputMessageAssistant: -// case llamastackclient.ChatCompletionListResponseInputMessageTool: -// case llamastackclient.ChatCompletionListResponseInputMessageDeveloper: +// switch variant := ChatCompletionListResponseDataInputMessageUnion.AsAny().(type) { +// case llamastackclient.ChatCompletionListResponseDataInputMessageUser: +// case llamastackclient.ChatCompletionListResponseDataInputMessageSystem: +// case llamastackclient.ChatCompletionListResponseDataInputMessageAssistant: +// case llamastackclient.ChatCompletionListResponseDataInputMessageTool: +// case llamastackclient.ChatCompletionListResponseDataInputMessageDeveloper: // default: // fmt.Errorf("no variant present") // } -func (u ChatCompletionListResponseInputMessageUnion) AsAny() anyChatCompletionListResponseInputMessage { +func (u ChatCompletionListResponseDataInputMessageUnion) AsAny() anyChatCompletionListResponseDataInputMessage { switch u.Role { case "user": return u.AsUser() @@ -4384,176 +4073,160 @@ func (u ChatCompletionListResponseInputMessageUnion) AsAny() anyChatCompletionLi return nil } -func (u ChatCompletionListResponseInputMessageUnion) AsUser() (v ChatCompletionListResponseInputMessageUser) { +func (u ChatCompletionListResponseDataInputMessageUnion) AsUser() (v ChatCompletionListResponseDataInputMessageUser) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionListResponseInputMessageUnion) AsSystem() (v ChatCompletionListResponseInputMessageSystem) { +func (u ChatCompletionListResponseDataInputMessageUnion) AsSystem() (v ChatCompletionListResponseDataInputMessageSystem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionListResponseInputMessageUnion) AsAssistant() (v ChatCompletionListResponseInputMessageAssistant) { +func (u ChatCompletionListResponseDataInputMessageUnion) AsAssistant() (v ChatCompletionListResponseDataInputMessageAssistant) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionListResponseInputMessageUnion) AsTool() (v ChatCompletionListResponseInputMessageTool) { +func (u ChatCompletionListResponseDataInputMessageUnion) AsTool() (v ChatCompletionListResponseDataInputMessageTool) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionListResponseInputMessageUnion) AsDeveloper() (v ChatCompletionListResponseInputMessageDeveloper) { +func (u ChatCompletionListResponseDataInputMessageUnion) AsDeveloper() (v ChatCompletionListResponseDataInputMessageDeveloper) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ChatCompletionListResponseInputMessageUnion) RawJSON() string { return u.JSON.raw } +func (u ChatCompletionListResponseDataInputMessageUnion) RawJSON() string { return u.JSON.raw } -func (r *ChatCompletionListResponseInputMessageUnion) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataInputMessageUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionListResponseInputMessageUnionContent is an implicit subunion of -// [ChatCompletionListResponseInputMessageUnion]. -// ChatCompletionListResponseInputMessageUnionContent provides convenient access to -// the sub-properties of the union. +// ChatCompletionListResponseDataInputMessageUnionContent is an implicit subunion +// of [ChatCompletionListResponseDataInputMessageUnion]. +// ChatCompletionListResponseDataInputMessageUnionContent provides convenient +// access to the sub-properties of the union. // // For type safety it is recommended to directly use a variant of the -// [ChatCompletionListResponseInputMessageUnion]. +// [ChatCompletionListResponseDataInputMessageUnion]. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString OfChatCompletionListResponseInputMessageUserContentArray -// OfChatCompletionListResponseInputMessageSystemContentArray -// OfChatCompletionListResponseInputMessageAssistantContentArray -// OfChatCompletionListResponseInputMessageToolContentArray -// OfChatCompletionListResponseInputMessageDeveloperContentArray] -type ChatCompletionListResponseInputMessageUnionContent struct { +// will be valid: OfString +// OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile +// OfListOpenAIChatCompletionContentPartText] +type ChatCompletionListResponseDataInputMessageUnionContent struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionListResponseInputMessageUserContentArrayItemUnion] instead of - // an object. - OfChatCompletionListResponseInputMessageUserContentArray []ChatCompletionListResponseInputMessageUserContentArrayItemUnion `json:",inline"` - // This field will be present if the value is a - // [[]ChatCompletionListResponseInputMessageSystemContentArrayItem] instead of an - // object. - OfChatCompletionListResponseInputMessageSystemContentArray []ChatCompletionListResponseInputMessageSystemContentArrayItem `json:",inline"` - // This field will be present if the value is a - // [[]ChatCompletionListResponseInputMessageAssistantContentArrayItem] instead of - // an object. - OfChatCompletionListResponseInputMessageAssistantContentArray []ChatCompletionListResponseInputMessageAssistantContentArrayItem `json:",inline"` - // This field will be present if the value is a - // [[]ChatCompletionListResponseInputMessageToolContentArrayItem] instead of an - // object. - OfChatCompletionListResponseInputMessageToolContentArray []ChatCompletionListResponseInputMessageToolContentArrayItem `json:",inline"` + // [[]ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion] + // instead of an object. + OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile []ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionListResponseInputMessageDeveloperContentArrayItem] instead of - // an object. - OfChatCompletionListResponseInputMessageDeveloperContentArray []ChatCompletionListResponseInputMessageDeveloperContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionListResponseInputMessageUserContentArray respjson.Field - OfChatCompletionListResponseInputMessageSystemContentArray respjson.Field - OfChatCompletionListResponseInputMessageAssistantContentArray respjson.Field - OfChatCompletionListResponseInputMessageToolContentArray respjson.Field - OfChatCompletionListResponseInputMessageDeveloperContentArray respjson.Field - raw string + // [[]ChatCompletionListResponseDataInputMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem] + // instead of an object. + OfListOpenAIChatCompletionContentPartText []ChatCompletionListResponseDataInputMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } -func (r *ChatCompletionListResponseInputMessageUnionContent) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataInputMessageUnionContent) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A message from the user in an OpenAI-compatible chat completion request. -type ChatCompletionListResponseInputMessageUser struct { - // The content of the message, which can include text and other media - Content ChatCompletionListResponseInputMessageUserContentUnion `json:"content,required"` - // Must be "user" to identify this as a user message - Role constant.User `json:"role,required"` - // (Optional) The name of the user message participant. - Name string `json:"name"` +type ChatCompletionListResponseDataInputMessageUser struct { + Content ChatCompletionListResponseDataInputMessageUserContentUnion `json:"content,required"` + Name string `json:"name,nullable"` + // Any of "user". + Role string `json:"role"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field - Role respjson.Field Name respjson.Field + Role respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseInputMessageUser) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseInputMessageUser) UnmarshalJSON(data []byte) error { +func (r ChatCompletionListResponseDataInputMessageUser) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionListResponseDataInputMessageUser) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionListResponseInputMessageUserContentUnion contains all possible +// ChatCompletionListResponseDataInputMessageUserContentUnion contains all possible // properties and values from [string], -// [[]ChatCompletionListResponseInputMessageUserContentArrayItemUnion]. +// [[]ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties // will be valid: OfString -// OfChatCompletionListResponseInputMessageUserContentArray] -type ChatCompletionListResponseInputMessageUserContentUnion struct { +// OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile] +type ChatCompletionListResponseDataInputMessageUserContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionListResponseInputMessageUserContentArrayItemUnion] instead of - // an object. - OfChatCompletionListResponseInputMessageUserContentArray []ChatCompletionListResponseInputMessageUserContentArrayItemUnion `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionListResponseInputMessageUserContentArray respjson.Field - raw string + // [[]ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion] + // instead of an object. + OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile []ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile respjson.Field + raw string } `json:"-"` } -func (u ChatCompletionListResponseInputMessageUserContentUnion) AsString() (v string) { +func (u ChatCompletionListResponseDataInputMessageUserContentUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionListResponseInputMessageUserContentUnion) AsChatCompletionListResponseInputMessageUserContentArray() (v []ChatCompletionListResponseInputMessageUserContentArrayItemUnion) { +func (u ChatCompletionListResponseDataInputMessageUserContentUnion) AsListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFile() (v []ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ChatCompletionListResponseInputMessageUserContentUnion) RawJSON() string { return u.JSON.raw } +func (u ChatCompletionListResponseDataInputMessageUserContentUnion) RawJSON() string { + return u.JSON.raw +} -func (r *ChatCompletionListResponseInputMessageUserContentUnion) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataInputMessageUserContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionListResponseInputMessageUserContentArrayItemUnion contains all -// possible properties and values from -// [ChatCompletionListResponseInputMessageUserContentArrayItemText], -// [ChatCompletionListResponseInputMessageUserContentArrayItemImageURL], -// [ChatCompletionListResponseInputMessageUserContentArrayItemFile]. +// ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion +// contains all possible properties and values from +// [ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText], +// [ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL], +// [ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile]. // -// Use the [ChatCompletionListResponseInputMessageUserContentArrayItemUnion.AsAny] +// Use the +// [ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion.AsAny] // method to switch on the variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type ChatCompletionListResponseInputMessageUserContentArrayItemUnion struct { +type ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion struct { // This field is from variant - // [ChatCompletionListResponseInputMessageUserContentArrayItemText]. + // [ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText]. Text string `json:"text"` // Any of "text", "image_url", "file". Type string `json:"type"` // This field is from variant - // [ChatCompletionListResponseInputMessageUserContentArrayItemImageURL]. - ImageURL ChatCompletionListResponseInputMessageUserContentArrayItemImageURLImageURL `json:"image_url"` + // [ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL]. + ImageURL ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL `json:"image_url"` // This field is from variant - // [ChatCompletionListResponseInputMessageUserContentArrayItemFile]. - File ChatCompletionListResponseInputMessageUserContentArrayItemFileFile `json:"file"` + // [ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile]. + File ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile `json:"file"` JSON struct { Text respjson.Field Type respjson.Field @@ -4563,32 +4236,32 @@ type ChatCompletionListResponseInputMessageUserContentArrayItemUnion struct { } `json:"-"` } -// anyChatCompletionListResponseInputMessageUserContentArrayItem is implemented by -// each variant of -// [ChatCompletionListResponseInputMessageUserContentArrayItemUnion] to add type -// safety for the return type of -// [ChatCompletionListResponseInputMessageUserContentArrayItemUnion.AsAny] -type anyChatCompletionListResponseInputMessageUserContentArrayItem interface { - implChatCompletionListResponseInputMessageUserContentArrayItemUnion() +// anyChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItem +// is implemented by each variant of +// [ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion] +// to add type safety for the return type of +// [ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion.AsAny] +type anyChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItem interface { + implChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion() } -func (ChatCompletionListResponseInputMessageUserContentArrayItemText) implChatCompletionListResponseInputMessageUserContentArrayItemUnion() { +func (ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) implChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion() { } -func (ChatCompletionListResponseInputMessageUserContentArrayItemImageURL) implChatCompletionListResponseInputMessageUserContentArrayItemUnion() { +func (ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) implChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion() { } -func (ChatCompletionListResponseInputMessageUserContentArrayItemFile) implChatCompletionListResponseInputMessageUserContentArrayItemUnion() { +func (ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) implChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion() { } // Use the following switch statement to find the correct variant // -// switch variant := ChatCompletionListResponseInputMessageUserContentArrayItemUnion.AsAny().(type) { -// case llamastackclient.ChatCompletionListResponseInputMessageUserContentArrayItemText: -// case llamastackclient.ChatCompletionListResponseInputMessageUserContentArrayItemImageURL: -// case llamastackclient.ChatCompletionListResponseInputMessageUserContentArrayItemFile: +// switch variant := ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion.AsAny().(type) { +// case llamastackclient.ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText: +// case llamastackclient.ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL: +// case llamastackclient.ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile: // default: // fmt.Errorf("no variant present") // } -func (u ChatCompletionListResponseInputMessageUserContentArrayItemUnion) AsAny() anyChatCompletionListResponseInputMessageUserContentArrayItem { +func (u ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) AsAny() anyChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItem { switch u.Type { case "text": return u.AsText() @@ -4600,36 +4273,35 @@ func (u ChatCompletionListResponseInputMessageUserContentArrayItemUnion) AsAny() return nil } -func (u ChatCompletionListResponseInputMessageUserContentArrayItemUnion) AsText() (v ChatCompletionListResponseInputMessageUserContentArrayItemText) { +func (u ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) AsText() (v ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionListResponseInputMessageUserContentArrayItemUnion) AsImageURL() (v ChatCompletionListResponseInputMessageUserContentArrayItemImageURL) { +func (u ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) AsImageURL() (v ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionListResponseInputMessageUserContentArrayItemUnion) AsFile() (v ChatCompletionListResponseInputMessageUserContentArrayItemFile) { +func (u ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) AsFile() (v ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ChatCompletionListResponseInputMessageUserContentArrayItemUnion) RawJSON() string { +func (u ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) RawJSON() string { return u.JSON.raw } -func (r *ChatCompletionListResponseInputMessageUserContentArrayItemUnion) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionListResponseInputMessageUserContentArrayItemText struct { - // The text content of the message +type ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -4640,19 +4312,19 @@ type ChatCompletionListResponseInputMessageUserContentArrayItemText struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseInputMessageUserContentArrayItemText) RawJSON() string { +func (r ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseInputMessageUserContentArrayItemText) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Image content part for OpenAI-compatible chat completion messages. -type ChatCompletionListResponseInputMessageUserContentArrayItemImageURL struct { - // Image URL specification and processing details - ImageURL ChatCompletionListResponseInputMessageUserContentArrayItemImageURLImageURL `json:"image_url,required"` - // Must be "image_url" to identify this as image content - Type constant.ImageURL `json:"type,required"` +type ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL struct { + // Image URL specification for OpenAI-compatible chat completion messages. + ImageURL ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL `json:"image_url,required"` + // Any of "image_url". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ImageURL respjson.Field @@ -4663,19 +4335,17 @@ type ChatCompletionListResponseInputMessageUserContentArrayItemImageURL struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseInputMessageUserContentArrayItemImageURL) RawJSON() string { +func (r ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseInputMessageUserContentArrayItemImageURL) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Image URL specification and processing details -type ChatCompletionListResponseInputMessageUserContentArrayItemImageURLImageURL struct { - // URL of the image to include in the message - URL string `json:"url,required"` - // (Optional) Level of detail for image processing. Can be "low", "high", or "auto" - Detail string `json:"detail"` +// Image URL specification for OpenAI-compatible chat completion messages. +type ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL struct { + URL string `json:"url,required"` + Detail string `json:"detail,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { URL respjson.Field @@ -4686,16 +4356,17 @@ type ChatCompletionListResponseInputMessageUserContentArrayItemImageURLImageURL } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseInputMessageUserContentArrayItemImageURLImageURL) RawJSON() string { +func (r ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseInputMessageUserContentArrayItemImageURLImageURL) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ChatCompletionListResponseInputMessageUserContentArrayItemFile struct { - File ChatCompletionListResponseInputMessageUserContentArrayItemFileFile `json:"file,required"` - Type constant.File `json:"type,required"` +type ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile struct { + File ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile `json:"file,required"` + // Any of "file". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { File respjson.Field @@ -4706,17 +4377,17 @@ type ChatCompletionListResponseInputMessageUserContentArrayItemFile struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseInputMessageUserContentArrayItemFile) RawJSON() string { +func (r ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseInputMessageUserContentArrayItemFile) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ChatCompletionListResponseInputMessageUserContentArrayItemFileFile struct { - FileData string `json:"file_data"` - FileID string `json:"file_id"` - Filename string `json:"filename"` +type ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile struct { + FileData string `json:"file_data,nullable"` + FileID string `json:"file_id,nullable"` + Filename string `json:"filename,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { FileData respjson.Field @@ -4728,85 +4399,81 @@ type ChatCompletionListResponseInputMessageUserContentArrayItemFileFile struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseInputMessageUserContentArrayItemFileFile) RawJSON() string { +func (r ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseInputMessageUserContentArrayItemFileFile) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataInputMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A system message providing instructions or context to the model. -type ChatCompletionListResponseInputMessageSystem struct { - // The content of the "system prompt". If multiple system messages are provided, - // they are concatenated. The underlying Llama Stack code may also add other system - // messages (for example, for formatting tool definitions). - Content ChatCompletionListResponseInputMessageSystemContentUnion `json:"content,required"` - // Must be "system" to identify this as a system message - Role constant.System `json:"role,required"` - // (Optional) The name of the system message participant. - Name string `json:"name"` +type ChatCompletionListResponseDataInputMessageSystem struct { + Content ChatCompletionListResponseDataInputMessageSystemContentUnion `json:"content,required"` + Name string `json:"name,nullable"` + // Any of "system". + Role string `json:"role"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field - Role respjson.Field Name respjson.Field + Role respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseInputMessageSystem) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseInputMessageSystem) UnmarshalJSON(data []byte) error { +func (r ChatCompletionListResponseDataInputMessageSystem) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionListResponseDataInputMessageSystem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionListResponseInputMessageSystemContentUnion contains all possible -// properties and values from [string], -// [[]ChatCompletionListResponseInputMessageSystemContentArrayItem]. +// ChatCompletionListResponseDataInputMessageSystemContentUnion contains all +// possible properties and values from [string], +// [[]ChatCompletionListResponseDataInputMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString -// OfChatCompletionListResponseInputMessageSystemContentArray] -type ChatCompletionListResponseInputMessageSystemContentUnion struct { +// will be valid: OfString OfListOpenAIChatCompletionContentPartText] +type ChatCompletionListResponseDataInputMessageSystemContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionListResponseInputMessageSystemContentArrayItem] instead of an - // object. - OfChatCompletionListResponseInputMessageSystemContentArray []ChatCompletionListResponseInputMessageSystemContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionListResponseInputMessageSystemContentArray respjson.Field - raw string + // [[]ChatCompletionListResponseDataInputMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem] + // instead of an object. + OfListOpenAIChatCompletionContentPartText []ChatCompletionListResponseDataInputMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } -func (u ChatCompletionListResponseInputMessageSystemContentUnion) AsString() (v string) { +func (u ChatCompletionListResponseDataInputMessageSystemContentUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionListResponseInputMessageSystemContentUnion) AsChatCompletionListResponseInputMessageSystemContentArray() (v []ChatCompletionListResponseInputMessageSystemContentArrayItem) { +func (u ChatCompletionListResponseDataInputMessageSystemContentUnion) AsListOpenAIChatCompletionContentPartTextParam() (v []ChatCompletionListResponseDataInputMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ChatCompletionListResponseInputMessageSystemContentUnion) RawJSON() string { return u.JSON.raw } +func (u ChatCompletionListResponseDataInputMessageSystemContentUnion) RawJSON() string { + return u.JSON.raw +} -func (r *ChatCompletionListResponseInputMessageSystemContentUnion) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataInputMessageSystemContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionListResponseInputMessageSystemContentArrayItem struct { - // The text content of the message +type ChatCompletionListResponseDataInputMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -4817,29 +4484,26 @@ type ChatCompletionListResponseInputMessageSystemContentArrayItem struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseInputMessageSystemContentArrayItem) RawJSON() string { +func (r ChatCompletionListResponseDataInputMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseInputMessageSystemContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataInputMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A message containing the model's (assistant) response in an OpenAI-compatible // chat completion request. -type ChatCompletionListResponseInputMessageAssistant struct { - // Must be "assistant" to identify this as the model's response - Role constant.Assistant `json:"role,required"` - // The content of the model's response - Content ChatCompletionListResponseInputMessageAssistantContentUnion `json:"content"` - // (Optional) The name of the assistant message participant. - Name string `json:"name"` - // List of tool calls. Each tool call is an OpenAIChatCompletionToolCall object. - ToolCalls []ChatCompletionListResponseInputMessageAssistantToolCall `json:"tool_calls"` +type ChatCompletionListResponseDataInputMessageAssistant struct { + Content ChatCompletionListResponseDataInputMessageAssistantContentUnion `json:"content,nullable"` + Name string `json:"name,nullable"` + // Any of "assistant". + Role string `json:"role"` + ToolCalls []ChatCompletionListResponseDataInputMessageAssistantToolCall `json:"tool_calls,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Role respjson.Field Content respjson.Field Name respjson.Field + Role respjson.Field ToolCalls respjson.Field ExtraFields map[string]respjson.Field raw string @@ -4847,59 +4511,57 @@ type ChatCompletionListResponseInputMessageAssistant struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseInputMessageAssistant) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseInputMessageAssistant) UnmarshalJSON(data []byte) error { +func (r ChatCompletionListResponseDataInputMessageAssistant) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionListResponseDataInputMessageAssistant) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionListResponseInputMessageAssistantContentUnion contains all +// ChatCompletionListResponseDataInputMessageAssistantContentUnion contains all // possible properties and values from [string], -// [[]ChatCompletionListResponseInputMessageAssistantContentArrayItem]. +// [[]ChatCompletionListResponseDataInputMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString -// OfChatCompletionListResponseInputMessageAssistantContentArray] -type ChatCompletionListResponseInputMessageAssistantContentUnion struct { +// will be valid: OfString OfListOpenAIChatCompletionContentPartText] +type ChatCompletionListResponseDataInputMessageAssistantContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionListResponseInputMessageAssistantContentArrayItem] instead of - // an object. - OfChatCompletionListResponseInputMessageAssistantContentArray []ChatCompletionListResponseInputMessageAssistantContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionListResponseInputMessageAssistantContentArray respjson.Field - raw string + // [[]ChatCompletionListResponseDataInputMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem] + // instead of an object. + OfListOpenAIChatCompletionContentPartText []ChatCompletionListResponseDataInputMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } -func (u ChatCompletionListResponseInputMessageAssistantContentUnion) AsString() (v string) { +func (u ChatCompletionListResponseDataInputMessageAssistantContentUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionListResponseInputMessageAssistantContentUnion) AsChatCompletionListResponseInputMessageAssistantContentArray() (v []ChatCompletionListResponseInputMessageAssistantContentArrayItem) { +func (u ChatCompletionListResponseDataInputMessageAssistantContentUnion) AsListOpenAIChatCompletionContentPartTextParam() (v []ChatCompletionListResponseDataInputMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ChatCompletionListResponseInputMessageAssistantContentUnion) RawJSON() string { +func (u ChatCompletionListResponseDataInputMessageAssistantContentUnion) RawJSON() string { return u.JSON.raw } -func (r *ChatCompletionListResponseInputMessageAssistantContentUnion) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataInputMessageAssistantContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionListResponseInputMessageAssistantContentArrayItem struct { - // The text content of the message +type ChatCompletionListResponseDataInputMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -4910,46 +4572,44 @@ type ChatCompletionListResponseInputMessageAssistantContentArrayItem struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseInputMessageAssistantContentArrayItem) RawJSON() string { +func (r ChatCompletionListResponseDataInputMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseInputMessageAssistantContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataInputMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Tool call specification for OpenAI-compatible chat completion responses. -type ChatCompletionListResponseInputMessageAssistantToolCall struct { - // Must be "function" to identify this as a function call - Type constant.Function `json:"type,required"` - // (Optional) Unique identifier for the tool call - ID string `json:"id"` - // (Optional) Function call details - Function ChatCompletionListResponseInputMessageAssistantToolCallFunction `json:"function"` - // (Optional) Index of the tool call in the list - Index int64 `json:"index"` +type ChatCompletionListResponseDataInputMessageAssistantToolCall struct { + ID string `json:"id,nullable"` + // Function call details for OpenAI-compatible tool calls. + Function ChatCompletionListResponseDataInputMessageAssistantToolCallFunction `json:"function,nullable"` + Index int64 `json:"index,nullable"` + // Any of "function". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field ID respjson.Field Function respjson.Field Index respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseInputMessageAssistantToolCall) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseInputMessageAssistantToolCall) UnmarshalJSON(data []byte) error { +func (r ChatCompletionListResponseDataInputMessageAssistantToolCall) RawJSON() string { + return r.JSON.raw +} +func (r *ChatCompletionListResponseDataInputMessageAssistantToolCall) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// (Optional) Function call details -type ChatCompletionListResponseInputMessageAssistantToolCallFunction struct { - // (Optional) Arguments to pass to the function as a JSON string - Arguments string `json:"arguments"` - // (Optional) Name of the function to call - Name string `json:"name"` +// Function call details for OpenAI-compatible tool calls. +type ChatCompletionListResponseDataInputMessageAssistantToolCallFunction struct { + Arguments string `json:"arguments,nullable"` + Name string `json:"name,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Arguments respjson.Field @@ -4960,84 +4620,82 @@ type ChatCompletionListResponseInputMessageAssistantToolCallFunction struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseInputMessageAssistantToolCallFunction) RawJSON() string { +func (r ChatCompletionListResponseDataInputMessageAssistantToolCallFunction) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseInputMessageAssistantToolCallFunction) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataInputMessageAssistantToolCallFunction) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A message representing the result of a tool invocation in an OpenAI-compatible // chat completion request. -type ChatCompletionListResponseInputMessageTool struct { - // The response content from the tool - Content ChatCompletionListResponseInputMessageToolContentUnion `json:"content,required"` - // Must be "tool" to identify this as a tool response - Role constant.Tool `json:"role,required"` - // Unique identifier for the tool call this response is for - ToolCallID string `json:"tool_call_id,required"` +type ChatCompletionListResponseDataInputMessageTool struct { + Content ChatCompletionListResponseDataInputMessageToolContentUnion `json:"content,required"` + ToolCallID string `json:"tool_call_id,required"` + // Any of "tool". + Role string `json:"role"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field - Role respjson.Field ToolCallID respjson.Field + Role respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseInputMessageTool) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseInputMessageTool) UnmarshalJSON(data []byte) error { +func (r ChatCompletionListResponseDataInputMessageTool) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionListResponseDataInputMessageTool) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionListResponseInputMessageToolContentUnion contains all possible +// ChatCompletionListResponseDataInputMessageToolContentUnion contains all possible // properties and values from [string], -// [[]ChatCompletionListResponseInputMessageToolContentArrayItem]. +// [[]ChatCompletionListResponseDataInputMessageToolContentListOpenAIChatCompletionContentPartTextParamItem]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString -// OfChatCompletionListResponseInputMessageToolContentArray] -type ChatCompletionListResponseInputMessageToolContentUnion struct { +// will be valid: OfString OfListOpenAIChatCompletionContentPartText] +type ChatCompletionListResponseDataInputMessageToolContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionListResponseInputMessageToolContentArrayItem] instead of an - // object. - OfChatCompletionListResponseInputMessageToolContentArray []ChatCompletionListResponseInputMessageToolContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionListResponseInputMessageToolContentArray respjson.Field - raw string + // [[]ChatCompletionListResponseDataInputMessageToolContentListOpenAIChatCompletionContentPartTextParamItem] + // instead of an object. + OfListOpenAIChatCompletionContentPartText []ChatCompletionListResponseDataInputMessageToolContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } -func (u ChatCompletionListResponseInputMessageToolContentUnion) AsString() (v string) { +func (u ChatCompletionListResponseDataInputMessageToolContentUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionListResponseInputMessageToolContentUnion) AsChatCompletionListResponseInputMessageToolContentArray() (v []ChatCompletionListResponseInputMessageToolContentArrayItem) { +func (u ChatCompletionListResponseDataInputMessageToolContentUnion) AsListOpenAIChatCompletionContentPartTextParam() (v []ChatCompletionListResponseDataInputMessageToolContentListOpenAIChatCompletionContentPartTextParamItem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ChatCompletionListResponseInputMessageToolContentUnion) RawJSON() string { return u.JSON.raw } +func (u ChatCompletionListResponseDataInputMessageToolContentUnion) RawJSON() string { + return u.JSON.raw +} -func (r *ChatCompletionListResponseInputMessageToolContentUnion) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataInputMessageToolContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionListResponseInputMessageToolContentArrayItem struct { - // The text content of the message +type ChatCompletionListResponseDataInputMessageToolContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -5048,85 +4706,81 @@ type ChatCompletionListResponseInputMessageToolContentArrayItem struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseInputMessageToolContentArrayItem) RawJSON() string { +func (r ChatCompletionListResponseDataInputMessageToolContentListOpenAIChatCompletionContentPartTextParamItem) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseInputMessageToolContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataInputMessageToolContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A message from the developer in an OpenAI-compatible chat completion request. -type ChatCompletionListResponseInputMessageDeveloper struct { - // The content of the developer message - Content ChatCompletionListResponseInputMessageDeveloperContentUnion `json:"content,required"` - // Must be "developer" to identify this as a developer message - Role constant.Developer `json:"role,required"` - // (Optional) The name of the developer message participant. - Name string `json:"name"` +type ChatCompletionListResponseDataInputMessageDeveloper struct { + Content ChatCompletionListResponseDataInputMessageDeveloperContentUnion `json:"content,required"` + Name string `json:"name,nullable"` + // Any of "developer". + Role string `json:"role"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field - Role respjson.Field Name respjson.Field + Role respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseInputMessageDeveloper) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseInputMessageDeveloper) UnmarshalJSON(data []byte) error { +func (r ChatCompletionListResponseDataInputMessageDeveloper) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionListResponseDataInputMessageDeveloper) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ChatCompletionListResponseInputMessageDeveloperContentUnion contains all +// ChatCompletionListResponseDataInputMessageDeveloperContentUnion contains all // possible properties and values from [string], -// [[]ChatCompletionListResponseInputMessageDeveloperContentArrayItem]. +// [[]ChatCompletionListResponseDataInputMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString -// OfChatCompletionListResponseInputMessageDeveloperContentArray] -type ChatCompletionListResponseInputMessageDeveloperContentUnion struct { +// will be valid: OfString OfListOpenAIChatCompletionContentPartText] +type ChatCompletionListResponseDataInputMessageDeveloperContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ChatCompletionListResponseInputMessageDeveloperContentArrayItem] instead of - // an object. - OfChatCompletionListResponseInputMessageDeveloperContentArray []ChatCompletionListResponseInputMessageDeveloperContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfChatCompletionListResponseInputMessageDeveloperContentArray respjson.Field - raw string + // [[]ChatCompletionListResponseDataInputMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem] + // instead of an object. + OfListOpenAIChatCompletionContentPartText []ChatCompletionListResponseDataInputMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIChatCompletionContentPartText respjson.Field + raw string } `json:"-"` } -func (u ChatCompletionListResponseInputMessageDeveloperContentUnion) AsString() (v string) { +func (u ChatCompletionListResponseDataInputMessageDeveloperContentUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ChatCompletionListResponseInputMessageDeveloperContentUnion) AsChatCompletionListResponseInputMessageDeveloperContentArray() (v []ChatCompletionListResponseInputMessageDeveloperContentArrayItem) { +func (u ChatCompletionListResponseDataInputMessageDeveloperContentUnion) AsListOpenAIChatCompletionContentPartTextParam() (v []ChatCompletionListResponseDataInputMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ChatCompletionListResponseInputMessageDeveloperContentUnion) RawJSON() string { +func (u ChatCompletionListResponseDataInputMessageDeveloperContentUnion) RawJSON() string { return u.JSON.raw } -func (r *ChatCompletionListResponseInputMessageDeveloperContentUnion) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataInputMessageDeveloperContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content part for OpenAI-compatible chat completion messages. -type ChatCompletionListResponseInputMessageDeveloperContentArrayItem struct { - // The text content of the message +type ChatCompletionListResponseDataInputMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -5137,25 +4791,22 @@ type ChatCompletionListResponseInputMessageDeveloperContentArrayItem struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseInputMessageDeveloperContentArrayItem) RawJSON() string { +func (r ChatCompletionListResponseDataInputMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseInputMessageDeveloperContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionListResponseDataInputMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Token usage information for the completion -type ChatCompletionListResponseUsage struct { - // Number of tokens in the completion +// Usage information for OpenAI chat completion. +type ChatCompletionListResponseDataUsage struct { CompletionTokens int64 `json:"completion_tokens,required"` - // Number of tokens in the prompt - PromptTokens int64 `json:"prompt_tokens,required"` - // Total tokens used (prompt + completion) - TotalTokens int64 `json:"total_tokens,required"` + PromptTokens int64 `json:"prompt_tokens,required"` + TotalTokens int64 `json:"total_tokens,required"` // Token details for output tokens in OpenAI chat completion usage. - CompletionTokensDetails ChatCompletionListResponseUsageCompletionTokensDetails `json:"completion_tokens_details"` + CompletionTokensDetails ChatCompletionListResponseDataUsageCompletionTokensDetails `json:"completion_tokens_details,nullable"` // Token details for prompt tokens in OpenAI chat completion usage. - PromptTokensDetails ChatCompletionListResponseUsagePromptTokensDetails `json:"prompt_tokens_details"` + PromptTokensDetails ChatCompletionListResponseDataUsagePromptTokensDetails `json:"prompt_tokens_details,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { CompletionTokens respjson.Field @@ -5169,15 +4820,14 @@ type ChatCompletionListResponseUsage struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseUsage) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseUsage) UnmarshalJSON(data []byte) error { +func (r ChatCompletionListResponseDataUsage) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionListResponseDataUsage) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Token details for output tokens in OpenAI chat completion usage. -type ChatCompletionListResponseUsageCompletionTokensDetails struct { - // Number of tokens used for reasoning (o1/o3 models) - ReasoningTokens int64 `json:"reasoning_tokens"` +type ChatCompletionListResponseDataUsageCompletionTokensDetails struct { + ReasoningTokens int64 `json:"reasoning_tokens,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ReasoningTokens respjson.Field @@ -5187,15 +4837,16 @@ type ChatCompletionListResponseUsageCompletionTokensDetails struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseUsageCompletionTokensDetails) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseUsageCompletionTokensDetails) UnmarshalJSON(data []byte) error { +func (r ChatCompletionListResponseDataUsageCompletionTokensDetails) RawJSON() string { + return r.JSON.raw +} +func (r *ChatCompletionListResponseDataUsageCompletionTokensDetails) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Token details for prompt tokens in OpenAI chat completion usage. -type ChatCompletionListResponseUsagePromptTokensDetails struct { - // Number of tokens retrieved from cache - CachedTokens int64 `json:"cached_tokens"` +type ChatCompletionListResponseDataUsagePromptTokensDetails struct { + CachedTokens int64 `json:"cached_tokens,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { CachedTokens respjson.Field @@ -5205,57 +4856,41 @@ type ChatCompletionListResponseUsagePromptTokensDetails struct { } // Returns the unmodified JSON received from the API -func (r ChatCompletionListResponseUsagePromptTokensDetails) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionListResponseUsagePromptTokensDetails) UnmarshalJSON(data []byte) error { +func (r ChatCompletionListResponseDataUsagePromptTokensDetails) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionListResponseDataUsagePromptTokensDetails) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +type ChatCompletionListResponseObject string + +const ( + ChatCompletionListResponseObjectList ChatCompletionListResponseObject = "list" +) + type ChatCompletionNewParams struct { - // List of messages in the conversation. - Messages []ChatCompletionNewParamsMessageUnion `json:"messages,omitzero,required"` - // The identifier of the model to use. The model must be registered with Llama - // Stack and available via the /models endpoint. - Model string `json:"model,required"` - // (Optional) The penalty for repeated tokens. - FrequencyPenalty param.Opt[float64] `json:"frequency_penalty,omitzero"` - // (Optional) The log probabilities to use. - Logprobs param.Opt[bool] `json:"logprobs,omitzero"` - // (Optional) The maximum number of tokens to generate. - MaxCompletionTokens param.Opt[int64] `json:"max_completion_tokens,omitzero"` - // (Optional) The maximum number of tokens to generate. - MaxTokens param.Opt[int64] `json:"max_tokens,omitzero"` - // (Optional) The number of completions to generate. - N param.Opt[int64] `json:"n,omitzero"` - // (Optional) Whether to parallelize tool calls. - ParallelToolCalls param.Opt[bool] `json:"parallel_tool_calls,omitzero"` - // (Optional) The penalty for repeated tokens. - PresencePenalty param.Opt[float64] `json:"presence_penalty,omitzero"` - // (Optional) The seed to use. - Seed param.Opt[int64] `json:"seed,omitzero"` - // (Optional) The temperature to use. - Temperature param.Opt[float64] `json:"temperature,omitzero"` - // (Optional) The top log probabilities to use. - TopLogprobs param.Opt[int64] `json:"top_logprobs,omitzero"` - // (Optional) The top p to use. - TopP param.Opt[float64] `json:"top_p,omitzero"` - // (Optional) The user to use. - User param.Opt[string] `json:"user,omitzero"` - // (Optional) The function call to use. - FunctionCall ChatCompletionNewParamsFunctionCallUnion `json:"function_call,omitzero"` - // (Optional) List of functions to use. - Functions []map[string]ChatCompletionNewParamsFunctionUnion `json:"functions,omitzero"` - // (Optional) The logit bias to use. - LogitBias map[string]float64 `json:"logit_bias,omitzero"` - // (Optional) The response format to use. + Messages []ChatCompletionNewParamsMessageUnion `json:"messages,omitzero,required"` + Model string `json:"model,required"` + FrequencyPenalty param.Opt[float64] `json:"frequency_penalty,omitzero"` + Logprobs param.Opt[bool] `json:"logprobs,omitzero"` + MaxCompletionTokens param.Opt[int64] `json:"max_completion_tokens,omitzero"` + MaxTokens param.Opt[int64] `json:"max_tokens,omitzero"` + N param.Opt[int64] `json:"n,omitzero"` + ParallelToolCalls param.Opt[bool] `json:"parallel_tool_calls,omitzero"` + PresencePenalty param.Opt[float64] `json:"presence_penalty,omitzero"` + Seed param.Opt[int64] `json:"seed,omitzero"` + Temperature param.Opt[float64] `json:"temperature,omitzero"` + TopLogprobs param.Opt[int64] `json:"top_logprobs,omitzero"` + TopP param.Opt[float64] `json:"top_p,omitzero"` + User param.Opt[string] `json:"user,omitzero"` + FunctionCall ChatCompletionNewParamsFunctionCallUnion `json:"function_call,omitzero"` + Functions []map[string]any `json:"functions,omitzero"` + LogitBias map[string]float64 `json:"logit_bias,omitzero"` + // Text response format for OpenAI-compatible chat completion requests. ResponseFormat ChatCompletionNewParamsResponseFormatUnion `json:"response_format,omitzero"` - // (Optional) The stop tokens to use. - Stop ChatCompletionNewParamsStopUnion `json:"stop,omitzero"` - // (Optional) The stream options to use. - StreamOptions map[string]ChatCompletionNewParamsStreamOptionUnion `json:"stream_options,omitzero"` - // (Optional) The tool choice to use. - ToolChoice ChatCompletionNewParamsToolChoiceUnion `json:"tool_choice,omitzero"` - // (Optional) The tools to use. - Tools []map[string]ChatCompletionNewParamsToolUnion `json:"tools,omitzero"` + Stop ChatCompletionNewParamsStopUnion `json:"stop,omitzero"` + StreamOptions map[string]any `json:"stream_options,omitzero"` + ToolChoice ChatCompletionNewParamsToolChoiceUnion `json:"tool_choice,omitzero"` + Tools []map[string]any `json:"tools,omitzero"` paramObj } @@ -5321,6 +4956,20 @@ func (u ChatCompletionNewParamsMessageUnion) GetToolCallID() *string { return nil } +// Returns a pointer to the underlying variant's property, if present. +func (u ChatCompletionNewParamsMessageUnion) GetName() *string { + if vt := u.OfUser; vt != nil && vt.Name.Valid() { + return &vt.Name.Value + } else if vt := u.OfSystem; vt != nil && vt.Name.Valid() { + return &vt.Name.Value + } else if vt := u.OfAssistant; vt != nil && vt.Name.Valid() { + return &vt.Name.Value + } else if vt := u.OfDeveloper; vt != nil && vt.Name.Valid() { + return &vt.Name.Value + } + return nil +} + // Returns a pointer to the underlying variant's property, if present. func (u ChatCompletionNewParamsMessageUnion) GetRole() *string { if vt := u.OfUser; vt != nil { @@ -5337,20 +4986,6 @@ func (u ChatCompletionNewParamsMessageUnion) GetRole() *string { return nil } -// Returns a pointer to the underlying variant's property, if present. -func (u ChatCompletionNewParamsMessageUnion) GetName() *string { - if vt := u.OfUser; vt != nil && vt.Name.Valid() { - return &vt.Name.Value - } else if vt := u.OfSystem; vt != nil && vt.Name.Valid() { - return &vt.Name.Value - } else if vt := u.OfAssistant; vt != nil && vt.Name.Valid() { - return &vt.Name.Value - } else if vt := u.OfDeveloper; vt != nil && vt.Name.Valid() { - return &vt.Name.Value - } - return nil -} - // Returns a subunion which exports methods to access subproperties // // Or use AsAny() to get the underlying value @@ -5370,22 +5005,22 @@ func (u ChatCompletionNewParamsMessageUnion) GetContent() (res chatCompletionNew } // Can have the runtime types [*string], -// [_[]ChatCompletionNewParamsMessageUserContentArrayItemUnion], -// [_[]ChatCompletionNewParamsMessageSystemContentArrayItem], -// [_[]ChatCompletionNewParamsMessageAssistantContentArrayItem], -// [_[]ChatCompletionNewParamsMessageToolContentArrayItem], -// [\*[]ChatCompletionNewParamsMessageDeveloperContentArrayItem] +// [_[]ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion], +// [_[]ChatCompletionNewParamsMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem], +// [_[]ChatCompletionNewParamsMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem], +// [_[]ChatCompletionNewParamsMessageToolContentListOpenAIChatCompletionContentPartTextParamItem], +// [\*[]ChatCompletionNewParamsMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem] type chatCompletionNewParamsMessageUnionContent struct{ any } // Use the following switch statement to get the type of the union: // // switch u.AsAny().(type) { // case *string: -// case *[]llamastackclient.ChatCompletionNewParamsMessageUserContentArrayItemUnion: -// case *[]llamastackclient.ChatCompletionNewParamsMessageSystemContentArrayItem: -// case *[]llamastackclient.ChatCompletionNewParamsMessageAssistantContentArrayItem: -// case *[]llamastackclient.ChatCompletionNewParamsMessageToolContentArrayItem: -// case *[]llamastackclient.ChatCompletionNewParamsMessageDeveloperContentArrayItem: +// case *[]llamastackclient.ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion: +// case *[]llamastackclient.ChatCompletionNewParamsMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem: +// case *[]llamastackclient.ChatCompletionNewParamsMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem: +// case *[]llamastackclient.ChatCompletionNewParamsMessageToolContentListOpenAIChatCompletionContentPartTextParamItem: +// case *[]llamastackclient.ChatCompletionNewParamsMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem: // default: // fmt.Errorf("not present") // } @@ -5404,16 +5039,12 @@ func init() { // A message from the user in an OpenAI-compatible chat completion request. // -// The properties Content, Role are required. +// The property Content is required. type ChatCompletionNewParamsMessageUser struct { - // The content of the message, which can include text and other media Content ChatCompletionNewParamsMessageUserContentUnion `json:"content,omitzero,required"` - // (Optional) The name of the user message participant. - Name param.Opt[string] `json:"name,omitzero"` - // Must be "user" to identify this as a user message - // - // This field can be elided, and will marshal its zero value as "user". - Role constant.User `json:"role,required"` + Name param.Opt[string] `json:"name,omitzero"` + // Any of "user". + Role string `json:"role,omitzero"` paramObj } @@ -5425,17 +5056,23 @@ func (r *ChatCompletionNewParamsMessageUser) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ChatCompletionNewParamsMessageUser]( + "role", "user", + ) +} + // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. type ChatCompletionNewParamsMessageUserContentUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfChatCompletionNewsMessageUserContentArray []ChatCompletionNewParamsMessageUserContentArrayItemUnion `json:",omitzero,inline"` + OfString param.Opt[string] `json:",omitzero,inline"` + OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile []ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion `json:",omitzero,inline"` paramUnion } func (u ChatCompletionNewParamsMessageUserContentUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfChatCompletionNewsMessageUserContentArray) + return param.MarshalUnion(u, u.OfString, u.OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile) } func (u *ChatCompletionNewParamsMessageUserContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) @@ -5444,8 +5081,8 @@ func (u *ChatCompletionNewParamsMessageUserContentUnion) UnmarshalJSON(data []by func (u *ChatCompletionNewParamsMessageUserContentUnion) asAny() any { if !param.IsOmitted(u.OfString) { return &u.OfString.Value - } else if !param.IsOmitted(u.OfChatCompletionNewsMessageUserContentArray) { - return &u.OfChatCompletionNewsMessageUserContentArray + } else if !param.IsOmitted(u.OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile) { + return &u.OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile } return nil } @@ -5453,21 +5090,21 @@ func (u *ChatCompletionNewParamsMessageUserContentUnion) asAny() any { // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. -type ChatCompletionNewParamsMessageUserContentArrayItemUnion struct { - OfText *ChatCompletionNewParamsMessageUserContentArrayItemText `json:",omitzero,inline"` - OfImageURL *ChatCompletionNewParamsMessageUserContentArrayItemImageURL `json:",omitzero,inline"` - OfFile *ChatCompletionNewParamsMessageUserContentArrayItemFile `json:",omitzero,inline"` +type ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion struct { + OfText *ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText `json:",omitzero,inline"` + OfImageURL *ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL `json:",omitzero,inline"` + OfFile *ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile `json:",omitzero,inline"` paramUnion } -func (u ChatCompletionNewParamsMessageUserContentArrayItemUnion) MarshalJSON() ([]byte, error) { +func (u ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) MarshalJSON() ([]byte, error) { return param.MarshalUnion(u, u.OfText, u.OfImageURL, u.OfFile) } -func (u *ChatCompletionNewParamsMessageUserContentArrayItemUnion) UnmarshalJSON(data []byte) error { +func (u *ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *ChatCompletionNewParamsMessageUserContentArrayItemUnion) asAny() any { +func (u *ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) asAny() any { if !param.IsOmitted(u.OfText) { return u.OfText } else if !param.IsOmitted(u.OfImageURL) { @@ -5479,7 +5116,7 @@ func (u *ChatCompletionNewParamsMessageUserContentArrayItemUnion) asAny() any { } // Returns a pointer to the underlying variant's property, if present. -func (u ChatCompletionNewParamsMessageUserContentArrayItemUnion) GetText() *string { +func (u ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) GetText() *string { if vt := u.OfText; vt != nil { return &vt.Text } @@ -5487,7 +5124,7 @@ func (u ChatCompletionNewParamsMessageUserContentArrayItemUnion) GetText() *stri } // Returns a pointer to the underlying variant's property, if present. -func (u ChatCompletionNewParamsMessageUserContentArrayItemUnion) GetImageURL() *ChatCompletionNewParamsMessageUserContentArrayItemImageURLImageURL { +func (u ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) GetImageURL() *ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL { if vt := u.OfImageURL; vt != nil { return &vt.ImageURL } @@ -5495,7 +5132,7 @@ func (u ChatCompletionNewParamsMessageUserContentArrayItemUnion) GetImageURL() * } // Returns a pointer to the underlying variant's property, if present. -func (u ChatCompletionNewParamsMessageUserContentArrayItemUnion) GetFile() *ChatCompletionNewParamsMessageUserContentArrayItemFileFile { +func (u ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) GetFile() *ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile { if vt := u.OfFile; vt != nil { return &vt.File } @@ -5503,7 +5140,7 @@ func (u ChatCompletionNewParamsMessageUserContentArrayItemUnion) GetFile() *Chat } // Returns a pointer to the underlying variant's property, if present. -func (u ChatCompletionNewParamsMessageUserContentArrayItemUnion) GetType() *string { +func (u ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) GetType() *string { if vt := u.OfText; vt != nil { return (*string)(&vt.Type) } else if vt := u.OfImageURL; vt != nil { @@ -5515,120 +5152,125 @@ func (u ChatCompletionNewParamsMessageUserContentArrayItemUnion) GetType() *stri } func init() { - apijson.RegisterUnion[ChatCompletionNewParamsMessageUserContentArrayItemUnion]( + apijson.RegisterUnion[ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion]( "type", - apijson.Discriminator[ChatCompletionNewParamsMessageUserContentArrayItemText]("text"), - apijson.Discriminator[ChatCompletionNewParamsMessageUserContentArrayItemImageURL]("image_url"), - apijson.Discriminator[ChatCompletionNewParamsMessageUserContentArrayItemFile]("file"), + apijson.Discriminator[ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText]("text"), + apijson.Discriminator[ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL]("image_url"), + apijson.Discriminator[ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile]("file"), ) } // Text content part for OpenAI-compatible chat completion messages. // -// The properties Text, Type are required. -type ChatCompletionNewParamsMessageUserContentArrayItemText struct { - // The text content of the message +// The property Text is required. +type ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - // - // This field can be elided, and will marshal its zero value as "text". - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type,omitzero"` paramObj } -func (r ChatCompletionNewParamsMessageUserContentArrayItemText) MarshalJSON() (data []byte, err error) { - type shadow ChatCompletionNewParamsMessageUserContentArrayItemText +func (r ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) MarshalJSON() (data []byte, err error) { + type shadow ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ChatCompletionNewParamsMessageUserContentArrayItemText) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText]( + "type", "text", + ) +} + // Image content part for OpenAI-compatible chat completion messages. // -// The properties ImageURL, Type are required. -type ChatCompletionNewParamsMessageUserContentArrayItemImageURL struct { - // Image URL specification and processing details - ImageURL ChatCompletionNewParamsMessageUserContentArrayItemImageURLImageURL `json:"image_url,omitzero,required"` - // Must be "image_url" to identify this as image content - // - // This field can be elided, and will marshal its zero value as "image_url". - Type constant.ImageURL `json:"type,required"` +// The property ImageURL is required. +type ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL struct { + // Image URL specification for OpenAI-compatible chat completion messages. + ImageURL ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL `json:"image_url,omitzero,required"` + // Any of "image_url". + Type string `json:"type,omitzero"` paramObj } -func (r ChatCompletionNewParamsMessageUserContentArrayItemImageURL) MarshalJSON() (data []byte, err error) { - type shadow ChatCompletionNewParamsMessageUserContentArrayItemImageURL +func (r ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) MarshalJSON() (data []byte, err error) { + type shadow ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ChatCompletionNewParamsMessageUserContentArrayItemImageURL) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Image URL specification and processing details +func init() { + apijson.RegisterFieldValidator[ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL]( + "type", "image_url", + ) +} + +// Image URL specification for OpenAI-compatible chat completion messages. // // The property URL is required. -type ChatCompletionNewParamsMessageUserContentArrayItemImageURLImageURL struct { - // URL of the image to include in the message - URL string `json:"url,required"` - // (Optional) Level of detail for image processing. Can be "low", "high", or "auto" +type ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL struct { + URL string `json:"url,required"` Detail param.Opt[string] `json:"detail,omitzero"` paramObj } -func (r ChatCompletionNewParamsMessageUserContentArrayItemImageURLImageURL) MarshalJSON() (data []byte, err error) { - type shadow ChatCompletionNewParamsMessageUserContentArrayItemImageURLImageURL +func (r ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL) MarshalJSON() (data []byte, err error) { + type shadow ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ChatCompletionNewParamsMessageUserContentArrayItemImageURLImageURL) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// The properties File, Type are required. -type ChatCompletionNewParamsMessageUserContentArrayItemFile struct { - File ChatCompletionNewParamsMessageUserContentArrayItemFileFile `json:"file,omitzero,required"` - // This field can be elided, and will marshal its zero value as "file". - Type constant.File `json:"type,required"` +// The property File is required. +type ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile struct { + File ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile `json:"file,omitzero,required"` + // Any of "file". + Type string `json:"type,omitzero"` paramObj } -func (r ChatCompletionNewParamsMessageUserContentArrayItemFile) MarshalJSON() (data []byte, err error) { - type shadow ChatCompletionNewParamsMessageUserContentArrayItemFile +func (r ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) MarshalJSON() (data []byte, err error) { + type shadow ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ChatCompletionNewParamsMessageUserContentArrayItemFile) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ChatCompletionNewParamsMessageUserContentArrayItemFileFile struct { +func init() { + apijson.RegisterFieldValidator[ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile]( + "type", "file", + ) +} + +type ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile struct { FileData param.Opt[string] `json:"file_data,omitzero"` FileID param.Opt[string] `json:"file_id,omitzero"` Filename param.Opt[string] `json:"filename,omitzero"` paramObj } -func (r ChatCompletionNewParamsMessageUserContentArrayItemFileFile) MarshalJSON() (data []byte, err error) { - type shadow ChatCompletionNewParamsMessageUserContentArrayItemFileFile +func (r ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile) MarshalJSON() (data []byte, err error) { + type shadow ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ChatCompletionNewParamsMessageUserContentArrayItemFileFile) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A system message providing instructions or context to the model. // -// The properties Content, Role are required. +// The property Content is required. type ChatCompletionNewParamsMessageSystem struct { - // The content of the "system prompt". If multiple system messages are provided, - // they are concatenated. The underlying Llama Stack code may also add other system - // messages (for example, for formatting tool definitions). Content ChatCompletionNewParamsMessageSystemContentUnion `json:"content,omitzero,required"` - // (Optional) The name of the system message participant. - Name param.Opt[string] `json:"name,omitzero"` - // Must be "system" to identify this as a system message - // - // This field can be elided, and will marshal its zero value as "system". - Role constant.System `json:"role,required"` + Name param.Opt[string] `json:"name,omitzero"` + // Any of "system". + Role string `json:"role,omitzero"` paramObj } @@ -5640,17 +5282,23 @@ func (r *ChatCompletionNewParamsMessageSystem) UnmarshalJSON(data []byte) error return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ChatCompletionNewParamsMessageSystem]( + "role", "system", + ) +} + // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. type ChatCompletionNewParamsMessageSystemContentUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfChatCompletionNewsMessageSystemContentArray []ChatCompletionNewParamsMessageSystemContentArrayItem `json:",omitzero,inline"` + OfString param.Opt[string] `json:",omitzero,inline"` + OfListOpenAIChatCompletionContentPartText []ChatCompletionNewParamsMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem `json:",omitzero,inline"` paramUnion } func (u ChatCompletionNewParamsMessageSystemContentUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfChatCompletionNewsMessageSystemContentArray) + return param.MarshalUnion(u, u.OfString, u.OfListOpenAIChatCompletionContentPartText) } func (u *ChatCompletionNewParamsMessageSystemContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) @@ -5659,48 +5307,44 @@ func (u *ChatCompletionNewParamsMessageSystemContentUnion) UnmarshalJSON(data [] func (u *ChatCompletionNewParamsMessageSystemContentUnion) asAny() any { if !param.IsOmitted(u.OfString) { return &u.OfString.Value - } else if !param.IsOmitted(u.OfChatCompletionNewsMessageSystemContentArray) { - return &u.OfChatCompletionNewsMessageSystemContentArray + } else if !param.IsOmitted(u.OfListOpenAIChatCompletionContentPartText) { + return &u.OfListOpenAIChatCompletionContentPartText } return nil } // Text content part for OpenAI-compatible chat completion messages. // -// The properties Text, Type are required. -type ChatCompletionNewParamsMessageSystemContentArrayItem struct { - // The text content of the message +// The property Text is required. +type ChatCompletionNewParamsMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - // - // This field can be elided, and will marshal its zero value as "text". - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type,omitzero"` paramObj } -func (r ChatCompletionNewParamsMessageSystemContentArrayItem) MarshalJSON() (data []byte, err error) { - type shadow ChatCompletionNewParamsMessageSystemContentArrayItem +func (r ChatCompletionNewParamsMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem) MarshalJSON() (data []byte, err error) { + type shadow ChatCompletionNewParamsMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ChatCompletionNewParamsMessageSystemContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewParamsMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ChatCompletionNewParamsMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem]( + "type", "text", + ) +} + // A message containing the model's (assistant) response in an OpenAI-compatible // chat completion request. -// -// The property Role is required. type ChatCompletionNewParamsMessageAssistant struct { - // (Optional) The name of the assistant message participant. - Name param.Opt[string] `json:"name,omitzero"` - // The content of the model's response - Content ChatCompletionNewParamsMessageAssistantContentUnion `json:"content,omitzero"` - // List of tool calls. Each tool call is an OpenAIChatCompletionToolCall object. - ToolCalls []ChatCompletionNewParamsMessageAssistantToolCall `json:"tool_calls,omitzero"` - // Must be "assistant" to identify this as the model's response - // - // This field can be elided, and will marshal its zero value as "assistant". - Role constant.Assistant `json:"role,required"` + Name param.Opt[string] `json:"name,omitzero"` + Content ChatCompletionNewParamsMessageAssistantContentUnion `json:"content,omitzero"` + ToolCalls []ChatCompletionNewParamsMessageAssistantToolCall `json:"tool_calls,omitzero"` + // Any of "assistant". + Role string `json:"role,omitzero"` paramObj } @@ -5712,17 +5356,23 @@ func (r *ChatCompletionNewParamsMessageAssistant) UnmarshalJSON(data []byte) err return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ChatCompletionNewParamsMessageAssistant]( + "role", "assistant", + ) +} + // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. type ChatCompletionNewParamsMessageAssistantContentUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfChatCompletionNewsMessageAssistantContentArray []ChatCompletionNewParamsMessageAssistantContentArrayItem `json:",omitzero,inline"` + OfString param.Opt[string] `json:",omitzero,inline"` + OfListOpenAIChatCompletionContentPartText []ChatCompletionNewParamsMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem `json:",omitzero,inline"` paramUnion } func (u ChatCompletionNewParamsMessageAssistantContentUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfChatCompletionNewsMessageAssistantContentArray) + return param.MarshalUnion(u, u.OfString, u.OfListOpenAIChatCompletionContentPartText) } func (u *ChatCompletionNewParamsMessageAssistantContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) @@ -5731,47 +5381,44 @@ func (u *ChatCompletionNewParamsMessageAssistantContentUnion) UnmarshalJSON(data func (u *ChatCompletionNewParamsMessageAssistantContentUnion) asAny() any { if !param.IsOmitted(u.OfString) { return &u.OfString.Value - } else if !param.IsOmitted(u.OfChatCompletionNewsMessageAssistantContentArray) { - return &u.OfChatCompletionNewsMessageAssistantContentArray + } else if !param.IsOmitted(u.OfListOpenAIChatCompletionContentPartText) { + return &u.OfListOpenAIChatCompletionContentPartText } return nil } // Text content part for OpenAI-compatible chat completion messages. // -// The properties Text, Type are required. -type ChatCompletionNewParamsMessageAssistantContentArrayItem struct { - // The text content of the message +// The property Text is required. +type ChatCompletionNewParamsMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - // - // This field can be elided, and will marshal its zero value as "text". - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type,omitzero"` paramObj } -func (r ChatCompletionNewParamsMessageAssistantContentArrayItem) MarshalJSON() (data []byte, err error) { - type shadow ChatCompletionNewParamsMessageAssistantContentArrayItem +func (r ChatCompletionNewParamsMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem) MarshalJSON() (data []byte, err error) { + type shadow ChatCompletionNewParamsMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ChatCompletionNewParamsMessageAssistantContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewParamsMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ChatCompletionNewParamsMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem]( + "type", "text", + ) +} + // Tool call specification for OpenAI-compatible chat completion responses. -// -// The property Type is required. type ChatCompletionNewParamsMessageAssistantToolCall struct { - // (Optional) Unique identifier for the tool call - ID param.Opt[string] `json:"id,omitzero"` - // (Optional) Index of the tool call in the list - Index param.Opt[int64] `json:"index,omitzero"` - // (Optional) Function call details + ID param.Opt[string] `json:"id,omitzero"` + Index param.Opt[int64] `json:"index,omitzero"` + // Function call details for OpenAI-compatible tool calls. Function ChatCompletionNewParamsMessageAssistantToolCallFunction `json:"function,omitzero"` - // Must be "function" to identify this as a function call - // - // This field can be elided, and will marshal its zero value as "function". - Type constant.Function `json:"type,required"` + // Any of "function". + Type string `json:"type,omitzero"` paramObj } @@ -5783,12 +5430,16 @@ func (r *ChatCompletionNewParamsMessageAssistantToolCall) UnmarshalJSON(data []b return apijson.UnmarshalRoot(data, r) } -// (Optional) Function call details +func init() { + apijson.RegisterFieldValidator[ChatCompletionNewParamsMessageAssistantToolCall]( + "type", "function", + ) +} + +// Function call details for OpenAI-compatible tool calls. type ChatCompletionNewParamsMessageAssistantToolCallFunction struct { - // (Optional) Arguments to pass to the function as a JSON string Arguments param.Opt[string] `json:"arguments,omitzero"` - // (Optional) Name of the function to call - Name param.Opt[string] `json:"name,omitzero"` + Name param.Opt[string] `json:"name,omitzero"` paramObj } @@ -5803,16 +5454,12 @@ func (r *ChatCompletionNewParamsMessageAssistantToolCallFunction) UnmarshalJSON( // A message representing the result of a tool invocation in an OpenAI-compatible // chat completion request. // -// The properties Content, Role, ToolCallID are required. +// The properties Content, ToolCallID are required. type ChatCompletionNewParamsMessageTool struct { - // The response content from the tool - Content ChatCompletionNewParamsMessageToolContentUnion `json:"content,omitzero,required"` - // Unique identifier for the tool call this response is for - ToolCallID string `json:"tool_call_id,required"` - // Must be "tool" to identify this as a tool response - // - // This field can be elided, and will marshal its zero value as "tool". - Role constant.Tool `json:"role,required"` + Content ChatCompletionNewParamsMessageToolContentUnion `json:"content,omitzero,required"` + ToolCallID string `json:"tool_call_id,required"` + // Any of "tool". + Role string `json:"role,omitzero"` paramObj } @@ -5824,17 +5471,23 @@ func (r *ChatCompletionNewParamsMessageTool) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ChatCompletionNewParamsMessageTool]( + "role", "tool", + ) +} + // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. type ChatCompletionNewParamsMessageToolContentUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfChatCompletionNewsMessageToolContentArray []ChatCompletionNewParamsMessageToolContentArrayItem `json:",omitzero,inline"` + OfString param.Opt[string] `json:",omitzero,inline"` + OfListOpenAIChatCompletionContentPartText []ChatCompletionNewParamsMessageToolContentListOpenAIChatCompletionContentPartTextParamItem `json:",omitzero,inline"` paramUnion } func (u ChatCompletionNewParamsMessageToolContentUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfChatCompletionNewsMessageToolContentArray) + return param.MarshalUnion(u, u.OfString, u.OfListOpenAIChatCompletionContentPartText) } func (u *ChatCompletionNewParamsMessageToolContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) @@ -5843,45 +5496,44 @@ func (u *ChatCompletionNewParamsMessageToolContentUnion) UnmarshalJSON(data []by func (u *ChatCompletionNewParamsMessageToolContentUnion) asAny() any { if !param.IsOmitted(u.OfString) { return &u.OfString.Value - } else if !param.IsOmitted(u.OfChatCompletionNewsMessageToolContentArray) { - return &u.OfChatCompletionNewsMessageToolContentArray + } else if !param.IsOmitted(u.OfListOpenAIChatCompletionContentPartText) { + return &u.OfListOpenAIChatCompletionContentPartText } return nil } // Text content part for OpenAI-compatible chat completion messages. // -// The properties Text, Type are required. -type ChatCompletionNewParamsMessageToolContentArrayItem struct { - // The text content of the message +// The property Text is required. +type ChatCompletionNewParamsMessageToolContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - // - // This field can be elided, and will marshal its zero value as "text". - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type,omitzero"` paramObj } -func (r ChatCompletionNewParamsMessageToolContentArrayItem) MarshalJSON() (data []byte, err error) { - type shadow ChatCompletionNewParamsMessageToolContentArrayItem +func (r ChatCompletionNewParamsMessageToolContentListOpenAIChatCompletionContentPartTextParamItem) MarshalJSON() (data []byte, err error) { + type shadow ChatCompletionNewParamsMessageToolContentListOpenAIChatCompletionContentPartTextParamItem return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ChatCompletionNewParamsMessageToolContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewParamsMessageToolContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ChatCompletionNewParamsMessageToolContentListOpenAIChatCompletionContentPartTextParamItem]( + "type", "text", + ) +} + // A message from the developer in an OpenAI-compatible chat completion request. // -// The properties Content, Role are required. +// The property Content is required. type ChatCompletionNewParamsMessageDeveloper struct { - // The content of the developer message Content ChatCompletionNewParamsMessageDeveloperContentUnion `json:"content,omitzero,required"` - // (Optional) The name of the developer message participant. - Name param.Opt[string] `json:"name,omitzero"` - // Must be "developer" to identify this as a developer message - // - // This field can be elided, and will marshal its zero value as "developer". - Role constant.Developer `json:"role,required"` + Name param.Opt[string] `json:"name,omitzero"` + // Any of "developer". + Role string `json:"role,omitzero"` paramObj } @@ -5893,17 +5545,23 @@ func (r *ChatCompletionNewParamsMessageDeveloper) UnmarshalJSON(data []byte) err return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ChatCompletionNewParamsMessageDeveloper]( + "role", "developer", + ) +} + // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. type ChatCompletionNewParamsMessageDeveloperContentUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfChatCompletionNewsMessageDeveloperContentArray []ChatCompletionNewParamsMessageDeveloperContentArrayItem `json:",omitzero,inline"` + OfString param.Opt[string] `json:",omitzero,inline"` + OfListOpenAIChatCompletionContentPartText []ChatCompletionNewParamsMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem `json:",omitzero,inline"` paramUnion } func (u ChatCompletionNewParamsMessageDeveloperContentUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfChatCompletionNewsMessageDeveloperContentArray) + return param.MarshalUnion(u, u.OfString, u.OfListOpenAIChatCompletionContentPartText) } func (u *ChatCompletionNewParamsMessageDeveloperContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) @@ -5912,44 +5570,47 @@ func (u *ChatCompletionNewParamsMessageDeveloperContentUnion) UnmarshalJSON(data func (u *ChatCompletionNewParamsMessageDeveloperContentUnion) asAny() any { if !param.IsOmitted(u.OfString) { return &u.OfString.Value - } else if !param.IsOmitted(u.OfChatCompletionNewsMessageDeveloperContentArray) { - return &u.OfChatCompletionNewsMessageDeveloperContentArray + } else if !param.IsOmitted(u.OfListOpenAIChatCompletionContentPartText) { + return &u.OfListOpenAIChatCompletionContentPartText } return nil } // Text content part for OpenAI-compatible chat completion messages. // -// The properties Text, Type are required. -type ChatCompletionNewParamsMessageDeveloperContentArrayItem struct { - // The text content of the message +// The property Text is required. +type ChatCompletionNewParamsMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - // - // This field can be elided, and will marshal its zero value as "text". - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type,omitzero"` paramObj } -func (r ChatCompletionNewParamsMessageDeveloperContentArrayItem) MarshalJSON() (data []byte, err error) { - type shadow ChatCompletionNewParamsMessageDeveloperContentArrayItem +func (r ChatCompletionNewParamsMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem) MarshalJSON() (data []byte, err error) { + type shadow ChatCompletionNewParamsMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ChatCompletionNewParamsMessageDeveloperContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ChatCompletionNewParamsMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ChatCompletionNewParamsMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem]( + "type", "text", + ) +} + // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. type ChatCompletionNewParamsFunctionCallUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfChatCompletionNewsFunctionCallMapMap map[string]ChatCompletionNewParamsFunctionCallMapItemUnion `json:",omitzero,inline"` + OfString param.Opt[string] `json:",omitzero,inline"` + OfAnyMap map[string]any `json:",omitzero,inline"` paramUnion } func (u ChatCompletionNewParamsFunctionCallUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfChatCompletionNewsFunctionCallMapMap) + return param.MarshalUnion(u, u.OfString, u.OfAnyMap) } func (u *ChatCompletionNewParamsFunctionCallUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) @@ -5958,70 +5619,8 @@ func (u *ChatCompletionNewParamsFunctionCallUnion) UnmarshalJSON(data []byte) er func (u *ChatCompletionNewParamsFunctionCallUnion) asAny() any { if !param.IsOmitted(u.OfString) { return &u.OfString.Value - } else if !param.IsOmitted(u.OfChatCompletionNewsFunctionCallMapMap) { - return &u.OfChatCompletionNewsFunctionCallMapMap - } - return nil -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ChatCompletionNewParamsFunctionCallMapItemUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u ChatCompletionNewParamsFunctionCallMapItemUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *ChatCompletionNewParamsFunctionCallMapItemUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ChatCompletionNewParamsFunctionCallMapItemUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ChatCompletionNewParamsFunctionUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u ChatCompletionNewParamsFunctionUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *ChatCompletionNewParamsFunctionUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ChatCompletionNewParamsFunctionUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray + } else if !param.IsOmitted(u.OfAnyMap) { + return &u.OfAnyMap } return nil } @@ -6083,19 +5682,10 @@ func init() { ) } -func NewChatCompletionNewParamsResponseFormatText() ChatCompletionNewParamsResponseFormatText { - return ChatCompletionNewParamsResponseFormatText{ - Type: "text", - } -} - // Text response format for OpenAI-compatible chat completion requests. -// -// This struct has a constant value, construct it with -// [NewChatCompletionNewParamsResponseFormatText]. type ChatCompletionNewParamsResponseFormatText struct { - // Must be "text" to indicate plain text response format - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type,omitzero"` paramObj } @@ -6107,16 +5697,20 @@ func (r *ChatCompletionNewParamsResponseFormatText) UnmarshalJSON(data []byte) e return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ChatCompletionNewParamsResponseFormatText]( + "type", "text", + ) +} + // JSON schema response format for OpenAI-compatible chat completion requests. // -// The properties JsonSchema, Type are required. +// The property JsonSchema is required. type ChatCompletionNewParamsResponseFormatJsonSchema struct { - // The JSON schema specification for the response + // JSON schema specification for OpenAI-compatible structured response format. JsonSchema ChatCompletionNewParamsResponseFormatJsonSchemaJsonSchema `json:"json_schema,omitzero,required"` - // Must be "json_schema" to indicate structured JSON response format - // - // This field can be elided, and will marshal its zero value as "json_schema". - Type constant.JsonSchema `json:"type,required"` + // Any of "json_schema". + Type string `json:"type,omitzero"` paramObj } @@ -6128,18 +5722,18 @@ func (r *ChatCompletionNewParamsResponseFormatJsonSchema) UnmarshalJSON(data []b return apijson.UnmarshalRoot(data, r) } -// The JSON schema specification for the response -// -// The property Name is required. +func init() { + apijson.RegisterFieldValidator[ChatCompletionNewParamsResponseFormatJsonSchema]( + "type", "json_schema", + ) +} + +// JSON schema specification for OpenAI-compatible structured response format. type ChatCompletionNewParamsResponseFormatJsonSchemaJsonSchema struct { - // Name of the schema - Name string `json:"name,required"` - // (Optional) Description of the schema Description param.Opt[string] `json:"description,omitzero"` - // (Optional) Whether to enforce strict adherence to the schema - Strict param.Opt[bool] `json:"strict,omitzero"` - // (Optional) The JSON schema definition - Schema map[string]ChatCompletionNewParamsResponseFormatJsonSchemaJsonSchemaSchemaUnion `json:"schema,omitzero"` + Strict param.Opt[bool] `json:"strict,omitzero"` + Name param.Opt[string] `json:"name,omitzero"` + Schema map[string]any `json:"schema,omitzero"` paramObj } @@ -6151,50 +5745,10 @@ func (r *ChatCompletionNewParamsResponseFormatJsonSchemaJsonSchema) UnmarshalJSO return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ChatCompletionNewParamsResponseFormatJsonSchemaJsonSchemaSchemaUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u ChatCompletionNewParamsResponseFormatJsonSchemaJsonSchemaSchemaUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *ChatCompletionNewParamsResponseFormatJsonSchemaJsonSchemaSchemaUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ChatCompletionNewParamsResponseFormatJsonSchemaJsonSchemaSchemaUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - -func NewChatCompletionNewParamsResponseFormatJsonObject() ChatCompletionNewParamsResponseFormatJsonObject { - return ChatCompletionNewParamsResponseFormatJsonObject{ - Type: "json_object", - } -} - // JSON object response format for OpenAI-compatible chat completion requests. -// -// This struct has a constant value, construct it with -// [NewChatCompletionNewParamsResponseFormatJsonObject]. type ChatCompletionNewParamsResponseFormatJsonObject struct { - // Must be "json_object" to indicate generic JSON object response format - Type constant.JsonObject `json:"type,required"` + // Any of "json_object". + Type string `json:"type,omitzero"` paramObj } @@ -6206,17 +5760,23 @@ func (r *ChatCompletionNewParamsResponseFormatJsonObject) UnmarshalJSON(data []b return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ChatCompletionNewParamsResponseFormatJsonObject]( + "type", "json_object", + ) +} + // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. type ChatCompletionNewParamsStopUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfStringArray []string `json:",omitzero,inline"` + OfString param.Opt[string] `json:",omitzero,inline"` + OfListString []string `json:",omitzero,inline"` paramUnion } func (u ChatCompletionNewParamsStopUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfStringArray) + return param.MarshalUnion(u, u.OfString, u.OfListString) } func (u *ChatCompletionNewParamsStopUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) @@ -6225,39 +5785,8 @@ func (u *ChatCompletionNewParamsStopUnion) UnmarshalJSON(data []byte) error { func (u *ChatCompletionNewParamsStopUnion) asAny() any { if !param.IsOmitted(u.OfString) { return &u.OfString.Value - } else if !param.IsOmitted(u.OfStringArray) { - return &u.OfStringArray - } - return nil -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ChatCompletionNewParamsStreamOptionUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u ChatCompletionNewParamsStreamOptionUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *ChatCompletionNewParamsStreamOptionUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ChatCompletionNewParamsStreamOptionUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray + } else if !param.IsOmitted(u.OfListString) { + return &u.OfListString } return nil } @@ -6266,13 +5795,13 @@ func (u *ChatCompletionNewParamsStreamOptionUnion) asAny() any { // // Use [param.IsOmitted] to confirm if a field is set. type ChatCompletionNewParamsToolChoiceUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfChatCompletionNewsToolChoiceMapMap map[string]ChatCompletionNewParamsToolChoiceMapItemUnion `json:",omitzero,inline"` + OfString param.Opt[string] `json:",omitzero,inline"` + OfAnyMap map[string]any `json:",omitzero,inline"` paramUnion } func (u ChatCompletionNewParamsToolChoiceUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfChatCompletionNewsToolChoiceMapMap) + return param.MarshalUnion(u, u.OfString, u.OfAnyMap) } func (u *ChatCompletionNewParamsToolChoiceUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) @@ -6281,82 +5810,17 @@ func (u *ChatCompletionNewParamsToolChoiceUnion) UnmarshalJSON(data []byte) erro func (u *ChatCompletionNewParamsToolChoiceUnion) asAny() any { if !param.IsOmitted(u.OfString) { return &u.OfString.Value - } else if !param.IsOmitted(u.OfChatCompletionNewsToolChoiceMapMap) { - return &u.OfChatCompletionNewsToolChoiceMapMap - } - return nil -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ChatCompletionNewParamsToolChoiceMapItemUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u ChatCompletionNewParamsToolChoiceMapItemUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *ChatCompletionNewParamsToolChoiceMapItemUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ChatCompletionNewParamsToolChoiceMapItemUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ChatCompletionNewParamsToolUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u ChatCompletionNewParamsToolUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *ChatCompletionNewParamsToolUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ChatCompletionNewParamsToolUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray + } else if !param.IsOmitted(u.OfAnyMap) { + return &u.OfAnyMap } return nil } type ChatCompletionListParams struct { - // The ID of the last chat completion to return. After param.Opt[string] `query:"after,omitzero" json:"-"` - // The maximum number of chat completions to return. - Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` - // The model to filter by. + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` Model param.Opt[string] `query:"model,omitzero" json:"-"` - // The order to sort the chat completions by: "asc" or "desc". Defaults to "desc". + // Sort order for paginated responses. // // Any of "asc", "desc". Order ChatCompletionListParamsOrder `query:"order,omitzero" json:"-"` @@ -6372,7 +5836,7 @@ func (r ChatCompletionListParams) URLQuery() (v url.Values, err error) { }) } -// The order to sort the chat completions by: "asc" or "desc". Defaults to "desc". +// Sort order for paginated responses. type ChatCompletionListParamsOrder string const ( diff --git a/chatcompletion_test.go b/chatcompletion_test.go index 34c5f93..789db4e 100644 --- a/chatcompletion_test.go +++ b/chatcompletion_test.go @@ -37,6 +37,7 @@ func TestChatCompletionNewWithOptionalParams(t *testing.T) { OfString: llamastackclient.String("string"), }, Name: llamastackclient.String("name"), + Role: "user", }, }}, Model: "model", @@ -44,10 +45,8 @@ func TestChatCompletionNewWithOptionalParams(t *testing.T) { FunctionCall: llamastackclient.ChatCompletionNewParamsFunctionCallUnion{ OfString: llamastackclient.String("string"), }, - Functions: []map[string]llamastackclient.ChatCompletionNewParamsFunctionUnion{{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + Functions: []map[string]any{{ + "foo": "bar", }}, LogitBias: map[string]float64{ "foo": 0, @@ -59,25 +58,23 @@ func TestChatCompletionNewWithOptionalParams(t *testing.T) { ParallelToolCalls: llamastackclient.Bool(true), PresencePenalty: llamastackclient.Float(0), ResponseFormat: llamastackclient.ChatCompletionNewParamsResponseFormatUnion{ - OfText: &llamastackclient.ChatCompletionNewParamsResponseFormatText{}, + OfText: &llamastackclient.ChatCompletionNewParamsResponseFormatText{ + Type: "text", + }, }, Seed: llamastackclient.Int(0), Stop: llamastackclient.ChatCompletionNewParamsStopUnion{ OfString: llamastackclient.String("string"), }, - StreamOptions: map[string]llamastackclient.ChatCompletionNewParamsStreamOptionUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + StreamOptions: map[string]any{ + "foo": "bar", }, Temperature: llamastackclient.Float(0), ToolChoice: llamastackclient.ChatCompletionNewParamsToolChoiceUnion{ OfString: llamastackclient.String("string"), }, - Tools: []map[string]llamastackclient.ChatCompletionNewParamsToolUnion{{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + Tools: []map[string]any{{ + "foo": "bar", }}, TopLogprobs: llamastackclient.Int(0), TopP: llamastackclient.Float(0), diff --git a/client.go b/client.go index 0e744ef..73f6921 100644 --- a/client.go +++ b/client.go @@ -44,6 +44,7 @@ type Client struct { Scoring ScoringService ScoringFunctions ScoringFunctionService Files FileService + Batches BatchService Alpha AlphaService Beta BetaService } @@ -91,6 +92,7 @@ func NewClient(opts ...option.RequestOption) (r Client) { r.Scoring = NewScoringService(opts...) r.ScoringFunctions = NewScoringFunctionService(opts...) r.Files = NewFileService(opts...) + r.Batches = NewBatchService(opts...) r.Alpha = NewAlphaService(opts...) r.Beta = NewBetaService(opts...) diff --git a/client_test.go b/client_test.go index b8d8be8..a542dfc 100644 --- a/client_test.go +++ b/client_test.go @@ -50,6 +50,7 @@ func TestUserAgentHeader(t *testing.T) { Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, + Role: "user", }, }}, Model: "model", @@ -82,6 +83,7 @@ func TestRetryAfter(t *testing.T) { Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, + Role: "user", }, }}, Model: "model", @@ -125,6 +127,7 @@ func TestDeleteRetryCountHeader(t *testing.T) { Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, + Role: "user", }, }}, Model: "model", @@ -163,6 +166,7 @@ func TestOverwriteRetryCountHeader(t *testing.T) { Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, + Role: "user", }, }}, Model: "model", @@ -200,6 +204,7 @@ func TestRetryAfterMs(t *testing.T) { Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, + Role: "user", }, }}, Model: "model", @@ -231,6 +236,7 @@ func TestContextCancel(t *testing.T) { Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, + Role: "user", }, }}, Model: "model", @@ -259,6 +265,7 @@ func TestContextCancelDelay(t *testing.T) { Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, + Role: "user", }, }}, Model: "model", @@ -293,6 +300,7 @@ func TestContextDeadline(t *testing.T) { Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, + Role: "user", }, }}, Model: "model", @@ -346,6 +354,7 @@ func TestContextDeadlineStreaming(t *testing.T) { Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, + Role: "user", }, }}, Model: "model", @@ -401,6 +410,7 @@ func TestContextDeadlineStreamingWithRequestTimeout(t *testing.T) { Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, + Role: "user", }, }}, Model: "model", diff --git a/completion.go b/completion.go index e95e849..592a73a 100644 --- a/completion.go +++ b/completion.go @@ -19,7 +19,6 @@ import ( "github.com/llamastack/llama-stack-client-go/packages/param" "github.com/llamastack/llama-stack-client-go/packages/respjson" "github.com/llamastack/llama-stack-client-go/packages/ssestream" - "github.com/llamastack/llama-stack-client-go/shared/constant" ) // CompletionService contains methods and other services that help with interacting @@ -41,8 +40,10 @@ func NewCompletionService(opts ...option.RequestOption) (r CompletionService) { return } -// Create completion. Generate an OpenAI-compatible completion for the given prompt -// using the specified model. +// Create completion. +// +// Generate an OpenAI-compatible completion for the given prompt using the +// specified model. func (r *CompletionService) New(ctx context.Context, body CompletionNewParams, opts ...option.RequestOption) (res *CompletionNewResponse, err error) { opts = slices.Concat(r.Options, opts) path := "v1/completions" @@ -50,8 +51,10 @@ func (r *CompletionService) New(ctx context.Context, body CompletionNewParams, o return } -// Create completion. Generate an OpenAI-compatible completion for the given prompt -// using the specified model. +// Create completion. +// +// Generate an OpenAI-compatible completion for the given prompt using the +// specified model. func (r *CompletionService) NewStreaming(ctx context.Context, body CompletionNewParams, opts ...option.RequestOption) (stream *ssestream.Stream[CompletionNewResponse]) { var ( raw *http.Response @@ -65,12 +68,18 @@ func (r *CompletionService) NewStreaming(ctx context.Context, body CompletionNew } // Response from an OpenAI-compatible completion request. +// +// :id: The ID of the completion :choices: List of choices :created: The Unix +// timestamp in seconds when the completion was created :model: The model that was +// used to generate the completion :object: The object type, which will be +// "text_completion" type CompletionNewResponse struct { ID string `json:"id,required"` Choices []CompletionNewResponseChoice `json:"choices,required"` Created int64 `json:"created,required"` Model string `json:"model,required"` - Object constant.TextCompletion `json:"object,required"` + // Any of "text_completion". + Object CompletionNewResponseObject `json:"object"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -90,13 +99,17 @@ func (r *CompletionNewResponse) UnmarshalJSON(data []byte) error { } // A choice from an OpenAI-compatible completion response. +// +// :finish_reason: The reason the model stopped generating :text: The text of the +// choice :index: The index of the choice :logprobs: (Optional) The log +// probabilities for the tokens in the choice type CompletionNewResponseChoice struct { FinishReason string `json:"finish_reason,required"` Index int64 `json:"index,required"` Text string `json:"text,required"` // The log probabilities for the tokens in the message from an OpenAI-compatible // chat completion response. - Logprobs CompletionNewResponseChoiceLogprobs `json:"logprobs"` + Logprobs CompletionNewResponseChoiceLogprobs `json:"logprobs,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { FinishReason respjson.Field @@ -117,10 +130,8 @@ func (r *CompletionNewResponseChoice) UnmarshalJSON(data []byte) error { // The log probabilities for the tokens in the message from an OpenAI-compatible // chat completion response. type CompletionNewResponseChoiceLogprobs struct { - // (Optional) The log probabilities for the tokens in the message - Content []CompletionNewResponseChoiceLogprobsContent `json:"content"` - // (Optional) The log probabilities for the tokens in the message - Refusal []CompletionNewResponseChoiceLogprobsRefusal `json:"refusal"` + Content []CompletionNewResponseChoiceLogprobsContent `json:"content,nullable"` + Refusal []CompletionNewResponseChoiceLogprobsRefusal `json:"refusal,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field @@ -138,11 +149,14 @@ func (r *CompletionNewResponseChoiceLogprobs) UnmarshalJSON(data []byte) error { // The log probability for a token from an OpenAI-compatible chat completion // response. +// +// :token: The token :bytes: (Optional) The bytes for the token :logprob: The log +// probability of the token :top_logprobs: The top log probabilities for the token type CompletionNewResponseChoiceLogprobsContent struct { Token string `json:"token,required"` Logprob float64 `json:"logprob,required"` TopLogprobs []CompletionNewResponseChoiceLogprobsContentTopLogprob `json:"top_logprobs,required"` - Bytes []int64 `json:"bytes"` + Bytes []int64 `json:"bytes,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Token respjson.Field @@ -162,10 +176,13 @@ func (r *CompletionNewResponseChoiceLogprobsContent) UnmarshalJSON(data []byte) // The top log probability for a token from an OpenAI-compatible chat completion // response. +// +// :token: The token :bytes: (Optional) The bytes for the token :logprob: The log +// probability of the token type CompletionNewResponseChoiceLogprobsContentTopLogprob struct { Token string `json:"token,required"` Logprob float64 `json:"logprob,required"` - Bytes []int64 `json:"bytes"` + Bytes []int64 `json:"bytes,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Token respjson.Field @@ -184,11 +201,14 @@ func (r *CompletionNewResponseChoiceLogprobsContentTopLogprob) UnmarshalJSON(dat // The log probability for a token from an OpenAI-compatible chat completion // response. +// +// :token: The token :bytes: (Optional) The bytes for the token :logprob: The log +// probability of the token :top_logprobs: The top log probabilities for the token type CompletionNewResponseChoiceLogprobsRefusal struct { Token string `json:"token,required"` Logprob float64 `json:"logprob,required"` TopLogprobs []CompletionNewResponseChoiceLogprobsRefusalTopLogprob `json:"top_logprobs,required"` - Bytes []int64 `json:"bytes"` + Bytes []int64 `json:"bytes,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Token respjson.Field @@ -208,10 +228,13 @@ func (r *CompletionNewResponseChoiceLogprobsRefusal) UnmarshalJSON(data []byte) // The top log probability for a token from an OpenAI-compatible chat completion // response. +// +// :token: The token :bytes: (Optional) The bytes for the token :logprob: The log +// probability of the token type CompletionNewResponseChoiceLogprobsRefusalTopLogprob struct { Token string `json:"token,required"` Logprob float64 `json:"logprob,required"` - Bytes []int64 `json:"bytes"` + Bytes []int64 `json:"bytes,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Token respjson.Field @@ -228,42 +251,30 @@ func (r *CompletionNewResponseChoiceLogprobsRefusalTopLogprob) UnmarshalJSON(dat return apijson.UnmarshalRoot(data, r) } +type CompletionNewResponseObject string + +const ( + CompletionNewResponseObjectTextCompletion CompletionNewResponseObject = "text_completion" +) + type CompletionNewParams struct { - // The identifier of the model to use. The model must be registered with Llama - // Stack and available via the /models endpoint. - Model string `json:"model,required"` - // The prompt to generate a completion for. - Prompt CompletionNewParamsPromptUnion `json:"prompt,omitzero,required"` - // (Optional) The number of completions to generate. - BestOf param.Opt[int64] `json:"best_of,omitzero"` - // (Optional) Whether to echo the prompt. - Echo param.Opt[bool] `json:"echo,omitzero"` - // (Optional) The penalty for repeated tokens. - FrequencyPenalty param.Opt[float64] `json:"frequency_penalty,omitzero"` - // (Optional) The log probabilities to use. - Logprobs param.Opt[bool] `json:"logprobs,omitzero"` - // (Optional) The maximum number of tokens to generate. - MaxTokens param.Opt[int64] `json:"max_tokens,omitzero"` - // (Optional) The number of completions to generate. - N param.Opt[int64] `json:"n,omitzero"` - // (Optional) The penalty for repeated tokens. - PresencePenalty param.Opt[float64] `json:"presence_penalty,omitzero"` - // (Optional) The seed to use. - Seed param.Opt[int64] `json:"seed,omitzero"` - // (Optional) The suffix that should be appended to the completion. - Suffix param.Opt[string] `json:"suffix,omitzero"` - // (Optional) The temperature to use. - Temperature param.Opt[float64] `json:"temperature,omitzero"` - // (Optional) The top p to use. - TopP param.Opt[float64] `json:"top_p,omitzero"` - // (Optional) The user to use. - User param.Opt[string] `json:"user,omitzero"` - // (Optional) The logit bias to use. - LogitBias map[string]float64 `json:"logit_bias,omitzero"` - // (Optional) The stop tokens to use. - Stop CompletionNewParamsStopUnion `json:"stop,omitzero"` - // (Optional) The stream options to use. - StreamOptions map[string]CompletionNewParamsStreamOptionUnion `json:"stream_options,omitzero"` + Model string `json:"model,required"` + Prompt CompletionNewParamsPromptUnion `json:"prompt,omitzero,required"` + BestOf param.Opt[int64] `json:"best_of,omitzero"` + Echo param.Opt[bool] `json:"echo,omitzero"` + FrequencyPenalty param.Opt[float64] `json:"frequency_penalty,omitzero"` + Logprobs param.Opt[bool] `json:"logprobs,omitzero"` + MaxTokens param.Opt[int64] `json:"max_tokens,omitzero"` + N param.Opt[int64] `json:"n,omitzero"` + PresencePenalty param.Opt[float64] `json:"presence_penalty,omitzero"` + Seed param.Opt[int64] `json:"seed,omitzero"` + Suffix param.Opt[string] `json:"suffix,omitzero"` + Temperature param.Opt[float64] `json:"temperature,omitzero"` + TopP param.Opt[float64] `json:"top_p,omitzero"` + User param.Opt[string] `json:"user,omitzero"` + LogitBias map[string]float64 `json:"logit_bias,omitzero"` + Stop CompletionNewParamsStopUnion `json:"stop,omitzero"` + StreamOptions map[string]any `json:"stream_options,omitzero"` paramObj } @@ -279,15 +290,15 @@ func (r *CompletionNewParams) UnmarshalJSON(data []byte) error { // // Use [param.IsOmitted] to confirm if a field is set. type CompletionNewParamsPromptUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfStringArray []string `json:",omitzero,inline"` - OfIntArray []int64 `json:",omitzero,inline"` - OfArrayOfIntArray [][]int64 `json:",omitzero,inline"` + OfString param.Opt[string] `json:",omitzero,inline"` + OfListString []string `json:",omitzero,inline"` + OfListInteger []int64 `json:",omitzero,inline"` + OfListArray [][]int64 `json:",omitzero,inline"` paramUnion } func (u CompletionNewParamsPromptUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfStringArray, u.OfIntArray, u.OfArrayOfIntArray) + return param.MarshalUnion(u, u.OfString, u.OfListString, u.OfListInteger, u.OfListArray) } func (u *CompletionNewParamsPromptUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) @@ -296,12 +307,12 @@ func (u *CompletionNewParamsPromptUnion) UnmarshalJSON(data []byte) error { func (u *CompletionNewParamsPromptUnion) asAny() any { if !param.IsOmitted(u.OfString) { return &u.OfString.Value - } else if !param.IsOmitted(u.OfStringArray) { - return &u.OfStringArray - } else if !param.IsOmitted(u.OfIntArray) { - return &u.OfIntArray - } else if !param.IsOmitted(u.OfArrayOfIntArray) { - return &u.OfArrayOfIntArray + } else if !param.IsOmitted(u.OfListString) { + return &u.OfListString + } else if !param.IsOmitted(u.OfListInteger) { + return &u.OfListInteger + } else if !param.IsOmitted(u.OfListArray) { + return &u.OfListArray } return nil } @@ -310,13 +321,13 @@ func (u *CompletionNewParamsPromptUnion) asAny() any { // // Use [param.IsOmitted] to confirm if a field is set. type CompletionNewParamsStopUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfStringArray []string `json:",omitzero,inline"` + OfString param.Opt[string] `json:",omitzero,inline"` + OfListString []string `json:",omitzero,inline"` paramUnion } func (u CompletionNewParamsStopUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfStringArray) + return param.MarshalUnion(u, u.OfString, u.OfListString) } func (u *CompletionNewParamsStopUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) @@ -325,39 +336,8 @@ func (u *CompletionNewParamsStopUnion) UnmarshalJSON(data []byte) error { func (u *CompletionNewParamsStopUnion) asAny() any { if !param.IsOmitted(u.OfString) { return &u.OfString.Value - } else if !param.IsOmitted(u.OfStringArray) { - return &u.OfStringArray - } - return nil -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type CompletionNewParamsStreamOptionUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u CompletionNewParamsStreamOptionUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *CompletionNewParamsStreamOptionUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *CompletionNewParamsStreamOptionUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray + } else if !param.IsOmitted(u.OfListString) { + return &u.OfListString } return nil } diff --git a/completion_test.go b/completion_test.go index 9f15245..6335e0d 100644 --- a/completion_test.go +++ b/completion_test.go @@ -49,10 +49,8 @@ func TestCompletionNewWithOptionalParams(t *testing.T) { Stop: llamastackclient.CompletionNewParamsStopUnion{ OfString: llamastackclient.String("string"), }, - StreamOptions: map[string]llamastackclient.CompletionNewParamsStreamOptionUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + StreamOptions: map[string]any{ + "foo": "bar", }, Suffix: llamastackclient.String("suffix"), Temperature: llamastackclient.Float(0), diff --git a/conversation.go b/conversation.go index ba75c12..be75931 100644 --- a/conversation.go +++ b/conversation.go @@ -20,7 +20,6 @@ import ( "github.com/llamastack/llama-stack-client-go/option" "github.com/llamastack/llama-stack-client-go/packages/param" "github.com/llamastack/llama-stack-client-go/packages/respjson" - "github.com/llamastack/llama-stack-client-go/shared/constant" ) // ConversationService contains methods and other services that help with @@ -44,7 +43,9 @@ func NewConversationService(opts ...option.RequestOption) (r ConversationService return } -// Create a conversation. Create a conversation. +// Create a conversation. +// +// Create a conversation. func (r *ConversationService) New(ctx context.Context, body ConversationNewParams, opts ...option.RequestOption) (res *ConversationObject, err error) { opts = slices.Concat(r.Options, opts) path := "v1/conversations" @@ -52,7 +53,9 @@ func (r *ConversationService) New(ctx context.Context, body ConversationNewParam return } -// Retrieve a conversation. Get a conversation with the given ID. +// Retrieve a conversation. +// +// Get a conversation with the given ID. func (r *ConversationService) Get(ctx context.Context, conversationID string, opts ...option.RequestOption) (res *ConversationObject, err error) { opts = slices.Concat(r.Options, opts) if conversationID == "" { @@ -64,7 +67,9 @@ func (r *ConversationService) Get(ctx context.Context, conversationID string, op return } -// Update a conversation. Update a conversation's metadata with the given ID. +// Update a conversation. +// +// Update a conversation's metadata with the given ID. func (r *ConversationService) Update(ctx context.Context, conversationID string, body ConversationUpdateParams, opts ...option.RequestOption) (res *ConversationObject, err error) { opts = slices.Concat(r.Options, opts) if conversationID == "" { @@ -76,7 +81,9 @@ func (r *ConversationService) Update(ctx context.Context, conversationID string, return } -// Delete a conversation. Delete a conversation with the given ID. +// Delete a conversation. +// +// Delete a conversation with the given ID. func (r *ConversationService) Delete(ctx context.Context, conversationID string, opts ...option.RequestOption) (res *ConversationDeleteResponse, err error) { opts = slices.Concat(r.Options, opts) if conversationID == "" { @@ -90,18 +97,29 @@ func (r *ConversationService) Delete(ctx context.Context, conversationID string, // OpenAI-compatible conversation object. type ConversationObject struct { - ID string `json:"id,required"` - CreatedAt int64 `json:"created_at,required"` - Object constant.Conversation `json:"object,required"` - Items []any `json:"items"` - Metadata map[string]string `json:"metadata"` + // The unique ID of the conversation. + ID string `json:"id,required"` + // The time at which the conversation was created, measured in seconds since the + // Unix epoch. + CreatedAt int64 `json:"created_at,required"` + // Initial items to include in the conversation context. You may add up to 20 items + // at a time. + Items []map[string]any `json:"items,nullable"` + // Set of 16 key-value pairs that can be attached to an object. This can be useful + // for storing additional information about the object in a structured format, and + // querying for objects via API or the dashboard. + Metadata map[string]string `json:"metadata,nullable"` + // The object type, which is always conversation. + // + // Any of "conversation". + Object ConversationObjectObject `json:"object"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field CreatedAt respjson.Field - Object respjson.Field Items respjson.Field Metadata respjson.Field + Object respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -113,11 +131,21 @@ func (r *ConversationObject) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +// The object type, which is always conversation. +type ConversationObjectObject string + +const ( + ConversationObjectObjectConversation ConversationObjectObject = "conversation" +) + // Response for deleted conversation. type ConversationDeleteResponse struct { - ID string `json:"id,required"` - Deleted bool `json:"deleted,required"` - Object string `json:"object,required"` + // The deleted conversation identifier + ID string `json:"id,required"` + // Whether the object was deleted + Deleted bool `json:"deleted"` + // Object type + Object string `json:"object"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -135,10 +163,8 @@ func (r *ConversationDeleteResponse) UnmarshalJSON(data []byte) error { } type ConversationNewParams struct { - // Initial items to include in the conversation context. - Items []ConversationNewParamsItemUnion `json:"items,omitzero"` - // Set of key-value pairs that can be attached to an object. - Metadata map[string]string `json:"metadata,omitzero"` + Items []ConversationNewParamsItemUnion `json:"items,omitzero"` + Metadata map[string]string `json:"metadata,omitzero"` paramObj } @@ -215,7 +241,7 @@ func (u ConversationNewParamsItemUnion) GetContent() *ConversationNewParamsItemM // Returns a pointer to the underlying variant's property, if present. func (u ConversationNewParamsItemUnion) GetRole() *string { if vt := u.OfMessage; vt != nil { - return (*string)(&vt.Role) + return &vt.Role } return nil } @@ -276,30 +302,6 @@ func (u ConversationNewParamsItemUnion) GetTools() []ConversationNewParamsItemMc return nil } -// Returns a pointer to the underlying variant's property, if present. -func (u ConversationNewParamsItemUnion) GetType() *string { - if vt := u.OfMessage; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfWebSearchCall; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfFileSearchCall; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfFunctionCall; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfFunctionCallOutput; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfMcpApprovalRequest; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfMcpApprovalResponse; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfMcpCall; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfMcpListTools; vt != nil { - return (*string)(&vt.Type) - } - return nil -} - // Returns a pointer to the underlying variant's property, if present. func (u ConversationNewParamsItemUnion) GetID() *string { if vt := u.OfMessage; vt != nil && vt.ID.Valid() { @@ -340,6 +342,30 @@ func (u ConversationNewParamsItemUnion) GetStatus() *string { return nil } +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemUnion) GetType() *string { + if vt := u.OfMessage; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfWebSearchCall; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfFileSearchCall; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfFunctionCall; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfFunctionCallOutput; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfMcpApprovalRequest; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfMcpApprovalResponse; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfMcpCall; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfMcpListTools; vt != nil { + return (*string)(&vt.Type) + } + return nil +} + // Returns a pointer to the underlying variant's property, if present. func (u ConversationNewParamsItemUnion) GetArguments() *string { if vt := u.OfFunctionCall; vt != nil { @@ -415,15 +441,15 @@ func init() { // under one type because the Responses API gives them all the same "type" value, // and there is no way to tell them apart in certain scenarios. // -// The properties Content, Role, Type are required. +// The properties Content, Role are required. type ConversationNewParamsItemMessage struct { Content ConversationNewParamsItemMessageContentUnion `json:"content,omitzero,required"` // Any of "system", "developer", "user", "assistant". - Role ConversationNewParamsItemMessageRole `json:"role,omitzero,required"` - ID param.Opt[string] `json:"id,omitzero"` - Status param.Opt[string] `json:"status,omitzero"` - // This field can be elided, and will marshal its zero value as "message". - Type constant.Message `json:"type,required"` + Role string `json:"role,omitzero,required"` + ID param.Opt[string] `json:"id,omitzero"` + Status param.Opt[string] `json:"status,omitzero"` + // Any of "message". + Type string `json:"type,omitzero"` paramObj } @@ -435,18 +461,27 @@ func (r *ConversationNewParamsItemMessage) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ConversationNewParamsItemMessage]( + "role", "system", "developer", "user", "assistant", + ) + apijson.RegisterFieldValidator[ConversationNewParamsItemMessage]( + "type", "message", + ) +} + // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. type ConversationNewParamsItemMessageContentUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfConversationNewsItemMessageContentArray []ConversationNewParamsItemMessageContentArrayItemUnion `json:",omitzero,inline"` - OfVariant2 []ConversationNewParamsItemMessageContentArrayItemUnion `json:",omitzero,inline"` + OfString param.Opt[string] `json:",omitzero,inline"` + OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile []ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion `json:",omitzero,inline"` + OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal []ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion `json:",omitzero,inline"` paramUnion } func (u ConversationNewParamsItemMessageContentUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfConversationNewsItemMessageContentArray, u.OfVariant2) + return param.MarshalUnion(u, u.OfString, u.OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile, u.OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal) } func (u *ConversationNewParamsItemMessageContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) @@ -455,10 +490,10 @@ func (u *ConversationNewParamsItemMessageContentUnion) UnmarshalJSON(data []byte func (u *ConversationNewParamsItemMessageContentUnion) asAny() any { if !param.IsOmitted(u.OfString) { return &u.OfString.Value - } else if !param.IsOmitted(u.OfConversationNewsItemMessageContentArray) { - return &u.OfConversationNewsItemMessageContentArray - } else if !param.IsOmitted(u.OfVariant2) { - return &u.OfVariant2 + } else if !param.IsOmitted(u.OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile) { + return &u.OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile + } else if !param.IsOmitted(u.OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal) { + return &u.OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal } return nil } @@ -466,21 +501,21 @@ func (u *ConversationNewParamsItemMessageContentUnion) asAny() any { // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. -type ConversationNewParamsItemMessageContentArrayItemUnion struct { - OfInputText *ConversationNewParamsItemMessageContentArrayItemInputText `json:",omitzero,inline"` - OfInputImage *ConversationNewParamsItemMessageContentArrayItemInputImage `json:",omitzero,inline"` - OfInputFile *ConversationNewParamsItemMessageContentArrayItemInputFile `json:",omitzero,inline"` +type ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion struct { + OfInputText *ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText `json:",omitzero,inline"` + OfInputImage *ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage `json:",omitzero,inline"` + OfInputFile *ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile `json:",omitzero,inline"` paramUnion } -func (u ConversationNewParamsItemMessageContentArrayItemUnion) MarshalJSON() ([]byte, error) { +func (u ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) MarshalJSON() ([]byte, error) { return param.MarshalUnion(u, u.OfInputText, u.OfInputImage, u.OfInputFile) } -func (u *ConversationNewParamsItemMessageContentArrayItemUnion) UnmarshalJSON(data []byte) error { +func (u *ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *ConversationNewParamsItemMessageContentArrayItemUnion) asAny() any { +func (u *ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) asAny() any { if !param.IsOmitted(u.OfInputText) { return u.OfInputText } else if !param.IsOmitted(u.OfInputImage) { @@ -492,7 +527,7 @@ func (u *ConversationNewParamsItemMessageContentArrayItemUnion) asAny() any { } // Returns a pointer to the underlying variant's property, if present. -func (u ConversationNewParamsItemMessageContentArrayItemUnion) GetText() *string { +func (u ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetText() *string { if vt := u.OfInputText; vt != nil { return &vt.Text } @@ -500,15 +535,15 @@ func (u ConversationNewParamsItemMessageContentArrayItemUnion) GetText() *string } // Returns a pointer to the underlying variant's property, if present. -func (u ConversationNewParamsItemMessageContentArrayItemUnion) GetDetail() *string { +func (u ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetDetail() *string { if vt := u.OfInputImage; vt != nil { - return (*string)(&vt.Detail) + return &vt.Detail } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u ConversationNewParamsItemMessageContentArrayItemUnion) GetImageURL() *string { +func (u ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetImageURL() *string { if vt := u.OfInputImage; vt != nil && vt.ImageURL.Valid() { return &vt.ImageURL.Value } @@ -516,7 +551,7 @@ func (u ConversationNewParamsItemMessageContentArrayItemUnion) GetImageURL() *st } // Returns a pointer to the underlying variant's property, if present. -func (u ConversationNewParamsItemMessageContentArrayItemUnion) GetFileData() *string { +func (u ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetFileData() *string { if vt := u.OfInputFile; vt != nil && vt.FileData.Valid() { return &vt.FileData.Value } @@ -524,7 +559,7 @@ func (u ConversationNewParamsItemMessageContentArrayItemUnion) GetFileData() *st } // Returns a pointer to the underlying variant's property, if present. -func (u ConversationNewParamsItemMessageContentArrayItemUnion) GetFileURL() *string { +func (u ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetFileURL() *string { if vt := u.OfInputFile; vt != nil && vt.FileURL.Valid() { return &vt.FileURL.Value } @@ -532,7 +567,7 @@ func (u ConversationNewParamsItemMessageContentArrayItemUnion) GetFileURL() *str } // Returns a pointer to the underlying variant's property, if present. -func (u ConversationNewParamsItemMessageContentArrayItemUnion) GetFilename() *string { +func (u ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetFilename() *string { if vt := u.OfInputFile; vt != nil && vt.Filename.Valid() { return &vt.Filename.Value } @@ -540,7 +575,7 @@ func (u ConversationNewParamsItemMessageContentArrayItemUnion) GetFilename() *st } // Returns a pointer to the underlying variant's property, if present. -func (u ConversationNewParamsItemMessageContentArrayItemUnion) GetType() *string { +func (u ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetType() *string { if vt := u.OfInputText; vt != nil { return (*string)(&vt.Type) } else if vt := u.OfInputImage; vt != nil { @@ -552,7 +587,7 @@ func (u ConversationNewParamsItemMessageContentArrayItemUnion) GetType() *string } // Returns a pointer to the underlying variant's property, if present. -func (u ConversationNewParamsItemMessageContentArrayItemUnion) GetFileID() *string { +func (u ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetFileID() *string { if vt := u.OfInputImage; vt != nil && vt.FileID.Valid() { return &vt.FileID.Value } else if vt := u.OfInputFile; vt != nil && vt.FileID.Valid() { @@ -562,119 +597,446 @@ func (u ConversationNewParamsItemMessageContentArrayItemUnion) GetFileID() *stri } func init() { - apijson.RegisterUnion[ConversationNewParamsItemMessageContentArrayItemUnion]( + apijson.RegisterUnion[ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion]( "type", - apijson.Discriminator[ConversationNewParamsItemMessageContentArrayItemInputText]("input_text"), - apijson.Discriminator[ConversationNewParamsItemMessageContentArrayItemInputImage]("input_image"), - apijson.Discriminator[ConversationNewParamsItemMessageContentArrayItemInputFile]("input_file"), + apijson.Discriminator[ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText]("input_text"), + apijson.Discriminator[ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]("input_image"), + apijson.Discriminator[ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]("input_file"), ) } // Text content for input messages in OpenAI response format. // -// The properties Text, Type are required. -type ConversationNewParamsItemMessageContentArrayItemInputText struct { - // The text content of the input message +// The property Text is required. +type ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText struct { Text string `json:"text,required"` - // Content type identifier, always "input_text" - // - // This field can be elided, and will marshal its zero value as "input_text". - Type constant.InputText `json:"type,required"` + // Any of "input_text". + Type string `json:"type,omitzero"` paramObj } -func (r ConversationNewParamsItemMessageContentArrayItemInputText) MarshalJSON() (data []byte, err error) { - type shadow ConversationNewParamsItemMessageContentArrayItemInputText +func (r ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ConversationNewParamsItemMessageContentArrayItemInputText) UnmarshalJSON(data []byte) error { +func (r *ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText]( + "type", "input_text", + ) +} + // Image content for input messages in OpenAI response format. -// -// The properties Detail, Type are required. -type ConversationNewParamsItemMessageContentArrayItemInputImage struct { - // Level of detail for image processing, can be "low", "high", or "auto" - // - // Any of "low", "high", "auto". - Detail ConversationNewParamsItemMessageContentArrayItemInputImageDetail `json:"detail,omitzero,required"` - // (Optional) The ID of the file to be sent to the model. - FileID param.Opt[string] `json:"file_id,omitzero"` - // (Optional) URL of the image content +type ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage struct { + FileID param.Opt[string] `json:"file_id,omitzero"` ImageURL param.Opt[string] `json:"image_url,omitzero"` - // Content type identifier, always "input_image" - // - // This field can be elided, and will marshal its zero value as "input_image". - Type constant.InputImage `json:"type,required"` + // Any of "low", "high", "auto". + Detail string `json:"detail,omitzero"` + // Any of "input_image". + Type string `json:"type,omitzero"` paramObj } -func (r ConversationNewParamsItemMessageContentArrayItemInputImage) MarshalJSON() (data []byte, err error) { - type shadow ConversationNewParamsItemMessageContentArrayItemInputImage +func (r ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ConversationNewParamsItemMessageContentArrayItemInputImage) UnmarshalJSON(data []byte) error { +func (r *ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ConversationNewParamsItemMessageContentArrayItemInputImageDetail string - -const ( - ConversationNewParamsItemMessageContentArrayItemInputImageDetailLow ConversationNewParamsItemMessageContentArrayItemInputImageDetail = "low" - ConversationNewParamsItemMessageContentArrayItemInputImageDetailHigh ConversationNewParamsItemMessageContentArrayItemInputImageDetail = "high" - ConversationNewParamsItemMessageContentArrayItemInputImageDetailAuto ConversationNewParamsItemMessageContentArrayItemInputImageDetail = "auto" -) +func init() { + apijson.RegisterFieldValidator[ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]( + "detail", "low", "high", "auto", + ) + apijson.RegisterFieldValidator[ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]( + "type", "input_image", + ) +} // File content for input messages in OpenAI response format. -// -// The property Type is required. -type ConversationNewParamsItemMessageContentArrayItemInputFile struct { - // The data of the file to be sent to the model. +type ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile struct { FileData param.Opt[string] `json:"file_data,omitzero"` - // (Optional) The ID of the file to be sent to the model. - FileID param.Opt[string] `json:"file_id,omitzero"` - // The URL of the file to be sent to the model. - FileURL param.Opt[string] `json:"file_url,omitzero"` - // The name of the file to be sent to the model. + FileID param.Opt[string] `json:"file_id,omitzero"` + FileURL param.Opt[string] `json:"file_url,omitzero"` Filename param.Opt[string] `json:"filename,omitzero"` - // The type of the input item. Always `input_file`. - // - // This field can be elided, and will marshal its zero value as "input_file". - Type constant.InputFile `json:"type,required"` + // Any of "input_file". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ConversationNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]( + "type", "input_file", + ) +} + +// Only one field can be non-zero. +// +// Use [param.IsOmitted] to confirm if a field is set. +type ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion struct { + OfOutputText *ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText `json:",omitzero,inline"` + OfRefusal *ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal `json:",omitzero,inline"` + paramUnion +} + +func (u ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfOutputText, u.OfRefusal) +} +func (u *ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) asAny() any { + if !param.IsOmitted(u.OfOutputText) { + return u.OfOutputText + } else if !param.IsOmitted(u.OfRefusal) { + return u.OfRefusal + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) GetText() *string { + if vt := u.OfOutputText; vt != nil { + return &vt.Text + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) GetAnnotations() []ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion { + if vt := u.OfOutputText; vt != nil { + return vt.Annotations + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) GetRefusal() *string { + if vt := u.OfRefusal; vt != nil { + return &vt.Refusal + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) GetType() *string { + if vt := u.OfOutputText; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfRefusal; vt != nil { + return (*string)(&vt.Type) + } + return nil +} + +func init() { + apijson.RegisterUnion[ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion]( + "type", + apijson.Discriminator[ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]("output_text"), + apijson.Discriminator[ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]("refusal"), + ) +} + +// The property Text is required. +type ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText struct { + Text string `json:"text,required"` + Annotations []ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion `json:"annotations,omitzero"` + // Any of "output_text". + Type string `json:"type,omitzero"` paramObj } -func (r ConversationNewParamsItemMessageContentArrayItemInputFile) MarshalJSON() (data []byte, err error) { - type shadow ConversationNewParamsItemMessageContentArrayItemInputFile +func (r ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ConversationNewParamsItemMessageContentArrayItemInputFile) UnmarshalJSON(data []byte) error { +func (r *ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ConversationNewParamsItemMessageRole string +func init() { + apijson.RegisterFieldValidator[ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]( + "type", "output_text", + ) +} -const ( - ConversationNewParamsItemMessageRoleSystem ConversationNewParamsItemMessageRole = "system" - ConversationNewParamsItemMessageRoleDeveloper ConversationNewParamsItemMessageRole = "developer" - ConversationNewParamsItemMessageRoleUser ConversationNewParamsItemMessageRole = "user" - ConversationNewParamsItemMessageRoleAssistant ConversationNewParamsItemMessageRole = "assistant" -) +// Only one field can be non-zero. +// +// Use [param.IsOmitted] to confirm if a field is set. +type ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion struct { + OfFileCitation *ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation `json:",omitzero,inline"` + OfURLCitation *ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation `json:",omitzero,inline"` + OfContainerFileCitation *ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation `json:",omitzero,inline"` + OfFilePath *ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath `json:",omitzero,inline"` + paramUnion +} + +func (u ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfFileCitation, u.OfURLCitation, u.OfContainerFileCitation, u.OfFilePath) +} +func (u *ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) asAny() any { + if !param.IsOmitted(u.OfFileCitation) { + return u.OfFileCitation + } else if !param.IsOmitted(u.OfURLCitation) { + return u.OfURLCitation + } else if !param.IsOmitted(u.OfContainerFileCitation) { + return u.OfContainerFileCitation + } else if !param.IsOmitted(u.OfFilePath) { + return u.OfFilePath + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetTitle() *string { + if vt := u.OfURLCitation; vt != nil { + return &vt.Title + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetURL() *string { + if vt := u.OfURLCitation; vt != nil { + return &vt.URL + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetContainerID() *string { + if vt := u.OfContainerFileCitation; vt != nil { + return &vt.ContainerID + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetFileID() *string { + if vt := u.OfFileCitation; vt != nil { + return (*string)(&vt.FileID) + } else if vt := u.OfContainerFileCitation; vt != nil { + return (*string)(&vt.FileID) + } else if vt := u.OfFilePath; vt != nil { + return (*string)(&vt.FileID) + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetFilename() *string { + if vt := u.OfFileCitation; vt != nil { + return (*string)(&vt.Filename) + } else if vt := u.OfContainerFileCitation; vt != nil { + return (*string)(&vt.Filename) + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetIndex() *int64 { + if vt := u.OfFileCitation; vt != nil { + return (*int64)(&vt.Index) + } else if vt := u.OfFilePath; vt != nil { + return (*int64)(&vt.Index) + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetType() *string { + if vt := u.OfFileCitation; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfURLCitation; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfContainerFileCitation; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfFilePath; vt != nil { + return (*string)(&vt.Type) + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetEndIndex() *int64 { + if vt := u.OfURLCitation; vt != nil { + return (*int64)(&vt.EndIndex) + } else if vt := u.OfContainerFileCitation; vt != nil { + return (*int64)(&vt.EndIndex) + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetStartIndex() *int64 { + if vt := u.OfURLCitation; vt != nil { + return (*int64)(&vt.StartIndex) + } else if vt := u.OfContainerFileCitation; vt != nil { + return (*int64)(&vt.StartIndex) + } + return nil +} + +func init() { + apijson.RegisterUnion[ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion]( + "type", + apijson.Discriminator[ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation]("file_citation"), + apijson.Discriminator[ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]("url_citation"), + apijson.Discriminator[ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation]("container_file_citation"), + apijson.Discriminator[ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath]("file_path"), + ) +} + +// File citation annotation for referencing specific files in response content. +// +// The properties FileID, Filename, Index are required. +type ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation struct { + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Index int64 `json:"index,required"` + // Any of "file_citation". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation]( + "type", "file_citation", + ) +} + +// URL citation annotation for referencing external web resources. +// +// The properties EndIndex, StartIndex, Title, URL are required. +type ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation struct { + EndIndex int64 `json:"end_index,required"` + StartIndex int64 `json:"start_index,required"` + Title string `json:"title,required"` + URL string `json:"url,required"` + // Any of "url_citation". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]( + "type", "url_citation", + ) +} + +// The properties ContainerID, EndIndex, FileID, Filename, StartIndex are required. +type ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation struct { + ContainerID string `json:"container_id,required"` + EndIndex int64 `json:"end_index,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + StartIndex int64 `json:"start_index,required"` + // Any of "container_file_citation". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation]( + "type", "container_file_citation", + ) +} + +// The properties FileID, Index are required. +type ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath struct { + FileID string `json:"file_id,required"` + Index int64 `json:"index,required"` + // Any of "file_path". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath]( + "type", "file_path", + ) +} + +// Refusal content within a streamed response part. +// +// The property Refusal is required. +type ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal struct { + Refusal string `json:"refusal,required"` + // Any of "refusal". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ConversationNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]( + "type", "refusal", + ) +} // Web search tool call output message for OpenAI responses. // -// The properties ID, Status, Type are required. +// The properties ID, Status are required. type ConversationNewParamsItemWebSearchCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // Current status of the web search operation + ID string `json:"id,required"` Status string `json:"status,required"` - // Tool call type identifier, always "web_search_call" - // - // This field can be elided, and will marshal its zero value as "web_search_call". - Type constant.WebSearchCall `json:"type,required"` + // Any of "web_search_call". + Type string `json:"type,omitzero"` paramObj } @@ -686,22 +1048,22 @@ func (r *ConversationNewParamsItemWebSearchCall) UnmarshalJSON(data []byte) erro return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ConversationNewParamsItemWebSearchCall]( + "type", "web_search_call", + ) +} + // File search tool call output message for OpenAI responses. // -// The properties ID, Queries, Status, Type are required. +// The properties ID, Queries, Status are required. type ConversationNewParamsItemFileSearchCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // List of search queries executed - Queries []string `json:"queries,omitzero,required"` - // Current status of the file search operation - Status string `json:"status,required"` - // (Optional) Search results returned by the file search operation + ID string `json:"id,required"` + Queries []string `json:"queries,omitzero,required"` + Status string `json:"status,required"` Results []ConversationNewParamsItemFileSearchCallResult `json:"results,omitzero"` - // Tool call type identifier, always "file_search_call" - // - // This field can be elided, and will marshal its zero value as "file_search_call". - Type constant.FileSearchCall `json:"type,required"` + // Any of "file_search_call". + Type string `json:"type,omitzero"` paramObj } @@ -713,20 +1075,21 @@ func (r *ConversationNewParamsItemFileSearchCall) UnmarshalJSON(data []byte) err return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ConversationNewParamsItemFileSearchCall]( + "type", "file_search_call", + ) +} + // Search results returned by the file search operation. // // The properties Attributes, FileID, Filename, Score, Text are required. type ConversationNewParamsItemFileSearchCallResult struct { - // (Optional) Key-value attributes associated with the file - Attributes map[string]ConversationNewParamsItemFileSearchCallResultAttributeUnion `json:"attributes,omitzero,required"` - // Unique identifier of the file containing the result - FileID string `json:"file_id,required"` - // Name of the file containing the result - Filename string `json:"filename,required"` - // Relevance score for this search result (between 0 and 1) - Score float64 `json:"score,required"` - // Text content of the search result - Text string `json:"text,required"` + Attributes map[string]any `json:"attributes,omitzero,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Score float64 `json:"score,required"` + Text string `json:"text,required"` paramObj } @@ -738,55 +1101,17 @@ func (r *ConversationNewParamsItemFileSearchCallResult) UnmarshalJSON(data []byt return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ConversationNewParamsItemFileSearchCallResultAttributeUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u ConversationNewParamsItemFileSearchCallResultAttributeUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *ConversationNewParamsItemFileSearchCallResultAttributeUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ConversationNewParamsItemFileSearchCallResultAttributeUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - // Function tool call output message for OpenAI responses. // -// The properties Arguments, CallID, Name, Type are required. +// The properties Arguments, CallID, Name are required. type ConversationNewParamsItemFunctionCall struct { - // JSON string containing the function arguments - Arguments string `json:"arguments,required"` - // Unique identifier for the function call - CallID string `json:"call_id,required"` - // Name of the function being called - Name string `json:"name,required"` - // (Optional) Additional identifier for the tool call - ID param.Opt[string] `json:"id,omitzero"` - // (Optional) Current status of the function call execution - Status param.Opt[string] `json:"status,omitzero"` - // Tool call type identifier, always "function_call" - // - // This field can be elided, and will marshal its zero value as "function_call". - Type constant.FunctionCall `json:"type,required"` + Arguments string `json:"arguments,required"` + CallID string `json:"call_id,required"` + Name string `json:"name,required"` + ID param.Opt[string] `json:"id,omitzero"` + Status param.Opt[string] `json:"status,omitzero"` + // Any of "function_call". + Type string `json:"type,omitzero"` paramObj } @@ -798,18 +1123,23 @@ func (r *ConversationNewParamsItemFunctionCall) UnmarshalJSON(data []byte) error return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ConversationNewParamsItemFunctionCall]( + "type", "function_call", + ) +} + // This represents the output of a function call that gets passed back to the // model. // -// The properties CallID, Output, Type are required. +// The properties CallID, Output are required. type ConversationNewParamsItemFunctionCallOutput struct { CallID string `json:"call_id,required"` Output string `json:"output,required"` ID param.Opt[string] `json:"id,omitzero"` Status param.Opt[string] `json:"status,omitzero"` - // This field can be elided, and will marshal its zero value as - // "function_call_output". - Type constant.FunctionCallOutput `json:"type,required"` + // Any of "function_call_output". + Type string `json:"type,omitzero"` paramObj } @@ -821,17 +1151,22 @@ func (r *ConversationNewParamsItemFunctionCallOutput) UnmarshalJSON(data []byte) return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ConversationNewParamsItemFunctionCallOutput]( + "type", "function_call_output", + ) +} + // A request for human approval of a tool invocation. // -// The properties ID, Arguments, Name, ServerLabel, Type are required. +// The properties ID, Arguments, Name, ServerLabel are required. type ConversationNewParamsItemMcpApprovalRequest struct { ID string `json:"id,required"` Arguments string `json:"arguments,required"` Name string `json:"name,required"` ServerLabel string `json:"server_label,required"` - // This field can be elided, and will marshal its zero value as - // "mcp_approval_request". - Type constant.McpApprovalRequest `json:"type,required"` + // Any of "mcp_approval_request". + Type string `json:"type,omitzero"` paramObj } @@ -843,17 +1178,22 @@ func (r *ConversationNewParamsItemMcpApprovalRequest) UnmarshalJSON(data []byte) return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ConversationNewParamsItemMcpApprovalRequest]( + "type", "mcp_approval_request", + ) +} + // A response to an MCP approval request. // -// The properties ApprovalRequestID, Approve, Type are required. +// The properties ApprovalRequestID, Approve are required. type ConversationNewParamsItemMcpApprovalResponse struct { ApprovalRequestID string `json:"approval_request_id,required"` Approve bool `json:"approve,required"` ID param.Opt[string] `json:"id,omitzero"` Reason param.Opt[string] `json:"reason,omitzero"` - // This field can be elided, and will marshal its zero value as - // "mcp_approval_response". - Type constant.McpApprovalResponse `json:"type,required"` + // Any of "mcp_approval_response". + Type string `json:"type,omitzero"` paramObj } @@ -865,26 +1205,24 @@ func (r *ConversationNewParamsItemMcpApprovalResponse) UnmarshalJSON(data []byte return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ConversationNewParamsItemMcpApprovalResponse]( + "type", "mcp_approval_response", + ) +} + // Model Context Protocol (MCP) call output message for OpenAI responses. // -// The properties ID, Arguments, Name, ServerLabel, Type are required. +// The properties ID, Arguments, Name, ServerLabel are required. type ConversationNewParamsItemMcpCall struct { - // Unique identifier for this MCP call - ID string `json:"id,required"` - // JSON string containing the MCP call arguments - Arguments string `json:"arguments,required"` - // Name of the MCP method being called - Name string `json:"name,required"` - // Label identifying the MCP server handling the call - ServerLabel string `json:"server_label,required"` - // (Optional) Error message if the MCP call failed - Error param.Opt[string] `json:"error,omitzero"` - // (Optional) Output result from the successful MCP call - Output param.Opt[string] `json:"output,omitzero"` - // Tool call type identifier, always "mcp_call" - // - // This field can be elided, and will marshal its zero value as "mcp_call". - Type constant.McpCall `json:"type,required"` + ID string `json:"id,required"` + Arguments string `json:"arguments,required"` + Name string `json:"name,required"` + ServerLabel string `json:"server_label,required"` + Error param.Opt[string] `json:"error,omitzero"` + Output param.Opt[string] `json:"output,omitzero"` + // Any of "mcp_call". + Type string `json:"type,omitzero"` paramObj } @@ -896,20 +1234,21 @@ func (r *ConversationNewParamsItemMcpCall) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ConversationNewParamsItemMcpCall]( + "type", "mcp_call", + ) +} + // MCP list tools output message containing available tools from an MCP server. // -// The properties ID, ServerLabel, Tools, Type are required. +// The properties ID, ServerLabel, Tools are required. type ConversationNewParamsItemMcpListTools struct { - // Unique identifier for this MCP list tools operation - ID string `json:"id,required"` - // Label identifying the MCP server providing the tools - ServerLabel string `json:"server_label,required"` - // List of available tools provided by the MCP server - Tools []ConversationNewParamsItemMcpListToolsTool `json:"tools,omitzero,required"` - // Tool call type identifier, always "mcp_list_tools" - // - // This field can be elided, and will marshal its zero value as "mcp_list_tools". - Type constant.McpListTools `json:"type,required"` + ID string `json:"id,required"` + ServerLabel string `json:"server_label,required"` + Tools []ConversationNewParamsItemMcpListToolsTool `json:"tools,omitzero,required"` + // Any of "mcp_list_tools". + Type string `json:"type,omitzero"` paramObj } @@ -921,15 +1260,18 @@ func (r *ConversationNewParamsItemMcpListTools) UnmarshalJSON(data []byte) error return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ConversationNewParamsItemMcpListTools]( + "type", "mcp_list_tools", + ) +} + // Tool definition returned by MCP list tools operation. // // The properties InputSchema, Name are required. type ConversationNewParamsItemMcpListToolsTool struct { - // JSON schema defining the tool's input parameters - InputSchema map[string]ConversationNewParamsItemMcpListToolsToolInputSchemaUnion `json:"input_schema,omitzero,required"` - // Name of the tool - Name string `json:"name,required"` - // (Optional) Description of what the tool does + InputSchema map[string]any `json:"input_schema,omitzero,required"` + Name string `json:"name,required"` Description param.Opt[string] `json:"description,omitzero"` paramObj } @@ -942,39 +1284,7 @@ func (r *ConversationNewParamsItemMcpListToolsTool) UnmarshalJSON(data []byte) e return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ConversationNewParamsItemMcpListToolsToolInputSchemaUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u ConversationNewParamsItemMcpListToolsToolInputSchemaUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *ConversationNewParamsItemMcpListToolsToolInputSchemaUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ConversationNewParamsItemMcpListToolsToolInputSchemaUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - type ConversationUpdateParams struct { - // Set of key-value pairs that can be attached to an object. Metadata map[string]string `json:"metadata,omitzero,required"` paramObj } diff --git a/conversation_test.go b/conversation_test.go index 791bbb9..d2081c9 100644 --- a/conversation_test.go +++ b/conversation_test.go @@ -36,9 +36,10 @@ func TestConversationNewWithOptionalParams(t *testing.T) { Content: llamastackclient.ConversationNewParamsItemMessageContentUnion{ OfString: llamastackclient.String("string"), }, - Role: llamastackclient.ConversationNewParamsItemMessageRoleSystem, + Role: "system", ID: llamastackclient.String("id"), Status: llamastackclient.String("status"), + Type: "message", }, }}, Metadata: map[string]string{ diff --git a/conversationitem.go b/conversationitem.go index 2c2ea7e..d17b27d 100644 --- a/conversationitem.go +++ b/conversationitem.go @@ -24,7 +24,6 @@ import ( "github.com/llamastack/llama-stack-client-go/packages/pagination" "github.com/llamastack/llama-stack-client-go/packages/param" "github.com/llamastack/llama-stack-client-go/packages/respjson" - "github.com/llamastack/llama-stack-client-go/shared/constant" ) // ConversationItemService contains methods and other services that help with @@ -46,7 +45,9 @@ func NewConversationItemService(opts ...option.RequestOption) (r ConversationIte return } -// Create items. Create items in the conversation. +// Create items. +// +// Create items in the conversation. func (r *ConversationItemService) New(ctx context.Context, conversationID string, body ConversationItemNewParams, opts ...option.RequestOption) (res *ConversationItemNewResponse, err error) { opts = slices.Concat(r.Options, opts) if conversationID == "" { @@ -58,7 +59,9 @@ func (r *ConversationItemService) New(ctx context.Context, conversationID string return } -// List items. List items in the conversation. +// List items. +// +// List items in the conversation. func (r *ConversationItemService) List(ctx context.Context, conversationID string, query ConversationItemListParams, opts ...option.RequestOption) (res *pagination.OpenAICursorPage[ConversationItemListResponseUnion], err error) { var raw *http.Response opts = slices.Concat(r.Options, opts) @@ -80,13 +83,35 @@ func (r *ConversationItemService) List(ctx context.Context, conversationID strin return res, nil } -// List items. List items in the conversation. +// List items. +// +// List items in the conversation. func (r *ConversationItemService) ListAutoPaging(ctx context.Context, conversationID string, query ConversationItemListParams, opts ...option.RequestOption) *pagination.OpenAICursorPageAutoPager[ConversationItemListResponseUnion] { return pagination.NewOpenAICursorPageAutoPager(r.List(ctx, conversationID, query, opts...)) } -// Retrieve an item. Retrieve a conversation item. -func (r *ConversationItemService) Get(ctx context.Context, itemID string, query ConversationItemGetParams, opts ...option.RequestOption) (res *ConversationItemGetResponseUnion, err error) { +// Delete an item. +// +// Delete a conversation item. +func (r *ConversationItemService) Delete(ctx context.Context, itemID string, body ConversationItemDeleteParams, opts ...option.RequestOption) (res *ConversationItemDeleteResponse, err error) { + opts = slices.Concat(r.Options, opts) + if body.ConversationID == "" { + err = errors.New("missing required conversation_id parameter") + return + } + if itemID == "" { + err = errors.New("missing required item_id parameter") + return + } + path := fmt.Sprintf("v1/conversations/%s/items/%s", body.ConversationID, itemID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return +} + +// Retrieve an item. +// +// Retrieve a conversation item. +func (r *ConversationItemService) Get(ctx context.Context, itemID string, query ConversationItemGetParams, opts ...option.RequestOption) (res *ConversationItemGetResponse, err error) { opts = slices.Concat(r.Options, opts) if query.ConversationID == "" { err = errors.New("missing required conversation_id parameter") @@ -103,18 +128,23 @@ func (r *ConversationItemService) Get(ctx context.Context, itemID string, query // List of conversation items with pagination. type ConversationItemNewResponse struct { - Data []ConversationItemNewResponseDataUnion `json:"data,required"` - HasMore bool `json:"has_more,required"` - Object string `json:"object,required"` - FirstID string `json:"first_id"` - LastID string `json:"last_id"` + // List of conversation items + Data []ConversationItemNewResponseDataUnion `json:"data,required"` + // The ID of the first item in the list + FirstID string `json:"first_id,nullable"` + // Whether there are more items available + HasMore bool `json:"has_more"` + // The ID of the last item in the list + LastID string `json:"last_id,nullable"` + // Object type + Object string `json:"object"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Data respjson.Field - HasMore respjson.Field - Object respjson.Field FirstID respjson.Field + HasMore respjson.Field LastID respjson.Field + Object respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -145,13 +175,13 @@ type ConversationItemNewResponseDataUnion struct { // This field is from variant [ConversationItemNewResponseDataMessage]. Content ConversationItemNewResponseDataMessageContentUnion `json:"content"` // This field is from variant [ConversationItemNewResponseDataMessage]. - Role ConversationItemNewResponseDataMessageRole `json:"role"` + Role string `json:"role"` + ID string `json:"id"` + Status string `json:"status"` // Any of "message", "web_search_call", "file_search_call", "function_call", // "function_call_output", "mcp_approval_request", "mcp_approval_response", // "mcp_call", "mcp_list_tools". - Type string `json:"type"` - ID string `json:"id"` - Status string `json:"status"` + Type string `json:"type"` // This field is from variant [ConversationItemNewResponseDataFileSearchCall]. Queries []string `json:"queries"` // This field is from variant [ConversationItemNewResponseDataFileSearchCall]. @@ -174,9 +204,9 @@ type ConversationItemNewResponseDataUnion struct { JSON struct { Content respjson.Field Role respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field Queries respjson.Field Results respjson.Field Arguments respjson.Field @@ -308,17 +338,18 @@ func (r *ConversationItemNewResponseDataUnion) UnmarshalJSON(data []byte) error type ConversationItemNewResponseDataMessage struct { Content ConversationItemNewResponseDataMessageContentUnion `json:"content,required"` // Any of "system", "developer", "user", "assistant". - Role ConversationItemNewResponseDataMessageRole `json:"role,required"` - Type constant.Message `json:"type,required"` - ID string `json:"id"` - Status string `json:"status"` + Role string `json:"role,required"` + ID string `json:"id,nullable"` + Status string `json:"status,nullable"` + // Any of "message". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field Role respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -332,24 +363,31 @@ func (r *ConversationItemNewResponseDataMessage) UnmarshalJSON(data []byte) erro // ConversationItemNewResponseDataMessageContentUnion contains all possible // properties and values from [string], -// [[]ConversationItemNewResponseDataMessageContentArrayItemUnion], -// [[]ConversationItemNewResponseDataMessageContentArrayItemUnion]. +// [[]ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion], +// [[]ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString OfVariant2] +// will be valid: OfString +// OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile +// OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal] type ConversationItemNewResponseDataMessageContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ConversationItemNewResponseDataMessageContentArrayItemUnion] instead of an - // object. - OfVariant2 []ConversationItemNewResponseDataMessageContentArrayItemUnion `json:",inline"` - JSON struct { - OfString respjson.Field - OfVariant2 respjson.Field - raw string + // [[]ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion] + // instead of an object. + OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile []ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion `json:",inline"` + // This field will be present if the value is a + // [[]ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion] + // instead of an object. + OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal []ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile respjson.Field + OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal respjson.Field + raw string } `json:"-"` } @@ -358,12 +396,12 @@ func (u ConversationItemNewResponseDataMessageContentUnion) AsString() (v string return } -func (u ConversationItemNewResponseDataMessageContentUnion) AsConversationItemNewResponseDataMessageContentArray() (v []ConversationItemNewResponseDataMessageContentArrayItemUnion) { +func (u ConversationItemNewResponseDataMessageContentUnion) AsListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile() (v []ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ConversationItemNewResponseDataMessageContentUnion) AsVariant2() (v []ConversationItemNewResponseDataMessageContentArrayItemUnion) { +func (u ConversationItemNewResponseDataMessageContentUnion) AsListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal() (v []ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -375,37 +413,38 @@ func (r *ConversationItemNewResponseDataMessageContentUnion) UnmarshalJSON(data return apijson.UnmarshalRoot(data, r) } -// ConversationItemNewResponseDataMessageContentArrayItemUnion contains all -// possible properties and values from -// [ConversationItemNewResponseDataMessageContentArrayItemInputText], -// [ConversationItemNewResponseDataMessageContentArrayItemInputImage], -// [ConversationItemNewResponseDataMessageContentArrayItemInputFile]. +// ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion +// contains all possible properties and values from +// [ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText], +// [ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage], +// [ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. // -// Use the [ConversationItemNewResponseDataMessageContentArrayItemUnion.AsAny] +// Use the +// [ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny] // method to switch on the variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type ConversationItemNewResponseDataMessageContentArrayItemUnion struct { +type ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion struct { // This field is from variant - // [ConversationItemNewResponseDataMessageContentArrayItemInputText]. + // [ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText]. Text string `json:"text"` // Any of "input_text", "input_image", "input_file". Type string `json:"type"` // This field is from variant - // [ConversationItemNewResponseDataMessageContentArrayItemInputImage]. - Detail ConversationItemNewResponseDataMessageContentArrayItemInputImageDetail `json:"detail"` - FileID string `json:"file_id"` + // [ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]. + Detail string `json:"detail"` + FileID string `json:"file_id"` // This field is from variant - // [ConversationItemNewResponseDataMessageContentArrayItemInputImage]. + // [ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]. ImageURL string `json:"image_url"` // This field is from variant - // [ConversationItemNewResponseDataMessageContentArrayItemInputFile]. + // [ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. FileData string `json:"file_data"` // This field is from variant - // [ConversationItemNewResponseDataMessageContentArrayItemInputFile]. + // [ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. FileURL string `json:"file_url"` // This field is from variant - // [ConversationItemNewResponseDataMessageContentArrayItemInputFile]. + // [ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. Filename string `json:"filename"` JSON struct { Text respjson.Field @@ -420,31 +459,32 @@ type ConversationItemNewResponseDataMessageContentArrayItemUnion struct { } `json:"-"` } -// anyConversationItemNewResponseDataMessageContentArrayItem is implemented by each -// variant of [ConversationItemNewResponseDataMessageContentArrayItemUnion] to add -// type safety for the return type of -// [ConversationItemNewResponseDataMessageContentArrayItemUnion.AsAny] -type anyConversationItemNewResponseDataMessageContentArrayItem interface { - implConversationItemNewResponseDataMessageContentArrayItemUnion() +// anyConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem +// is implemented by each variant of +// [ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion] +// to add type safety for the return type of +// [ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny] +type anyConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem interface { + implConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() } -func (ConversationItemNewResponseDataMessageContentArrayItemInputText) implConversationItemNewResponseDataMessageContentArrayItemUnion() { +func (ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) implConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { } -func (ConversationItemNewResponseDataMessageContentArrayItemInputImage) implConversationItemNewResponseDataMessageContentArrayItemUnion() { +func (ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) implConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { } -func (ConversationItemNewResponseDataMessageContentArrayItemInputFile) implConversationItemNewResponseDataMessageContentArrayItemUnion() { +func (ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) implConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { } // Use the following switch statement to find the correct variant // -// switch variant := ConversationItemNewResponseDataMessageContentArrayItemUnion.AsAny().(type) { -// case llamastackclient.ConversationItemNewResponseDataMessageContentArrayItemInputText: -// case llamastackclient.ConversationItemNewResponseDataMessageContentArrayItemInputImage: -// case llamastackclient.ConversationItemNewResponseDataMessageContentArrayItemInputFile: +// switch variant := ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny().(type) { +// case llamastackclient.ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText: +// case llamastackclient.ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage: +// case llamastackclient.ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile: // default: // fmt.Errorf("no variant present") // } -func (u ConversationItemNewResponseDataMessageContentArrayItemUnion) AsAny() anyConversationItemNewResponseDataMessageContentArrayItem { +func (u ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsAny() anyConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem { switch u.Type { case "input_text": return u.AsInputText() @@ -456,36 +496,35 @@ func (u ConversationItemNewResponseDataMessageContentArrayItemUnion) AsAny() any return nil } -func (u ConversationItemNewResponseDataMessageContentArrayItemUnion) AsInputText() (v ConversationItemNewResponseDataMessageContentArrayItemInputText) { +func (u ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputText() (v ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ConversationItemNewResponseDataMessageContentArrayItemUnion) AsInputImage() (v ConversationItemNewResponseDataMessageContentArrayItemInputImage) { +func (u ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputImage() (v ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ConversationItemNewResponseDataMessageContentArrayItemUnion) AsInputFile() (v ConversationItemNewResponseDataMessageContentArrayItemInputFile) { +func (u ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputFile() (v ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ConversationItemNewResponseDataMessageContentArrayItemUnion) RawJSON() string { +func (u ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) RawJSON() string { return u.JSON.raw } -func (r *ConversationItemNewResponseDataMessageContentArrayItemUnion) UnmarshalJSON(data []byte) error { +func (r *ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content for input messages in OpenAI response format. -type ConversationItemNewResponseDataMessageContentArrayItemInputText struct { - // The text content of the input message +type ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText struct { Text string `json:"text,required"` - // Content type identifier, always "input_text" - Type constant.InputText `json:"type,required"` + // Any of "input_text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -496,313 +535,356 @@ type ConversationItemNewResponseDataMessageContentArrayItemInputText struct { } // Returns the unmodified JSON received from the API -func (r ConversationItemNewResponseDataMessageContentArrayItemInputText) RawJSON() string { +func (r ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemNewResponseDataMessageContentArrayItemInputText) UnmarshalJSON(data []byte) error { +func (r *ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Image content for input messages in OpenAI response format. -type ConversationItemNewResponseDataMessageContentArrayItemInputImage struct { - // Level of detail for image processing, can be "low", "high", or "auto" - // +type ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage struct { // Any of "low", "high", "auto". - Detail ConversationItemNewResponseDataMessageContentArrayItemInputImageDetail `json:"detail,required"` - // Content type identifier, always "input_image" - Type constant.InputImage `json:"type,required"` - // (Optional) The ID of the file to be sent to the model. - FileID string `json:"file_id"` - // (Optional) URL of the image content - ImageURL string `json:"image_url"` + Detail string `json:"detail"` + FileID string `json:"file_id,nullable"` + ImageURL string `json:"image_url,nullable"` + // Any of "input_image". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Detail respjson.Field - Type respjson.Field FileID respjson.Field ImageURL respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ConversationItemNewResponseDataMessageContentArrayItemInputImage) RawJSON() string { +func (r ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemNewResponseDataMessageContentArrayItemInputImage) UnmarshalJSON(data []byte) error { +func (r *ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ConversationItemNewResponseDataMessageContentArrayItemInputImageDetail string - -const ( - ConversationItemNewResponseDataMessageContentArrayItemInputImageDetailLow ConversationItemNewResponseDataMessageContentArrayItemInputImageDetail = "low" - ConversationItemNewResponseDataMessageContentArrayItemInputImageDetailHigh ConversationItemNewResponseDataMessageContentArrayItemInputImageDetail = "high" - ConversationItemNewResponseDataMessageContentArrayItemInputImageDetailAuto ConversationItemNewResponseDataMessageContentArrayItemInputImageDetail = "auto" -) - // File content for input messages in OpenAI response format. -type ConversationItemNewResponseDataMessageContentArrayItemInputFile struct { - // The type of the input item. Always `input_file`. - Type constant.InputFile `json:"type,required"` - // The data of the file to be sent to the model. - FileData string `json:"file_data"` - // (Optional) The ID of the file to be sent to the model. - FileID string `json:"file_id"` - // The URL of the file to be sent to the model. - FileURL string `json:"file_url"` - // The name of the file to be sent to the model. - Filename string `json:"filename"` +type ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile struct { + FileData string `json:"file_data,nullable"` + FileID string `json:"file_id,nullable"` + FileURL string `json:"file_url,nullable"` + Filename string `json:"filename,nullable"` + // Any of "input_file". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field FileData respjson.Field FileID respjson.Field FileURL respjson.Field Filename respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ConversationItemNewResponseDataMessageContentArrayItemInputFile) RawJSON() string { +func (r ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemNewResponseDataMessageContentArrayItemInputFile) UnmarshalJSON(data []byte) error { +func (r *ConversationItemNewResponseDataMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ConversationItemNewResponseDataMessageContentArrayItemDetail string +// ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion +// contains all possible properties and values from +// [ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText], +// [ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]. +// +// Use the +// [ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny] +// method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion struct { + // This field is from variant + // [ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]. + Text string `json:"text"` + // This field is from variant + // [ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]. + Annotations []ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion `json:"annotations"` + // Any of "output_text", "refusal". + Type string `json:"type"` + // This field is from variant + // [ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]. + Refusal string `json:"refusal"` + JSON struct { + Text respjson.Field + Annotations respjson.Field + Type respjson.Field + Refusal respjson.Field + raw string + } `json:"-"` +} -const ( - ConversationItemNewResponseDataMessageContentArrayItemDetailLow ConversationItemNewResponseDataMessageContentArrayItemDetail = "low" - ConversationItemNewResponseDataMessageContentArrayItemDetailHigh ConversationItemNewResponseDataMessageContentArrayItemDetail = "high" - ConversationItemNewResponseDataMessageContentArrayItemDetailAuto ConversationItemNewResponseDataMessageContentArrayItemDetail = "auto" -) +// anyConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem +// is implemented by each variant of +// [ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion] +// to add type safety for the return type of +// [ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny] +type anyConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem interface { + implConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() +} -type ConversationItemNewResponseDataMessageRole string +func (ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) implConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() { +} +func (ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) implConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() { +} -const ( - ConversationItemNewResponseDataMessageRoleSystem ConversationItemNewResponseDataMessageRole = "system" - ConversationItemNewResponseDataMessageRoleDeveloper ConversationItemNewResponseDataMessageRole = "developer" - ConversationItemNewResponseDataMessageRoleUser ConversationItemNewResponseDataMessageRole = "user" - ConversationItemNewResponseDataMessageRoleAssistant ConversationItemNewResponseDataMessageRole = "assistant" -) +// Use the following switch statement to find the correct variant +// +// switch variant := ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny().(type) { +// case llamastackclient.ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText: +// case llamastackclient.ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal: +// default: +// fmt.Errorf("no variant present") +// } +func (u ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsAny() anyConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem { + switch u.Type { + case "output_text": + return u.AsOutputText() + case "refusal": + return u.AsRefusal() + } + return nil +} -// Web search tool call output message for OpenAI responses. -type ConversationItemNewResponseDataWebSearchCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // Current status of the web search operation - Status string `json:"status,required"` - // Tool call type identifier, always "web_search_call" - Type constant.WebSearchCall `json:"type,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - ID respjson.Field - Status respjson.Field - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` +func (u ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsOutputText() (v ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsRefusal() (v ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return } // Returns the unmodified JSON received from the API -func (r ConversationItemNewResponseDataWebSearchCall) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemNewResponseDataWebSearchCall) UnmarshalJSON(data []byte) error { +func (u ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// File search tool call output message for OpenAI responses. -type ConversationItemNewResponseDataFileSearchCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // List of search queries executed - Queries []string `json:"queries,required"` - // Current status of the file search operation - Status string `json:"status,required"` - // Tool call type identifier, always "file_search_call" - Type constant.FileSearchCall `json:"type,required"` - // (Optional) Search results returned by the file search operation - Results []ConversationItemNewResponseDataFileSearchCallResult `json:"results"` +type ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText struct { + Text string `json:"text,required"` + Annotations []ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion `json:"annotations"` + // Any of "output_text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - ID respjson.Field - Queries respjson.Field - Status respjson.Field + Text respjson.Field + Annotations respjson.Field Type respjson.Field - Results respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ConversationItemNewResponseDataFileSearchCall) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemNewResponseDataFileSearchCall) UnmarshalJSON(data []byte) error { +func (r ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Search results returned by the file search operation. -type ConversationItemNewResponseDataFileSearchCallResult struct { - // (Optional) Key-value attributes associated with the file - Attributes map[string]ConversationItemNewResponseDataFileSearchCallResultAttributeUnion `json:"attributes,required"` - // Unique identifier of the file containing the result - FileID string `json:"file_id,required"` - // Name of the file containing the result - Filename string `json:"filename,required"` - // Relevance score for this search result (between 0 and 1) - Score float64 `json:"score,required"` - // Text content of the search result - Text string `json:"text,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Attributes respjson.Field +// ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion +// contains all possible properties and values from +// [ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation], +// [ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation], +// [ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation], +// [ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath]. +// +// Use the +// [ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny] +// method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion struct { + FileID string `json:"file_id"` + Filename string `json:"filename"` + Index int64 `json:"index"` + // Any of "file_citation", "url_citation", "container_file_citation", "file_path". + Type string `json:"type"` + EndIndex int64 `json:"end_index"` + StartIndex int64 `json:"start_index"` + // This field is from variant + // [ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]. + Title string `json:"title"` + // This field is from variant + // [ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]. + URL string `json:"url"` + // This field is from variant + // [ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation]. + ContainerID string `json:"container_id"` + JSON struct { FileID respjson.Field Filename respjson.Field - Score respjson.Field - Text respjson.Field - ExtraFields map[string]respjson.Field + Index respjson.Field + Type respjson.Field + EndIndex respjson.Field + StartIndex respjson.Field + Title respjson.Field + URL respjson.Field + ContainerID respjson.Field raw string } `json:"-"` } -// Returns the unmodified JSON received from the API -func (r ConversationItemNewResponseDataFileSearchCallResult) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemNewResponseDataFileSearchCallResult) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) +// anyConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation +// is implemented by each variant of +// [ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion] +// to add type safety for the return type of +// [ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny] +type anyConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation interface { + implConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() } -// ConversationItemNewResponseDataFileSearchCallResultAttributeUnion contains all -// possible properties and values from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. +func (ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) implConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} +func (ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) implConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} +func (ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) implConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} +func (ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) implConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} + +// Use the following switch statement to find the correct variant // -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ConversationItemNewResponseDataFileSearchCallResultAttributeUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` +// switch variant := ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny().(type) { +// case llamastackclient.ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation: +// case llamastackclient.ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation: +// case llamastackclient.ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation: +// case llamastackclient.ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath: +// default: +// fmt.Errorf("no variant present") +// } +func (u ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsAny() anyConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation { + switch u.Type { + case "file_citation": + return u.AsFileCitation() + case "url_citation": + return u.AsURLCitation() + case "container_file_citation": + return u.AsContainerFileCitation() + case "file_path": + return u.AsFilePath() + } + return nil } -func (u ConversationItemNewResponseDataFileSearchCallResultAttributeUnion) AsBool() (v bool) { +func (u ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsFileCitation() (v ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ConversationItemNewResponseDataFileSearchCallResultAttributeUnion) AsFloat() (v float64) { +func (u ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsURLCitation() (v ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ConversationItemNewResponseDataFileSearchCallResultAttributeUnion) AsString() (v string) { +func (u ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsContainerFileCitation() (v ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ConversationItemNewResponseDataFileSearchCallResultAttributeUnion) AsAnyArray() (v []any) { +func (u ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsFilePath() (v ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ConversationItemNewResponseDataFileSearchCallResultAttributeUnion) RawJSON() string { +func (u ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) RawJSON() string { return u.JSON.raw } -func (r *ConversationItemNewResponseDataFileSearchCallResultAttributeUnion) UnmarshalJSON(data []byte) error { +func (r *ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Function tool call output message for OpenAI responses. -type ConversationItemNewResponseDataFunctionCall struct { - // JSON string containing the function arguments - Arguments string `json:"arguments,required"` - // Unique identifier for the function call - CallID string `json:"call_id,required"` - // Name of the function being called - Name string `json:"name,required"` - // Tool call type identifier, always "function_call" - Type constant.FunctionCall `json:"type,required"` - // (Optional) Additional identifier for the tool call - ID string `json:"id"` - // (Optional) Current status of the function call execution - Status string `json:"status"` +// File citation annotation for referencing specific files in response content. +type ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation struct { + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Index int64 `json:"index,required"` + // Any of "file_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Arguments respjson.Field - CallID respjson.Field - Name respjson.Field + FileID respjson.Field + Filename respjson.Field + Index respjson.Field Type respjson.Field - ID respjson.Field - Status respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ConversationItemNewResponseDataFunctionCall) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemNewResponseDataFunctionCall) UnmarshalJSON(data []byte) error { +func (r ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// This represents the output of a function call that gets passed back to the -// model. -type ConversationItemNewResponseDataFunctionCallOutput struct { - CallID string `json:"call_id,required"` - Output string `json:"output,required"` - Type constant.FunctionCallOutput `json:"type,required"` - ID string `json:"id"` - Status string `json:"status"` +// URL citation annotation for referencing external web resources. +type ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation struct { + EndIndex int64 `json:"end_index,required"` + StartIndex int64 `json:"start_index,required"` + Title string `json:"title,required"` + URL string `json:"url,required"` + // Any of "url_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - CallID respjson.Field - Output respjson.Field + EndIndex respjson.Field + StartIndex respjson.Field + Title respjson.Field + URL respjson.Field Type respjson.Field - ID respjson.Field - Status respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ConversationItemNewResponseDataFunctionCallOutput) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemNewResponseDataFunctionCallOutput) UnmarshalJSON(data []byte) error { +func (r ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// A request for human approval of a tool invocation. -type ConversationItemNewResponseDataMcpApprovalRequest struct { - ID string `json:"id,required"` - Arguments string `json:"arguments,required"` - Name string `json:"name,required"` - ServerLabel string `json:"server_label,required"` - Type constant.McpApprovalRequest `json:"type,required"` +type ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation struct { + ContainerID string `json:"container_id,required"` + EndIndex int64 `json:"end_index,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + StartIndex int64 `json:"start_index,required"` + // Any of "container_file_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - ID respjson.Field - Arguments respjson.Field - Name respjson.Field - ServerLabel respjson.Field + ContainerID respjson.Field + EndIndex respjson.Field + FileID respjson.Field + Filename respjson.Field + StartIndex respjson.Field Type respjson.Field ExtraFields map[string]respjson.Field raw string @@ -810,87 +892,68 @@ type ConversationItemNewResponseDataMcpApprovalRequest struct { } // Returns the unmodified JSON received from the API -func (r ConversationItemNewResponseDataMcpApprovalRequest) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemNewResponseDataMcpApprovalRequest) UnmarshalJSON(data []byte) error { +func (r ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// A response to an MCP approval request. -type ConversationItemNewResponseDataMcpApprovalResponse struct { - ApprovalRequestID string `json:"approval_request_id,required"` - Approve bool `json:"approve,required"` - Type constant.McpApprovalResponse `json:"type,required"` - ID string `json:"id"` - Reason string `json:"reason"` +type ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath struct { + FileID string `json:"file_id,required"` + Index int64 `json:"index,required"` + // Any of "file_path". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - ApprovalRequestID respjson.Field - Approve respjson.Field - Type respjson.Field - ID respjson.Field - Reason respjson.Field - ExtraFields map[string]respjson.Field - raw string + FileID respjson.Field + Index respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ConversationItemNewResponseDataMcpApprovalResponse) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemNewResponseDataMcpApprovalResponse) UnmarshalJSON(data []byte) error { +func (r ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Model Context Protocol (MCP) call output message for OpenAI responses. -type ConversationItemNewResponseDataMcpCall struct { - // Unique identifier for this MCP call - ID string `json:"id,required"` - // JSON string containing the MCP call arguments - Arguments string `json:"arguments,required"` - // Name of the MCP method being called - Name string `json:"name,required"` - // Label identifying the MCP server handling the call - ServerLabel string `json:"server_label,required"` - // Tool call type identifier, always "mcp_call" - Type constant.McpCall `json:"type,required"` - // (Optional) Error message if the MCP call failed - Error string `json:"error"` - // (Optional) Output result from the successful MCP call - Output string `json:"output"` +// Refusal content within a streamed response part. +type ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal struct { + Refusal string `json:"refusal,required"` + // Any of "refusal". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - ID respjson.Field - Arguments respjson.Field - Name respjson.Field - ServerLabel respjson.Field + Refusal respjson.Field Type respjson.Field - Error respjson.Field - Output respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ConversationItemNewResponseDataMcpCall) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemNewResponseDataMcpCall) UnmarshalJSON(data []byte) error { +func (r ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemNewResponseDataMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// MCP list tools output message containing available tools from an MCP server. -type ConversationItemNewResponseDataMcpListTools struct { - // Unique identifier for this MCP list tools operation - ID string `json:"id,required"` - // Label identifying the MCP server providing the tools - ServerLabel string `json:"server_label,required"` - // List of available tools provided by the MCP server - Tools []ConversationItemNewResponseDataMcpListToolsTool `json:"tools,required"` - // Tool call type identifier, always "mcp_list_tools" - Type constant.McpListTools `json:"type,required"` +// Web search tool call output message for OpenAI responses. +type ConversationItemNewResponseDataWebSearchCall struct { + ID string `json:"id,required"` + Status string `json:"status,required"` + // Any of "web_search_call". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field - ServerLabel respjson.Field - Tools respjson.Field + Status respjson.Field Type respjson.Field ExtraFields map[string]respjson.Field raw string @@ -898,97 +961,243 @@ type ConversationItemNewResponseDataMcpListTools struct { } // Returns the unmodified JSON received from the API -func (r ConversationItemNewResponseDataMcpListTools) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemNewResponseDataMcpListTools) UnmarshalJSON(data []byte) error { +func (r ConversationItemNewResponseDataWebSearchCall) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemNewResponseDataWebSearchCall) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Tool definition returned by MCP list tools operation. -type ConversationItemNewResponseDataMcpListToolsTool struct { - // JSON schema defining the tool's input parameters - InputSchema map[string]ConversationItemNewResponseDataMcpListToolsToolInputSchemaUnion `json:"input_schema,required"` - // Name of the tool - Name string `json:"name,required"` - // (Optional) Description of what the tool does - Description string `json:"description"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - InputSchema respjson.Field +// File search tool call output message for OpenAI responses. +type ConversationItemNewResponseDataFileSearchCall struct { + ID string `json:"id,required"` + Queries []string `json:"queries,required"` + Status string `json:"status,required"` + Results []ConversationItemNewResponseDataFileSearchCallResult `json:"results,nullable"` + // Any of "file_search_call". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Queries respjson.Field + Status respjson.Field + Results respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemNewResponseDataFileSearchCall) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemNewResponseDataFileSearchCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Search results returned by the file search operation. +type ConversationItemNewResponseDataFileSearchCallResult struct { + Attributes map[string]any `json:"attributes,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Score float64 `json:"score,required"` + Text string `json:"text,required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Attributes respjson.Field + FileID respjson.Field + Filename respjson.Field + Score respjson.Field + Text respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemNewResponseDataFileSearchCallResult) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemNewResponseDataFileSearchCallResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Function tool call output message for OpenAI responses. +type ConversationItemNewResponseDataFunctionCall struct { + Arguments string `json:"arguments,required"` + CallID string `json:"call_id,required"` + Name string `json:"name,required"` + ID string `json:"id,nullable"` + Status string `json:"status,nullable"` + // Any of "function_call". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Arguments respjson.Field + CallID respjson.Field Name respjson.Field - Description respjson.Field + ID respjson.Field + Status respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ConversationItemNewResponseDataMcpListToolsTool) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemNewResponseDataMcpListToolsTool) UnmarshalJSON(data []byte) error { +func (r ConversationItemNewResponseDataFunctionCall) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemNewResponseDataFunctionCall) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ConversationItemNewResponseDataMcpListToolsToolInputSchemaUnion contains all -// possible properties and values from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ConversationItemNewResponseDataMcpListToolsToolInputSchemaUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string +// This represents the output of a function call that gets passed back to the +// model. +type ConversationItemNewResponseDataFunctionCallOutput struct { + CallID string `json:"call_id,required"` + Output string `json:"output,required"` + ID string `json:"id,nullable"` + Status string `json:"status,nullable"` + // Any of "function_call_output". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + CallID respjson.Field + Output respjson.Field + ID respjson.Field + Status respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } -func (u ConversationItemNewResponseDataMcpListToolsToolInputSchemaUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Returns the unmodified JSON received from the API +func (r ConversationItemNewResponseDataFunctionCallOutput) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemNewResponseDataFunctionCallOutput) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ConversationItemNewResponseDataMcpListToolsToolInputSchemaUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// A request for human approval of a tool invocation. +type ConversationItemNewResponseDataMcpApprovalRequest struct { + ID string `json:"id,required"` + Arguments string `json:"arguments,required"` + Name string `json:"name,required"` + ServerLabel string `json:"server_label,required"` + // Any of "mcp_approval_request". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Arguments respjson.Field + Name respjson.Field + ServerLabel respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } -func (u ConversationItemNewResponseDataMcpListToolsToolInputSchemaUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Returns the unmodified JSON received from the API +func (r ConversationItemNewResponseDataMcpApprovalRequest) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemNewResponseDataMcpApprovalRequest) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ConversationItemNewResponseDataMcpListToolsToolInputSchemaUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// A response to an MCP approval request. +type ConversationItemNewResponseDataMcpApprovalResponse struct { + ApprovalRequestID string `json:"approval_request_id,required"` + Approve bool `json:"approve,required"` + ID string `json:"id,nullable"` + Reason string `json:"reason,nullable"` + // Any of "mcp_approval_response". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ApprovalRequestID respjson.Field + Approve respjson.Field + ID respjson.Field + Reason respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } // Returns the unmodified JSON received from the API -func (u ConversationItemNewResponseDataMcpListToolsToolInputSchemaUnion) RawJSON() string { - return u.JSON.raw +func (r ConversationItemNewResponseDataMcpApprovalResponse) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemNewResponseDataMcpApprovalResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (r *ConversationItemNewResponseDataMcpListToolsToolInputSchemaUnion) UnmarshalJSON(data []byte) error { +// Model Context Protocol (MCP) call output message for OpenAI responses. +type ConversationItemNewResponseDataMcpCall struct { + ID string `json:"id,required"` + Arguments string `json:"arguments,required"` + Name string `json:"name,required"` + ServerLabel string `json:"server_label,required"` + Error string `json:"error,nullable"` + Output string `json:"output,nullable"` + // Any of "mcp_call". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Arguments respjson.Field + Name respjson.Field + ServerLabel respjson.Field + Error respjson.Field + Output respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemNewResponseDataMcpCall) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemNewResponseDataMcpCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// MCP list tools output message containing available tools from an MCP server. +type ConversationItemNewResponseDataMcpListTools struct { + ID string `json:"id,required"` + ServerLabel string `json:"server_label,required"` + Tools []ConversationItemNewResponseDataMcpListToolsTool `json:"tools,required"` + // Any of "mcp_list_tools". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + ServerLabel respjson.Field + Tools respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemNewResponseDataMcpListTools) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemNewResponseDataMcpListTools) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ConversationItemNewResponseDataRole string +// Tool definition returned by MCP list tools operation. +type ConversationItemNewResponseDataMcpListToolsTool struct { + InputSchema map[string]any `json:"input_schema,required"` + Name string `json:"name,required"` + Description string `json:"description,nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputSchema respjson.Field + Name respjson.Field + Description respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} -const ( - ConversationItemNewResponseDataRoleSystem ConversationItemNewResponseDataRole = "system" - ConversationItemNewResponseDataRoleDeveloper ConversationItemNewResponseDataRole = "developer" - ConversationItemNewResponseDataRoleUser ConversationItemNewResponseDataRole = "user" - ConversationItemNewResponseDataRoleAssistant ConversationItemNewResponseDataRole = "assistant" -) +// Returns the unmodified JSON received from the API +func (r ConversationItemNewResponseDataMcpListToolsTool) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemNewResponseDataMcpListToolsTool) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} // ConversationItemListResponseUnion contains all possible properties and values // from [ConversationItemListResponseMessage], @@ -1009,13 +1218,13 @@ type ConversationItemListResponseUnion struct { // This field is from variant [ConversationItemListResponseMessage]. Content ConversationItemListResponseMessageContentUnion `json:"content"` // This field is from variant [ConversationItemListResponseMessage]. - Role ConversationItemListResponseMessageRole `json:"role"` + Role string `json:"role"` + ID string `json:"id"` + Status string `json:"status"` // Any of "message", "web_search_call", "file_search_call", "function_call", // "function_call_output", "mcp_approval_request", "mcp_approval_response", // "mcp_call", "mcp_list_tools". - Type string `json:"type"` - ID string `json:"id"` - Status string `json:"status"` + Type string `json:"type"` // This field is from variant [ConversationItemListResponseFileSearchCall]. Queries []string `json:"queries"` // This field is from variant [ConversationItemListResponseFileSearchCall]. @@ -1038,9 +1247,9 @@ type ConversationItemListResponseUnion struct { JSON struct { Content respjson.Field Role respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field Queries respjson.Field Results respjson.Field Arguments respjson.Field @@ -1171,17 +1380,18 @@ func (r *ConversationItemListResponseUnion) UnmarshalJSON(data []byte) error { type ConversationItemListResponseMessage struct { Content ConversationItemListResponseMessageContentUnion `json:"content,required"` // Any of "system", "developer", "user", "assistant". - Role ConversationItemListResponseMessageRole `json:"role,required"` - Type constant.Message `json:"type,required"` - ID string `json:"id"` - Status string `json:"status"` + Role string `json:"role,required"` + ID string `json:"id,nullable"` + Status string `json:"status,nullable"` + // Any of "message". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field Role respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -1195,24 +1405,31 @@ func (r *ConversationItemListResponseMessage) UnmarshalJSON(data []byte) error { // ConversationItemListResponseMessageContentUnion contains all possible properties // and values from [string], -// [[]ConversationItemListResponseMessageContentArrayItemUnion], -// [[]ConversationItemListResponseMessageContentArrayItemUnion]. +// [[]ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion], +// [[]ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString OfVariant2] +// will be valid: OfString +// OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile +// OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal] type ConversationItemListResponseMessageContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ConversationItemListResponseMessageContentArrayItemUnion] instead of an - // object. - OfVariant2 []ConversationItemListResponseMessageContentArrayItemUnion `json:",inline"` - JSON struct { - OfString respjson.Field - OfVariant2 respjson.Field - raw string + // [[]ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion] + // instead of an object. + OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile []ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion `json:",inline"` + // This field will be present if the value is a + // [[]ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion] + // instead of an object. + OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal []ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile respjson.Field + OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal respjson.Field + raw string } `json:"-"` } @@ -1221,12 +1438,12 @@ func (u ConversationItemListResponseMessageContentUnion) AsString() (v string) { return } -func (u ConversationItemListResponseMessageContentUnion) AsConversationItemListResponseMessageContentArray() (v []ConversationItemListResponseMessageContentArrayItemUnion) { +func (u ConversationItemListResponseMessageContentUnion) AsListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile() (v []ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ConversationItemListResponseMessageContentUnion) AsVariant2() (v []ConversationItemListResponseMessageContentArrayItemUnion) { +func (u ConversationItemListResponseMessageContentUnion) AsListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal() (v []ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -1238,37 +1455,38 @@ func (r *ConversationItemListResponseMessageContentUnion) UnmarshalJSON(data []b return apijson.UnmarshalRoot(data, r) } -// ConversationItemListResponseMessageContentArrayItemUnion contains all possible -// properties and values from -// [ConversationItemListResponseMessageContentArrayItemInputText], -// [ConversationItemListResponseMessageContentArrayItemInputImage], -// [ConversationItemListResponseMessageContentArrayItemInputFile]. +// ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion +// contains all possible properties and values from +// [ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText], +// [ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage], +// [ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. // -// Use the [ConversationItemListResponseMessageContentArrayItemUnion.AsAny] method -// to switch on the variant. +// Use the +// [ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny] +// method to switch on the variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type ConversationItemListResponseMessageContentArrayItemUnion struct { +type ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion struct { // This field is from variant - // [ConversationItemListResponseMessageContentArrayItemInputText]. + // [ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText]. Text string `json:"text"` // Any of "input_text", "input_image", "input_file". Type string `json:"type"` // This field is from variant - // [ConversationItemListResponseMessageContentArrayItemInputImage]. - Detail ConversationItemListResponseMessageContentArrayItemInputImageDetail `json:"detail"` - FileID string `json:"file_id"` + // [ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]. + Detail string `json:"detail"` + FileID string `json:"file_id"` // This field is from variant - // [ConversationItemListResponseMessageContentArrayItemInputImage]. + // [ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]. ImageURL string `json:"image_url"` // This field is from variant - // [ConversationItemListResponseMessageContentArrayItemInputFile]. + // [ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. FileData string `json:"file_data"` // This field is from variant - // [ConversationItemListResponseMessageContentArrayItemInputFile]. + // [ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. FileURL string `json:"file_url"` // This field is from variant - // [ConversationItemListResponseMessageContentArrayItemInputFile]. + // [ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. Filename string `json:"filename"` JSON struct { Text respjson.Field @@ -1283,31 +1501,32 @@ type ConversationItemListResponseMessageContentArrayItemUnion struct { } `json:"-"` } -// anyConversationItemListResponseMessageContentArrayItem is implemented by each -// variant of [ConversationItemListResponseMessageContentArrayItemUnion] to add -// type safety for the return type of -// [ConversationItemListResponseMessageContentArrayItemUnion.AsAny] -type anyConversationItemListResponseMessageContentArrayItem interface { - implConversationItemListResponseMessageContentArrayItemUnion() +// anyConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem +// is implemented by each variant of +// [ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion] +// to add type safety for the return type of +// [ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny] +type anyConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem interface { + implConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() } -func (ConversationItemListResponseMessageContentArrayItemInputText) implConversationItemListResponseMessageContentArrayItemUnion() { +func (ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) implConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { } -func (ConversationItemListResponseMessageContentArrayItemInputImage) implConversationItemListResponseMessageContentArrayItemUnion() { +func (ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) implConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { } -func (ConversationItemListResponseMessageContentArrayItemInputFile) implConversationItemListResponseMessageContentArrayItemUnion() { +func (ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) implConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { } // Use the following switch statement to find the correct variant // -// switch variant := ConversationItemListResponseMessageContentArrayItemUnion.AsAny().(type) { -// case llamastackclient.ConversationItemListResponseMessageContentArrayItemInputText: -// case llamastackclient.ConversationItemListResponseMessageContentArrayItemInputImage: -// case llamastackclient.ConversationItemListResponseMessageContentArrayItemInputFile: +// switch variant := ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny().(type) { +// case llamastackclient.ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText: +// case llamastackclient.ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage: +// case llamastackclient.ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile: // default: // fmt.Errorf("no variant present") // } -func (u ConversationItemListResponseMessageContentArrayItemUnion) AsAny() anyConversationItemListResponseMessageContentArrayItem { +func (u ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsAny() anyConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem { switch u.Type { case "input_text": return u.AsInputText() @@ -1319,34 +1538,35 @@ func (u ConversationItemListResponseMessageContentArrayItemUnion) AsAny() anyCon return nil } -func (u ConversationItemListResponseMessageContentArrayItemUnion) AsInputText() (v ConversationItemListResponseMessageContentArrayItemInputText) { +func (u ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputText() (v ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ConversationItemListResponseMessageContentArrayItemUnion) AsInputImage() (v ConversationItemListResponseMessageContentArrayItemInputImage) { +func (u ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputImage() (v ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ConversationItemListResponseMessageContentArrayItemUnion) AsInputFile() (v ConversationItemListResponseMessageContentArrayItemInputFile) { +func (u ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputFile() (v ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ConversationItemListResponseMessageContentArrayItemUnion) RawJSON() string { return u.JSON.raw } +func (u ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) RawJSON() string { + return u.JSON.raw +} -func (r *ConversationItemListResponseMessageContentArrayItemUnion) UnmarshalJSON(data []byte) error { +func (r *ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content for input messages in OpenAI response format. -type ConversationItemListResponseMessageContentArrayItemInputText struct { - // The text content of the input message +type ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText struct { Text string `json:"text,required"` - // Content type identifier, always "input_text" - Type constant.InputText `json:"type,required"` + // Any of "input_text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -1357,263 +1577,505 @@ type ConversationItemListResponseMessageContentArrayItemInputText struct { } // Returns the unmodified JSON received from the API -func (r ConversationItemListResponseMessageContentArrayItemInputText) RawJSON() string { +func (r ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemListResponseMessageContentArrayItemInputText) UnmarshalJSON(data []byte) error { +func (r *ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Image content for input messages in OpenAI response format. -type ConversationItemListResponseMessageContentArrayItemInputImage struct { - // Level of detail for image processing, can be "low", "high", or "auto" - // +type ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage struct { // Any of "low", "high", "auto". - Detail ConversationItemListResponseMessageContentArrayItemInputImageDetail `json:"detail,required"` - // Content type identifier, always "input_image" - Type constant.InputImage `json:"type,required"` - // (Optional) The ID of the file to be sent to the model. - FileID string `json:"file_id"` - // (Optional) URL of the image content - ImageURL string `json:"image_url"` + Detail string `json:"detail"` + FileID string `json:"file_id,nullable"` + ImageURL string `json:"image_url,nullable"` + // Any of "input_image". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Detail respjson.Field - Type respjson.Field FileID respjson.Field ImageURL respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ConversationItemListResponseMessageContentArrayItemInputImage) RawJSON() string { +func (r ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemListResponseMessageContentArrayItemInputImage) UnmarshalJSON(data []byte) error { +func (r *ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ConversationItemListResponseMessageContentArrayItemInputImageDetail string - -const ( - ConversationItemListResponseMessageContentArrayItemInputImageDetailLow ConversationItemListResponseMessageContentArrayItemInputImageDetail = "low" - ConversationItemListResponseMessageContentArrayItemInputImageDetailHigh ConversationItemListResponseMessageContentArrayItemInputImageDetail = "high" - ConversationItemListResponseMessageContentArrayItemInputImageDetailAuto ConversationItemListResponseMessageContentArrayItemInputImageDetail = "auto" -) - // File content for input messages in OpenAI response format. -type ConversationItemListResponseMessageContentArrayItemInputFile struct { - // The type of the input item. Always `input_file`. - Type constant.InputFile `json:"type,required"` - // The data of the file to be sent to the model. - FileData string `json:"file_data"` - // (Optional) The ID of the file to be sent to the model. - FileID string `json:"file_id"` - // The URL of the file to be sent to the model. - FileURL string `json:"file_url"` - // The name of the file to be sent to the model. - Filename string `json:"filename"` +type ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile struct { + FileData string `json:"file_data,nullable"` + FileID string `json:"file_id,nullable"` + FileURL string `json:"file_url,nullable"` + Filename string `json:"filename,nullable"` + // Any of "input_file". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field FileData respjson.Field FileID respjson.Field FileURL respjson.Field Filename respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ConversationItemListResponseMessageContentArrayItemInputFile) RawJSON() string { +func (r ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemListResponseMessageContentArrayItemInputFile) UnmarshalJSON(data []byte) error { +func (r *ConversationItemListResponseMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ConversationItemListResponseMessageContentArrayItemDetail string - -const ( - ConversationItemListResponseMessageContentArrayItemDetailLow ConversationItemListResponseMessageContentArrayItemDetail = "low" - ConversationItemListResponseMessageContentArrayItemDetailHigh ConversationItemListResponseMessageContentArrayItemDetail = "high" - ConversationItemListResponseMessageContentArrayItemDetailAuto ConversationItemListResponseMessageContentArrayItemDetail = "auto" -) - -type ConversationItemListResponseMessageRole string - -const ( - ConversationItemListResponseMessageRoleSystem ConversationItemListResponseMessageRole = "system" - ConversationItemListResponseMessageRoleDeveloper ConversationItemListResponseMessageRole = "developer" - ConversationItemListResponseMessageRoleUser ConversationItemListResponseMessageRole = "user" - ConversationItemListResponseMessageRoleAssistant ConversationItemListResponseMessageRole = "assistant" -) - -// Web search tool call output message for OpenAI responses. -type ConversationItemListResponseWebSearchCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // Current status of the web search operation - Status string `json:"status,required"` - // Tool call type identifier, always "web_search_call" - Type constant.WebSearchCall `json:"type,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - ID respjson.Field - Status respjson.Field +// ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion +// contains all possible properties and values from +// [ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText], +// [ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]. +// +// Use the +// [ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny] +// method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion struct { + // This field is from variant + // [ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]. + Text string `json:"text"` + // This field is from variant + // [ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]. + Annotations []ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion `json:"annotations"` + // Any of "output_text", "refusal". + Type string `json:"type"` + // This field is from variant + // [ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]. + Refusal string `json:"refusal"` + JSON struct { + Text respjson.Field + Annotations respjson.Field Type respjson.Field - ExtraFields map[string]respjson.Field + Refusal respjson.Field raw string } `json:"-"` } -// Returns the unmodified JSON received from the API -func (r ConversationItemListResponseWebSearchCall) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemListResponseWebSearchCall) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) +// anyConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem +// is implemented by each variant of +// [ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion] +// to add type safety for the return type of +// [ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny] +type anyConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem interface { + implConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() } -// File search tool call output message for OpenAI responses. -type ConversationItemListResponseFileSearchCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // List of search queries executed - Queries []string `json:"queries,required"` - // Current status of the file search operation - Status string `json:"status,required"` - // Tool call type identifier, always "file_search_call" - Type constant.FileSearchCall `json:"type,required"` - // (Optional) Search results returned by the file search operation - Results []ConversationItemListResponseFileSearchCallResult `json:"results"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - ID respjson.Field - Queries respjson.Field - Status respjson.Field - Type respjson.Field - Results respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` +func (ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) implConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() { +} +func (ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) implConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny().(type) { +// case llamastackclient.ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText: +// case llamastackclient.ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal: +// default: +// fmt.Errorf("no variant present") +// } +func (u ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsAny() anyConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem { + switch u.Type { + case "output_text": + return u.AsOutputText() + case "refusal": + return u.AsRefusal() + } + return nil +} + +func (u ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsOutputText() (v ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsRefusal() (v ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return } // Returns the unmodified JSON received from the API -func (r ConversationItemListResponseFileSearchCall) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemListResponseFileSearchCall) UnmarshalJSON(data []byte) error { +func (u ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Search results returned by the file search operation. -type ConversationItemListResponseFileSearchCallResult struct { - // (Optional) Key-value attributes associated with the file - Attributes map[string]ConversationItemListResponseFileSearchCallResultAttributeUnion `json:"attributes,required"` - // Unique identifier of the file containing the result - FileID string `json:"file_id,required"` - // Name of the file containing the result - Filename string `json:"filename,required"` - // Relevance score for this search result (between 0 and 1) - Score float64 `json:"score,required"` - // Text content of the search result - Text string `json:"text,required"` +type ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText struct { + Text string `json:"text,required"` + Annotations []ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion `json:"annotations"` + // Any of "output_text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Attributes respjson.Field - FileID respjson.Field - Filename respjson.Field - Score respjson.Field Text respjson.Field + Annotations respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ConversationItemListResponseFileSearchCallResult) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemListResponseFileSearchCallResult) UnmarshalJSON(data []byte) error { +func (r ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ConversationItemListResponseFileSearchCallResultAttributeUnion contains all -// possible properties and values from [bool], [float64], [string], [[]any]. +// ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion +// contains all possible properties and values from +// [ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation], +// [ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation], +// [ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation], +// [ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath]. // -// Use the methods beginning with 'As' to cast the union to one of its variants. +// Use the +// [ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny] +// method to switch on the variant. // -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ConversationItemListResponseFileSearchCallResultAttributeUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion struct { + FileID string `json:"file_id"` + Filename string `json:"filename"` + Index int64 `json:"index"` + // Any of "file_citation", "url_citation", "container_file_citation", "file_path". + Type string `json:"type"` + EndIndex int64 `json:"end_index"` + StartIndex int64 `json:"start_index"` + // This field is from variant + // [ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]. + Title string `json:"title"` + // This field is from variant + // [ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]. + URL string `json:"url"` + // This field is from variant + // [ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation]. + ContainerID string `json:"container_id"` + JSON struct { + FileID respjson.Field + Filename respjson.Field + Index respjson.Field + Type respjson.Field + EndIndex respjson.Field + StartIndex respjson.Field + Title respjson.Field + URL respjson.Field + ContainerID respjson.Field + raw string } `json:"-"` } -func (u ConversationItemListResponseFileSearchCallResultAttributeUnion) AsBool() (v bool) { +// anyConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation +// is implemented by each variant of +// [ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion] +// to add type safety for the return type of +// [ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny] +type anyConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation interface { + implConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() +} + +func (ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) implConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} +func (ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) implConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} +func (ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) implConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} +func (ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) implConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny().(type) { +// case llamastackclient.ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation: +// case llamastackclient.ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation: +// case llamastackclient.ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation: +// case llamastackclient.ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath: +// default: +// fmt.Errorf("no variant present") +// } +func (u ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsAny() anyConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation { + switch u.Type { + case "file_citation": + return u.AsFileCitation() + case "url_citation": + return u.AsURLCitation() + case "container_file_citation": + return u.AsContainerFileCitation() + case "file_path": + return u.AsFilePath() + } + return nil +} + +func (u ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsFileCitation() (v ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ConversationItemListResponseFileSearchCallResultAttributeUnion) AsFloat() (v float64) { +func (u ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsURLCitation() (v ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ConversationItemListResponseFileSearchCallResultAttributeUnion) AsString() (v string) { +func (u ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsContainerFileCitation() (v ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ConversationItemListResponseFileSearchCallResultAttributeUnion) AsAnyArray() (v []any) { +func (u ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsFilePath() (v ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ConversationItemListResponseFileSearchCallResultAttributeUnion) RawJSON() string { +func (u ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) RawJSON() string { return u.JSON.raw } -func (r *ConversationItemListResponseFileSearchCallResultAttributeUnion) UnmarshalJSON(data []byte) error { +func (r *ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// File citation annotation for referencing specific files in response content. +type ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation struct { + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Index int64 `json:"index,required"` + // Any of "file_citation". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + FileID respjson.Field + Filename respjson.Field + Index respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// URL citation annotation for referencing external web resources. +type ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation struct { + EndIndex int64 `json:"end_index,required"` + StartIndex int64 `json:"start_index,required"` + Title string `json:"title,required"` + URL string `json:"url,required"` + // Any of "url_citation". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + EndIndex respjson.Field + StartIndex respjson.Field + Title respjson.Field + URL respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation struct { + ContainerID string `json:"container_id,required"` + EndIndex int64 `json:"end_index,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + StartIndex int64 `json:"start_index,required"` + // Any of "container_file_citation". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ContainerID respjson.Field + EndIndex respjson.Field + FileID respjson.Field + Filename respjson.Field + StartIndex respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath struct { + FileID string `json:"file_id,required"` + Index int64 `json:"index,required"` + // Any of "file_path". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + FileID respjson.Field + Index respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Refusal content within a streamed response part. +type ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal struct { + Refusal string `json:"refusal,required"` + // Any of "refusal". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Refusal respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemListResponseMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Web search tool call output message for OpenAI responses. +type ConversationItemListResponseWebSearchCall struct { + ID string `json:"id,required"` + Status string `json:"status,required"` + // Any of "web_search_call". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Status respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemListResponseWebSearchCall) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemListResponseWebSearchCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// File search tool call output message for OpenAI responses. +type ConversationItemListResponseFileSearchCall struct { + ID string `json:"id,required"` + Queries []string `json:"queries,required"` + Status string `json:"status,required"` + Results []ConversationItemListResponseFileSearchCallResult `json:"results,nullable"` + // Any of "file_search_call". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Queries respjson.Field + Status respjson.Field + Results respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemListResponseFileSearchCall) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemListResponseFileSearchCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Search results returned by the file search operation. +type ConversationItemListResponseFileSearchCallResult struct { + Attributes map[string]any `json:"attributes,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Score float64 `json:"score,required"` + Text string `json:"text,required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Attributes respjson.Field + FileID respjson.Field + Filename respjson.Field + Score respjson.Field + Text respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemListResponseFileSearchCallResult) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemListResponseFileSearchCallResult) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Function tool call output message for OpenAI responses. type ConversationItemListResponseFunctionCall struct { - // JSON string containing the function arguments Arguments string `json:"arguments,required"` - // Unique identifier for the function call - CallID string `json:"call_id,required"` - // Name of the function being called - Name string `json:"name,required"` - // Tool call type identifier, always "function_call" - Type constant.FunctionCall `json:"type,required"` - // (Optional) Additional identifier for the tool call - ID string `json:"id"` - // (Optional) Current status of the function call execution - Status string `json:"status"` + CallID string `json:"call_id,required"` + Name string `json:"name,required"` + ID string `json:"id,nullable"` + Status string `json:"status,nullable"` + // Any of "function_call". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Arguments respjson.Field CallID respjson.Field Name respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -1628,18 +2090,19 @@ func (r *ConversationItemListResponseFunctionCall) UnmarshalJSON(data []byte) er // This represents the output of a function call that gets passed back to the // model. type ConversationItemListResponseFunctionCallOutput struct { - CallID string `json:"call_id,required"` - Output string `json:"output,required"` - Type constant.FunctionCallOutput `json:"type,required"` - ID string `json:"id"` - Status string `json:"status"` + CallID string `json:"call_id,required"` + Output string `json:"output,required"` + ID string `json:"id,nullable"` + Status string `json:"status,nullable"` + // Any of "function_call_output". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { CallID respjson.Field Output respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -1653,11 +2116,12 @@ func (r *ConversationItemListResponseFunctionCallOutput) UnmarshalJSON(data []by // A request for human approval of a tool invocation. type ConversationItemListResponseMcpApprovalRequest struct { - ID string `json:"id,required"` - Arguments string `json:"arguments,required"` - Name string `json:"name,required"` - ServerLabel string `json:"server_label,required"` - Type constant.McpApprovalRequest `json:"type,required"` + ID string `json:"id,required"` + Arguments string `json:"arguments,required"` + Name string `json:"name,required"` + ServerLabel string `json:"server_label,required"` + // Any of "mcp_approval_request". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -1678,18 +2142,19 @@ func (r *ConversationItemListResponseMcpApprovalRequest) UnmarshalJSON(data []by // A response to an MCP approval request. type ConversationItemListResponseMcpApprovalResponse struct { - ApprovalRequestID string `json:"approval_request_id,required"` - Approve bool `json:"approve,required"` - Type constant.McpApprovalResponse `json:"type,required"` - ID string `json:"id"` - Reason string `json:"reason"` + ApprovalRequestID string `json:"approval_request_id,required"` + Approve bool `json:"approve,required"` + ID string `json:"id,nullable"` + Reason string `json:"reason,nullable"` + // Any of "mcp_approval_response". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ApprovalRequestID respjson.Field Approve respjson.Field - Type respjson.Field ID respjson.Field Reason respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -1703,29 +2168,23 @@ func (r *ConversationItemListResponseMcpApprovalResponse) UnmarshalJSON(data []b // Model Context Protocol (MCP) call output message for OpenAI responses. type ConversationItemListResponseMcpCall struct { - // Unique identifier for this MCP call - ID string `json:"id,required"` - // JSON string containing the MCP call arguments - Arguments string `json:"arguments,required"` - // Name of the MCP method being called - Name string `json:"name,required"` - // Label identifying the MCP server handling the call + ID string `json:"id,required"` + Arguments string `json:"arguments,required"` + Name string `json:"name,required"` ServerLabel string `json:"server_label,required"` - // Tool call type identifier, always "mcp_call" - Type constant.McpCall `json:"type,required"` - // (Optional) Error message if the MCP call failed - Error string `json:"error"` - // (Optional) Output result from the successful MCP call - Output string `json:"output"` + Error string `json:"error,nullable"` + Output string `json:"output,nullable"` + // Any of "mcp_call". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field Arguments respjson.Field Name respjson.Field ServerLabel respjson.Field - Type respjson.Field Error respjson.Field Output respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -1739,14 +2198,11 @@ func (r *ConversationItemListResponseMcpCall) UnmarshalJSON(data []byte) error { // MCP list tools output message containing available tools from an MCP server. type ConversationItemListResponseMcpListTools struct { - // Unique identifier for this MCP list tools operation - ID string `json:"id,required"` - // Label identifying the MCP server providing the tools - ServerLabel string `json:"server_label,required"` - // List of available tools provided by the MCP server - Tools []ConversationItemListResponseMcpListToolsTool `json:"tools,required"` - // Tool call type identifier, always "mcp_list_tools" - Type constant.McpListTools `json:"type,required"` + ID string `json:"id,required"` + ServerLabel string `json:"server_label,required"` + Tools []ConversationItemListResponseMcpListToolsTool `json:"tools,required"` + // Any of "mcp_list_tools". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -1766,12 +2222,9 @@ func (r *ConversationItemListResponseMcpListTools) UnmarshalJSON(data []byte) er // Tool definition returned by MCP list tools operation. type ConversationItemListResponseMcpListToolsTool struct { - // JSON schema defining the tool's input parameters - InputSchema map[string]ConversationItemListResponseMcpListToolsToolInputSchemaUnion `json:"input_schema,required"` - // Name of the tool - Name string `json:"name,required"` - // (Optional) Description of what the tool does - Description string `json:"description"` + InputSchema map[string]any `json:"input_schema,required"` + Name string `json:"name,required"` + Description string `json:"description,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { InputSchema respjson.Field @@ -1788,347 +2241,143 @@ func (r *ConversationItemListResponseMcpListToolsTool) UnmarshalJSON(data []byte return apijson.UnmarshalRoot(data, r) } -// ConversationItemListResponseMcpListToolsToolInputSchemaUnion contains all -// possible properties and values from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ConversationItemListResponseMcpListToolsToolInputSchemaUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ConversationItemListResponseMcpListToolsToolInputSchemaUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ConversationItemListResponseMcpListToolsToolInputSchemaUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ConversationItemListResponseMcpListToolsToolInputSchemaUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ConversationItemListResponseMcpListToolsToolInputSchemaUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ConversationItemListResponseMcpListToolsToolInputSchemaUnion) RawJSON() string { - return u.JSON.raw -} - -func (r *ConversationItemListResponseMcpListToolsToolInputSchemaUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type ConversationItemListResponseRole string - -const ( - ConversationItemListResponseRoleSystem ConversationItemListResponseRole = "system" - ConversationItemListResponseRoleDeveloper ConversationItemListResponseRole = "developer" - ConversationItemListResponseRoleUser ConversationItemListResponseRole = "user" - ConversationItemListResponseRoleAssistant ConversationItemListResponseRole = "assistant" -) - -// ConversationItemGetResponseUnion contains all possible properties and values -// from [ConversationItemGetResponseMessage], -// [ConversationItemGetResponseWebSearchCall], -// [ConversationItemGetResponseFileSearchCall], -// [ConversationItemGetResponseFunctionCall], -// [ConversationItemGetResponseFunctionCallOutput], -// [ConversationItemGetResponseMcpApprovalRequest], -// [ConversationItemGetResponseMcpApprovalResponse], -// [ConversationItemGetResponseMcpCall], [ConversationItemGetResponseMcpListTools]. -// -// Use the [ConversationItemGetResponseUnion.AsAny] method to switch on the -// variant. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -type ConversationItemGetResponseUnion struct { - // This field is from variant [ConversationItemGetResponseMessage]. - Content ConversationItemGetResponseMessageContentUnion `json:"content"` - // This field is from variant [ConversationItemGetResponseMessage]. - Role ConversationItemGetResponseMessageRole `json:"role"` - // Any of "message", "web_search_call", "file_search_call", "function_call", - // "function_call_output", "mcp_approval_request", "mcp_approval_response", - // "mcp_call", "mcp_list_tools". - Type string `json:"type"` - ID string `json:"id"` - Status string `json:"status"` - // This field is from variant [ConversationItemGetResponseFileSearchCall]. - Queries []string `json:"queries"` - // This field is from variant [ConversationItemGetResponseFileSearchCall]. - Results []ConversationItemGetResponseFileSearchCallResult `json:"results"` - Arguments string `json:"arguments"` - CallID string `json:"call_id"` - Name string `json:"name"` - Output string `json:"output"` - ServerLabel string `json:"server_label"` - // This field is from variant [ConversationItemGetResponseMcpApprovalResponse]. - ApprovalRequestID string `json:"approval_request_id"` - // This field is from variant [ConversationItemGetResponseMcpApprovalResponse]. - Approve bool `json:"approve"` - // This field is from variant [ConversationItemGetResponseMcpApprovalResponse]. - Reason string `json:"reason"` - // This field is from variant [ConversationItemGetResponseMcpCall]. - Error string `json:"error"` - // This field is from variant [ConversationItemGetResponseMcpListTools]. - Tools []ConversationItemGetResponseMcpListToolsTool `json:"tools"` - JSON struct { - Content respjson.Field - Role respjson.Field - Type respjson.Field - ID respjson.Field - Status respjson.Field - Queries respjson.Field - Results respjson.Field - Arguments respjson.Field - CallID respjson.Field - Name respjson.Field - Output respjson.Field - ServerLabel respjson.Field - ApprovalRequestID respjson.Field - Approve respjson.Field - Reason respjson.Field - Error respjson.Field - Tools respjson.Field - raw string +// Response for deleted conversation item. +type ConversationItemDeleteResponse struct { + // The deleted item identifier + ID string `json:"id,required"` + // Whether the object was deleted + Deleted bool `json:"deleted"` + // Object type + Object string `json:"object"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Deleted respjson.Field + Object respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } -// anyConversationItemGetResponse is implemented by each variant of -// [ConversationItemGetResponseUnion] to add type safety for the return type of -// [ConversationItemGetResponseUnion.AsAny] -type anyConversationItemGetResponse interface { - implConversationItemGetResponseUnion() -} - -func (ConversationItemGetResponseMessage) implConversationItemGetResponseUnion() {} -func (ConversationItemGetResponseWebSearchCall) implConversationItemGetResponseUnion() {} -func (ConversationItemGetResponseFileSearchCall) implConversationItemGetResponseUnion() {} -func (ConversationItemGetResponseFunctionCall) implConversationItemGetResponseUnion() {} -func (ConversationItemGetResponseFunctionCallOutput) implConversationItemGetResponseUnion() {} -func (ConversationItemGetResponseMcpApprovalRequest) implConversationItemGetResponseUnion() {} -func (ConversationItemGetResponseMcpApprovalResponse) implConversationItemGetResponseUnion() {} -func (ConversationItemGetResponseMcpCall) implConversationItemGetResponseUnion() {} -func (ConversationItemGetResponseMcpListTools) implConversationItemGetResponseUnion() {} - -// Use the following switch statement to find the correct variant -// -// switch variant := ConversationItemGetResponseUnion.AsAny().(type) { -// case llamastackclient.ConversationItemGetResponseMessage: -// case llamastackclient.ConversationItemGetResponseWebSearchCall: -// case llamastackclient.ConversationItemGetResponseFileSearchCall: -// case llamastackclient.ConversationItemGetResponseFunctionCall: -// case llamastackclient.ConversationItemGetResponseFunctionCallOutput: -// case llamastackclient.ConversationItemGetResponseMcpApprovalRequest: -// case llamastackclient.ConversationItemGetResponseMcpApprovalResponse: -// case llamastackclient.ConversationItemGetResponseMcpCall: -// case llamastackclient.ConversationItemGetResponseMcpListTools: -// default: -// fmt.Errorf("no variant present") -// } -func (u ConversationItemGetResponseUnion) AsAny() anyConversationItemGetResponse { - switch u.Type { - case "message": - return u.AsMessage() - case "web_search_call": - return u.AsWebSearchCall() - case "file_search_call": - return u.AsFileSearchCall() - case "function_call": - return u.AsFunctionCall() - case "function_call_output": - return u.AsFunctionCallOutput() - case "mcp_approval_request": - return u.AsMcpApprovalRequest() - case "mcp_approval_response": - return u.AsMcpApprovalResponse() - case "mcp_call": - return u.AsMcpCall() - case "mcp_list_tools": - return u.AsMcpListTools() - } - return nil -} - -func (u ConversationItemGetResponseUnion) AsMessage() (v ConversationItemGetResponseMessage) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ConversationItemGetResponseUnion) AsWebSearchCall() (v ConversationItemGetResponseWebSearchCall) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ConversationItemGetResponseUnion) AsFileSearchCall() (v ConversationItemGetResponseFileSearchCall) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ConversationItemGetResponseUnion) AsFunctionCall() (v ConversationItemGetResponseFunctionCall) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ConversationItemGetResponseUnion) AsFunctionCallOutput() (v ConversationItemGetResponseFunctionCallOutput) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ConversationItemGetResponseUnion) AsMcpApprovalRequest() (v ConversationItemGetResponseMcpApprovalRequest) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ConversationItemGetResponseUnion) AsMcpApprovalResponse() (v ConversationItemGetResponseMcpApprovalResponse) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ConversationItemGetResponseUnion) AsMcpCall() (v ConversationItemGetResponseMcpCall) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ConversationItemGetResponseUnion) AsMcpListTools() (v ConversationItemGetResponseMcpListTools) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - // Returns the unmodified JSON received from the API -func (u ConversationItemGetResponseUnion) RawJSON() string { return u.JSON.raw } - -func (r *ConversationItemGetResponseUnion) UnmarshalJSON(data []byte) error { +func (r ConversationItemDeleteResponse) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemDeleteResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Corresponds to the various Message types in the Responses API. They are all // under one type because the Responses API gives them all the same "type" value, // and there is no way to tell them apart in certain scenarios. -type ConversationItemGetResponseMessage struct { - Content ConversationItemGetResponseMessageContentUnion `json:"content,required"` +type ConversationItemGetResponse struct { + Content ConversationItemGetResponseContentUnion `json:"content,required"` // Any of "system", "developer", "user", "assistant". - Role ConversationItemGetResponseMessageRole `json:"role,required"` - Type constant.Message `json:"type,required"` - ID string `json:"id"` - Status string `json:"status"` + Role ConversationItemGetResponseRole `json:"role,required"` + ID string `json:"id,nullable"` + Status string `json:"status,nullable"` + // Any of "message". + Type ConversationItemGetResponseType `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field Role respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ConversationItemGetResponseMessage) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemGetResponseMessage) UnmarshalJSON(data []byte) error { +func (r ConversationItemGetResponse) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemGetResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ConversationItemGetResponseMessageContentUnion contains all possible properties -// and values from [string], -// [[]ConversationItemGetResponseMessageContentArrayItemUnion], -// [[]ConversationItemGetResponseMessageContentArrayItemUnion]. +// ConversationItemGetResponseContentUnion contains all possible properties and +// values from [string], +// [[]ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion], +// [[]ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString OfVariant2] -type ConversationItemGetResponseMessageContentUnion struct { +// will be valid: OfString +// OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile +// OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal] +type ConversationItemGetResponseContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ConversationItemGetResponseMessageContentArrayItemUnion] instead of an - // object. - OfVariant2 []ConversationItemGetResponseMessageContentArrayItemUnion `json:",inline"` - JSON struct { - OfString respjson.Field - OfVariant2 respjson.Field - raw string + // [[]ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion] + // instead of an object. + OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile []ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion `json:",inline"` + // This field will be present if the value is a + // [[]ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion] + // instead of an object. + OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal []ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile respjson.Field + OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal respjson.Field + raw string } `json:"-"` } -func (u ConversationItemGetResponseMessageContentUnion) AsString() (v string) { +func (u ConversationItemGetResponseContentUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ConversationItemGetResponseMessageContentUnion) AsConversationItemGetResponseMessageContentArray() (v []ConversationItemGetResponseMessageContentArrayItemUnion) { +func (u ConversationItemGetResponseContentUnion) AsListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile() (v []ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ConversationItemGetResponseMessageContentUnion) AsVariant2() (v []ConversationItemGetResponseMessageContentArrayItemUnion) { +func (u ConversationItemGetResponseContentUnion) AsListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal() (v []ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ConversationItemGetResponseMessageContentUnion) RawJSON() string { return u.JSON.raw } +func (u ConversationItemGetResponseContentUnion) RawJSON() string { return u.JSON.raw } -func (r *ConversationItemGetResponseMessageContentUnion) UnmarshalJSON(data []byte) error { +func (r *ConversationItemGetResponseContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ConversationItemGetResponseMessageContentArrayItemUnion contains all possible -// properties and values from -// [ConversationItemGetResponseMessageContentArrayItemInputText], -// [ConversationItemGetResponseMessageContentArrayItemInputImage], -// [ConversationItemGetResponseMessageContentArrayItemInputFile]. +// ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion +// contains all possible properties and values from +// [ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText], +// [ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage], +// [ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. // -// Use the [ConversationItemGetResponseMessageContentArrayItemUnion.AsAny] method -// to switch on the variant. +// Use the +// [ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny] +// method to switch on the variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type ConversationItemGetResponseMessageContentArrayItemUnion struct { +type ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion struct { // This field is from variant - // [ConversationItemGetResponseMessageContentArrayItemInputText]. + // [ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText]. Text string `json:"text"` // Any of "input_text", "input_image", "input_file". Type string `json:"type"` // This field is from variant - // [ConversationItemGetResponseMessageContentArrayItemInputImage]. - Detail ConversationItemGetResponseMessageContentArrayItemInputImageDetail `json:"detail"` - FileID string `json:"file_id"` + // [ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]. + Detail string `json:"detail"` + FileID string `json:"file_id"` // This field is from variant - // [ConversationItemGetResponseMessageContentArrayItemInputImage]. + // [ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]. ImageURL string `json:"image_url"` // This field is from variant - // [ConversationItemGetResponseMessageContentArrayItemInputFile]. + // [ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. FileData string `json:"file_data"` // This field is from variant - // [ConversationItemGetResponseMessageContentArrayItemInputFile]. + // [ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. FileURL string `json:"file_url"` // This field is from variant - // [ConversationItemGetResponseMessageContentArrayItemInputFile]. + // [ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. Filename string `json:"filename"` JSON struct { Text respjson.Field @@ -2143,31 +2392,32 @@ type ConversationItemGetResponseMessageContentArrayItemUnion struct { } `json:"-"` } -// anyConversationItemGetResponseMessageContentArrayItem is implemented by each -// variant of [ConversationItemGetResponseMessageContentArrayItemUnion] to add type -// safety for the return type of -// [ConversationItemGetResponseMessageContentArrayItemUnion.AsAny] -type anyConversationItemGetResponseMessageContentArrayItem interface { - implConversationItemGetResponseMessageContentArrayItemUnion() +// anyConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem +// is implemented by each variant of +// [ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion] +// to add type safety for the return type of +// [ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny] +type anyConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem interface { + implConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() } -func (ConversationItemGetResponseMessageContentArrayItemInputText) implConversationItemGetResponseMessageContentArrayItemUnion() { +func (ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) implConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { } -func (ConversationItemGetResponseMessageContentArrayItemInputImage) implConversationItemGetResponseMessageContentArrayItemUnion() { +func (ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) implConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { } -func (ConversationItemGetResponseMessageContentArrayItemInputFile) implConversationItemGetResponseMessageContentArrayItemUnion() { +func (ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) implConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { } // Use the following switch statement to find the correct variant // -// switch variant := ConversationItemGetResponseMessageContentArrayItemUnion.AsAny().(type) { -// case llamastackclient.ConversationItemGetResponseMessageContentArrayItemInputText: -// case llamastackclient.ConversationItemGetResponseMessageContentArrayItemInputImage: -// case llamastackclient.ConversationItemGetResponseMessageContentArrayItemInputFile: +// switch variant := ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny().(type) { +// case llamastackclient.ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText: +// case llamastackclient.ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage: +// case llamastackclient.ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile: // default: // fmt.Errorf("no variant present") // } -func (u ConversationItemGetResponseMessageContentArrayItemUnion) AsAny() anyConversationItemGetResponseMessageContentArrayItem { +func (u ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsAny() anyConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem { switch u.Type { case "input_text": return u.AsInputText() @@ -2179,34 +2429,35 @@ func (u ConversationItemGetResponseMessageContentArrayItemUnion) AsAny() anyConv return nil } -func (u ConversationItemGetResponseMessageContentArrayItemUnion) AsInputText() (v ConversationItemGetResponseMessageContentArrayItemInputText) { +func (u ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputText() (v ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ConversationItemGetResponseMessageContentArrayItemUnion) AsInputImage() (v ConversationItemGetResponseMessageContentArrayItemInputImage) { +func (u ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputImage() (v ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ConversationItemGetResponseMessageContentArrayItemUnion) AsInputFile() (v ConversationItemGetResponseMessageContentArrayItemInputFile) { +func (u ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputFile() (v ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ConversationItemGetResponseMessageContentArrayItemUnion) RawJSON() string { return u.JSON.raw } +func (u ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) RawJSON() string { + return u.JSON.raw +} -func (r *ConversationItemGetResponseMessageContentArrayItemUnion) UnmarshalJSON(data []byte) error { +func (r *ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content for input messages in OpenAI response format. -type ConversationItemGetResponseMessageContentArrayItemInputText struct { - // The text content of the input message +type ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText struct { Text string `json:"text,required"` - // Content type identifier, always "input_text" - Type constant.InputText `json:"type,required"` + // Any of "input_text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -2217,313 +2468,327 @@ type ConversationItemGetResponseMessageContentArrayItemInputText struct { } // Returns the unmodified JSON received from the API -func (r ConversationItemGetResponseMessageContentArrayItemInputText) RawJSON() string { +func (r ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemGetResponseMessageContentArrayItemInputText) UnmarshalJSON(data []byte) error { +func (r *ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Image content for input messages in OpenAI response format. -type ConversationItemGetResponseMessageContentArrayItemInputImage struct { - // Level of detail for image processing, can be "low", "high", or "auto" - // +type ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage struct { // Any of "low", "high", "auto". - Detail ConversationItemGetResponseMessageContentArrayItemInputImageDetail `json:"detail,required"` - // Content type identifier, always "input_image" - Type constant.InputImage `json:"type,required"` - // (Optional) The ID of the file to be sent to the model. - FileID string `json:"file_id"` - // (Optional) URL of the image content - ImageURL string `json:"image_url"` + Detail string `json:"detail"` + FileID string `json:"file_id,nullable"` + ImageURL string `json:"image_url,nullable"` + // Any of "input_image". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Detail respjson.Field - Type respjson.Field FileID respjson.Field ImageURL respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ConversationItemGetResponseMessageContentArrayItemInputImage) RawJSON() string { +func (r ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemGetResponseMessageContentArrayItemInputImage) UnmarshalJSON(data []byte) error { +func (r *ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ConversationItemGetResponseMessageContentArrayItemInputImageDetail string - -const ( - ConversationItemGetResponseMessageContentArrayItemInputImageDetailLow ConversationItemGetResponseMessageContentArrayItemInputImageDetail = "low" - ConversationItemGetResponseMessageContentArrayItemInputImageDetailHigh ConversationItemGetResponseMessageContentArrayItemInputImageDetail = "high" - ConversationItemGetResponseMessageContentArrayItemInputImageDetailAuto ConversationItemGetResponseMessageContentArrayItemInputImageDetail = "auto" -) - // File content for input messages in OpenAI response format. -type ConversationItemGetResponseMessageContentArrayItemInputFile struct { - // The type of the input item. Always `input_file`. - Type constant.InputFile `json:"type,required"` - // The data of the file to be sent to the model. - FileData string `json:"file_data"` - // (Optional) The ID of the file to be sent to the model. - FileID string `json:"file_id"` - // The URL of the file to be sent to the model. - FileURL string `json:"file_url"` - // The name of the file to be sent to the model. - Filename string `json:"filename"` +type ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile struct { + FileData string `json:"file_data,nullable"` + FileID string `json:"file_id,nullable"` + FileURL string `json:"file_url,nullable"` + Filename string `json:"filename,nullable"` + // Any of "input_file". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field FileData respjson.Field FileID respjson.Field FileURL respjson.Field Filename respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ConversationItemGetResponseMessageContentArrayItemInputFile) RawJSON() string { +func (r ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemGetResponseMessageContentArrayItemInputFile) UnmarshalJSON(data []byte) error { +func (r *ConversationItemGetResponseContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ConversationItemGetResponseMessageContentArrayItemDetail string - -const ( - ConversationItemGetResponseMessageContentArrayItemDetailLow ConversationItemGetResponseMessageContentArrayItemDetail = "low" - ConversationItemGetResponseMessageContentArrayItemDetailHigh ConversationItemGetResponseMessageContentArrayItemDetail = "high" - ConversationItemGetResponseMessageContentArrayItemDetailAuto ConversationItemGetResponseMessageContentArrayItemDetail = "auto" -) - -type ConversationItemGetResponseMessageRole string - -const ( - ConversationItemGetResponseMessageRoleSystem ConversationItemGetResponseMessageRole = "system" - ConversationItemGetResponseMessageRoleDeveloper ConversationItemGetResponseMessageRole = "developer" - ConversationItemGetResponseMessageRoleUser ConversationItemGetResponseMessageRole = "user" - ConversationItemGetResponseMessageRoleAssistant ConversationItemGetResponseMessageRole = "assistant" -) - -// Web search tool call output message for OpenAI responses. -type ConversationItemGetResponseWebSearchCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // Current status of the web search operation - Status string `json:"status,required"` - // Tool call type identifier, always "web_search_call" - Type constant.WebSearchCall `json:"type,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - ID respjson.Field - Status respjson.Field +// ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion +// contains all possible properties and values from +// [ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText], +// [ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]. +// +// Use the +// [ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny] +// method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion struct { + // This field is from variant + // [ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]. + Text string `json:"text"` + // This field is from variant + // [ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]. + Annotations []ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion `json:"annotations"` + // Any of "output_text", "refusal". + Type string `json:"type"` + // This field is from variant + // [ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]. + Refusal string `json:"refusal"` + JSON struct { + Text respjson.Field + Annotations respjson.Field Type respjson.Field - ExtraFields map[string]respjson.Field + Refusal respjson.Field raw string } `json:"-"` } -// Returns the unmodified JSON received from the API -func (r ConversationItemGetResponseWebSearchCall) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemGetResponseWebSearchCall) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) +// anyConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem +// is implemented by each variant of +// [ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion] +// to add type safety for the return type of +// [ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny] +type anyConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem interface { + implConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() } -// File search tool call output message for OpenAI responses. -type ConversationItemGetResponseFileSearchCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // List of search queries executed - Queries []string `json:"queries,required"` - // Current status of the file search operation - Status string `json:"status,required"` - // Tool call type identifier, always "file_search_call" - Type constant.FileSearchCall `json:"type,required"` - // (Optional) Search results returned by the file search operation - Results []ConversationItemGetResponseFileSearchCallResult `json:"results"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - ID respjson.Field - Queries respjson.Field - Status respjson.Field - Type respjson.Field - Results respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` +func (ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) implConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() { +} +func (ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) implConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny().(type) { +// case llamastackclient.ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText: +// case llamastackclient.ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal: +// default: +// fmt.Errorf("no variant present") +// } +func (u ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsAny() anyConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem { + switch u.Type { + case "output_text": + return u.AsOutputText() + case "refusal": + return u.AsRefusal() + } + return nil +} + +func (u ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsOutputText() (v ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsRefusal() (v ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return } // Returns the unmodified JSON received from the API -func (r ConversationItemGetResponseFileSearchCall) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemGetResponseFileSearchCall) UnmarshalJSON(data []byte) error { +func (u ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Search results returned by the file search operation. -type ConversationItemGetResponseFileSearchCallResult struct { - // (Optional) Key-value attributes associated with the file - Attributes map[string]ConversationItemGetResponseFileSearchCallResultAttributeUnion `json:"attributes,required"` - // Unique identifier of the file containing the result - FileID string `json:"file_id,required"` - // Name of the file containing the result - Filename string `json:"filename,required"` - // Relevance score for this search result (between 0 and 1) - Score float64 `json:"score,required"` - // Text content of the search result - Text string `json:"text,required"` +type ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText struct { + Text string `json:"text,required"` + Annotations []ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion `json:"annotations"` + // Any of "output_text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Attributes respjson.Field - FileID respjson.Field - Filename respjson.Field - Score respjson.Field Text respjson.Field + Annotations respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ConversationItemGetResponseFileSearchCallResult) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemGetResponseFileSearchCallResult) UnmarshalJSON(data []byte) error { +func (r ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ConversationItemGetResponseFileSearchCallResultAttributeUnion contains all -// possible properties and values from [bool], [float64], [string], [[]any]. +// ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion +// contains all possible properties and values from +// [ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation], +// [ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation], +// [ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation], +// [ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath]. // -// Use the methods beginning with 'As' to cast the union to one of its variants. +// Use the +// [ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny] +// method to switch on the variant. // -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ConversationItemGetResponseFileSearchCallResultAttributeUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion struct { + FileID string `json:"file_id"` + Filename string `json:"filename"` + Index int64 `json:"index"` + // Any of "file_citation", "url_citation", "container_file_citation", "file_path". + Type string `json:"type"` + EndIndex int64 `json:"end_index"` + StartIndex int64 `json:"start_index"` + // This field is from variant + // [ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]. + Title string `json:"title"` + // This field is from variant + // [ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]. + URL string `json:"url"` + // This field is from variant + // [ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation]. + ContainerID string `json:"container_id"` + JSON struct { + FileID respjson.Field + Filename respjson.Field + Index respjson.Field + Type respjson.Field + EndIndex respjson.Field + StartIndex respjson.Field + Title respjson.Field + URL respjson.Field + ContainerID respjson.Field + raw string } `json:"-"` } -func (u ConversationItemGetResponseFileSearchCallResultAttributeUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// anyConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation +// is implemented by each variant of +// [ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion] +// to add type safety for the return type of +// [ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny] +type anyConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation interface { + implConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() } -func (u ConversationItemGetResponseFileSearchCallResultAttributeUnion) AsFloat() (v float64) { +func (ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) implConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} +func (ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) implConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} +func (ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) implConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} +func (ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) implConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny().(type) { +// case llamastackclient.ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation: +// case llamastackclient.ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation: +// case llamastackclient.ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation: +// case llamastackclient.ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath: +// default: +// fmt.Errorf("no variant present") +// } +func (u ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsAny() anyConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation { + switch u.Type { + case "file_citation": + return u.AsFileCitation() + case "url_citation": + return u.AsURLCitation() + case "container_file_citation": + return u.AsContainerFileCitation() + case "file_path": + return u.AsFilePath() + } + return nil +} + +func (u ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsFileCitation() (v ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ConversationItemGetResponseFileSearchCallResultAttributeUnion) AsString() (v string) { +func (u ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsURLCitation() (v ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ConversationItemGetResponseFileSearchCallResultAttributeUnion) AsAnyArray() (v []any) { +func (u ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsContainerFileCitation() (v ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsFilePath() (v ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ConversationItemGetResponseFileSearchCallResultAttributeUnion) RawJSON() string { +func (u ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) RawJSON() string { return u.JSON.raw } -func (r *ConversationItemGetResponseFileSearchCallResultAttributeUnion) UnmarshalJSON(data []byte) error { +func (r *ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Function tool call output message for OpenAI responses. -type ConversationItemGetResponseFunctionCall struct { - // JSON string containing the function arguments - Arguments string `json:"arguments,required"` - // Unique identifier for the function call - CallID string `json:"call_id,required"` - // Name of the function being called - Name string `json:"name,required"` - // Tool call type identifier, always "function_call" - Type constant.FunctionCall `json:"type,required"` - // (Optional) Additional identifier for the tool call - ID string `json:"id"` - // (Optional) Current status of the function call execution - Status string `json:"status"` +// File citation annotation for referencing specific files in response content. +type ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation struct { + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Index int64 `json:"index,required"` + // Any of "file_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Arguments respjson.Field - CallID respjson.Field - Name respjson.Field + FileID respjson.Field + Filename respjson.Field + Index respjson.Field Type respjson.Field - ID respjson.Field - Status respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ConversationItemGetResponseFunctionCall) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemGetResponseFunctionCall) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// This represents the output of a function call that gets passed back to the -// model. -type ConversationItemGetResponseFunctionCallOutput struct { - CallID string `json:"call_id,required"` - Output string `json:"output,required"` - Type constant.FunctionCallOutput `json:"type,required"` - ID string `json:"id"` - Status string `json:"status"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - CallID respjson.Field - Output respjson.Field - Type respjson.Field - ID respjson.Field - Status respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` +func (r ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) RawJSON() string { + return r.JSON.raw } - -// Returns the unmodified JSON received from the API -func (r ConversationItemGetResponseFunctionCallOutput) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemGetResponseFunctionCallOutput) UnmarshalJSON(data []byte) error { +func (r *ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// A request for human approval of a tool invocation. -type ConversationItemGetResponseMcpApprovalRequest struct { - ID string `json:"id,required"` - Arguments string `json:"arguments,required"` - Name string `json:"name,required"` - ServerLabel string `json:"server_label,required"` - Type constant.McpApprovalRequest `json:"type,required"` +// URL citation annotation for referencing external web resources. +type ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation struct { + EndIndex int64 `json:"end_index,required"` + StartIndex int64 `json:"start_index,required"` + Title string `json:"title,required"` + URL string `json:"url,required"` + // Any of "url_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - ID respjson.Field - Arguments respjson.Field - Name respjson.Field - ServerLabel respjson.Field + EndIndex respjson.Field + StartIndex respjson.Field + Title respjson.Field + URL respjson.Field Type respjson.Field ExtraFields map[string]respjson.Field raw string @@ -2531,87 +2796,51 @@ type ConversationItemGetResponseMcpApprovalRequest struct { } // Returns the unmodified JSON received from the API -func (r ConversationItemGetResponseMcpApprovalRequest) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemGetResponseMcpApprovalRequest) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A response to an MCP approval request. -type ConversationItemGetResponseMcpApprovalResponse struct { - ApprovalRequestID string `json:"approval_request_id,required"` - Approve bool `json:"approve,required"` - Type constant.McpApprovalResponse `json:"type,required"` - ID string `json:"id"` - Reason string `json:"reason"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - ApprovalRequestID respjson.Field - Approve respjson.Field - Type respjson.Field - ID respjson.Field - Reason respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` +func (r ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) RawJSON() string { + return r.JSON.raw } - -// Returns the unmodified JSON received from the API -func (r ConversationItemGetResponseMcpApprovalResponse) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemGetResponseMcpApprovalResponse) UnmarshalJSON(data []byte) error { +func (r *ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Model Context Protocol (MCP) call output message for OpenAI responses. -type ConversationItemGetResponseMcpCall struct { - // Unique identifier for this MCP call - ID string `json:"id,required"` - // JSON string containing the MCP call arguments - Arguments string `json:"arguments,required"` - // Name of the MCP method being called - Name string `json:"name,required"` - // Label identifying the MCP server handling the call - ServerLabel string `json:"server_label,required"` - // Tool call type identifier, always "mcp_call" - Type constant.McpCall `json:"type,required"` - // (Optional) Error message if the MCP call failed - Error string `json:"error"` - // (Optional) Output result from the successful MCP call - Output string `json:"output"` +type ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation struct { + ContainerID string `json:"container_id,required"` + EndIndex int64 `json:"end_index,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + StartIndex int64 `json:"start_index,required"` + // Any of "container_file_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - ID respjson.Field - Arguments respjson.Field - Name respjson.Field - ServerLabel respjson.Field + ContainerID respjson.Field + EndIndex respjson.Field + FileID respjson.Field + Filename respjson.Field + StartIndex respjson.Field Type respjson.Field - Error respjson.Field - Output respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ConversationItemGetResponseMcpCall) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemGetResponseMcpCall) UnmarshalJSON(data []byte) error { +func (r ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// MCP list tools output message containing available tools from an MCP server. -type ConversationItemGetResponseMcpListTools struct { - // Unique identifier for this MCP list tools operation - ID string `json:"id,required"` - // Label identifying the MCP server providing the tools - ServerLabel string `json:"server_label,required"` - // List of available tools provided by the MCP server - Tools []ConversationItemGetResponseMcpListToolsTool `json:"tools,required"` - // Tool call type identifier, always "mcp_list_tools" - Type constant.McpListTools `json:"type,required"` +type ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath struct { + FileID string `json:"file_id,required"` + Index int64 `json:"index,required"` + // Any of "file_path". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - ID respjson.Field - ServerLabel respjson.Field - Tools respjson.Field + FileID respjson.Field + Index respjson.Field Type respjson.Field ExtraFields map[string]respjson.Field raw string @@ -2619,86 +2848,32 @@ type ConversationItemGetResponseMcpListTools struct { } // Returns the unmodified JSON received from the API -func (r ConversationItemGetResponseMcpListTools) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemGetResponseMcpListTools) UnmarshalJSON(data []byte) error { +func (r ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Tool definition returned by MCP list tools operation. -type ConversationItemGetResponseMcpListToolsTool struct { - // JSON schema defining the tool's input parameters - InputSchema map[string]ConversationItemGetResponseMcpListToolsToolInputSchemaUnion `json:"input_schema,required"` - // Name of the tool - Name string `json:"name,required"` - // (Optional) Description of what the tool does - Description string `json:"description"` +// Refusal content within a streamed response part. +type ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal struct { + Refusal string `json:"refusal,required"` + // Any of "refusal". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - InputSchema respjson.Field - Name respjson.Field - Description respjson.Field + Refusal respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ConversationItemGetResponseMcpListToolsTool) RawJSON() string { return r.JSON.raw } -func (r *ConversationItemGetResponseMcpListToolsTool) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ConversationItemGetResponseMcpListToolsToolInputSchemaUnion contains all -// possible properties and values from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ConversationItemGetResponseMcpListToolsToolInputSchemaUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ConversationItemGetResponseMcpListToolsToolInputSchemaUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ConversationItemGetResponseMcpListToolsToolInputSchemaUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ConversationItemGetResponseMcpListToolsToolInputSchemaUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ConversationItemGetResponseMcpListToolsToolInputSchemaUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ConversationItemGetResponseMcpListToolsToolInputSchemaUnion) RawJSON() string { - return u.JSON.raw +func (r ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) RawJSON() string { + return r.JSON.raw } - -func (r *ConversationItemGetResponseMcpListToolsToolInputSchemaUnion) UnmarshalJSON(data []byte) error { +func (r *ConversationItemGetResponseContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } @@ -2711,8 +2886,13 @@ const ( ConversationItemGetResponseRoleAssistant ConversationItemGetResponseRole = "assistant" ) +type ConversationItemGetResponseType string + +const ( + ConversationItemGetResponseTypeMessage ConversationItemGetResponseType = "message" +) + type ConversationItemNewParams struct { - // Items to include in the conversation context. Items []ConversationItemNewParamsItemUnion `json:"items,omitzero,required"` paramObj } @@ -2790,7 +2970,7 @@ func (u ConversationItemNewParamsItemUnion) GetContent() *ConversationItemNewPar // Returns a pointer to the underlying variant's property, if present. func (u ConversationItemNewParamsItemUnion) GetRole() *string { if vt := u.OfMessage; vt != nil { - return (*string)(&vt.Role) + return &vt.Role } return nil } @@ -2851,6 +3031,46 @@ func (u ConversationItemNewParamsItemUnion) GetTools() []ConversationItemNewPara return nil } +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemUnion) GetID() *string { + if vt := u.OfMessage; vt != nil && vt.ID.Valid() { + return &vt.ID.Value + } else if vt := u.OfWebSearchCall; vt != nil { + return (*string)(&vt.ID) + } else if vt := u.OfFileSearchCall; vt != nil { + return (*string)(&vt.ID) + } else if vt := u.OfFunctionCall; vt != nil && vt.ID.Valid() { + return &vt.ID.Value + } else if vt := u.OfFunctionCallOutput; vt != nil && vt.ID.Valid() { + return &vt.ID.Value + } else if vt := u.OfMcpApprovalRequest; vt != nil { + return (*string)(&vt.ID) + } else if vt := u.OfMcpApprovalResponse; vt != nil && vt.ID.Valid() { + return &vt.ID.Value + } else if vt := u.OfMcpCall; vt != nil { + return (*string)(&vt.ID) + } else if vt := u.OfMcpListTools; vt != nil { + return (*string)(&vt.ID) + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemUnion) GetStatus() *string { + if vt := u.OfMessage; vt != nil && vt.Status.Valid() { + return &vt.Status.Value + } else if vt := u.OfWebSearchCall; vt != nil { + return (*string)(&vt.Status) + } else if vt := u.OfFileSearchCall; vt != nil { + return (*string)(&vt.Status) + } else if vt := u.OfFunctionCall; vt != nil && vt.Status.Valid() { + return &vt.Status.Value + } else if vt := u.OfFunctionCallOutput; vt != nil && vt.Status.Valid() { + return &vt.Status.Value + } + return nil +} + // Returns a pointer to the underlying variant's property, if present. func (u ConversationItemNewParamsItemUnion) GetType() *string { if vt := u.OfMessage; vt != nil { @@ -2876,380 +3096,676 @@ func (u ConversationItemNewParamsItemUnion) GetType() *string { } // Returns a pointer to the underlying variant's property, if present. -func (u ConversationItemNewParamsItemUnion) GetID() *string { - if vt := u.OfMessage; vt != nil && vt.ID.Valid() { - return &vt.ID.Value - } else if vt := u.OfWebSearchCall; vt != nil { - return (*string)(&vt.ID) - } else if vt := u.OfFileSearchCall; vt != nil { - return (*string)(&vt.ID) - } else if vt := u.OfFunctionCall; vt != nil && vt.ID.Valid() { - return &vt.ID.Value - } else if vt := u.OfFunctionCallOutput; vt != nil && vt.ID.Valid() { - return &vt.ID.Value +func (u ConversationItemNewParamsItemUnion) GetArguments() *string { + if vt := u.OfFunctionCall; vt != nil { + return (*string)(&vt.Arguments) } else if vt := u.OfMcpApprovalRequest; vt != nil { - return (*string)(&vt.ID) - } else if vt := u.OfMcpApprovalResponse; vt != nil && vt.ID.Valid() { - return &vt.ID.Value + return (*string)(&vt.Arguments) } else if vt := u.OfMcpCall; vt != nil { - return (*string)(&vt.ID) + return (*string)(&vt.Arguments) + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemUnion) GetCallID() *string { + if vt := u.OfFunctionCall; vt != nil { + return (*string)(&vt.CallID) + } else if vt := u.OfFunctionCallOutput; vt != nil { + return (*string)(&vt.CallID) + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemUnion) GetName() *string { + if vt := u.OfFunctionCall; vt != nil { + return (*string)(&vt.Name) + } else if vt := u.OfMcpApprovalRequest; vt != nil { + return (*string)(&vt.Name) + } else if vt := u.OfMcpCall; vt != nil { + return (*string)(&vt.Name) + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemUnion) GetOutput() *string { + if vt := u.OfFunctionCallOutput; vt != nil { + return (*string)(&vt.Output) + } else if vt := u.OfMcpCall; vt != nil && vt.Output.Valid() { + return &vt.Output.Value + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemUnion) GetServerLabel() *string { + if vt := u.OfMcpApprovalRequest; vt != nil { + return (*string)(&vt.ServerLabel) + } else if vt := u.OfMcpCall; vt != nil { + return (*string)(&vt.ServerLabel) } else if vt := u.OfMcpListTools; vt != nil { - return (*string)(&vt.ID) + return (*string)(&vt.ServerLabel) + } + return nil +} + +func init() { + apijson.RegisterUnion[ConversationItemNewParamsItemUnion]( + "type", + apijson.Discriminator[ConversationItemNewParamsItemMessage]("message"), + apijson.Discriminator[ConversationItemNewParamsItemWebSearchCall]("web_search_call"), + apijson.Discriminator[ConversationItemNewParamsItemFileSearchCall]("file_search_call"), + apijson.Discriminator[ConversationItemNewParamsItemFunctionCall]("function_call"), + apijson.Discriminator[ConversationItemNewParamsItemFunctionCallOutput]("function_call_output"), + apijson.Discriminator[ConversationItemNewParamsItemMcpApprovalRequest]("mcp_approval_request"), + apijson.Discriminator[ConversationItemNewParamsItemMcpApprovalResponse]("mcp_approval_response"), + apijson.Discriminator[ConversationItemNewParamsItemMcpCall]("mcp_call"), + apijson.Discriminator[ConversationItemNewParamsItemMcpListTools]("mcp_list_tools"), + ) +} + +// Corresponds to the various Message types in the Responses API. They are all +// under one type because the Responses API gives them all the same "type" value, +// and there is no way to tell them apart in certain scenarios. +// +// The properties Content, Role are required. +type ConversationItemNewParamsItemMessage struct { + Content ConversationItemNewParamsItemMessageContentUnion `json:"content,omitzero,required"` + // Any of "system", "developer", "user", "assistant". + Role string `json:"role,omitzero,required"` + ID param.Opt[string] `json:"id,omitzero"` + Status param.Opt[string] `json:"status,omitzero"` + // Any of "message". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ConversationItemNewParamsItemMessage) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParamsItemMessage + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationItemNewParamsItemMessage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ConversationItemNewParamsItemMessage]( + "role", "system", "developer", "user", "assistant", + ) + apijson.RegisterFieldValidator[ConversationItemNewParamsItemMessage]( + "type", "message", + ) +} + +// Only one field can be non-zero. +// +// Use [param.IsOmitted] to confirm if a field is set. +type ConversationItemNewParamsItemMessageContentUnion struct { + OfString param.Opt[string] `json:",omitzero,inline"` + OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile []ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion `json:",omitzero,inline"` + OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal []ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion `json:",omitzero,inline"` + paramUnion +} + +func (u ConversationItemNewParamsItemMessageContentUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfString, u.OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile, u.OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal) +} +func (u *ConversationItemNewParamsItemMessageContentUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *ConversationItemNewParamsItemMessageContentUnion) asAny() any { + if !param.IsOmitted(u.OfString) { + return &u.OfString.Value + } else if !param.IsOmitted(u.OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile) { + return &u.OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile + } else if !param.IsOmitted(u.OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal) { + return &u.OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal } return nil } -// Returns a pointer to the underlying variant's property, if present. -func (u ConversationItemNewParamsItemUnion) GetStatus() *string { - if vt := u.OfMessage; vt != nil && vt.Status.Valid() { - return &vt.Status.Value - } else if vt := u.OfWebSearchCall; vt != nil { - return (*string)(&vt.Status) - } else if vt := u.OfFileSearchCall; vt != nil { - return (*string)(&vt.Status) - } else if vt := u.OfFunctionCall; vt != nil && vt.Status.Valid() { - return &vt.Status.Value - } else if vt := u.OfFunctionCallOutput; vt != nil && vt.Status.Valid() { - return &vt.Status.Value - } - return nil +// Only one field can be non-zero. +// +// Use [param.IsOmitted] to confirm if a field is set. +type ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion struct { + OfInputText *ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText `json:",omitzero,inline"` + OfInputImage *ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage `json:",omitzero,inline"` + OfInputFile *ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile `json:",omitzero,inline"` + paramUnion +} + +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfInputText, u.OfInputImage, u.OfInputFile) +} +func (u *ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) asAny() any { + if !param.IsOmitted(u.OfInputText) { + return u.OfInputText + } else if !param.IsOmitted(u.OfInputImage) { + return u.OfInputImage + } else if !param.IsOmitted(u.OfInputFile) { + return u.OfInputFile + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetText() *string { + if vt := u.OfInputText; vt != nil { + return &vt.Text + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetDetail() *string { + if vt := u.OfInputImage; vt != nil { + return &vt.Detail + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetImageURL() *string { + if vt := u.OfInputImage; vt != nil && vt.ImageURL.Valid() { + return &vt.ImageURL.Value + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetFileData() *string { + if vt := u.OfInputFile; vt != nil && vt.FileData.Valid() { + return &vt.FileData.Value + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetFileURL() *string { + if vt := u.OfInputFile; vt != nil && vt.FileURL.Valid() { + return &vt.FileURL.Value + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetFilename() *string { + if vt := u.OfInputFile; vt != nil && vt.Filename.Valid() { + return &vt.Filename.Value + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetType() *string { + if vt := u.OfInputText; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfInputImage; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfInputFile; vt != nil { + return (*string)(&vt.Type) + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetFileID() *string { + if vt := u.OfInputImage; vt != nil && vt.FileID.Valid() { + return &vt.FileID.Value + } else if vt := u.OfInputFile; vt != nil && vt.FileID.Valid() { + return &vt.FileID.Value + } + return nil +} + +func init() { + apijson.RegisterUnion[ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion]( + "type", + apijson.Discriminator[ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText]("input_text"), + apijson.Discriminator[ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]("input_image"), + apijson.Discriminator[ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]("input_file"), + ) +} + +// Text content for input messages in OpenAI response format. +// +// The property Text is required. +type ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText struct { + Text string `json:"text,required"` + // Any of "input_text". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText]( + "type", "input_text", + ) +} + +// Image content for input messages in OpenAI response format. +type ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage struct { + FileID param.Opt[string] `json:"file_id,omitzero"` + ImageURL param.Opt[string] `json:"image_url,omitzero"` + // Any of "low", "high", "auto". + Detail string `json:"detail,omitzero"` + // Any of "input_image". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]( + "detail", "low", "high", "auto", + ) + apijson.RegisterFieldValidator[ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]( + "type", "input_image", + ) +} + +// File content for input messages in OpenAI response format. +type ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile struct { + FileData param.Opt[string] `json:"file_data,omitzero"` + FileID param.Opt[string] `json:"file_id,omitzero"` + FileURL param.Opt[string] `json:"file_url,omitzero"` + Filename param.Opt[string] `json:"filename,omitzero"` + // Any of "input_file". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ConversationItemNewParamsItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]( + "type", "input_file", + ) +} + +// Only one field can be non-zero. +// +// Use [param.IsOmitted] to confirm if a field is set. +type ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion struct { + OfOutputText *ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText `json:",omitzero,inline"` + OfRefusal *ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal `json:",omitzero,inline"` + paramUnion } -// Returns a pointer to the underlying variant's property, if present. -func (u ConversationItemNewParamsItemUnion) GetArguments() *string { - if vt := u.OfFunctionCall; vt != nil { - return (*string)(&vt.Arguments) - } else if vt := u.OfMcpApprovalRequest; vt != nil { - return (*string)(&vt.Arguments) - } else if vt := u.OfMcpCall; vt != nil { - return (*string)(&vt.Arguments) +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfOutputText, u.OfRefusal) +} +func (u *ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) asAny() any { + if !param.IsOmitted(u.OfOutputText) { + return u.OfOutputText + } else if !param.IsOmitted(u.OfRefusal) { + return u.OfRefusal } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u ConversationItemNewParamsItemUnion) GetCallID() *string { - if vt := u.OfFunctionCall; vt != nil { - return (*string)(&vt.CallID) - } else if vt := u.OfFunctionCallOutput; vt != nil { - return (*string)(&vt.CallID) +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) GetText() *string { + if vt := u.OfOutputText; vt != nil { + return &vt.Text } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u ConversationItemNewParamsItemUnion) GetName() *string { - if vt := u.OfFunctionCall; vt != nil { - return (*string)(&vt.Name) - } else if vt := u.OfMcpApprovalRequest; vt != nil { - return (*string)(&vt.Name) - } else if vt := u.OfMcpCall; vt != nil { - return (*string)(&vt.Name) +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) GetAnnotations() []ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion { + if vt := u.OfOutputText; vt != nil { + return vt.Annotations } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u ConversationItemNewParamsItemUnion) GetOutput() *string { - if vt := u.OfFunctionCallOutput; vt != nil { - return (*string)(&vt.Output) - } else if vt := u.OfMcpCall; vt != nil && vt.Output.Valid() { - return &vt.Output.Value +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) GetRefusal() *string { + if vt := u.OfRefusal; vt != nil { + return &vt.Refusal } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u ConversationItemNewParamsItemUnion) GetServerLabel() *string { - if vt := u.OfMcpApprovalRequest; vt != nil { - return (*string)(&vt.ServerLabel) - } else if vt := u.OfMcpCall; vt != nil { - return (*string)(&vt.ServerLabel) - } else if vt := u.OfMcpListTools; vt != nil { - return (*string)(&vt.ServerLabel) +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) GetType() *string { + if vt := u.OfOutputText; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfRefusal; vt != nil { + return (*string)(&vt.Type) } return nil } func init() { - apijson.RegisterUnion[ConversationItemNewParamsItemUnion]( + apijson.RegisterUnion[ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion]( "type", - apijson.Discriminator[ConversationItemNewParamsItemMessage]("message"), - apijson.Discriminator[ConversationItemNewParamsItemWebSearchCall]("web_search_call"), - apijson.Discriminator[ConversationItemNewParamsItemFileSearchCall]("file_search_call"), - apijson.Discriminator[ConversationItemNewParamsItemFunctionCall]("function_call"), - apijson.Discriminator[ConversationItemNewParamsItemFunctionCallOutput]("function_call_output"), - apijson.Discriminator[ConversationItemNewParamsItemMcpApprovalRequest]("mcp_approval_request"), - apijson.Discriminator[ConversationItemNewParamsItemMcpApprovalResponse]("mcp_approval_response"), - apijson.Discriminator[ConversationItemNewParamsItemMcpCall]("mcp_call"), - apijson.Discriminator[ConversationItemNewParamsItemMcpListTools]("mcp_list_tools"), + apijson.Discriminator[ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]("output_text"), + apijson.Discriminator[ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]("refusal"), ) } -// Corresponds to the various Message types in the Responses API. They are all -// under one type because the Responses API gives them all the same "type" value, -// and there is no way to tell them apart in certain scenarios. -// -// The properties Content, Role, Type are required. -type ConversationItemNewParamsItemMessage struct { - Content ConversationItemNewParamsItemMessageContentUnion `json:"content,omitzero,required"` - // Any of "system", "developer", "user", "assistant". - Role ConversationItemNewParamsItemMessageRole `json:"role,omitzero,required"` - ID param.Opt[string] `json:"id,omitzero"` - Status param.Opt[string] `json:"status,omitzero"` - // This field can be elided, and will marshal its zero value as "message". - Type constant.Message `json:"type,required"` +// The property Text is required. +type ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText struct { + Text string `json:"text,required"` + Annotations []ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion `json:"annotations,omitzero"` + // Any of "output_text". + Type string `json:"type,omitzero"` paramObj } -func (r ConversationItemNewParamsItemMessage) MarshalJSON() (data []byte, err error) { - type shadow ConversationItemNewParamsItemMessage +func (r ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ConversationItemNewParamsItemMessage) UnmarshalJSON(data []byte) error { +func (r *ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ConversationItemNewParamsItemMessageContentUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfConversationItemNewsItemMessageContentArray []ConversationItemNewParamsItemMessageContentArrayItemUnion `json:",omitzero,inline"` - OfVariant2 []ConversationItemNewParamsItemMessageContentArrayItemUnion `json:",omitzero,inline"` - paramUnion -} - -func (u ConversationItemNewParamsItemMessageContentUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfConversationItemNewsItemMessageContentArray, u.OfVariant2) -} -func (u *ConversationItemNewParamsItemMessageContentUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ConversationItemNewParamsItemMessageContentUnion) asAny() any { - if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfConversationItemNewsItemMessageContentArray) { - return &u.OfConversationItemNewsItemMessageContentArray - } else if !param.IsOmitted(u.OfVariant2) { - return &u.OfVariant2 - } - return nil +func init() { + apijson.RegisterFieldValidator[ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]( + "type", "output_text", + ) } // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. -type ConversationItemNewParamsItemMessageContentArrayItemUnion struct { - OfInputText *ConversationItemNewParamsItemMessageContentArrayItemInputText `json:",omitzero,inline"` - OfInputImage *ConversationItemNewParamsItemMessageContentArrayItemInputImage `json:",omitzero,inline"` - OfInputFile *ConversationItemNewParamsItemMessageContentArrayItemInputFile `json:",omitzero,inline"` +type ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion struct { + OfFileCitation *ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation `json:",omitzero,inline"` + OfURLCitation *ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation `json:",omitzero,inline"` + OfContainerFileCitation *ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation `json:",omitzero,inline"` + OfFilePath *ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath `json:",omitzero,inline"` paramUnion } -func (u ConversationItemNewParamsItemMessageContentArrayItemUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfInputText, u.OfInputImage, u.OfInputFile) +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfFileCitation, u.OfURLCitation, u.OfContainerFileCitation, u.OfFilePath) } -func (u *ConversationItemNewParamsItemMessageContentArrayItemUnion) UnmarshalJSON(data []byte) error { +func (u *ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *ConversationItemNewParamsItemMessageContentArrayItemUnion) asAny() any { - if !param.IsOmitted(u.OfInputText) { - return u.OfInputText - } else if !param.IsOmitted(u.OfInputImage) { - return u.OfInputImage - } else if !param.IsOmitted(u.OfInputFile) { - return u.OfInputFile +func (u *ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) asAny() any { + if !param.IsOmitted(u.OfFileCitation) { + return u.OfFileCitation + } else if !param.IsOmitted(u.OfURLCitation) { + return u.OfURLCitation + } else if !param.IsOmitted(u.OfContainerFileCitation) { + return u.OfContainerFileCitation + } else if !param.IsOmitted(u.OfFilePath) { + return u.OfFilePath } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u ConversationItemNewParamsItemMessageContentArrayItemUnion) GetText() *string { - if vt := u.OfInputText; vt != nil { - return &vt.Text +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetTitle() *string { + if vt := u.OfURLCitation; vt != nil { + return &vt.Title } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u ConversationItemNewParamsItemMessageContentArrayItemUnion) GetDetail() *string { - if vt := u.OfInputImage; vt != nil { - return (*string)(&vt.Detail) +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetURL() *string { + if vt := u.OfURLCitation; vt != nil { + return &vt.URL } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u ConversationItemNewParamsItemMessageContentArrayItemUnion) GetImageURL() *string { - if vt := u.OfInputImage; vt != nil && vt.ImageURL.Valid() { - return &vt.ImageURL.Value +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetContainerID() *string { + if vt := u.OfContainerFileCitation; vt != nil { + return &vt.ContainerID } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u ConversationItemNewParamsItemMessageContentArrayItemUnion) GetFileData() *string { - if vt := u.OfInputFile; vt != nil && vt.FileData.Valid() { - return &vt.FileData.Value +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetFileID() *string { + if vt := u.OfFileCitation; vt != nil { + return (*string)(&vt.FileID) + } else if vt := u.OfContainerFileCitation; vt != nil { + return (*string)(&vt.FileID) + } else if vt := u.OfFilePath; vt != nil { + return (*string)(&vt.FileID) } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u ConversationItemNewParamsItemMessageContentArrayItemUnion) GetFileURL() *string { - if vt := u.OfInputFile; vt != nil && vt.FileURL.Valid() { - return &vt.FileURL.Value +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetFilename() *string { + if vt := u.OfFileCitation; vt != nil { + return (*string)(&vt.Filename) + } else if vt := u.OfContainerFileCitation; vt != nil { + return (*string)(&vt.Filename) } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u ConversationItemNewParamsItemMessageContentArrayItemUnion) GetFilename() *string { - if vt := u.OfInputFile; vt != nil && vt.Filename.Valid() { - return &vt.Filename.Value +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetIndex() *int64 { + if vt := u.OfFileCitation; vt != nil { + return (*int64)(&vt.Index) + } else if vt := u.OfFilePath; vt != nil { + return (*int64)(&vt.Index) } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u ConversationItemNewParamsItemMessageContentArrayItemUnion) GetType() *string { - if vt := u.OfInputText; vt != nil { +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetType() *string { + if vt := u.OfFileCitation; vt != nil { return (*string)(&vt.Type) - } else if vt := u.OfInputImage; vt != nil { + } else if vt := u.OfURLCitation; vt != nil { return (*string)(&vt.Type) - } else if vt := u.OfInputFile; vt != nil { + } else if vt := u.OfContainerFileCitation; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfFilePath; vt != nil { return (*string)(&vt.Type) } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u ConversationItemNewParamsItemMessageContentArrayItemUnion) GetFileID() *string { - if vt := u.OfInputImage; vt != nil && vt.FileID.Valid() { - return &vt.FileID.Value - } else if vt := u.OfInputFile; vt != nil && vt.FileID.Valid() { - return &vt.FileID.Value +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetEndIndex() *int64 { + if vt := u.OfURLCitation; vt != nil { + return (*int64)(&vt.EndIndex) + } else if vt := u.OfContainerFileCitation; vt != nil { + return (*int64)(&vt.EndIndex) + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetStartIndex() *int64 { + if vt := u.OfURLCitation; vt != nil { + return (*int64)(&vt.StartIndex) + } else if vt := u.OfContainerFileCitation; vt != nil { + return (*int64)(&vt.StartIndex) } return nil } func init() { - apijson.RegisterUnion[ConversationItemNewParamsItemMessageContentArrayItemUnion]( + apijson.RegisterUnion[ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion]( "type", - apijson.Discriminator[ConversationItemNewParamsItemMessageContentArrayItemInputText]("input_text"), - apijson.Discriminator[ConversationItemNewParamsItemMessageContentArrayItemInputImage]("input_image"), - apijson.Discriminator[ConversationItemNewParamsItemMessageContentArrayItemInputFile]("input_file"), + apijson.Discriminator[ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation]("file_citation"), + apijson.Discriminator[ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]("url_citation"), + apijson.Discriminator[ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation]("container_file_citation"), + apijson.Discriminator[ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath]("file_path"), ) } -// Text content for input messages in OpenAI response format. +// File citation annotation for referencing specific files in response content. // -// The properties Text, Type are required. -type ConversationItemNewParamsItemMessageContentArrayItemInputText struct { - // The text content of the input message - Text string `json:"text,required"` - // Content type identifier, always "input_text" - // - // This field can be elided, and will marshal its zero value as "input_text". - Type constant.InputText `json:"type,required"` +// The properties FileID, Filename, Index are required. +type ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation struct { + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Index int64 `json:"index,required"` + // Any of "file_citation". + Type string `json:"type,omitzero"` paramObj } -func (r ConversationItemNewParamsItemMessageContentArrayItemInputText) MarshalJSON() (data []byte, err error) { - type shadow ConversationItemNewParamsItemMessageContentArrayItemInputText +func (r ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ConversationItemNewParamsItemMessageContentArrayItemInputText) UnmarshalJSON(data []byte) error { +func (r *ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Image content for input messages in OpenAI response format. +func init() { + apijson.RegisterFieldValidator[ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation]( + "type", "file_citation", + ) +} + +// URL citation annotation for referencing external web resources. // -// The properties Detail, Type are required. -type ConversationItemNewParamsItemMessageContentArrayItemInputImage struct { - // Level of detail for image processing, can be "low", "high", or "auto" - // - // Any of "low", "high", "auto". - Detail ConversationItemNewParamsItemMessageContentArrayItemInputImageDetail `json:"detail,omitzero,required"` - // (Optional) The ID of the file to be sent to the model. - FileID param.Opt[string] `json:"file_id,omitzero"` - // (Optional) URL of the image content - ImageURL param.Opt[string] `json:"image_url,omitzero"` - // Content type identifier, always "input_image" - // - // This field can be elided, and will marshal its zero value as "input_image". - Type constant.InputImage `json:"type,required"` +// The properties EndIndex, StartIndex, Title, URL are required. +type ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation struct { + EndIndex int64 `json:"end_index,required"` + StartIndex int64 `json:"start_index,required"` + Title string `json:"title,required"` + URL string `json:"url,required"` + // Any of "url_citation". + Type string `json:"type,omitzero"` paramObj } -func (r ConversationItemNewParamsItemMessageContentArrayItemInputImage) MarshalJSON() (data []byte, err error) { - type shadow ConversationItemNewParamsItemMessageContentArrayItemInputImage +func (r ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ConversationItemNewParamsItemMessageContentArrayItemInputImage) UnmarshalJSON(data []byte) error { +func (r *ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ConversationItemNewParamsItemMessageContentArrayItemInputImageDetail string +func init() { + apijson.RegisterFieldValidator[ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]( + "type", "url_citation", + ) +} -const ( - ConversationItemNewParamsItemMessageContentArrayItemInputImageDetailLow ConversationItemNewParamsItemMessageContentArrayItemInputImageDetail = "low" - ConversationItemNewParamsItemMessageContentArrayItemInputImageDetailHigh ConversationItemNewParamsItemMessageContentArrayItemInputImageDetail = "high" - ConversationItemNewParamsItemMessageContentArrayItemInputImageDetailAuto ConversationItemNewParamsItemMessageContentArrayItemInputImageDetail = "auto" -) +// The properties ContainerID, EndIndex, FileID, Filename, StartIndex are required. +type ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation struct { + ContainerID string `json:"container_id,required"` + EndIndex int64 `json:"end_index,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + StartIndex int64 `json:"start_index,required"` + // Any of "container_file_citation". + Type string `json:"type,omitzero"` + paramObj +} -// File content for input messages in OpenAI response format. -// -// The property Type is required. -type ConversationItemNewParamsItemMessageContentArrayItemInputFile struct { - // The data of the file to be sent to the model. - FileData param.Opt[string] `json:"file_data,omitzero"` - // (Optional) The ID of the file to be sent to the model. - FileID param.Opt[string] `json:"file_id,omitzero"` - // The URL of the file to be sent to the model. - FileURL param.Opt[string] `json:"file_url,omitzero"` - // The name of the file to be sent to the model. - Filename param.Opt[string] `json:"filename,omitzero"` - // The type of the input item. Always `input_file`. - // - // This field can be elided, and will marshal its zero value as "input_file". - Type constant.InputFile `json:"type,required"` +func (r ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation]( + "type", "container_file_citation", + ) +} + +// The properties FileID, Index are required. +type ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath struct { + FileID string `json:"file_id,required"` + Index int64 `json:"index,required"` + // Any of "file_path". + Type string `json:"type,omitzero"` paramObj } -func (r ConversationItemNewParamsItemMessageContentArrayItemInputFile) MarshalJSON() (data []byte, err error) { - type shadow ConversationItemNewParamsItemMessageContentArrayItemInputFile +func (r ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ConversationItemNewParamsItemMessageContentArrayItemInputFile) UnmarshalJSON(data []byte) error { +func (r *ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ConversationItemNewParamsItemMessageRole string +func init() { + apijson.RegisterFieldValidator[ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath]( + "type", "file_path", + ) +} + +// Refusal content within a streamed response part. +// +// The property Refusal is required. +type ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal struct { + Refusal string `json:"refusal,required"` + // Any of "refusal". + Type string `json:"type,omitzero"` + paramObj +} -const ( - ConversationItemNewParamsItemMessageRoleSystem ConversationItemNewParamsItemMessageRole = "system" - ConversationItemNewParamsItemMessageRoleDeveloper ConversationItemNewParamsItemMessageRole = "developer" - ConversationItemNewParamsItemMessageRoleUser ConversationItemNewParamsItemMessageRole = "user" - ConversationItemNewParamsItemMessageRoleAssistant ConversationItemNewParamsItemMessageRole = "assistant" -) +func (r ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ConversationItemNewParamsItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]( + "type", "refusal", + ) +} // Web search tool call output message for OpenAI responses. // -// The properties ID, Status, Type are required. +// The properties ID, Status are required. type ConversationItemNewParamsItemWebSearchCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // Current status of the web search operation + ID string `json:"id,required"` Status string `json:"status,required"` - // Tool call type identifier, always "web_search_call" - // - // This field can be elided, and will marshal its zero value as "web_search_call". - Type constant.WebSearchCall `json:"type,required"` + // Any of "web_search_call". + Type string `json:"type,omitzero"` paramObj } @@ -3261,22 +3777,22 @@ func (r *ConversationItemNewParamsItemWebSearchCall) UnmarshalJSON(data []byte) return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ConversationItemNewParamsItemWebSearchCall]( + "type", "web_search_call", + ) +} + // File search tool call output message for OpenAI responses. // -// The properties ID, Queries, Status, Type are required. +// The properties ID, Queries, Status are required. type ConversationItemNewParamsItemFileSearchCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // List of search queries executed - Queries []string `json:"queries,omitzero,required"` - // Current status of the file search operation - Status string `json:"status,required"` - // (Optional) Search results returned by the file search operation + ID string `json:"id,required"` + Queries []string `json:"queries,omitzero,required"` + Status string `json:"status,required"` Results []ConversationItemNewParamsItemFileSearchCallResult `json:"results,omitzero"` - // Tool call type identifier, always "file_search_call" - // - // This field can be elided, and will marshal its zero value as "file_search_call". - Type constant.FileSearchCall `json:"type,required"` + // Any of "file_search_call". + Type string `json:"type,omitzero"` paramObj } @@ -3288,20 +3804,21 @@ func (r *ConversationItemNewParamsItemFileSearchCall) UnmarshalJSON(data []byte) return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ConversationItemNewParamsItemFileSearchCall]( + "type", "file_search_call", + ) +} + // Search results returned by the file search operation. // // The properties Attributes, FileID, Filename, Score, Text are required. type ConversationItemNewParamsItemFileSearchCallResult struct { - // (Optional) Key-value attributes associated with the file - Attributes map[string]ConversationItemNewParamsItemFileSearchCallResultAttributeUnion `json:"attributes,omitzero,required"` - // Unique identifier of the file containing the result - FileID string `json:"file_id,required"` - // Name of the file containing the result - Filename string `json:"filename,required"` - // Relevance score for this search result (between 0 and 1) - Score float64 `json:"score,required"` - // Text content of the search result - Text string `json:"text,required"` + Attributes map[string]any `json:"attributes,omitzero,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Score float64 `json:"score,required"` + Text string `json:"text,required"` paramObj } @@ -3313,55 +3830,17 @@ func (r *ConversationItemNewParamsItemFileSearchCallResult) UnmarshalJSON(data [ return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ConversationItemNewParamsItemFileSearchCallResultAttributeUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u ConversationItemNewParamsItemFileSearchCallResultAttributeUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *ConversationItemNewParamsItemFileSearchCallResultAttributeUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ConversationItemNewParamsItemFileSearchCallResultAttributeUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - // Function tool call output message for OpenAI responses. // -// The properties Arguments, CallID, Name, Type are required. +// The properties Arguments, CallID, Name are required. type ConversationItemNewParamsItemFunctionCall struct { - // JSON string containing the function arguments - Arguments string `json:"arguments,required"` - // Unique identifier for the function call - CallID string `json:"call_id,required"` - // Name of the function being called - Name string `json:"name,required"` - // (Optional) Additional identifier for the tool call - ID param.Opt[string] `json:"id,omitzero"` - // (Optional) Current status of the function call execution - Status param.Opt[string] `json:"status,omitzero"` - // Tool call type identifier, always "function_call" - // - // This field can be elided, and will marshal its zero value as "function_call". - Type constant.FunctionCall `json:"type,required"` + Arguments string `json:"arguments,required"` + CallID string `json:"call_id,required"` + Name string `json:"name,required"` + ID param.Opt[string] `json:"id,omitzero"` + Status param.Opt[string] `json:"status,omitzero"` + // Any of "function_call". + Type string `json:"type,omitzero"` paramObj } @@ -3373,18 +3852,23 @@ func (r *ConversationItemNewParamsItemFunctionCall) UnmarshalJSON(data []byte) e return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ConversationItemNewParamsItemFunctionCall]( + "type", "function_call", + ) +} + // This represents the output of a function call that gets passed back to the // model. // -// The properties CallID, Output, Type are required. +// The properties CallID, Output are required. type ConversationItemNewParamsItemFunctionCallOutput struct { CallID string `json:"call_id,required"` Output string `json:"output,required"` ID param.Opt[string] `json:"id,omitzero"` Status param.Opt[string] `json:"status,omitzero"` - // This field can be elided, and will marshal its zero value as - // "function_call_output". - Type constant.FunctionCallOutput `json:"type,required"` + // Any of "function_call_output". + Type string `json:"type,omitzero"` paramObj } @@ -3396,17 +3880,22 @@ func (r *ConversationItemNewParamsItemFunctionCallOutput) UnmarshalJSON(data []b return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ConversationItemNewParamsItemFunctionCallOutput]( + "type", "function_call_output", + ) +} + // A request for human approval of a tool invocation. // -// The properties ID, Arguments, Name, ServerLabel, Type are required. +// The properties ID, Arguments, Name, ServerLabel are required. type ConversationItemNewParamsItemMcpApprovalRequest struct { ID string `json:"id,required"` Arguments string `json:"arguments,required"` Name string `json:"name,required"` ServerLabel string `json:"server_label,required"` - // This field can be elided, and will marshal its zero value as - // "mcp_approval_request". - Type constant.McpApprovalRequest `json:"type,required"` + // Any of "mcp_approval_request". + Type string `json:"type,omitzero"` paramObj } @@ -3418,17 +3907,22 @@ func (r *ConversationItemNewParamsItemMcpApprovalRequest) UnmarshalJSON(data []b return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ConversationItemNewParamsItemMcpApprovalRequest]( + "type", "mcp_approval_request", + ) +} + // A response to an MCP approval request. // -// The properties ApprovalRequestID, Approve, Type are required. +// The properties ApprovalRequestID, Approve are required. type ConversationItemNewParamsItemMcpApprovalResponse struct { ApprovalRequestID string `json:"approval_request_id,required"` Approve bool `json:"approve,required"` ID param.Opt[string] `json:"id,omitzero"` Reason param.Opt[string] `json:"reason,omitzero"` - // This field can be elided, and will marshal its zero value as - // "mcp_approval_response". - Type constant.McpApprovalResponse `json:"type,required"` + // Any of "mcp_approval_response". + Type string `json:"type,omitzero"` paramObj } @@ -3440,26 +3934,24 @@ func (r *ConversationItemNewParamsItemMcpApprovalResponse) UnmarshalJSON(data [] return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ConversationItemNewParamsItemMcpApprovalResponse]( + "type", "mcp_approval_response", + ) +} + // Model Context Protocol (MCP) call output message for OpenAI responses. // -// The properties ID, Arguments, Name, ServerLabel, Type are required. +// The properties ID, Arguments, Name, ServerLabel are required. type ConversationItemNewParamsItemMcpCall struct { - // Unique identifier for this MCP call - ID string `json:"id,required"` - // JSON string containing the MCP call arguments - Arguments string `json:"arguments,required"` - // Name of the MCP method being called - Name string `json:"name,required"` - // Label identifying the MCP server handling the call - ServerLabel string `json:"server_label,required"` - // (Optional) Error message if the MCP call failed - Error param.Opt[string] `json:"error,omitzero"` - // (Optional) Output result from the successful MCP call - Output param.Opt[string] `json:"output,omitzero"` - // Tool call type identifier, always "mcp_call" - // - // This field can be elided, and will marshal its zero value as "mcp_call". - Type constant.McpCall `json:"type,required"` + ID string `json:"id,required"` + Arguments string `json:"arguments,required"` + Name string `json:"name,required"` + ServerLabel string `json:"server_label,required"` + Error param.Opt[string] `json:"error,omitzero"` + Output param.Opt[string] `json:"output,omitzero"` + // Any of "mcp_call". + Type string `json:"type,omitzero"` paramObj } @@ -3471,20 +3963,21 @@ func (r *ConversationItemNewParamsItemMcpCall) UnmarshalJSON(data []byte) error return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ConversationItemNewParamsItemMcpCall]( + "type", "mcp_call", + ) +} + // MCP list tools output message containing available tools from an MCP server. // -// The properties ID, ServerLabel, Tools, Type are required. +// The properties ID, ServerLabel, Tools are required. type ConversationItemNewParamsItemMcpListTools struct { - // Unique identifier for this MCP list tools operation - ID string `json:"id,required"` - // Label identifying the MCP server providing the tools - ServerLabel string `json:"server_label,required"` - // List of available tools provided by the MCP server - Tools []ConversationItemNewParamsItemMcpListToolsTool `json:"tools,omitzero,required"` - // Tool call type identifier, always "mcp_list_tools" - // - // This field can be elided, and will marshal its zero value as "mcp_list_tools". - Type constant.McpListTools `json:"type,required"` + ID string `json:"id,required"` + ServerLabel string `json:"server_label,required"` + Tools []ConversationItemNewParamsItemMcpListToolsTool `json:"tools,omitzero,required"` + // Any of "mcp_list_tools". + Type string `json:"type,omitzero"` paramObj } @@ -3496,15 +3989,18 @@ func (r *ConversationItemNewParamsItemMcpListTools) UnmarshalJSON(data []byte) e return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ConversationItemNewParamsItemMcpListTools]( + "type", "mcp_list_tools", + ) +} + // Tool definition returned by MCP list tools operation. // // The properties InputSchema, Name are required. type ConversationItemNewParamsItemMcpListToolsTool struct { - // JSON schema defining the tool's input parameters - InputSchema map[string]ConversationItemNewParamsItemMcpListToolsToolInputSchemaUnion `json:"input_schema,omitzero,required"` - // Name of the tool - Name string `json:"name,required"` - // (Optional) Description of what the tool does + InputSchema map[string]any `json:"input_schema,omitzero,required"` + Name string `json:"name,required"` Description param.Opt[string] `json:"description,omitzero"` paramObj } @@ -3517,51 +4013,14 @@ func (r *ConversationItemNewParamsItemMcpListToolsTool) UnmarshalJSON(data []byt return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ConversationItemNewParamsItemMcpListToolsToolInputSchemaUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u ConversationItemNewParamsItemMcpListToolsToolInputSchemaUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *ConversationItemNewParamsItemMcpListToolsToolInputSchemaUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ConversationItemNewParamsItemMcpListToolsToolInputSchemaUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - type ConversationItemListParams struct { - // An item ID to list items after, used in pagination. After param.Opt[string] `query:"after,omitzero" json:"-"` - // A limit on the number of objects to be returned (1-100, default 20). - Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` - // Specify additional output data to include in the response. - // + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` // Any of "web_search_call.action.sources", "code_interpreter_call.outputs", // "computer_call_output.output.image_url", "file_search_call.results", // "message.input_image.image_url", "message.output_text.logprobs", // "reasoning.encrypted_content". Include []string `query:"include,omitzero" json:"-"` - // The order to return items in (asc or desc, default desc). - // // Any of "asc", "desc". Order ConversationItemListParamsOrder `query:"order,omitzero" json:"-"` paramObj @@ -3576,7 +4035,6 @@ func (r ConversationItemListParams) URLQuery() (v url.Values, err error) { }) } -// The order to return items in (asc or desc, default desc). type ConversationItemListParamsOrder string const ( @@ -3584,6 +4042,11 @@ const ( ConversationItemListParamsOrderDesc ConversationItemListParamsOrder = "desc" ) +type ConversationItemDeleteParams struct { + ConversationID string `path:"conversation_id,required" json:"-"` + paramObj +} + type ConversationItemGetParams struct { ConversationID string `path:"conversation_id,required" json:"-"` paramObj diff --git a/conversationitem_test.go b/conversationitem_test.go index 02219a1..1922adb 100644 --- a/conversationitem_test.go +++ b/conversationitem_test.go @@ -39,9 +39,10 @@ func TestConversationItemNew(t *testing.T) { Content: llamastackclient.ConversationItemNewParamsItemMessageContentUnion{ OfString: llamastackclient.String("string"), }, - Role: llamastackclient.ConversationItemNewParamsItemMessageRoleSystem, + Role: "system", ID: llamastackclient.String("id"), Status: llamastackclient.String("status"), + Type: "message", }, }}, }, @@ -85,6 +86,33 @@ func TestConversationItemListWithOptionalParams(t *testing.T) { } } +func TestConversationItemDelete(t *testing.T) { + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := llamastackclient.NewClient( + option.WithBaseURL(baseURL), + ) + _, err := client.Conversations.Items.Delete( + context.TODO(), + "item_id", + llamastackclient.ConversationItemDeleteParams{ + ConversationID: "conversation_id", + }, + ) + if err != nil { + var apierr *llamastackclient.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} + func TestConversationItemGet(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { diff --git a/embedding.go b/embedding.go index ac37302..18f2e8a 100644 --- a/embedding.go +++ b/embedding.go @@ -19,7 +19,6 @@ import ( "github.com/llamastack/llama-stack-client-go/option" "github.com/llamastack/llama-stack-client-go/packages/param" "github.com/llamastack/llama-stack-client-go/packages/respjson" - "github.com/llamastack/llama-stack-client-go/shared/constant" ) // EmbeddingService contains methods and other services that help with interacting @@ -41,8 +40,10 @@ func NewEmbeddingService(opts ...option.RequestOption) (r EmbeddingService) { return } -// Create embeddings. Generate OpenAI-compatible embeddings for the given input -// using the specified model. +// Create embeddings. +// +// Generate OpenAI-compatible embeddings for the given input using the specified +// model. func (r *EmbeddingService) New(ctx context.Context, body EmbeddingNewParams, opts ...option.RequestOption) (res *CreateEmbeddingsResponse, err error) { opts = slices.Concat(r.Options, opts) path := "v1/embeddings" @@ -52,20 +53,18 @@ func (r *EmbeddingService) New(ctx context.Context, body EmbeddingNewParams, opt // Response from an OpenAI-compatible embeddings request. type CreateEmbeddingsResponse struct { - // List of embedding data objects - Data []CreateEmbeddingsResponseData `json:"data,required"` - // The model that was used to generate the embeddings - Model string `json:"model,required"` - // The object type, which will be "list" - Object constant.List `json:"object,required"` - // Usage information + Data []CreateEmbeddingsResponseData `json:"data,required"` + Model string `json:"model,required"` + // Usage information for an OpenAI-compatible embeddings response. Usage CreateEmbeddingsResponseUsage `json:"usage,required"` + // Any of "list". + Object CreateEmbeddingsResponseObject `json:"object"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Data respjson.Field Model respjson.Field - Object respjson.Field Usage respjson.Field + Object respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -79,13 +78,10 @@ func (r *CreateEmbeddingsResponse) UnmarshalJSON(data []byte) error { // A single embedding data object from an OpenAI-compatible embeddings response. type CreateEmbeddingsResponseData struct { - // The embedding vector as a list of floats (when encoding_format="float") or as a - // base64-encoded string (when encoding_format="base64") Embedding CreateEmbeddingsResponseDataEmbeddingUnion `json:"embedding,required"` - // The index of the embedding in the input list - Index int64 `json:"index,required"` - // The object type, which will be "embedding" - Object constant.Embedding `json:"object,required"` + Index int64 `json:"index,required"` + // Any of "embedding". + Object string `json:"object"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Embedding respjson.Field @@ -108,20 +104,20 @@ func (r *CreateEmbeddingsResponseData) UnmarshalJSON(data []byte) error { // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfFloatArray OfString] +// will be valid: OfListNumber OfString] type CreateEmbeddingsResponseDataEmbeddingUnion struct { // This field will be present if the value is a [[]float64] instead of an object. - OfFloatArray []float64 `json:",inline"` + OfListNumber []float64 `json:",inline"` // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` JSON struct { - OfFloatArray respjson.Field + OfListNumber respjson.Field OfString respjson.Field raw string } `json:"-"` } -func (u CreateEmbeddingsResponseDataEmbeddingUnion) AsFloatArray() (v []float64) { +func (u CreateEmbeddingsResponseDataEmbeddingUnion) AsListNumber() (v []float64) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -138,12 +134,10 @@ func (r *CreateEmbeddingsResponseDataEmbeddingUnion) UnmarshalJSON(data []byte) return apijson.UnmarshalRoot(data, r) } -// Usage information +// Usage information for an OpenAI-compatible embeddings response. type CreateEmbeddingsResponseUsage struct { - // The number of tokens in the input PromptTokens int64 `json:"prompt_tokens,required"` - // The total number of tokens used - TotalTokens int64 `json:"total_tokens,required"` + TotalTokens int64 `json:"total_tokens,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { PromptTokens respjson.Field @@ -159,22 +153,18 @@ func (r *CreateEmbeddingsResponseUsage) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +type CreateEmbeddingsResponseObject string + +const ( + CreateEmbeddingsResponseObjectList CreateEmbeddingsResponseObject = "list" +) + type EmbeddingNewParams struct { - // Input text to embed, encoded as a string or array of strings. To embed multiple - // inputs in a single request, pass an array of strings. - Input EmbeddingNewParamsInputUnion `json:"input,omitzero,required"` - // The identifier of the model to use. The model must be an embedding model - // registered with Llama Stack and available via the /models endpoint. - Model string `json:"model,required"` - // (Optional) The number of dimensions the resulting output embeddings should have. - // Only supported in text-embedding-3 and later models. - Dimensions param.Opt[int64] `json:"dimensions,omitzero"` - // (Optional) The format to return the embeddings in. Can be either "float" or - // "base64". Defaults to "float". - EncodingFormat param.Opt[string] `json:"encoding_format,omitzero"` - // (Optional) A unique identifier representing your end-user, which can help OpenAI - // to monitor and detect abuse. - User param.Opt[string] `json:"user,omitzero"` + Input EmbeddingNewParamsInputUnion `json:"input,omitzero,required"` + Model string `json:"model,required"` + Dimensions param.Opt[int64] `json:"dimensions,omitzero"` + EncodingFormat param.Opt[string] `json:"encoding_format,omitzero"` + User param.Opt[string] `json:"user,omitzero"` paramObj } @@ -190,13 +180,13 @@ func (r *EmbeddingNewParams) UnmarshalJSON(data []byte) error { // // Use [param.IsOmitted] to confirm if a field is set. type EmbeddingNewParamsInputUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfStringArray []string `json:",omitzero,inline"` + OfString param.Opt[string] `json:",omitzero,inline"` + OfListString []string `json:",omitzero,inline"` paramUnion } func (u EmbeddingNewParamsInputUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfStringArray) + return param.MarshalUnion(u, u.OfString, u.OfListString) } func (u *EmbeddingNewParamsInputUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) @@ -205,8 +195,8 @@ func (u *EmbeddingNewParamsInputUnion) UnmarshalJSON(data []byte) error { func (u *EmbeddingNewParamsInputUnion) asAny() any { if !param.IsOmitted(u.OfString) { return &u.OfString.Value - } else if !param.IsOmitted(u.OfStringArray) { - return &u.OfStringArray + } else if !param.IsOmitted(u.OfListString) { + return &u.OfListString } return nil } diff --git a/file.go b/file.go index a07d61e..bae6af8 100644 --- a/file.go +++ b/file.go @@ -49,7 +49,9 @@ func NewFileService(opts ...option.RequestOption) (r FileService) { return } -// Upload file. Upload a file that can be used across various endpoints. +// Upload file. +// +// Upload a file that can be used across various endpoints. // // The file upload should be a multipart form request with: // @@ -63,7 +65,9 @@ func (r *FileService) New(ctx context.Context, body FileNewParams, opts ...optio return } -// Retrieve file. Returns information about a specific file. +// Retrieve file. +// +// Returns information about a specific file. func (r *FileService) Get(ctx context.Context, fileID string, opts ...option.RequestOption) (res *File, err error) { opts = slices.Concat(r.Options, opts) if fileID == "" { @@ -75,7 +79,9 @@ func (r *FileService) Get(ctx context.Context, fileID string, opts ...option.Req return } -// List files. Returns a list of files that belong to the user's organization. +// List files. +// +// Returns a list of files that belong to the user's organization. func (r *FileService) List(ctx context.Context, query FileListParams, opts ...option.RequestOption) (res *pagination.OpenAICursorPage[File], err error) { var raw *http.Response opts = slices.Concat(r.Options, opts) @@ -93,7 +99,9 @@ func (r *FileService) List(ctx context.Context, query FileListParams, opts ...op return res, nil } -// List files. Returns a list of files that belong to the user's organization. +// List files. +// +// Returns a list of files that belong to the user's organization. func (r *FileService) ListAutoPaging(ctx context.Context, query FileListParams, opts ...option.RequestOption) *pagination.OpenAICursorPageAutoPager[File] { return pagination.NewOpenAICursorPageAutoPager(r.List(ctx, query, opts...)) } @@ -110,7 +118,9 @@ func (r *FileService) Delete(ctx context.Context, fileID string, opts ...option. return } -// Retrieve file content. Returns the contents of the specified file. +// Retrieve file content. +// +// Returns the contents of the specified file. func (r *FileService) Content(ctx context.Context, fileID string, opts ...option.RequestOption) (res *FileContentResponse, err error) { opts = slices.Concat(r.Options, opts) if fileID == "" { @@ -124,12 +134,10 @@ func (r *FileService) Content(ctx context.Context, fileID string, opts ...option // Response for deleting a file in OpenAI Files API. type DeleteFileResponse struct { - // The file identifier that was deleted - ID string `json:"id,required"` - // Whether the file was successfully deleted - Deleted bool `json:"deleted,required"` - // The object type, which is always "file" - Object constant.File `json:"object,required"` + ID string `json:"id,required"` + Deleted bool `json:"deleted,required"` + // Any of "file". + Object DeleteFileResponseObject `json:"object"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -146,24 +154,25 @@ func (r *DeleteFileResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +type DeleteFileResponseObject string + +const ( + DeleteFileResponseObjectFile DeleteFileResponseObject = "file" +) + // OpenAI File object as defined in the OpenAI Files API. type File struct { - // The file identifier, which can be referenced in the API endpoints - ID string `json:"id,required"` - // The size of the file, in bytes - Bytes int64 `json:"bytes,required"` - // The Unix timestamp (in seconds) for when the file was created - CreatedAt int64 `json:"created_at,required"` - // The Unix timestamp (in seconds) for when the file expires - ExpiresAt int64 `json:"expires_at,required"` - // The name of the file - Filename string `json:"filename,required"` - // The object type, which is always "file" - Object constant.File `json:"object,required"` - // The intended purpose of the file + ID string `json:"id,required"` + Bytes int64 `json:"bytes,required"` + CreatedAt int64 `json:"created_at,required"` + ExpiresAt int64 `json:"expires_at,required"` + Filename string `json:"filename,required"` + // Valid purpose values for OpenAI Files API. // // Any of "assistants", "batch". Purpose FilePurpose `json:"purpose,required"` + // Any of "file". + Object FileObject `json:"object"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -171,8 +180,8 @@ type File struct { CreatedAt respjson.Field ExpiresAt respjson.Field Filename respjson.Field - Object respjson.Field Purpose respjson.Field + Object respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -184,7 +193,7 @@ func (r *File) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// The intended purpose of the file +// Valid purpose values for OpenAI Files API. type FilePurpose string const ( @@ -192,18 +201,20 @@ const ( FilePurposeBatch FilePurpose = "batch" ) +type FileObject string + +const ( + FileObjectFile FileObject = "file" +) + // Response for listing files in OpenAI Files API. type ListFilesResponse struct { - // List of file objects - Data []File `json:"data,required"` - // ID of the first file in the list for pagination + Data []File `json:"data,required"` FirstID string `json:"first_id,required"` - // Whether there are more files available beyond this page - HasMore bool `json:"has_more,required"` - // ID of the last file in the list for pagination - LastID string `json:"last_id,required"` - // The object type, which is always "list" - Object constant.List `json:"object,required"` + HasMore bool `json:"has_more,required"` + LastID string `json:"last_id,required"` + // Any of "list". + Object ListFilesResponseObject `json:"object"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Data respjson.Field @@ -222,6 +233,12 @@ func (r *ListFilesResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +type ListFilesResponseObject string + +const ( + ListFilesResponseObjectList ListFilesResponseObject = "list" +) + type FileContentResponse = any type FileNewParams struct { @@ -230,7 +247,9 @@ type FileNewParams struct { // // Any of "assistants", "batch". Purpose FileNewParamsPurpose `json:"purpose,omitzero,required"` - // Control expiration of uploaded files. Params: + // Control expiration of uploaded files. + // + // Params: // // - anchor, must be "created_at" // - seconds, must be int between 3600 and 2592000 (1 hour to 30 days) @@ -264,7 +283,9 @@ const ( FileNewParamsPurposeBatch FileNewParamsPurpose = "batch" ) -// Control expiration of uploaded files. Params: +// Control expiration of uploaded files. +// +// Params: // // - anchor, must be "created_at" // - seconds, must be int between 3600 and 2592000 (1 hour to 30 days) @@ -286,20 +307,13 @@ func (r *FileNewParamsExpiresAfter) UnmarshalJSON(data []byte) error { } type FileListParams 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, - // ending with obj_foo, your subsequent call can include after=obj_foo in order to - // fetch the next page of the list. After param.Opt[string] `query:"after,omitzero" json:"-"` - // A limit on the number of objects to be returned. Limit can range between 1 and - // 10,000, and the default is 10,000. - Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` - // Sort order by the `created_at` timestamp of the objects. `asc` for ascending - // order and `desc` for descending order. + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + // Sort order for paginated responses. // // Any of "asc", "desc". Order FileListParamsOrder `query:"order,omitzero" json:"-"` - // Only return files with the given purpose. + // Valid purpose values for OpenAI Files API. // // Any of "assistants", "batch". Purpose FileListParamsPurpose `query:"purpose,omitzero" json:"-"` @@ -314,8 +328,7 @@ func (r FileListParams) URLQuery() (v url.Values, err error) { }) } -// Sort order by the `created_at` timestamp of the objects. `asc` for ascending -// order and `desc` for descending order. +// Sort order for paginated responses. type FileListParamsOrder string const ( @@ -323,7 +336,7 @@ const ( FileListParamsOrderDesc FileListParamsOrder = "desc" ) -// Only return files with the given purpose. +// Valid purpose values for OpenAI Files API. type FileListParamsPurpose string const ( diff --git a/file_test.go b/file_test.go index 1622855..10015e5 100644 --- a/file_test.go +++ b/file_test.go @@ -36,7 +36,7 @@ func TestFileNewWithOptionalParams(t *testing.T) { File: io.Reader(bytes.NewBuffer([]byte("some file contents"))), Purpose: llamastackclient.FileNewParamsPurposeAssistants, ExpiresAfter: llamastackclient.FileNewParamsExpiresAfter{ - Seconds: 0, + Seconds: 3600, }, }) if err != nil { diff --git a/inspect.go b/inspect.go index 868a391..496b067 100644 --- a/inspect.go +++ b/inspect.go @@ -10,7 +10,6 @@ package llamastackclient import ( "context" - "encoding/json" "net/http" "slices" @@ -39,7 +38,9 @@ func NewInspectService(opts ...option.RequestOption) (r InspectService) { return } -// Get health status. Get the current health status of the service. +// Get health status. +// +// Get the current health status of the service. func (r *InspectService) Health(ctx context.Context, opts ...option.RequestOption) (res *HealthInfo, err error) { opts = slices.Concat(r.Options, opts) path := "v1/health" @@ -47,7 +48,9 @@ func (r *InspectService) Health(ctx context.Context, opts ...option.RequestOptio return } -// Get version. Get the version of the service. +// Get version. +// +// Get the version of the service. func (r *InspectService) Version(ctx context.Context, opts ...option.RequestOption) (res *VersionInfo, err error) { opts = slices.Concat(r.Options, opts) path := "v1/version" @@ -57,8 +60,6 @@ func (r *InspectService) Version(ctx context.Context, opts ...option.RequestOpti // Health status information for the service. type HealthInfo struct { - // Current health status of the service - // // Any of "OK", "Error", "Not Implemented". Status HealthInfoStatus `json:"status,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. @@ -75,7 +76,6 @@ func (r *HealthInfo) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Current health status of the service type HealthInfoStatus string const ( @@ -87,16 +87,11 @@ const ( // Information about a registered provider including its configuration and health // status. type ProviderInfo struct { - // The API name this provider implements - API string `json:"api,required"` - // Configuration parameters for the provider - Config map[string]ProviderInfoConfigUnion `json:"config,required"` - // Current health status of the provider - Health map[string]ProviderInfoHealthUnion `json:"health,required"` - // Unique identifier for the provider - ProviderID string `json:"provider_id,required"` - // The type of provider implementation - ProviderType string `json:"provider_type,required"` + API string `json:"api,required"` + Config map[string]any `json:"config,required"` + Health map[string]any `json:"health,required"` + ProviderID string `json:"provider_id,required"` + ProviderType string `json:"provider_type,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { API respjson.Field @@ -115,119 +110,12 @@ func (r *ProviderInfo) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ProviderInfoConfigUnion contains all possible properties and values from [bool], -// [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ProviderInfoConfigUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ProviderInfoConfigUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ProviderInfoConfigUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ProviderInfoConfigUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ProviderInfoConfigUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ProviderInfoConfigUnion) RawJSON() string { return u.JSON.raw } - -func (r *ProviderInfoConfigUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ProviderInfoHealthUnion contains all possible properties and values from [bool], -// [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ProviderInfoHealthUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ProviderInfoHealthUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ProviderInfoHealthUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ProviderInfoHealthUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ProviderInfoHealthUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ProviderInfoHealthUnion) RawJSON() string { return u.JSON.raw } - -func (r *ProviderInfoHealthUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - // Information about an API route including its path, method, and implementing // providers. type RouteInfo struct { - // HTTP method for the route - Method string `json:"method,required"` - // List of provider types that implement this route + Method string `json:"method,required"` ProviderTypes []string `json:"provider_types,required"` - // The API endpoint path - Route string `json:"route,required"` + Route string `json:"route,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Method respjson.Field @@ -246,7 +134,6 @@ func (r *RouteInfo) UnmarshalJSON(data []byte) error { // Version information for the service. type VersionInfo struct { - // Version number of the service Version string `json:"version,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { diff --git a/model.go b/model.go index b3d163b..a1f3ed4 100644 --- a/model.go +++ b/model.go @@ -10,7 +10,6 @@ package llamastackclient import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -21,7 +20,6 @@ import ( "github.com/llamastack/llama-stack-client-go/option" "github.com/llamastack/llama-stack-client-go/packages/param" "github.com/llamastack/llama-stack-client-go/packages/respjson" - "github.com/llamastack/llama-stack-client-go/shared/constant" ) // ModelService contains methods and other services that help with interacting with @@ -45,7 +43,9 @@ func NewModelService(opts ...option.RequestOption) (r ModelService) { return } -// Get model. Get a model by its identifier. +// Get model. +// +// Get a model by its identifier. func (r *ModelService) Get(ctx context.Context, modelID string, opts ...option.RequestOption) (res *ModelGetResponse, err error) { opts = slices.Concat(r.Options, opts) if modelID == "" { @@ -70,7 +70,9 @@ func (r *ModelService) List(ctx context.Context, opts ...option.RequestOption) ( return } -// Register model. Register a model. +// Register model. +// +// Register a model. // // Deprecated: deprecated func (r *ModelService) Register(ctx context.Context, body ModelRegisterParams, opts ...option.RequestOption) (res *ModelRegisterResponse, err error) { @@ -80,7 +82,9 @@ func (r *ModelService) Register(ctx context.Context, body ModelRegisterParams, o return } -// Unregister model. Unregister a model. +// Unregister model. +// +// Unregister a model. // // Deprecated: deprecated func (r *ModelService) Unregister(ctx context.Context, modelID string, opts ...option.RequestOption) (err error) { @@ -112,19 +116,25 @@ func (r *ListModelsResponse) UnmarshalJSON(data []byte) error { } // A model from OpenAI. +// +// :id: The ID of the model :object: The object type, which will be "model" +// :created: The Unix timestamp in seconds when the model was created :owned_by: +// The owner of the model :custom_metadata: Llama Stack-specific metadata including +// model_type, provider info, and additional metadata type Model struct { - ID string `json:"id,required"` - Created int64 `json:"created,required"` - Object constant.Model `json:"object,required"` - OwnedBy string `json:"owned_by,required"` - CustomMetadata map[string]ModelCustomMetadataUnion `json:"custom_metadata"` + ID string `json:"id,required"` + Created int64 `json:"created,required"` + OwnedBy string `json:"owned_by,required"` + CustomMetadata map[string]any `json:"custom_metadata,nullable"` + // Any of "model". + Object ModelObject `json:"object"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field Created respjson.Field - Object respjson.Field OwnedBy respjson.Field CustomMetadata respjson.Field + Object respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -136,82 +146,36 @@ func (r *Model) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ModelCustomMetadataUnion contains all possible properties and values from -// [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ModelCustomMetadataUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ModelCustomMetadataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} +type ModelObject string -func (u ModelCustomMetadataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ModelCustomMetadataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ModelCustomMetadataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ModelCustomMetadataUnion) RawJSON() string { return u.JSON.raw } - -func (r *ModelCustomMetadataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} +const ( + ModelObjectModel ModelObject = "model" +) // A model resource representing an AI model registered in Llama Stack. type ModelGetResponse struct { // Unique identifier for this resource in llama stack Identifier string `json:"identifier,required"` + // ID of the provider that owns this resource + ProviderID string `json:"provider_id,required"` // Any additional metadata for this model - Metadata map[string]ModelGetResponseMetadataUnion `json:"metadata,required"` - // The type of model (LLM or embedding model) + Metadata map[string]any `json:"metadata"` + // Enumeration of supported model types in Llama Stack. // // Any of "llm", "embedding", "rerank". - ModelType ModelGetResponseModelType `json:"model_type,required"` - // ID of the provider that owns this resource - ProviderID string `json:"provider_id,required"` - // The resource type, always 'model' for model resources - Type constant.Model `json:"type,required"` + ModelType ModelGetResponseModelType `json:"model_type"` // Unique identifier for this resource in the provider - ProviderResourceID string `json:"provider_resource_id"` + ProviderResourceID string `json:"provider_resource_id,nullable"` + // Any of "model". + Type ModelGetResponseType `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Identifier respjson.Field + ProviderID respjson.Field Metadata respjson.Field ModelType respjson.Field - ProviderID respjson.Field - Type respjson.Field ProviderResourceID respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -223,59 +187,7 @@ func (r *ModelGetResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ModelGetResponseMetadataUnion contains all possible properties and values from -// [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ModelGetResponseMetadataUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ModelGetResponseMetadataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ModelGetResponseMetadataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ModelGetResponseMetadataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ModelGetResponseMetadataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ModelGetResponseMetadataUnion) RawJSON() string { return u.JSON.raw } - -func (r *ModelGetResponseMetadataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// The type of model (LLM or embedding model) +// Enumeration of supported model types in Llama Stack. type ModelGetResponseModelType string const ( @@ -284,30 +196,36 @@ const ( ModelGetResponseModelTypeRerank ModelGetResponseModelType = "rerank" ) +type ModelGetResponseType string + +const ( + ModelGetResponseTypeModel ModelGetResponseType = "model" +) + // A model resource representing an AI model registered in Llama Stack. type ModelRegisterResponse struct { // Unique identifier for this resource in llama stack Identifier string `json:"identifier,required"` + // ID of the provider that owns this resource + ProviderID string `json:"provider_id,required"` // Any additional metadata for this model - Metadata map[string]ModelRegisterResponseMetadataUnion `json:"metadata,required"` - // The type of model (LLM or embedding model) + Metadata map[string]any `json:"metadata"` + // Enumeration of supported model types in Llama Stack. // // Any of "llm", "embedding", "rerank". - ModelType ModelRegisterResponseModelType `json:"model_type,required"` - // ID of the provider that owns this resource - ProviderID string `json:"provider_id,required"` - // The resource type, always 'model' for model resources - Type constant.Model `json:"type,required"` + ModelType ModelRegisterResponseModelType `json:"model_type"` // Unique identifier for this resource in the provider - ProviderResourceID string `json:"provider_resource_id"` + ProviderResourceID string `json:"provider_resource_id,nullable"` + // Any of "model". + Type ModelRegisterResponseType `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Identifier respjson.Field + ProviderID respjson.Field Metadata respjson.Field ModelType respjson.Field - ProviderID respjson.Field - Type respjson.Field ProviderResourceID respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -319,59 +237,7 @@ func (r *ModelRegisterResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ModelRegisterResponseMetadataUnion contains all possible properties and values -// from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ModelRegisterResponseMetadataUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ModelRegisterResponseMetadataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ModelRegisterResponseMetadataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ModelRegisterResponseMetadataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ModelRegisterResponseMetadataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ModelRegisterResponseMetadataUnion) RawJSON() string { return u.JSON.raw } - -func (r *ModelRegisterResponseMetadataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// The type of model (LLM or embedding model) +// Enumeration of supported model types in Llama Stack. type ModelRegisterResponseModelType string const ( @@ -380,16 +246,18 @@ const ( ModelRegisterResponseModelTypeRerank ModelRegisterResponseModelType = "rerank" ) +type ModelRegisterResponseType string + +const ( + ModelRegisterResponseTypeModel ModelRegisterResponseType = "model" +) + type ModelRegisterParams struct { - // The identifier of the model to register. - ModelID string `json:"model_id,required"` - // The identifier of the provider. - ProviderID param.Opt[string] `json:"provider_id,omitzero"` - // The identifier of the model in the provider. + ModelID string `json:"model_id,required"` + ProviderID param.Opt[string] `json:"provider_id,omitzero"` ProviderModelID param.Opt[string] `json:"provider_model_id,omitzero"` - // Any additional metadata for this model. - Metadata map[string]ModelRegisterParamsMetadataUnion `json:"metadata,omitzero"` - // The type of model to register. + Metadata map[string]any `json:"metadata,omitzero"` + // Enumeration of supported model types in Llama Stack. // // Any of "llm", "embedding", "rerank". ModelType ModelRegisterParamsModelType `json:"model_type,omitzero"` @@ -404,38 +272,7 @@ func (r *ModelRegisterParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ModelRegisterParamsMetadataUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u ModelRegisterParamsMetadataUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *ModelRegisterParamsMetadataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ModelRegisterParamsMetadataUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - -// The type of model to register. +// Enumeration of supported model types in Llama Stack. type ModelRegisterParamsModelType string const ( diff --git a/model_test.go b/model_test.go index 4b9124d..f9998e1 100644 --- a/model_test.go +++ b/model_test.go @@ -74,10 +74,8 @@ func TestModelRegisterWithOptionalParams(t *testing.T) { ) _, err := client.Models.Register(context.TODO(), llamastackclient.ModelRegisterParams{ ModelID: "model_id", - Metadata: map[string]llamastackclient.ModelRegisterParamsMetadataUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + Metadata: map[string]any{ + "foo": "bar", }, ModelType: llamastackclient.ModelRegisterParamsModelTypeLlm, ProviderID: llamastackclient.String("provider_id"), diff --git a/moderation.go b/moderation.go index 76d082c..1d6e8a0 100644 --- a/moderation.go +++ b/moderation.go @@ -10,7 +10,6 @@ package llamastackclient import ( "context" - "encoding/json" "net/http" "slices" @@ -40,8 +39,9 @@ func NewModerationService(opts ...option.RequestOption) (r ModerationService) { return } -// Create moderation. Classifies if text and/or image inputs are potentially -// harmful. +// Create moderation. +// +// Classifies if text and/or image inputs are potentially harmful. func (r *ModerationService) New(ctx context.Context, body ModerationNewParams, opts ...option.RequestOption) (res *CreateResponse, err error) { opts = slices.Concat(r.Options, opts) path := "v1/moderations" @@ -51,11 +51,8 @@ func (r *ModerationService) New(ctx context.Context, body ModerationNewParams, o // A moderation object. type CreateResponse struct { - // The unique identifier for the moderation request. - ID string `json:"id,required"` - // The model used to generate the moderation results. - Model string `json:"model,required"` - // A list of moderation objects + ID string `json:"id,required"` + Model string `json:"model,required"` Results []CreateResponseResult `json:"results,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { @@ -75,23 +72,19 @@ func (r *CreateResponse) UnmarshalJSON(data []byte) error { // A moderation object. type CreateResponseResult struct { - // Whether any of the below categories are flagged. - Flagged bool `json:"flagged,required"` - Metadata map[string]CreateResponseResultMetadataUnion `json:"metadata,required"` - // A list of the categories, and whether they are flagged or not. - Categories map[string]bool `json:"categories"` - // A list of the categories along with the input type(s) that the score applies to. - CategoryAppliedInputTypes map[string][]string `json:"category_applied_input_types"` - // A list of the categories along with their scores as predicted by model. - CategoryScores map[string]float64 `json:"category_scores"` - UserMessage string `json:"user_message"` + Flagged bool `json:"flagged,required"` + Categories map[string]bool `json:"categories,nullable"` + CategoryAppliedInputTypes map[string][]string `json:"category_applied_input_types,nullable"` + CategoryScores map[string]float64 `json:"category_scores,nullable"` + Metadata map[string]any `json:"metadata"` + UserMessage string `json:"user_message,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Flagged respjson.Field - Metadata respjson.Field Categories respjson.Field CategoryAppliedInputTypes respjson.Field CategoryScores respjson.Field + Metadata respjson.Field UserMessage respjson.Field ExtraFields map[string]respjson.Field raw string @@ -104,64 +97,9 @@ func (r *CreateResponseResult) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// CreateResponseResultMetadataUnion contains all possible properties and values -// from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type CreateResponseResultMetadataUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u CreateResponseResultMetadataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u CreateResponseResultMetadataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u CreateResponseResultMetadataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u CreateResponseResultMetadataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u CreateResponseResultMetadataUnion) RawJSON() string { return u.JSON.raw } - -func (r *CreateResponseResultMetadataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - type ModerationNewParams struct { - // Input (or inputs) to classify. Can be a single string, an array of strings, or - // an array of multi-modal input objects similar to other models. Input ModerationNewParamsInputUnion `json:"input,omitzero,required"` - // (Optional) The content moderation model you would like to use. - Model param.Opt[string] `json:"model,omitzero"` + Model param.Opt[string] `json:"model,omitzero"` paramObj } @@ -177,13 +115,13 @@ func (r *ModerationNewParams) UnmarshalJSON(data []byte) error { // // Use [param.IsOmitted] to confirm if a field is set. type ModerationNewParamsInputUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfStringArray []string `json:",omitzero,inline"` + OfString param.Opt[string] `json:",omitzero,inline"` + OfListString []string `json:",omitzero,inline"` paramUnion } func (u ModerationNewParamsInputUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfStringArray) + return param.MarshalUnion(u, u.OfString, u.OfListString) } func (u *ModerationNewParamsInputUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) @@ -192,8 +130,8 @@ func (u *ModerationNewParamsInputUnion) UnmarshalJSON(data []byte) error { func (u *ModerationNewParamsInputUnion) asAny() any { if !param.IsOmitted(u.OfString) { return &u.OfString.Value - } else if !param.IsOmitted(u.OfStringArray) { - return &u.OfStringArray + } else if !param.IsOmitted(u.OfListString) { + return &u.OfListString } return nil } diff --git a/prompt.go b/prompt.go index 12d6b77..568297d 100644 --- a/prompt.go +++ b/prompt.go @@ -45,7 +45,9 @@ func NewPromptService(opts ...option.RequestOption) (r PromptService) { return } -// Create prompt. Create a new prompt. +// Create prompt. +// +// Create a new prompt. func (r *PromptService) New(ctx context.Context, body PromptNewParams, opts ...option.RequestOption) (res *Prompt, err error) { opts = slices.Concat(r.Options, opts) path := "v1/prompts" @@ -53,7 +55,9 @@ func (r *PromptService) New(ctx context.Context, body PromptNewParams, opts ...o return } -// Get prompt. Get a prompt by its identifier and optional version. +// Get prompt. +// +// Get a prompt by its identifier and optional version. func (r *PromptService) Get(ctx context.Context, promptID string, query PromptGetParams, opts ...option.RequestOption) (res *Prompt, err error) { opts = slices.Concat(r.Options, opts) if promptID == "" { @@ -65,7 +69,9 @@ func (r *PromptService) Get(ctx context.Context, promptID string, query PromptGe return } -// Update prompt. Update an existing prompt (increments version). +// Update prompt. +// +// Update an existing prompt (increments version). func (r *PromptService) Update(ctx context.Context, promptID string, body PromptUpdateParams, opts ...option.RequestOption) (res *Prompt, err error) { opts = slices.Concat(r.Options, opts) if promptID == "" { @@ -90,7 +96,9 @@ func (r *PromptService) List(ctx context.Context, opts ...option.RequestOption) return } -// Delete prompt. Delete a prompt. +// Delete prompt. +// +// Delete a prompt. func (r *PromptService) Delete(ctx context.Context, promptID string, opts ...option.RequestOption) (err error) { opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) @@ -103,8 +111,9 @@ func (r *PromptService) Delete(ctx context.Context, promptID string, opts ...opt return } -// Set prompt version. Set which version of a prompt should be the default in -// get_prompt (latest). +// Set prompt version. +// +// Set which version of a prompt should be the default in get_prompt (latest). func (r *PromptService) SetDefaultVersion(ctx context.Context, promptID string, body PromptSetDefaultVersionParams, opts ...option.RequestOption) (res *Prompt, err error) { opts = slices.Concat(r.Options, opts) if promptID == "" { @@ -136,24 +145,23 @@ func (r *ListPromptsResponse) UnmarshalJSON(data []byte) error { // A prompt resource representing a stored OpenAI Compatible prompt template in // Llama Stack. type Prompt struct { - // Boolean indicating whether this version is the default version for this prompt - IsDefault bool `json:"is_default,required"` - // Unique identifier formatted as 'pmpt\_<48-digit-hash>' + // Unique identifier in format 'pmpt\_<48-digit-hash>' PromptID string `json:"prompt_id,required"` - // List of prompt variable names that can be used in the prompt template - Variables []string `json:"variables,required"` // Version (integer starting at 1, incremented on save) Version int64 `json:"version,required"` - // The system prompt text with variable placeholders. Variables are only supported - // when using the Responses API. - Prompt string `json:"prompt"` + // Boolean indicating whether this version is the default version + IsDefault bool `json:"is_default"` + // The system prompt with variable placeholders + Prompt string `json:"prompt,nullable"` + // List of variable names that can be used in the prompt template + Variables []string `json:"variables"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - IsDefault respjson.Field PromptID respjson.Field - Variables respjson.Field Version respjson.Field + IsDefault respjson.Field Prompt respjson.Field + Variables respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -166,9 +174,7 @@ func (r *Prompt) UnmarshalJSON(data []byte) error { } type PromptNewParams struct { - // The prompt text content with variable placeholders. - Prompt string `json:"prompt,required"` - // List of variable names that can be used in the prompt template. + Prompt string `json:"prompt,required"` Variables []string `json:"variables,omitzero"` paramObj } @@ -182,7 +188,6 @@ func (r *PromptNewParams) UnmarshalJSON(data []byte) error { } type PromptGetParams struct { - // The version of the prompt to get (defaults to latest). Version param.Opt[int64] `query:"version,omitzero" json:"-"` paramObj } @@ -196,14 +201,10 @@ func (r PromptGetParams) URLQuery() (v url.Values, err error) { } type PromptUpdateParams struct { - // The updated prompt text content. - Prompt string `json:"prompt,required"` - // Set the new version as the default (default=True). - SetAsDefault bool `json:"set_as_default,required"` - // The current version of the prompt being updated. - Version int64 `json:"version,required"` - // Updated list of variable names that can be used in the prompt template. - Variables []string `json:"variables,omitzero"` + Prompt string `json:"prompt,required"` + Version int64 `json:"version,required"` + SetAsDefault param.Opt[bool] `json:"set_as_default,omitzero"` + Variables []string `json:"variables,omitzero"` paramObj } @@ -216,7 +217,6 @@ func (r *PromptUpdateParams) UnmarshalJSON(data []byte) error { } type PromptSetDefaultVersionParams struct { - // The version to set as default. Version int64 `json:"version,required"` paramObj } diff --git a/prompt_test.go b/prompt_test.go index 097cfdf..db6ead6 100644 --- a/prompt_test.go +++ b/prompt_test.go @@ -86,8 +86,8 @@ func TestPromptUpdateWithOptionalParams(t *testing.T) { "prompt_id", llamastackclient.PromptUpdateParams{ Prompt: "prompt", - SetAsDefault: true, Version: 0, + SetAsDefault: llamastackclient.Bool(true), Variables: []string{"string"}, }, ) diff --git a/promptversion.go b/promptversion.go index d81aa41..0d754b4 100644 --- a/promptversion.go +++ b/promptversion.go @@ -38,7 +38,9 @@ func NewPromptVersionService(opts ...option.RequestOption) (r PromptVersionServi return } -// List prompt versions. List all versions of a specific prompt. +// List prompt versions. +// +// List all versions of a specific prompt. func (r *PromptVersionService) List(ctx context.Context, promptID string, opts ...option.RequestOption) (res *[]Prompt, err error) { var env ListPromptsResponse opts = slices.Concat(r.Options, opts) diff --git a/provider.go b/provider.go index 9d5506b..b79e828 100644 --- a/provider.go +++ b/provider.go @@ -40,7 +40,9 @@ func NewProviderService(opts ...option.RequestOption) (r ProviderService) { return } -// Get provider. Get detailed information about a specific provider. +// Get provider. +// +// Get detailed information about a specific provider. func (r *ProviderService) Get(ctx context.Context, providerID string, opts ...option.RequestOption) (res *ProviderInfo, err error) { opts = slices.Concat(r.Options, opts) if providerID == "" { @@ -52,7 +54,9 @@ func (r *ProviderService) Get(ctx context.Context, providerID string, opts ...op return } -// List providers. List all available providers. +// List providers. +// +// List all available providers. func (r *ProviderService) List(ctx context.Context, opts ...option.RequestOption) (res *[]ProviderInfo, err error) { var env ListProvidersResponse opts = slices.Concat(r.Options, opts) @@ -67,7 +71,6 @@ func (r *ProviderService) List(ctx context.Context, opts ...option.RequestOption // Response containing a list of all available providers. type ListProvidersResponse struct { - // List of provider information objects Data []ProviderInfo `json:"data,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { diff --git a/response.go b/response.go index 6e3f14e..76530c9 100644 --- a/response.go +++ b/response.go @@ -25,7 +25,6 @@ import ( "github.com/llamastack/llama-stack-client-go/packages/param" "github.com/llamastack/llama-stack-client-go/packages/respjson" "github.com/llamastack/llama-stack-client-go/packages/ssestream" - "github.com/llamastack/llama-stack-client-go/shared/constant" ) // ResponseService contains methods and other services that help with interacting @@ -119,59 +118,45 @@ func (r *ResponseService) Delete(ctx context.Context, responseID string, opts .. // Complete OpenAI response object containing generation results and metadata. type ResponseObject struct { - // Unique identifier for this response - ID string `json:"id,required"` - // Unix timestamp when the response was created - CreatedAt int64 `json:"created_at,required"` - // Model identifier used for generation - Model string `json:"model,required"` - // Object type identifier, always "response" - Object constant.Response `json:"object,required"` - // List of generated output items (messages, tool calls, etc.) - Output []ResponseObjectOutputUnion `json:"output,required"` - // Whether tool calls can be executed in parallel - ParallelToolCalls bool `json:"parallel_tool_calls,required"` - // Current status of the response generation - Status string `json:"status,required"` - // Text formatting configuration for the response - Text ResponseObjectText `json:"text,required"` - // (Optional) Error details if the response generation failed - Error ResponseObjectError `json:"error"` - // (Optional) System message inserted into the model's context - Instructions string `json:"instructions"` - // (Optional) Max number of total calls to built-in tools that can be processed in - // a response - MaxToolCalls int64 `json:"max_tool_calls"` - // (Optional) ID of the previous response in a conversation - PreviousResponseID string `json:"previous_response_id"` - // (Optional) Reference to a prompt template and its variables. - Prompt ResponseObjectPrompt `json:"prompt"` - // (Optional) Sampling temperature used for generation - Temperature float64 `json:"temperature"` - // (Optional) An array of tools the model may call while generating a response. - Tools []ResponseObjectToolUnion `json:"tools"` - // (Optional) Nucleus sampling parameter used for generation - TopP float64 `json:"top_p"` - // (Optional) Truncation strategy applied to the response - Truncation string `json:"truncation"` - // (Optional) Token usage information for the response - Usage ResponseObjectUsage `json:"usage"` + ID string `json:"id,required"` + CreatedAt int64 `json:"created_at,required"` + Model string `json:"model,required"` + Output []ResponseObjectOutputUnion `json:"output,required"` + Status string `json:"status,required"` + // Error details for failed OpenAI response requests. + Error ResponseObjectError `json:"error,nullable"` + Instructions string `json:"instructions,nullable"` + MaxToolCalls int64 `json:"max_tool_calls,nullable"` + // Any of "response". + Object ResponseObjectObject `json:"object"` + ParallelToolCalls bool `json:"parallel_tool_calls"` + PreviousResponseID string `json:"previous_response_id,nullable"` + // OpenAI compatible Prompt object that is used in OpenAI responses. + Prompt ResponseObjectPrompt `json:"prompt,nullable"` + Temperature float64 `json:"temperature,nullable"` + // Text response configuration for OpenAI responses. + Text ResponseObjectText `json:"text"` + Tools []ResponseObjectToolUnion `json:"tools,nullable"` + TopP float64 `json:"top_p,nullable"` + Truncation string `json:"truncation,nullable"` + // Usage information for OpenAI response. + Usage ResponseObjectUsage `json:"usage,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field CreatedAt respjson.Field Model respjson.Field - Object respjson.Field Output respjson.Field - ParallelToolCalls respjson.Field Status respjson.Field - Text respjson.Field Error respjson.Field Instructions respjson.Field MaxToolCalls respjson.Field + Object respjson.Field + ParallelToolCalls respjson.Field PreviousResponseID respjson.Field Prompt respjson.Field Temperature respjson.Field + Text respjson.Field Tools respjson.Field TopP respjson.Field Truncation respjson.Field @@ -200,12 +185,12 @@ type ResponseObjectOutputUnion struct { // This field is from variant [ResponseObjectOutputMessage]. Content ResponseObjectOutputMessageContentUnion `json:"content"` // This field is from variant [ResponseObjectOutputMessage]. - Role ResponseObjectOutputMessageRole `json:"role"` - // Any of "message", "web_search_call", "file_search_call", "function_call", - // "mcp_call", "mcp_list_tools", "mcp_approval_request". - Type string `json:"type"` + Role string `json:"role"` ID string `json:"id"` Status string `json:"status"` + // Any of "message", "web_search_call", "file_search_call", "function_call", + // "mcp_call", "mcp_list_tools", "mcp_approval_request". + Type string `json:"type"` // This field is from variant [ResponseObjectOutputFileSearchCall]. Queries []string `json:"queries"` // This field is from variant [ResponseObjectOutputFileSearchCall]. @@ -224,9 +209,9 @@ type ResponseObjectOutputUnion struct { JSON struct { Content respjson.Field Role respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field Queries respjson.Field Results respjson.Field Arguments respjson.Field @@ -336,17 +321,18 @@ func (r *ResponseObjectOutputUnion) UnmarshalJSON(data []byte) error { type ResponseObjectOutputMessage struct { Content ResponseObjectOutputMessageContentUnion `json:"content,required"` // Any of "system", "developer", "user", "assistant". - Role ResponseObjectOutputMessageRole `json:"role,required"` - Type constant.Message `json:"type,required"` - ID string `json:"id"` - Status string `json:"status"` + Role string `json:"role,required"` + ID string `json:"id,nullable"` + Status string `json:"status,nullable"` + // Any of "message". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field Role respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -359,23 +345,32 @@ func (r *ResponseObjectOutputMessage) UnmarshalJSON(data []byte) error { } // ResponseObjectOutputMessageContentUnion contains all possible properties and -// values from [string], [[]ResponseObjectOutputMessageContentArrayItemUnion], -// [[]ResponseObjectOutputMessageContentArrayItemUnion]. +// values from [string], +// [[]ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion], +// [[]ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString OfVariant2] +// will be valid: OfString +// OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile +// OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal] type ResponseObjectOutputMessageContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ResponseObjectOutputMessageContentArrayItemUnion] instead of an object. - OfVariant2 []ResponseObjectOutputMessageContentArrayItemUnion `json:",inline"` - JSON struct { - OfString respjson.Field - OfVariant2 respjson.Field - raw string + // [[]ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion] + // instead of an object. + OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile []ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion `json:",inline"` + // This field will be present if the value is a + // [[]ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion] + // instead of an object. + OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal []ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile respjson.Field + OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal respjson.Field + raw string } `json:"-"` } @@ -384,12 +379,12 @@ func (u ResponseObjectOutputMessageContentUnion) AsString() (v string) { return } -func (u ResponseObjectOutputMessageContentUnion) AsResponseObjectOutputMessageContentArray() (v []ResponseObjectOutputMessageContentArrayItemUnion) { +func (u ResponseObjectOutputMessageContentUnion) AsListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile() (v []ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectOutputMessageContentUnion) AsVariant2() (v []ResponseObjectOutputMessageContentArrayItemUnion) { +func (u ResponseObjectOutputMessageContentUnion) AsListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal() (v []ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -401,37 +396,38 @@ func (r *ResponseObjectOutputMessageContentUnion) UnmarshalJSON(data []byte) err return apijson.UnmarshalRoot(data, r) } -// ResponseObjectOutputMessageContentArrayItemUnion contains all possible -// properties and values from -// [ResponseObjectOutputMessageContentArrayItemInputText], -// [ResponseObjectOutputMessageContentArrayItemInputImage], -// [ResponseObjectOutputMessageContentArrayItemInputFile]. +// ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion +// contains all possible properties and values from +// [ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText], +// [ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage], +// [ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. // -// Use the [ResponseObjectOutputMessageContentArrayItemUnion.AsAny] method to -// switch on the variant. +// Use the +// [ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny] +// method to switch on the variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type ResponseObjectOutputMessageContentArrayItemUnion struct { +type ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion struct { // This field is from variant - // [ResponseObjectOutputMessageContentArrayItemInputText]. + // [ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText]. Text string `json:"text"` // Any of "input_text", "input_image", "input_file". Type string `json:"type"` // This field is from variant - // [ResponseObjectOutputMessageContentArrayItemInputImage]. - Detail ResponseObjectOutputMessageContentArrayItemInputImageDetail `json:"detail"` - FileID string `json:"file_id"` + // [ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]. + Detail string `json:"detail"` + FileID string `json:"file_id"` // This field is from variant - // [ResponseObjectOutputMessageContentArrayItemInputImage]. + // [ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]. ImageURL string `json:"image_url"` // This field is from variant - // [ResponseObjectOutputMessageContentArrayItemInputFile]. + // [ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. FileData string `json:"file_data"` // This field is from variant - // [ResponseObjectOutputMessageContentArrayItemInputFile]. + // [ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. FileURL string `json:"file_url"` // This field is from variant - // [ResponseObjectOutputMessageContentArrayItemInputFile]. + // [ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. Filename string `json:"filename"` JSON struct { Text respjson.Field @@ -446,30 +442,32 @@ type ResponseObjectOutputMessageContentArrayItemUnion struct { } `json:"-"` } -// anyResponseObjectOutputMessageContentArrayItem is implemented by each variant of -// [ResponseObjectOutputMessageContentArrayItemUnion] to add type safety for the -// return type of [ResponseObjectOutputMessageContentArrayItemUnion.AsAny] -type anyResponseObjectOutputMessageContentArrayItem interface { - implResponseObjectOutputMessageContentArrayItemUnion() +// anyResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem +// is implemented by each variant of +// [ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion] +// to add type safety for the return type of +// [ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny] +type anyResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem interface { + implResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() } -func (ResponseObjectOutputMessageContentArrayItemInputText) implResponseObjectOutputMessageContentArrayItemUnion() { +func (ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) implResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { } -func (ResponseObjectOutputMessageContentArrayItemInputImage) implResponseObjectOutputMessageContentArrayItemUnion() { +func (ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) implResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { } -func (ResponseObjectOutputMessageContentArrayItemInputFile) implResponseObjectOutputMessageContentArrayItemUnion() { +func (ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) implResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { } // Use the following switch statement to find the correct variant // -// switch variant := ResponseObjectOutputMessageContentArrayItemUnion.AsAny().(type) { -// case llamastackclient.ResponseObjectOutputMessageContentArrayItemInputText: -// case llamastackclient.ResponseObjectOutputMessageContentArrayItemInputImage: -// case llamastackclient.ResponseObjectOutputMessageContentArrayItemInputFile: +// switch variant := ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny().(type) { +// case llamastackclient.ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText: +// case llamastackclient.ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage: +// case llamastackclient.ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile: // default: // fmt.Errorf("no variant present") // } -func (u ResponseObjectOutputMessageContentArrayItemUnion) AsAny() anyResponseObjectOutputMessageContentArrayItem { +func (u ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsAny() anyResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem { switch u.Type { case "input_text": return u.AsInputText() @@ -481,34 +479,35 @@ func (u ResponseObjectOutputMessageContentArrayItemUnion) AsAny() anyResponseObj return nil } -func (u ResponseObjectOutputMessageContentArrayItemUnion) AsInputText() (v ResponseObjectOutputMessageContentArrayItemInputText) { +func (u ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputText() (v ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectOutputMessageContentArrayItemUnion) AsInputImage() (v ResponseObjectOutputMessageContentArrayItemInputImage) { +func (u ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputImage() (v ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectOutputMessageContentArrayItemUnion) AsInputFile() (v ResponseObjectOutputMessageContentArrayItemInputFile) { +func (u ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputFile() (v ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ResponseObjectOutputMessageContentArrayItemUnion) RawJSON() string { return u.JSON.raw } +func (u ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) RawJSON() string { + return u.JSON.raw +} -func (r *ResponseObjectOutputMessageContentArrayItemUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content for input messages in OpenAI response format. -type ResponseObjectOutputMessageContentArrayItemInputText struct { - // The text content of the input message +type ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText struct { Text string `json:"text,required"` - // Content type identifier, always "input_text" - Type constant.InputText `json:"type,required"` + // Any of "input_text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -519,317 +518,356 @@ type ResponseObjectOutputMessageContentArrayItemInputText struct { } // Returns the unmodified JSON received from the API -func (r ResponseObjectOutputMessageContentArrayItemInputText) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectOutputMessageContentArrayItemInputText) UnmarshalJSON(data []byte) error { +func (r ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Image content for input messages in OpenAI response format. -type ResponseObjectOutputMessageContentArrayItemInputImage struct { - // Level of detail for image processing, can be "low", "high", or "auto" - // +type ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage struct { // Any of "low", "high", "auto". - Detail ResponseObjectOutputMessageContentArrayItemInputImageDetail `json:"detail,required"` - // Content type identifier, always "input_image" - Type constant.InputImage `json:"type,required"` - // (Optional) The ID of the file to be sent to the model. - FileID string `json:"file_id"` - // (Optional) URL of the image content - ImageURL string `json:"image_url"` + Detail string `json:"detail"` + FileID string `json:"file_id,nullable"` + ImageURL string `json:"image_url,nullable"` + // Any of "input_image". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Detail respjson.Field - Type respjson.Field FileID respjson.Field ImageURL respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectOutputMessageContentArrayItemInputImage) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectOutputMessageContentArrayItemInputImage) UnmarshalJSON(data []byte) error { +func (r ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ResponseObjectOutputMessageContentArrayItemInputImageDetail string - -const ( - ResponseObjectOutputMessageContentArrayItemInputImageDetailLow ResponseObjectOutputMessageContentArrayItemInputImageDetail = "low" - ResponseObjectOutputMessageContentArrayItemInputImageDetailHigh ResponseObjectOutputMessageContentArrayItemInputImageDetail = "high" - ResponseObjectOutputMessageContentArrayItemInputImageDetailAuto ResponseObjectOutputMessageContentArrayItemInputImageDetail = "auto" -) - // File content for input messages in OpenAI response format. -type ResponseObjectOutputMessageContentArrayItemInputFile struct { - // The type of the input item. Always `input_file`. - Type constant.InputFile `json:"type,required"` - // The data of the file to be sent to the model. - FileData string `json:"file_data"` - // (Optional) The ID of the file to be sent to the model. - FileID string `json:"file_id"` - // The URL of the file to be sent to the model. - FileURL string `json:"file_url"` - // The name of the file to be sent to the model. - Filename string `json:"filename"` +type ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile struct { + FileData string `json:"file_data,nullable"` + FileID string `json:"file_id,nullable"` + FileURL string `json:"file_url,nullable"` + Filename string `json:"filename,nullable"` + // Any of "input_file". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field FileData respjson.Field FileID respjson.Field FileURL respjson.Field Filename respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectOutputMessageContentArrayItemInputFile) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectOutputMessageContentArrayItemInputFile) UnmarshalJSON(data []byte) error { +func (r ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ResponseObjectOutputMessageContentArrayItemDetail string +// ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion +// contains all possible properties and values from +// [ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText], +// [ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]. +// +// Use the +// [ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny] +// method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion struct { + // This field is from variant + // [ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]. + Text string `json:"text"` + // This field is from variant + // [ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]. + Annotations []ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion `json:"annotations"` + // Any of "output_text", "refusal". + Type string `json:"type"` + // This field is from variant + // [ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]. + Refusal string `json:"refusal"` + JSON struct { + Text respjson.Field + Annotations respjson.Field + Type respjson.Field + Refusal respjson.Field + raw string + } `json:"-"` +} + +// anyResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem +// is implemented by each variant of +// [ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion] +// to add type safety for the return type of +// [ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny] +type anyResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem interface { + implResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() +} -const ( - ResponseObjectOutputMessageContentArrayItemDetailLow ResponseObjectOutputMessageContentArrayItemDetail = "low" - ResponseObjectOutputMessageContentArrayItemDetailHigh ResponseObjectOutputMessageContentArrayItemDetail = "high" - ResponseObjectOutputMessageContentArrayItemDetailAuto ResponseObjectOutputMessageContentArrayItemDetail = "auto" -) +func (ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) implResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() { +} +func (ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) implResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() { +} -type ResponseObjectOutputMessageRole string +// Use the following switch statement to find the correct variant +// +// switch variant := ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny().(type) { +// case llamastackclient.ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText: +// case llamastackclient.ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal: +// default: +// fmt.Errorf("no variant present") +// } +func (u ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsAny() anyResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem { + switch u.Type { + case "output_text": + return u.AsOutputText() + case "refusal": + return u.AsRefusal() + } + return nil +} -const ( - ResponseObjectOutputMessageRoleSystem ResponseObjectOutputMessageRole = "system" - ResponseObjectOutputMessageRoleDeveloper ResponseObjectOutputMessageRole = "developer" - ResponseObjectOutputMessageRoleUser ResponseObjectOutputMessageRole = "user" - ResponseObjectOutputMessageRoleAssistant ResponseObjectOutputMessageRole = "assistant" -) +func (u ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsOutputText() (v ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} -// Web search tool call output message for OpenAI responses. -type ResponseObjectOutputWebSearchCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // Current status of the web search operation - Status string `json:"status,required"` - // Tool call type identifier, always "web_search_call" - Type constant.WebSearchCall `json:"type,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - ID respjson.Field - Status respjson.Field - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` +func (u ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsRefusal() (v ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return } // Returns the unmodified JSON received from the API -func (r ResponseObjectOutputWebSearchCall) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectOutputWebSearchCall) UnmarshalJSON(data []byte) error { +func (u ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// File search tool call output message for OpenAI responses. -type ResponseObjectOutputFileSearchCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // List of search queries executed - Queries []string `json:"queries,required"` - // Current status of the file search operation - Status string `json:"status,required"` - // Tool call type identifier, always "file_search_call" - Type constant.FileSearchCall `json:"type,required"` - // (Optional) Search results returned by the file search operation - Results []ResponseObjectOutputFileSearchCallResult `json:"results"` +type ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText struct { + Text string `json:"text,required"` + Annotations []ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion `json:"annotations"` + // Any of "output_text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - ID respjson.Field - Queries respjson.Field - Status respjson.Field + Text respjson.Field + Annotations respjson.Field Type respjson.Field - Results respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectOutputFileSearchCall) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectOutputFileSearchCall) UnmarshalJSON(data []byte) error { +func (r ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Search results returned by the file search operation. -type ResponseObjectOutputFileSearchCallResult struct { - // (Optional) Key-value attributes associated with the file - Attributes map[string]ResponseObjectOutputFileSearchCallResultAttributeUnion `json:"attributes,required"` - // Unique identifier of the file containing the result - FileID string `json:"file_id,required"` - // Name of the file containing the result - Filename string `json:"filename,required"` - // Relevance score for this search result (between 0 and 1) - Score float64 `json:"score,required"` - // Text content of the search result - Text string `json:"text,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Attributes respjson.Field +// ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion +// contains all possible properties and values from +// [ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation], +// [ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation], +// [ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation], +// [ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath]. +// +// Use the +// [ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny] +// method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion struct { + FileID string `json:"file_id"` + Filename string `json:"filename"` + Index int64 `json:"index"` + // Any of "file_citation", "url_citation", "container_file_citation", "file_path". + Type string `json:"type"` + EndIndex int64 `json:"end_index"` + StartIndex int64 `json:"start_index"` + // This field is from variant + // [ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]. + Title string `json:"title"` + // This field is from variant + // [ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]. + URL string `json:"url"` + // This field is from variant + // [ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation]. + ContainerID string `json:"container_id"` + JSON struct { FileID respjson.Field Filename respjson.Field - Score respjson.Field - Text respjson.Field - ExtraFields map[string]respjson.Field + Index respjson.Field + Type respjson.Field + EndIndex respjson.Field + StartIndex respjson.Field + Title respjson.Field + URL respjson.Field + ContainerID respjson.Field raw string } `json:"-"` } -// Returns the unmodified JSON received from the API -func (r ResponseObjectOutputFileSearchCallResult) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectOutputFileSearchCallResult) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) +// anyResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation +// is implemented by each variant of +// [ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion] +// to add type safety for the return type of +// [ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny] +type anyResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation interface { + implResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() } -// ResponseObjectOutputFileSearchCallResultAttributeUnion contains all possible -// properties and values from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. +func (ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) implResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} +func (ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) implResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} +func (ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) implResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} +func (ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) implResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} + +// Use the following switch statement to find the correct variant // -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ResponseObjectOutputFileSearchCallResultAttributeUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` +// switch variant := ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny().(type) { +// case llamastackclient.ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation: +// case llamastackclient.ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation: +// case llamastackclient.ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation: +// case llamastackclient.ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath: +// default: +// fmt.Errorf("no variant present") +// } +func (u ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsAny() anyResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation { + switch u.Type { + case "file_citation": + return u.AsFileCitation() + case "url_citation": + return u.AsURLCitation() + case "container_file_citation": + return u.AsContainerFileCitation() + case "file_path": + return u.AsFilePath() + } + return nil } -func (u ResponseObjectOutputFileSearchCallResultAttributeUnion) AsBool() (v bool) { +func (u ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsFileCitation() (v ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectOutputFileSearchCallResultAttributeUnion) AsFloat() (v float64) { +func (u ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsURLCitation() (v ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectOutputFileSearchCallResultAttributeUnion) AsString() (v string) { +func (u ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsContainerFileCitation() (v ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectOutputFileSearchCallResultAttributeUnion) AsAnyArray() (v []any) { +func (u ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsFilePath() (v ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ResponseObjectOutputFileSearchCallResultAttributeUnion) RawJSON() string { return u.JSON.raw } +func (u ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) RawJSON() string { + return u.JSON.raw +} -func (r *ResponseObjectOutputFileSearchCallResultAttributeUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Function tool call output message for OpenAI responses. -type ResponseObjectOutputFunctionCall struct { - // JSON string containing the function arguments - Arguments string `json:"arguments,required"` - // Unique identifier for the function call - CallID string `json:"call_id,required"` - // Name of the function being called - Name string `json:"name,required"` - // Tool call type identifier, always "function_call" - Type constant.FunctionCall `json:"type,required"` - // (Optional) Additional identifier for the tool call - ID string `json:"id"` - // (Optional) Current status of the function call execution - Status string `json:"status"` +// File citation annotation for referencing specific files in response content. +type ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation struct { + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Index int64 `json:"index,required"` + // Any of "file_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Arguments respjson.Field - CallID respjson.Field - Name respjson.Field + FileID respjson.Field + Filename respjson.Field + Index respjson.Field Type respjson.Field - ID respjson.Field - Status respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectOutputFunctionCall) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectOutputFunctionCall) UnmarshalJSON(data []byte) error { +func (r ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Model Context Protocol (MCP) call output message for OpenAI responses. -type ResponseObjectOutputMcpCall struct { - // Unique identifier for this MCP call - ID string `json:"id,required"` - // JSON string containing the MCP call arguments - Arguments string `json:"arguments,required"` - // Name of the MCP method being called - Name string `json:"name,required"` - // Label identifying the MCP server handling the call - ServerLabel string `json:"server_label,required"` - // Tool call type identifier, always "mcp_call" - Type constant.McpCall `json:"type,required"` - // (Optional) Error message if the MCP call failed - Error string `json:"error"` - // (Optional) Output result from the successful MCP call - Output string `json:"output"` +// URL citation annotation for referencing external web resources. +type ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation struct { + EndIndex int64 `json:"end_index,required"` + StartIndex int64 `json:"start_index,required"` + Title string `json:"title,required"` + URL string `json:"url,required"` + // Any of "url_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - ID respjson.Field - Arguments respjson.Field - Name respjson.Field - ServerLabel respjson.Field + EndIndex respjson.Field + StartIndex respjson.Field + Title respjson.Field + URL respjson.Field Type respjson.Field - Error respjson.Field - Output respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectOutputMcpCall) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectOutputMcpCall) UnmarshalJSON(data []byte) error { +func (r ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// MCP list tools output message containing available tools from an MCP server. -type ResponseObjectOutputMcpListTools struct { - // Unique identifier for this MCP list tools operation - ID string `json:"id,required"` - // Label identifying the MCP server providing the tools - ServerLabel string `json:"server_label,required"` - // List of available tools provided by the MCP server - Tools []ResponseObjectOutputMcpListToolsTool `json:"tools,required"` - // Tool call type identifier, always "mcp_list_tools" - Type constant.McpListTools `json:"type,required"` +type ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation struct { + ContainerID string `json:"container_id,required"` + EndIndex int64 `json:"end_index,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + StartIndex int64 `json:"start_index,required"` + // Any of "container_file_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - ID respjson.Field - ServerLabel respjson.Field - Tools respjson.Field + ContainerID respjson.Field + EndIndex respjson.Field + FileID respjson.Field + Filename respjson.Field + StartIndex respjson.Field Type respjson.Field ExtraFields map[string]respjson.Field raw string @@ -837,100 +875,94 @@ type ResponseObjectOutputMcpListTools struct { } // Returns the unmodified JSON received from the API -func (r ResponseObjectOutputMcpListTools) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectOutputMcpListTools) UnmarshalJSON(data []byte) error { +func (r ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Tool definition returned by MCP list tools operation. -type ResponseObjectOutputMcpListToolsTool struct { - // JSON schema defining the tool's input parameters - InputSchema map[string]ResponseObjectOutputMcpListToolsToolInputSchemaUnion `json:"input_schema,required"` - // Name of the tool - Name string `json:"name,required"` - // (Optional) Description of what the tool does - Description string `json:"description"` +type ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath struct { + FileID string `json:"file_id,required"` + Index int64 `json:"index,required"` + // Any of "file_path". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - InputSchema respjson.Field - Name respjson.Field - Description respjson.Field + FileID respjson.Field + Index respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectOutputMcpListToolsTool) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectOutputMcpListToolsTool) UnmarshalJSON(data []byte) error { +func (r ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseObjectOutputMcpListToolsToolInputSchemaUnion contains all possible -// properties and values from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ResponseObjectOutputMcpListToolsToolInputSchemaUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string +// Refusal content within a streamed response part. +type ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal struct { + Refusal string `json:"refusal,required"` + // Any of "refusal". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Refusal respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } -func (u ResponseObjectOutputMcpListToolsToolInputSchemaUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectOutputMcpListToolsToolInputSchemaUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Returns the unmodified JSON received from the API +func (r ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) RawJSON() string { + return r.JSON.raw } - -func (u ResponseObjectOutputMcpListToolsToolInputSchemaUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +func (r *ResponseObjectOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ResponseObjectOutputMcpListToolsToolInputSchemaUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Web search tool call output message for OpenAI responses. +type ResponseObjectOutputWebSearchCall struct { + ID string `json:"id,required"` + Status string `json:"status,required"` + // Any of "web_search_call". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Status respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } // Returns the unmodified JSON received from the API -func (u ResponseObjectOutputMcpListToolsToolInputSchemaUnion) RawJSON() string { return u.JSON.raw } - -func (r *ResponseObjectOutputMcpListToolsToolInputSchemaUnion) UnmarshalJSON(data []byte) error { +func (r ResponseObjectOutputWebSearchCall) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectOutputWebSearchCall) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// A request for human approval of a tool invocation. -type ResponseObjectOutputMcpApprovalRequest struct { - ID string `json:"id,required"` - Arguments string `json:"arguments,required"` - Name string `json:"name,required"` - ServerLabel string `json:"server_label,required"` - Type constant.McpApprovalRequest `json:"type,required"` +// File search tool call output message for OpenAI responses. +type ResponseObjectOutputFileSearchCall struct { + ID string `json:"id,required"` + Queries []string `json:"queries,required"` + Status string `json:"status,required"` + Results []ResponseObjectOutputFileSearchCallResult `json:"results,nullable"` + // Any of "file_search_call". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field - Arguments respjson.Field - Name respjson.Field - ServerLabel respjson.Field + Queries respjson.Field + Status respjson.Field + Results respjson.Field Type respjson.Field ExtraFields map[string]respjson.Field raw string @@ -938,138 +970,168 @@ type ResponseObjectOutputMcpApprovalRequest struct { } // Returns the unmodified JSON received from the API -func (r ResponseObjectOutputMcpApprovalRequest) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectOutputMcpApprovalRequest) UnmarshalJSON(data []byte) error { +func (r ResponseObjectOutputFileSearchCall) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectOutputFileSearchCall) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ResponseObjectOutputRole string - -const ( - ResponseObjectOutputRoleSystem ResponseObjectOutputRole = "system" - ResponseObjectOutputRoleDeveloper ResponseObjectOutputRole = "developer" - ResponseObjectOutputRoleUser ResponseObjectOutputRole = "user" - ResponseObjectOutputRoleAssistant ResponseObjectOutputRole = "assistant" -) - -// Text formatting configuration for the response -type ResponseObjectText struct { - // (Optional) Text format configuration specifying output format requirements - Format ResponseObjectTextFormat `json:"format"` +// Search results returned by the file search operation. +type ResponseObjectOutputFileSearchCallResult struct { + Attributes map[string]any `json:"attributes,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Score float64 `json:"score,required"` + Text string `json:"text,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Format respjson.Field + Attributes respjson.Field + FileID respjson.Field + Filename respjson.Field + Score respjson.Field + Text respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectText) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectText) UnmarshalJSON(data []byte) error { +func (r ResponseObjectOutputFileSearchCallResult) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectOutputFileSearchCallResult) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// (Optional) Text format configuration specifying output format requirements -type ResponseObjectTextFormat struct { - // Must be "text", "json_schema", or "json_object" to identify the format type - // - // Any of "text", "json_schema", "json_object". - Type ResponseObjectTextFormatType `json:"type,required"` - // (Optional) A description of the response format. Only used for json_schema. - Description string `json:"description"` - // The name of the response format. Only used for json_schema. - Name string `json:"name"` - // The JSON schema the response should conform to. In a Python SDK, this is often a - // `pydantic` model. Only used for json_schema. - Schema map[string]ResponseObjectTextFormatSchemaUnion `json:"schema"` - // (Optional) Whether to strictly enforce the JSON schema. If true, the response - // must match the schema exactly. Only used for json_schema. - Strict bool `json:"strict"` +// Function tool call output message for OpenAI responses. +type ResponseObjectOutputFunctionCall struct { + Arguments string `json:"arguments,required"` + CallID string `json:"call_id,required"` + Name string `json:"name,required"` + ID string `json:"id,nullable"` + Status string `json:"status,nullable"` + // Any of "function_call". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field - Description respjson.Field + Arguments respjson.Field + CallID respjson.Field Name respjson.Field - Schema respjson.Field - Strict respjson.Field + ID respjson.Field + Status respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectTextFormat) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectTextFormat) UnmarshalJSON(data []byte) error { +func (r ResponseObjectOutputFunctionCall) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectOutputFunctionCall) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Must be "text", "json_schema", or "json_object" to identify the format type -type ResponseObjectTextFormatType string +// Model Context Protocol (MCP) call output message for OpenAI responses. +type ResponseObjectOutputMcpCall struct { + ID string `json:"id,required"` + Arguments string `json:"arguments,required"` + Name string `json:"name,required"` + ServerLabel string `json:"server_label,required"` + Error string `json:"error,nullable"` + Output string `json:"output,nullable"` + // Any of "mcp_call". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Arguments respjson.Field + Name respjson.Field + ServerLabel respjson.Field + Error respjson.Field + Output respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} -const ( - ResponseObjectTextFormatTypeText ResponseObjectTextFormatType = "text" - ResponseObjectTextFormatTypeJsonSchema ResponseObjectTextFormatType = "json_schema" - ResponseObjectTextFormatTypeJsonObject ResponseObjectTextFormatType = "json_object" -) +// Returns the unmodified JSON received from the API +func (r ResponseObjectOutputMcpCall) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectOutputMcpCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} -// ResponseObjectTextFormatSchemaUnion contains all possible properties and values -// from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ResponseObjectTextFormatSchemaUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string +// MCP list tools output message containing available tools from an MCP server. +type ResponseObjectOutputMcpListTools struct { + ID string `json:"id,required"` + ServerLabel string `json:"server_label,required"` + Tools []ResponseObjectOutputMcpListToolsTool `json:"tools,required"` + // Any of "mcp_list_tools". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + ServerLabel respjson.Field + Tools respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } -func (u ResponseObjectTextFormatSchemaUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Returns the unmodified JSON received from the API +func (r ResponseObjectOutputMcpListTools) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectOutputMcpListTools) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ResponseObjectTextFormatSchemaUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Tool definition returned by MCP list tools operation. +type ResponseObjectOutputMcpListToolsTool struct { + InputSchema map[string]any `json:"input_schema,required"` + Name string `json:"name,required"` + Description string `json:"description,nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputSchema respjson.Field + Name respjson.Field + Description respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } -func (u ResponseObjectTextFormatSchemaUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Returns the unmodified JSON received from the API +func (r ResponseObjectOutputMcpListToolsTool) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectOutputMcpListToolsTool) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ResponseObjectTextFormatSchemaUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// A request for human approval of a tool invocation. +type ResponseObjectOutputMcpApprovalRequest struct { + ID string `json:"id,required"` + Arguments string `json:"arguments,required"` + Name string `json:"name,required"` + ServerLabel string `json:"server_label,required"` + // Any of "mcp_approval_request". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Arguments respjson.Field + Name respjson.Field + ServerLabel respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } // Returns the unmodified JSON received from the API -func (u ResponseObjectTextFormatSchemaUnion) RawJSON() string { return u.JSON.raw } - -func (r *ResponseObjectTextFormatSchemaUnion) UnmarshalJSON(data []byte) error { +func (r ResponseObjectOutputMcpApprovalRequest) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectOutputMcpApprovalRequest) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// (Optional) Error details if the response generation failed +// Error details for failed OpenAI response requests. type ResponseObjectError struct { - // Error code identifying the type of failure - Code string `json:"code,required"` - // Human-readable error message describing the failure + Code string `json:"code,required"` Message string `json:"message,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { @@ -1086,16 +1148,17 @@ func (r *ResponseObjectError) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// (Optional) Reference to a prompt template and its variables. +type ResponseObjectObject string + +const ( + ResponseObjectObjectResponse ResponseObjectObject = "response" +) + +// OpenAI compatible Prompt object that is used in OpenAI responses. type ResponseObjectPrompt struct { - // Unique identifier of the prompt template - ID string `json:"id,required"` - // Dictionary of variable names to OpenAIResponseInputMessageContent structure for - // template substitution. The substitution values can either be strings, or other - // Response input types like images or files. - Variables map[string]ResponseObjectPromptVariableUnion `json:"variables"` - // Version number of the prompt to use (defaults to latest if not specified) - Version string `json:"version"` + ID string `json:"id,required"` + Variables map[string]ResponseObjectPromptVariableUnion `json:"variables,nullable"` + Version string `json:"version,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -1127,8 +1190,8 @@ type ResponseObjectPromptVariableUnion struct { // Any of "input_text", "input_image", "input_file". Type string `json:"type"` // This field is from variant [ResponseObjectPromptVariableInputImage]. - Detail ResponseObjectPromptVariableInputImageDetail `json:"detail"` - FileID string `json:"file_id"` + Detail string `json:"detail"` + FileID string `json:"file_id"` // This field is from variant [ResponseObjectPromptVariableInputImage]. ImageURL string `json:"image_url"` // This field is from variant [ResponseObjectPromptVariableInputFile]. @@ -1206,10 +1269,9 @@ func (r *ResponseObjectPromptVariableUnion) UnmarshalJSON(data []byte) error { // Text content for input messages in OpenAI response format. type ResponseObjectPromptVariableInputText struct { - // The text content of the input message Text string `json:"text,required"` - // Content type identifier, always "input_text" - Type constant.InputText `json:"type,required"` + // Any of "input_text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -1227,22 +1289,18 @@ func (r *ResponseObjectPromptVariableInputText) UnmarshalJSON(data []byte) error // Image content for input messages in OpenAI response format. type ResponseObjectPromptVariableInputImage struct { - // Level of detail for image processing, can be "low", "high", or "auto" - // // Any of "low", "high", "auto". - Detail ResponseObjectPromptVariableInputImageDetail `json:"detail,required"` - // Content type identifier, always "input_image" - Type constant.InputImage `json:"type,required"` - // (Optional) The ID of the file to be sent to the model. - FileID string `json:"file_id"` - // (Optional) URL of the image content - ImageURL string `json:"image_url"` + Detail string `json:"detail"` + FileID string `json:"file_id,nullable"` + ImageURL string `json:"image_url,nullable"` + // Any of "input_image". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Detail respjson.Field - Type respjson.Field FileID respjson.Field ImageURL respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -1254,34 +1312,21 @@ func (r *ResponseObjectPromptVariableInputImage) UnmarshalJSON(data []byte) erro return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ResponseObjectPromptVariableInputImageDetail string - -const ( - ResponseObjectPromptVariableInputImageDetailLow ResponseObjectPromptVariableInputImageDetail = "low" - ResponseObjectPromptVariableInputImageDetailHigh ResponseObjectPromptVariableInputImageDetail = "high" - ResponseObjectPromptVariableInputImageDetailAuto ResponseObjectPromptVariableInputImageDetail = "auto" -) - // File content for input messages in OpenAI response format. type ResponseObjectPromptVariableInputFile struct { - // The type of the input item. Always `input_file`. - Type constant.InputFile `json:"type,required"` - // The data of the file to be sent to the model. - FileData string `json:"file_data"` - // (Optional) The ID of the file to be sent to the model. - FileID string `json:"file_id"` - // The URL of the file to be sent to the model. - FileURL string `json:"file_url"` - // The name of the file to be sent to the model. - Filename string `json:"filename"` + FileData string `json:"file_data,nullable"` + FileID string `json:"file_id,nullable"` + FileURL string `json:"file_url,nullable"` + Filename string `json:"filename,nullable"` + // Any of "input_file". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field FileData respjson.Field FileID respjson.Field FileURL respjson.Field Filename respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -1293,32 +1338,67 @@ func (r *ResponseObjectPromptVariableInputFile) UnmarshalJSON(data []byte) error return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ResponseObjectPromptVariableDetail string +// Text response configuration for OpenAI responses. +type ResponseObjectText struct { + // Configuration for Responses API text format. + Format ResponseObjectTextFormat `json:"format,nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Format respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} -const ( - ResponseObjectPromptVariableDetailLow ResponseObjectPromptVariableDetail = "low" - ResponseObjectPromptVariableDetailHigh ResponseObjectPromptVariableDetail = "high" - ResponseObjectPromptVariableDetailAuto ResponseObjectPromptVariableDetail = "auto" -) +// Returns the unmodified JSON received from the API +func (r ResponseObjectText) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectText) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} -// ResponseObjectToolUnion contains all possible properties and values from -// [ResponseObjectToolOpenAIResponseInputToolWebSearch], -// [ResponseObjectToolFileSearch], [ResponseObjectToolFunction], -// [ResponseObjectToolMcp]. -// -// Use the [ResponseObjectToolUnion.AsAny] method to switch on the variant. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -type ResponseObjectToolUnion struct { - // Any of nil, "file_search", "function", "mcp". - Type string `json:"type"` +// Configuration for Responses API text format. +type ResponseObjectTextFormat struct { + Description string `json:"description,nullable"` + Name string `json:"name,nullable"` + Schema map[string]any `json:"schema,nullable"` + Strict bool `json:"strict,nullable"` + // Any of "text", "json_schema", "json_object". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Description respjson.Field + Name respjson.Field + Schema respjson.Field + Strict respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseObjectTextFormat) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectTextFormat) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ResponseObjectToolUnion contains all possible properties and values from +// [ResponseObjectToolOpenAIResponseInputToolWebSearch], +// [ResponseObjectToolFileSearch], [ResponseObjectToolFunction], +// [ResponseObjectToolMcp]. +// +// Use the [ResponseObjectToolUnion.AsAny] method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ResponseObjectToolUnion struct { // This field is from variant [ResponseObjectToolOpenAIResponseInputToolWebSearch]. SearchContextSize string `json:"search_context_size"` + // Any of nil, "file_search", "function", "mcp". + Type string `json:"type"` // This field is from variant [ResponseObjectToolFileSearch]. VectorStoreIDs []string `json:"vector_store_ids"` // This field is from variant [ResponseObjectToolFileSearch]. - Filters map[string]ResponseObjectToolFileSearchFilterUnion `json:"filters"` + Filters map[string]any `json:"filters"` // This field is from variant [ResponseObjectToolFileSearch]. MaxNumResults int64 `json:"max_num_results"` // This field is from variant [ResponseObjectToolFileSearch]. @@ -1326,9 +1406,9 @@ type ResponseObjectToolUnion struct { // This field is from variant [ResponseObjectToolFunction]. Name string `json:"name"` // This field is from variant [ResponseObjectToolFunction]. - Description string `json:"description"` + Parameters map[string]any `json:"parameters"` // This field is from variant [ResponseObjectToolFunction]. - Parameters map[string]ResponseObjectToolFunctionParameterUnion `json:"parameters"` + Description string `json:"description"` // This field is from variant [ResponseObjectToolFunction]. Strict bool `json:"strict"` // This field is from variant [ResponseObjectToolMcp]. @@ -1336,15 +1416,15 @@ type ResponseObjectToolUnion struct { // This field is from variant [ResponseObjectToolMcp]. AllowedTools ResponseObjectToolMcpAllowedToolsUnion `json:"allowed_tools"` JSON struct { - Type respjson.Field SearchContextSize respjson.Field + Type respjson.Field VectorStoreIDs respjson.Field Filters respjson.Field MaxNumResults respjson.Field RankingOptions respjson.Field Name respjson.Field - Description respjson.Field Parameters respjson.Field + Description respjson.Field Strict respjson.Field ServerLabel respjson.Field AllowedTools respjson.Field @@ -1381,17 +1461,14 @@ func (r *ResponseObjectToolUnion) UnmarshalJSON(data []byte) error { // Web search tool configuration for OpenAI response inputs. type ResponseObjectToolOpenAIResponseInputToolWebSearch struct { - // Web search tool type variant to use - // + SearchContextSize string `json:"search_context_size,nullable"` // Any of "web_search", "web_search_preview", "web_search_preview_2025_03_11", // "web_search_2025_08_26". - Type ResponseObjectToolOpenAIResponseInputToolWebSearchType `json:"type,required"` - // (Optional) Size of search context, must be "low", "medium", or "high" - SearchContextSize string `json:"search_context_size"` + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field SearchContextSize respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -1403,35 +1480,22 @@ func (r *ResponseObjectToolOpenAIResponseInputToolWebSearch) UnmarshalJSON(data return apijson.UnmarshalRoot(data, r) } -// Web search tool type variant to use -type ResponseObjectToolOpenAIResponseInputToolWebSearchType string - -const ( - ResponseObjectToolOpenAIResponseInputToolWebSearchTypeWebSearch ResponseObjectToolOpenAIResponseInputToolWebSearchType = "web_search" - ResponseObjectToolOpenAIResponseInputToolWebSearchTypeWebSearchPreview ResponseObjectToolOpenAIResponseInputToolWebSearchType = "web_search_preview" - ResponseObjectToolOpenAIResponseInputToolWebSearchTypeWebSearchPreview2025_03_11 ResponseObjectToolOpenAIResponseInputToolWebSearchType = "web_search_preview_2025_03_11" - ResponseObjectToolOpenAIResponseInputToolWebSearchTypeWebSearch2025_08_26 ResponseObjectToolOpenAIResponseInputToolWebSearchType = "web_search_2025_08_26" -) - // File search tool configuration for OpenAI response inputs. type ResponseObjectToolFileSearch struct { - // Tool type identifier, always "file_search" - Type constant.FileSearch `json:"type,required"` - // List of vector store identifiers to search within - VectorStoreIDs []string `json:"vector_store_ids,required"` - // (Optional) Additional filters to apply to the search - Filters map[string]ResponseObjectToolFileSearchFilterUnion `json:"filters"` - // (Optional) Maximum number of search results to return (1-50) - MaxNumResults int64 `json:"max_num_results"` - // (Optional) Options for ranking and scoring search results - RankingOptions ResponseObjectToolFileSearchRankingOptions `json:"ranking_options"` + VectorStoreIDs []string `json:"vector_store_ids,required"` + Filters map[string]any `json:"filters,nullable"` + MaxNumResults int64 `json:"max_num_results,nullable"` + // Options for ranking and filtering search results. + RankingOptions ResponseObjectToolFileSearchRankingOptions `json:"ranking_options,nullable"` + // Any of "file_search". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field VectorStoreIDs respjson.Field Filters respjson.Field MaxNumResults respjson.Field RankingOptions respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -1443,64 +1507,10 @@ func (r *ResponseObjectToolFileSearch) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseObjectToolFileSearchFilterUnion contains all possible properties and -// values from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ResponseObjectToolFileSearchFilterUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ResponseObjectToolFileSearchFilterUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectToolFileSearchFilterUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectToolFileSearchFilterUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectToolFileSearchFilterUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ResponseObjectToolFileSearchFilterUnion) RawJSON() string { return u.JSON.raw } - -func (r *ResponseObjectToolFileSearchFilterUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// (Optional) Options for ranking and scoring search results +// Options for ranking and filtering search results. type ResponseObjectToolFileSearchRankingOptions struct { - // (Optional) Name of the ranking algorithm to use - Ranker string `json:"ranker"` - // (Optional) Minimum relevance score threshold for results - ScoreThreshold float64 `json:"score_threshold"` + Ranker string `json:"ranker,nullable"` + ScoreThreshold float64 `json:"score_threshold,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Ranker respjson.Field @@ -1518,23 +1528,19 @@ func (r *ResponseObjectToolFileSearchRankingOptions) UnmarshalJSON(data []byte) // Function tool configuration for OpenAI response inputs. type ResponseObjectToolFunction struct { - // Name of the function that can be called - Name string `json:"name,required"` - // Tool type identifier, always "function" - Type constant.Function `json:"type,required"` - // (Optional) Description of what the function does - Description string `json:"description"` - // (Optional) JSON schema defining the function's parameters - Parameters map[string]ResponseObjectToolFunctionParameterUnion `json:"parameters"` - // (Optional) Whether to enforce strict parameter validation - Strict bool `json:"strict"` + Name string `json:"name,required"` + Parameters map[string]any `json:"parameters,required"` + Description string `json:"description,nullable"` + Strict bool `json:"strict,nullable"` + // Any of "function". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Name respjson.Field - Type respjson.Field - Description respjson.Field Parameters respjson.Field + Description respjson.Field Strict respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -1546,71 +1552,18 @@ func (r *ResponseObjectToolFunction) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseObjectToolFunctionParameterUnion contains all possible properties and -// values from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ResponseObjectToolFunctionParameterUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ResponseObjectToolFunctionParameterUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectToolFunctionParameterUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectToolFunctionParameterUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectToolFunctionParameterUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ResponseObjectToolFunctionParameterUnion) RawJSON() string { return u.JSON.raw } - -func (r *ResponseObjectToolFunctionParameterUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - // Model Context Protocol (MCP) tool configuration for OpenAI response object. type ResponseObjectToolMcp struct { - // Label to identify this MCP server ServerLabel string `json:"server_label,required"` - // Tool type identifier, always "mcp" - Type constant.Mcp `json:"type,required"` - // (Optional) Restriction on which tools can be used from this server - AllowedTools ResponseObjectToolMcpAllowedToolsUnion `json:"allowed_tools"` + // Filter configuration for restricting which MCP tools can be used. + AllowedTools ResponseObjectToolMcpAllowedToolsUnion `json:"allowed_tools,nullable"` + // Any of "mcp". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ServerLabel respjson.Field - Type respjson.Field AllowedTools respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -1628,21 +1581,21 @@ func (r *ResponseObjectToolMcp) UnmarshalJSON(data []byte) error { // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfStringArray] +// will be valid: OfListString] type ResponseObjectToolMcpAllowedToolsUnion struct { // This field will be present if the value is a [[]string] instead of an object. - OfStringArray []string `json:",inline"` + OfListString []string `json:",inline"` // This field is from variant // [ResponseObjectToolMcpAllowedToolsAllowedToolsFilter]. ToolNames []string `json:"tool_names"` JSON struct { - OfStringArray respjson.Field - ToolNames respjson.Field - raw string + OfListString respjson.Field + ToolNames respjson.Field + raw string } `json:"-"` } -func (u ResponseObjectToolMcpAllowedToolsUnion) AsStringArray() (v []string) { +func (u ResponseObjectToolMcpAllowedToolsUnion) AsListString() (v []string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -1661,8 +1614,7 @@ func (r *ResponseObjectToolMcpAllowedToolsUnion) UnmarshalJSON(data []byte) erro // Filter configuration for restricting which MCP tools can be used. type ResponseObjectToolMcpAllowedToolsAllowedToolsFilter struct { - // (Optional) List of specific tool names that are allowed - ToolNames []string `json:"tool_names"` + ToolNames []string `json:"tool_names,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ToolNames respjson.Field @@ -1677,31 +1629,15 @@ func (r *ResponseObjectToolMcpAllowedToolsAllowedToolsFilter) UnmarshalJSON(data return apijson.UnmarshalRoot(data, r) } -// Web search tool type variant to use -type ResponseObjectToolType string - -const ( - ResponseObjectToolTypeWebSearch ResponseObjectToolType = "web_search" - ResponseObjectToolTypeWebSearchPreview ResponseObjectToolType = "web_search_preview" - ResponseObjectToolTypeWebSearchPreview2025_03_11 ResponseObjectToolType = "web_search_preview_2025_03_11" - ResponseObjectToolTypeWebSearch2025_08_26 ResponseObjectToolType = "web_search_2025_08_26" - ResponseObjectToolTypeFileSearch ResponseObjectToolType = "file_search" - ResponseObjectToolTypeFunction ResponseObjectToolType = "function" - ResponseObjectToolTypeMcp ResponseObjectToolType = "mcp" -) - -// (Optional) Token usage information for the response +// Usage information for OpenAI response. type ResponseObjectUsage struct { - // Number of tokens in the input - InputTokens int64 `json:"input_tokens,required"` - // Number of tokens in the output + InputTokens int64 `json:"input_tokens,required"` OutputTokens int64 `json:"output_tokens,required"` - // Total tokens used (input + output) - TotalTokens int64 `json:"total_tokens,required"` - // Detailed breakdown of input token usage - InputTokensDetails ResponseObjectUsageInputTokensDetails `json:"input_tokens_details"` - // Detailed breakdown of output token usage - OutputTokensDetails ResponseObjectUsageOutputTokensDetails `json:"output_tokens_details"` + TotalTokens int64 `json:"total_tokens,required"` + // Token details for input tokens in OpenAI response usage. + InputTokensDetails ResponseObjectUsageInputTokensDetails `json:"input_tokens_details,nullable"` + // Token details for output tokens in OpenAI response usage. + OutputTokensDetails ResponseObjectUsageOutputTokensDetails `json:"output_tokens_details,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { InputTokens respjson.Field @@ -1720,10 +1656,9 @@ func (r *ResponseObjectUsage) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Detailed breakdown of input token usage +// Token details for input tokens in OpenAI response usage. type ResponseObjectUsageInputTokensDetails struct { - // Number of tokens retrieved from cache - CachedTokens int64 `json:"cached_tokens"` + CachedTokens int64 `json:"cached_tokens,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { CachedTokens respjson.Field @@ -1738,10 +1673,9 @@ func (r *ResponseObjectUsageInputTokensDetails) UnmarshalJSON(data []byte) error return apijson.UnmarshalRoot(data, r) } -// Detailed breakdown of output token usage +// Token details for output tokens in OpenAI response usage. type ResponseObjectUsageOutputTokensDetails struct { - // Number of tokens used for reasoning (o1/o3 models) - ReasoningTokens int64 `json:"reasoning_tokens"` + ReasoningTokens int64 `json:"reasoning_tokens,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ReasoningTokens respjson.Field @@ -2227,9 +2161,9 @@ type ResponseObjectStreamUnionItem struct { // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion] Content ResponseObjectStreamUnionItemContent `json:"content"` Role string `json:"role"` - Type string `json:"type"` ID string `json:"id"` Status string `json:"status"` + Type string `json:"type"` Queries []string `json:"queries"` // This field is a union of // [[]ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult], @@ -2248,9 +2182,9 @@ type ResponseObjectStreamUnionItem struct { JSON struct { Content respjson.Field Role respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field Queries respjson.Field Results respjson.Field Arguments respjson.Field @@ -2276,18 +2210,25 @@ func (r *ResponseObjectStreamUnionItem) UnmarshalJSON(data []byte) error { // [ResponseObjectStreamUnion]. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString OfVariant2] +// will be valid: OfString +// OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile +// OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal] type ResponseObjectStreamUnionItemContent struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion] + // [[]ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion] + // instead of an object. + OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile []ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion `json:",inline"` + // This field will be present if the value is a + // [[]ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion] // instead of an object. - OfVariant2 []ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion `json:",inline"` - JSON struct { - OfString respjson.Field - OfVariant2 respjson.Field - raw string + OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal []ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile respjson.Field + OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal respjson.Field + raw string } `json:"-"` } @@ -2334,22 +2275,15 @@ func (r *ResponseObjectStreamUnionItemResults) UnmarshalJSON(data []byte) error // [ResponseObjectStreamUnion]. // // If the underlying value is not a json object, one of the following properties -// will be valid: -// OfResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTools -// OfResponseObjectStreamResponseOutputItemDoneItemMcpListToolsTools] +// will be valid: OfTools] type ResponseObjectStreamUnionItemTools struct { // This field will be present if the value is a // [[]ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTool] instead of // an object. - OfResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTools []ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTool `json:",inline"` - // This field will be present if the value is a - // [[]ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsTool] instead of an - // object. - OfResponseObjectStreamResponseOutputItemDoneItemMcpListToolsTools []ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsTool `json:",inline"` - JSON struct { - OfResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTools respjson.Field - OfResponseObjectStreamResponseOutputItemDoneItemMcpListToolsTools respjson.Field - raw string + OfTools []ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTool `json:",inline"` + JSON struct { + OfTools respjson.Field + raw string } `json:"-"` } @@ -2364,22 +2298,19 @@ func (r *ResponseObjectStreamUnionItemTools) UnmarshalJSON(data []byte) error { // For type safety it is recommended to directly use a variant of the // [ResponseObjectStreamUnion]. type ResponseObjectStreamUnionPart struct { + Text string `json:"text"` // This field is a union of // [[]ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion], // [[]ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion] Annotations ResponseObjectStreamUnionPartAnnotations `json:"annotations"` - Text string `json:"text"` + Logprobs []map[string]any `json:"logprobs"` Type string `json:"type"` - // This field is a union of - // [[]map[string]ResponseObjectStreamResponseContentPartAddedPartOutputTextLogprobUnion], - // [[]map[string]ResponseObjectStreamResponseContentPartDonePartOutputTextLogprobUnion] - Logprobs ResponseObjectStreamUnionPartLogprobs `json:"logprobs"` - Refusal string `json:"refusal"` - JSON struct { - Annotations respjson.Field + Refusal string `json:"refusal"` + JSON struct { Text respjson.Field - Type respjson.Field + Annotations respjson.Field Logprobs respjson.Field + Type respjson.Field Refusal respjson.Field raw string } `json:"-"` @@ -2397,22 +2328,15 @@ func (r *ResponseObjectStreamUnionPart) UnmarshalJSON(data []byte) error { // [ResponseObjectStreamUnion]. // // If the underlying value is not a json object, one of the following properties -// will be valid: -// OfResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotations -// OfResponseObjectStreamResponseContentPartDonePartOutputTextAnnotations] +// will be valid: OfAnnotations] type ResponseObjectStreamUnionPartAnnotations struct { // This field will be present if the value is a // [[]ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion] // instead of an object. - OfResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotations []ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion `json:",inline"` - // This field will be present if the value is a - // [[]ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion] - // instead of an object. - OfResponseObjectStreamResponseContentPartDonePartOutputTextAnnotations []ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion `json:",inline"` - JSON struct { - OfResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotations respjson.Field - OfResponseObjectStreamResponseContentPartDonePartOutputTextAnnotations respjson.Field - raw string + OfAnnotations []ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion `json:",inline"` + JSON struct { + OfAnnotations respjson.Field + raw string } `json:"-"` } @@ -2420,43 +2344,12 @@ func (r *ResponseObjectStreamUnionPartAnnotations) UnmarshalJSON(data []byte) er return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamUnionPartLogprobs is an implicit subunion of -// [ResponseObjectStreamUnion]. ResponseObjectStreamUnionPartLogprobs provides -// convenient access to the sub-properties of the union. -// -// For type safety it is recommended to directly use a variant of the -// [ResponseObjectStreamUnion]. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: -// OfMapOfResponseObjectStreamResponseContentPartAddedPartOutputTextLogprobMap -// OfMapOfResponseObjectStreamResponseContentPartDonePartOutputTextLogprobMap] -type ResponseObjectStreamUnionPartLogprobs struct { - // This field will be present if the value is a - // [[]map[string]ResponseObjectStreamResponseContentPartAddedPartOutputTextLogprobUnion] - // instead of an object. - OfMapOfResponseObjectStreamResponseContentPartAddedPartOutputTextLogprobMap []map[string]ResponseObjectStreamResponseContentPartAddedPartOutputTextLogprobUnion `json:",inline"` - // This field will be present if the value is a - // [[]map[string]ResponseObjectStreamResponseContentPartDonePartOutputTextLogprobUnion] - // instead of an object. - OfMapOfResponseObjectStreamResponseContentPartDonePartOutputTextLogprobMap []map[string]ResponseObjectStreamResponseContentPartDonePartOutputTextLogprobUnion `json:",inline"` - JSON struct { - OfMapOfResponseObjectStreamResponseContentPartAddedPartOutputTextLogprobMap respjson.Field - OfMapOfResponseObjectStreamResponseContentPartDonePartOutputTextLogprobMap respjson.Field - raw string - } `json:"-"` -} - -func (r *ResponseObjectStreamUnionPartLogprobs) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - // Streaming event indicating a new response has been created. type ResponseObjectStreamResponseCreated struct { - // The response object that was created + // Complete OpenAI response object containing generation results and metadata. Response ResponseObject `json:"response,required"` - // Event type identifier, always "response.created" - Type constant.ResponseCreated `json:"type,required"` + // Any of "response.created". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Response respjson.Field @@ -2474,12 +2367,11 @@ func (r *ResponseObjectStreamResponseCreated) UnmarshalJSON(data []byte) error { // Streaming event indicating the response remains in progress. type ResponseObjectStreamResponseInProgress struct { - // Current response state while in progress - Response ResponseObject `json:"response,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Event type identifier, always "response.in_progress" - Type constant.ResponseInProgress `json:"type,required"` + // Complete OpenAI response object containing generation results and metadata. + Response ResponseObject `json:"response,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.in_progress". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Response respjson.Field @@ -2498,16 +2390,15 @@ func (r *ResponseObjectStreamResponseInProgress) UnmarshalJSON(data []byte) erro // Streaming event for when a new output item is added to the response. type ResponseObjectStreamResponseOutputItemAdded struct { - // The output item that was added (message, tool call, etc.) - Item ResponseObjectStreamResponseOutputItemAddedItemUnion `json:"item,required"` - // Index position of this item in the output list - OutputIndex int64 `json:"output_index,required"` - // Unique identifier of the response containing this output - ResponseID string `json:"response_id,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Event type identifier, always "response.output_item.added" - Type constant.ResponseOutputItemAdded `json:"type,required"` + // Corresponds to the various Message types in the Responses API. They are all + // under one type because the Responses API gives them all the same "type" value, + // and there is no way to tell them apart in certain scenarios. + Item ResponseObjectStreamResponseOutputItemAddedItemUnion `json:"item,required"` + OutputIndex int64 `json:"output_index,required"` + ResponseID string `json:"response_id,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.output_item.added". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Item respjson.Field @@ -2546,12 +2437,12 @@ type ResponseObjectStreamResponseOutputItemAddedItemUnion struct { Content ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion `json:"content"` // This field is from variant // [ResponseObjectStreamResponseOutputItemAddedItemMessage]. - Role ResponseObjectStreamResponseOutputItemAddedItemMessageRole `json:"role"` - // Any of "message", "web_search_call", "file_search_call", "function_call", - // "mcp_call", "mcp_list_tools", "mcp_approval_request". - Type string `json:"type"` + Role string `json:"role"` ID string `json:"id"` Status string `json:"status"` + // Any of "message", "web_search_call", "file_search_call", "function_call", + // "mcp_call", "mcp_list_tools", "mcp_approval_request". + Type string `json:"type"` // This field is from variant // [ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall]. Queries []string `json:"queries"` @@ -2576,9 +2467,9 @@ type ResponseObjectStreamResponseOutputItemAddedItemUnion struct { JSON struct { Content respjson.Field Role respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field Queries respjson.Field Results respjson.Field Arguments respjson.Field @@ -2696,17 +2587,18 @@ func (r *ResponseObjectStreamResponseOutputItemAddedItemUnion) UnmarshalJSON(dat type ResponseObjectStreamResponseOutputItemAddedItemMessage struct { Content ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion `json:"content,required"` // Any of "system", "developer", "user", "assistant". - Role ResponseObjectStreamResponseOutputItemAddedItemMessageRole `json:"role,required"` - Type constant.Message `json:"type,required"` - ID string `json:"id"` - Status string `json:"status"` + Role string `json:"role,required"` + ID string `json:"id,nullable"` + Status string `json:"status,nullable"` + // Any of "message". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field Role respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -2720,24 +2612,31 @@ func (r *ResponseObjectStreamResponseOutputItemAddedItemMessage) UnmarshalJSON(d // ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion contains all // possible properties and values from [string], -// [[]ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion], -// [[]ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion]. +// [[]ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion], +// [[]ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString OfVariant2] +// will be valid: OfString +// OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile +// OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal] type ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion] + // [[]ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion] + // instead of an object. + OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile []ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion `json:",inline"` + // This field will be present if the value is a + // [[]ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion] // instead of an object. - OfVariant2 []ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion `json:",inline"` - JSON struct { - OfString respjson.Field - OfVariant2 respjson.Field - raw string + OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal []ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile respjson.Field + OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal respjson.Field + raw string } `json:"-"` } @@ -2746,12 +2645,12 @@ func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion) AsSt return } -func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion) AsResponseObjectStreamResponseOutputItemAddedItemMessageContentArray() (v []ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion) { +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion) AsListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile() (v []ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion) AsVariant2() (v []ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion) { +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion) AsListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal() (v []ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -2765,38 +2664,38 @@ func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion) Unm return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion +// ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion // contains all possible properties and values from -// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputText], -// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage], -// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputFile]. +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText], +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage], +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. // // Use the -// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion.AsAny] +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny] // method to switch on the variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion struct { +type ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion struct { // This field is from variant - // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputText]. + // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText]. Text string `json:"text"` // Any of "input_text", "input_image", "input_file". Type string `json:"type"` // This field is from variant - // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage]. - Detail ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImageDetail `json:"detail"` - FileID string `json:"file_id"` + // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]. + Detail string `json:"detail"` + FileID string `json:"file_id"` // This field is from variant - // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage]. + // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]. ImageURL string `json:"image_url"` // This field is from variant - // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputFile]. + // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. FileData string `json:"file_data"` // This field is from variant - // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputFile]. + // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. FileURL string `json:"file_url"` // This field is from variant - // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputFile]. + // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. Filename string `json:"filename"` JSON struct { Text respjson.Field @@ -2811,32 +2710,32 @@ type ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion } `json:"-"` } -// anyResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItem is -// implemented by each variant of -// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion] to -// add type safety for the return type of -// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion.AsAny] -type anyResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItem interface { - implResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion() +// anyResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem +// is implemented by each variant of +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion] +// to add type safety for the return type of +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny] +type anyResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem interface { + implResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() } -func (ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputText) implResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion() { +func (ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) implResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { } -func (ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage) implResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion() { +func (ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) implResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { } -func (ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputFile) implResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion() { +func (ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) implResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { } // Use the following switch statement to find the correct variant // -// switch variant := ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion.AsAny().(type) { -// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputText: -// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage: -// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputFile: +// switch variant := ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny().(type) { +// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText: +// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage: +// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile: // default: // fmt.Errorf("no variant present") // } -func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion) AsAny() anyResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItem { +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsAny() anyResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem { switch u.Type { case "input_text": return u.AsInputText() @@ -2848,36 +2747,35 @@ func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUn return nil } -func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion) AsInputText() (v ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputText) { +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputText() (v ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion) AsInputImage() (v ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage) { +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputImage() (v ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion) AsInputFile() (v ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputFile) { +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputFile() (v ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion) RawJSON() string { +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) RawJSON() string { return u.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content for input messages in OpenAI response format. -type ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputText struct { - // The text content of the input message +type ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText struct { Text string `json:"text,required"` - // Content type identifier, always "input_text" - Type constant.InputText `json:"type,required"` + // Any of "input_text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -2888,334 +2786,356 @@ type ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInput } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputText) RawJSON() string { +func (r ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputText) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Image content for input messages in OpenAI response format. -type ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage struct { - // Level of detail for image processing, can be "low", "high", or "auto" - // +type ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage struct { // Any of "low", "high", "auto". - Detail ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImageDetail `json:"detail,required"` - // Content type identifier, always "input_image" - Type constant.InputImage `json:"type,required"` - // (Optional) The ID of the file to be sent to the model. - FileID string `json:"file_id"` - // (Optional) URL of the image content - ImageURL string `json:"image_url"` + Detail string `json:"detail"` + FileID string `json:"file_id,nullable"` + ImageURL string `json:"image_url,nullable"` + // Any of "input_image". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Detail respjson.Field - Type respjson.Field FileID respjson.Field ImageURL respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage) RawJSON() string { +func (r ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImageDetail string - -const ( - ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImageDetailLow ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImageDetail = "low" - ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImageDetailHigh ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImageDetail = "high" - ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImageDetailAuto ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImageDetail = "auto" -) - // File content for input messages in OpenAI response format. -type ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputFile struct { - // The type of the input item. Always `input_file`. - Type constant.InputFile `json:"type,required"` - // The data of the file to be sent to the model. - FileData string `json:"file_data"` - // (Optional) The ID of the file to be sent to the model. - FileID string `json:"file_id"` - // The URL of the file to be sent to the model. - FileURL string `json:"file_url"` - // The name of the file to be sent to the model. - Filename string `json:"filename"` +type ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile struct { + FileData string `json:"file_data,nullable"` + FileID string `json:"file_id,nullable"` + FileURL string `json:"file_url,nullable"` + Filename string `json:"filename,nullable"` + // Any of "input_file". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field FileData respjson.Field FileID respjson.Field FileURL respjson.Field Filename respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputFile) RawJSON() string { +func (r ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputFile) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemDetail string - -const ( - ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemDetailLow ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemDetail = "low" - ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemDetailHigh ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemDetail = "high" - ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemDetailAuto ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemDetail = "auto" -) - -type ResponseObjectStreamResponseOutputItemAddedItemMessageRole string - -const ( - ResponseObjectStreamResponseOutputItemAddedItemMessageRoleSystem ResponseObjectStreamResponseOutputItemAddedItemMessageRole = "system" - ResponseObjectStreamResponseOutputItemAddedItemMessageRoleDeveloper ResponseObjectStreamResponseOutputItemAddedItemMessageRole = "developer" - ResponseObjectStreamResponseOutputItemAddedItemMessageRoleUser ResponseObjectStreamResponseOutputItemAddedItemMessageRole = "user" - ResponseObjectStreamResponseOutputItemAddedItemMessageRoleAssistant ResponseObjectStreamResponseOutputItemAddedItemMessageRole = "assistant" -) - -// Web search tool call output message for OpenAI responses. -type ResponseObjectStreamResponseOutputItemAddedItemWebSearchCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // Current status of the web search operation - Status string `json:"status,required"` - // Tool call type identifier, always "web_search_call" - Type constant.WebSearchCall `json:"type,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - ID respjson.Field - Status respjson.Field +// ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion +// contains all possible properties and values from +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText], +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]. +// +// Use the +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny] +// method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion struct { + // This field is from variant + // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]. + Text string `json:"text"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]. + Annotations []ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion `json:"annotations"` + // Any of "output_text", "refusal". + Type string `json:"type"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]. + Refusal string `json:"refusal"` + JSON struct { + Text respjson.Field + Annotations respjson.Field Type respjson.Field - ExtraFields map[string]respjson.Field + Refusal respjson.Field raw string } `json:"-"` } -// Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemAddedItemWebSearchCall) RawJSON() string { - return r.JSON.raw +// anyResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem +// is implemented by each variant of +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion] +// to add type safety for the return type of +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny] +type anyResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem interface { + implResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() } -func (r *ResponseObjectStreamResponseOutputItemAddedItemWebSearchCall) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) + +func (ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) implResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() { +} +func (ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) implResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() { } -// File search tool call output message for OpenAI responses. -type ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // List of search queries executed - Queries []string `json:"queries,required"` - // Current status of the file search operation - Status string `json:"status,required"` - // Tool call type identifier, always "file_search_call" - Type constant.FileSearchCall `json:"type,required"` - // (Optional) Search results returned by the file search operation - Results []ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult `json:"results"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - ID respjson.Field - Queries respjson.Field - Status respjson.Field - Type respjson.Field - Results respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` +// Use the following switch statement to find the correct variant +// +// switch variant := ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny().(type) { +// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText: +// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal: +// default: +// fmt.Errorf("no variant present") +// } +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsAny() anyResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem { + switch u.Type { + case "output_text": + return u.AsOutputText() + case "refusal": + return u.AsRefusal() + } + return nil +} + +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsOutputText() (v ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsRefusal() (v ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall) RawJSON() string { - return r.JSON.raw +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) RawJSON() string { + return u.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall) UnmarshalJSON(data []byte) error { + +func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Search results returned by the file search operation. -type ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult struct { - // (Optional) Key-value attributes associated with the file - Attributes map[string]ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion `json:"attributes,required"` - // Unique identifier of the file containing the result - FileID string `json:"file_id,required"` - // Name of the file containing the result - Filename string `json:"filename,required"` - // Relevance score for this search result (between 0 and 1) - Score float64 `json:"score,required"` - // Text content of the search result - Text string `json:"text,required"` +type ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText struct { + Text string `json:"text,required"` + Annotations []ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion `json:"annotations"` + // Any of "output_text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Attributes respjson.Field - FileID respjson.Field - Filename respjson.Field - Score respjson.Field Text respjson.Field + Annotations respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult) RawJSON() string { +func (r ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion -// contains all possible properties and values from [bool], [float64], [string], -// [[]any]. +// ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion +// contains all possible properties and values from +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation], +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation], +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation], +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath]. // -// Use the methods beginning with 'As' to cast the union to one of its variants. +// Use the +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny] +// method to switch on the variant. // -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion struct { + FileID string `json:"file_id"` + Filename string `json:"filename"` + Index int64 `json:"index"` + // Any of "file_citation", "url_citation", "container_file_citation", "file_path". + Type string `json:"type"` + EndIndex int64 `json:"end_index"` + StartIndex int64 `json:"start_index"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]. + Title string `json:"title"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]. + URL string `json:"url"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation]. + ContainerID string `json:"container_id"` + JSON struct { + FileID respjson.Field + Filename respjson.Field + Index respjson.Field + Type respjson.Field + EndIndex respjson.Field + StartIndex respjson.Field + Title respjson.Field + URL respjson.Field + ContainerID respjson.Field + raw string } `json:"-"` } -func (u ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion) AsBool() (v bool) { +// anyResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation +// is implemented by each variant of +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion] +// to add type safety for the return type of +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny] +type anyResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation interface { + implResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() +} + +func (ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) implResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} +func (ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) implResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} +func (ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) implResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} +func (ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) implResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny().(type) { +// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation: +// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation: +// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation: +// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath: +// default: +// fmt.Errorf("no variant present") +// } +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsAny() anyResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation { + switch u.Type { + case "file_citation": + return u.AsFileCitation() + case "url_citation": + return u.AsURLCitation() + case "container_file_citation": + return u.AsContainerFileCitation() + case "file_path": + return u.AsFilePath() + } + return nil +} + +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsFileCitation() (v ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion) AsFloat() (v float64) { +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsURLCitation() (v ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion) AsString() (v string) { +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsContainerFileCitation() (v ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion) AsAnyArray() (v []any) { +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsFilePath() (v ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion) RawJSON() string { +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) RawJSON() string { return u.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Function tool call output message for OpenAI responses. -type ResponseObjectStreamResponseOutputItemAddedItemFunctionCall struct { - // JSON string containing the function arguments - Arguments string `json:"arguments,required"` - // Unique identifier for the function call - CallID string `json:"call_id,required"` - // Name of the function being called - Name string `json:"name,required"` - // Tool call type identifier, always "function_call" - Type constant.FunctionCall `json:"type,required"` - // (Optional) Additional identifier for the tool call - ID string `json:"id"` - // (Optional) Current status of the function call execution - Status string `json:"status"` +// File citation annotation for referencing specific files in response content. +type ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation struct { + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Index int64 `json:"index,required"` + // Any of "file_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Arguments respjson.Field - CallID respjson.Field - Name respjson.Field + FileID respjson.Field + Filename respjson.Field + Index respjson.Field Type respjson.Field - ID respjson.Field - Status respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemAddedItemFunctionCall) RawJSON() string { +func (r ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemFunctionCall) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Model Context Protocol (MCP) call output message for OpenAI responses. -type ResponseObjectStreamResponseOutputItemAddedItemMcpCall struct { - // Unique identifier for this MCP call - ID string `json:"id,required"` - // JSON string containing the MCP call arguments - Arguments string `json:"arguments,required"` - // Name of the MCP method being called - Name string `json:"name,required"` - // Label identifying the MCP server handling the call - ServerLabel string `json:"server_label,required"` - // Tool call type identifier, always "mcp_call" - Type constant.McpCall `json:"type,required"` - // (Optional) Error message if the MCP call failed - Error string `json:"error"` - // (Optional) Output result from the successful MCP call - Output string `json:"output"` +// URL citation annotation for referencing external web resources. +type ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation struct { + EndIndex int64 `json:"end_index,required"` + StartIndex int64 `json:"start_index,required"` + Title string `json:"title,required"` + URL string `json:"url,required"` + // Any of "url_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - ID respjson.Field - Arguments respjson.Field - Name respjson.Field - ServerLabel respjson.Field + EndIndex respjson.Field + StartIndex respjson.Field + Title respjson.Field + URL respjson.Field Type respjson.Field - Error respjson.Field - Output respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemAddedItemMcpCall) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemMcpCall) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// MCP list tools output message containing available tools from an MCP server. -type ResponseObjectStreamResponseOutputItemAddedItemMcpListTools struct { - // Unique identifier for this MCP list tools operation - ID string `json:"id,required"` - // Label identifying the MCP server providing the tools - ServerLabel string `json:"server_label,required"` - // List of available tools provided by the MCP server - Tools []ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTool `json:"tools,required"` - // Tool call type identifier, always "mcp_list_tools" - Type constant.McpListTools `json:"type,required"` +type ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation struct { + ContainerID string `json:"container_id,required"` + EndIndex int64 `json:"end_index,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + StartIndex int64 `json:"start_index,required"` + // Any of "container_file_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - ID respjson.Field - ServerLabel respjson.Field - Tools respjson.Field + ContainerID respjson.Field + EndIndex respjson.Field + FileID respjson.Field + Filename respjson.Field + StartIndex respjson.Field Type respjson.Field ExtraFields map[string]respjson.Field raw string @@ -3223,107 +3143,96 @@ type ResponseObjectStreamResponseOutputItemAddedItemMcpListTools struct { } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemAddedItemMcpListTools) RawJSON() string { +func (r ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemMcpListTools) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Tool definition returned by MCP list tools operation. -type ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTool struct { - // JSON schema defining the tool's input parameters - InputSchema map[string]ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSchemaUnion `json:"input_schema,required"` - // Name of the tool - Name string `json:"name,required"` - // (Optional) Description of what the tool does - Description string `json:"description"` +type ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath struct { + FileID string `json:"file_id,required"` + Index int64 `json:"index,required"` + // Any of "file_path". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - InputSchema respjson.Field - Name respjson.Field - Description respjson.Field + FileID respjson.Field + Index respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTool) RawJSON() string { +func (r ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTool) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSchemaUnion -// contains all possible properties and values from [bool], [float64], [string], -// [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSchemaUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string +// Refusal content within a streamed response part. +type ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal struct { + Refusal string `json:"refusal,required"` + // Any of "refusal". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Refusal respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } -func (u ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSchemaUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSchemaUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) RawJSON() string { + return r.JSON.raw } - -func (u ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSchemaUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSchemaUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Web search tool call output message for OpenAI responses. +type ResponseObjectStreamResponseOutputItemAddedItemWebSearchCall struct { + ID string `json:"id,required"` + Status string `json:"status,required"` + // Any of "web_search_call". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Status respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } // Returns the unmodified JSON received from the API -func (u ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSchemaUnion) RawJSON() string { - return u.JSON.raw +func (r ResponseObjectStreamResponseOutputItemAddedItemWebSearchCall) RawJSON() string { + return r.JSON.raw } - -func (r *ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSchemaUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemAddedItemWebSearchCall) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// A request for human approval of a tool invocation. -type ResponseObjectStreamResponseOutputItemAddedItemMcpApprovalRequest struct { - ID string `json:"id,required"` - Arguments string `json:"arguments,required"` - Name string `json:"name,required"` - ServerLabel string `json:"server_label,required"` - Type constant.McpApprovalRequest `json:"type,required"` +// File search tool call output message for OpenAI responses. +type ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall struct { + ID string `json:"id,required"` + Queries []string `json:"queries,required"` + Status string `json:"status,required"` + Results []ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult `json:"results,nullable"` + // Any of "file_search_call". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field - Arguments respjson.Field - Name respjson.Field - ServerLabel respjson.Field + Queries respjson.Field + Status respjson.Field + Results respjson.Field Type respjson.Field ExtraFields map[string]respjson.Field raw string @@ -3331,51 +3240,205 @@ type ResponseObjectStreamResponseOutputItemAddedItemMcpApprovalRequest struct { } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemAddedItemMcpApprovalRequest) RawJSON() string { +func (r ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemMcpApprovalRequest) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ResponseObjectStreamResponseOutputItemAddedItemRole string - -const ( - ResponseObjectStreamResponseOutputItemAddedItemRoleSystem ResponseObjectStreamResponseOutputItemAddedItemRole = "system" - ResponseObjectStreamResponseOutputItemAddedItemRoleDeveloper ResponseObjectStreamResponseOutputItemAddedItemRole = "developer" - ResponseObjectStreamResponseOutputItemAddedItemRoleUser ResponseObjectStreamResponseOutputItemAddedItemRole = "user" - ResponseObjectStreamResponseOutputItemAddedItemRoleAssistant ResponseObjectStreamResponseOutputItemAddedItemRole = "assistant" -) - -// Streaming event for when an output item is completed. -type ResponseObjectStreamResponseOutputItemDone struct { - // The completed output item (message, tool call, etc.) - Item ResponseObjectStreamResponseOutputItemDoneItemUnion `json:"item,required"` - // Index position of this item in the output list - OutputIndex int64 `json:"output_index,required"` - // Unique identifier of the response containing this output - ResponseID string `json:"response_id,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Event type identifier, always "response.output_item.done" - Type constant.ResponseOutputItemDone `json:"type,required"` +// Search results returned by the file search operation. +type ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult struct { + Attributes map[string]any `json:"attributes,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Score float64 `json:"score,required"` + Text string `json:"text,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Item respjson.Field - OutputIndex respjson.Field - ResponseID respjson.Field - SequenceNumber respjson.Field - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string + Attributes respjson.Field + FileID respjson.Field + Filename respjson.Field + Score respjson.Field + Text respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemDone) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemDone) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} +func (r ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Function tool call output message for OpenAI responses. +type ResponseObjectStreamResponseOutputItemAddedItemFunctionCall struct { + Arguments string `json:"arguments,required"` + CallID string `json:"call_id,required"` + Name string `json:"name,required"` + ID string `json:"id,nullable"` + Status string `json:"status,nullable"` + // Any of "function_call". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Arguments respjson.Field + CallID respjson.Field + Name respjson.Field + ID respjson.Field + Status respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseOutputItemAddedItemFunctionCall) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseOutputItemAddedItemFunctionCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Model Context Protocol (MCP) call output message for OpenAI responses. +type ResponseObjectStreamResponseOutputItemAddedItemMcpCall struct { + ID string `json:"id,required"` + Arguments string `json:"arguments,required"` + Name string `json:"name,required"` + ServerLabel string `json:"server_label,required"` + Error string `json:"error,nullable"` + Output string `json:"output,nullable"` + // Any of "mcp_call". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Arguments respjson.Field + Name respjson.Field + ServerLabel respjson.Field + Error respjson.Field + Output respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseOutputItemAddedItemMcpCall) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseOutputItemAddedItemMcpCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// MCP list tools output message containing available tools from an MCP server. +type ResponseObjectStreamResponseOutputItemAddedItemMcpListTools struct { + ID string `json:"id,required"` + ServerLabel string `json:"server_label,required"` + Tools []ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTool `json:"tools,required"` + // Any of "mcp_list_tools". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + ServerLabel respjson.Field + Tools respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseOutputItemAddedItemMcpListTools) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseOutputItemAddedItemMcpListTools) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Tool definition returned by MCP list tools operation. +type ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTool struct { + InputSchema map[string]any `json:"input_schema,required"` + Name string `json:"name,required"` + Description string `json:"description,nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputSchema respjson.Field + Name respjson.Field + Description respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTool) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTool) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// A request for human approval of a tool invocation. +type ResponseObjectStreamResponseOutputItemAddedItemMcpApprovalRequest struct { + ID string `json:"id,required"` + Arguments string `json:"arguments,required"` + Name string `json:"name,required"` + ServerLabel string `json:"server_label,required"` + // Any of "mcp_approval_request". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Arguments respjson.Field + Name respjson.Field + ServerLabel respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseOutputItemAddedItemMcpApprovalRequest) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseOutputItemAddedItemMcpApprovalRequest) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Streaming event for when an output item is completed. +type ResponseObjectStreamResponseOutputItemDone struct { + // Corresponds to the various Message types in the Responses API. They are all + // under one type because the Responses API gives them all the same "type" value, + // and there is no way to tell them apart in certain scenarios. + Item ResponseObjectStreamResponseOutputItemDoneItemUnion `json:"item,required"` + OutputIndex int64 `json:"output_index,required"` + ResponseID string `json:"response_id,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.output_item.done". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Item respjson.Field + OutputIndex respjson.Field + ResponseID respjson.Field + SequenceNumber respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseOutputItemDone) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseOutputItemDone) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} // ResponseObjectStreamResponseOutputItemDoneItemUnion contains all possible // properties and values from @@ -3397,12 +3460,12 @@ type ResponseObjectStreamResponseOutputItemDoneItemUnion struct { Content ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion `json:"content"` // This field is from variant // [ResponseObjectStreamResponseOutputItemDoneItemMessage]. - Role ResponseObjectStreamResponseOutputItemDoneItemMessageRole `json:"role"` - // Any of "message", "web_search_call", "file_search_call", "function_call", - // "mcp_call", "mcp_list_tools", "mcp_approval_request". - Type string `json:"type"` + Role string `json:"role"` ID string `json:"id"` Status string `json:"status"` + // Any of "message", "web_search_call", "file_search_call", "function_call", + // "mcp_call", "mcp_list_tools", "mcp_approval_request". + Type string `json:"type"` // This field is from variant // [ResponseObjectStreamResponseOutputItemDoneItemFileSearchCall]. Queries []string `json:"queries"` @@ -3427,9 +3490,9 @@ type ResponseObjectStreamResponseOutputItemDoneItemUnion struct { JSON struct { Content respjson.Field Role respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field Queries respjson.Field Results respjson.Field Arguments respjson.Field @@ -3546,17 +3609,18 @@ func (r *ResponseObjectStreamResponseOutputItemDoneItemUnion) UnmarshalJSON(data type ResponseObjectStreamResponseOutputItemDoneItemMessage struct { Content ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion `json:"content,required"` // Any of "system", "developer", "user", "assistant". - Role ResponseObjectStreamResponseOutputItemDoneItemMessageRole `json:"role,required"` - Type constant.Message `json:"type,required"` - ID string `json:"id"` - Status string `json:"status"` + Role string `json:"role,required"` + ID string `json:"id,nullable"` + Status string `json:"status,nullable"` + // Any of "message". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field Role respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -3570,24 +3634,31 @@ func (r *ResponseObjectStreamResponseOutputItemDoneItemMessage) UnmarshalJSON(da // ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion contains all // possible properties and values from [string], -// [[]ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion], -// [[]ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion]. +// [[]ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion], +// [[]ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString OfVariant2] +// will be valid: OfString +// OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile +// OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal] type ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion] + // [[]ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion] + // instead of an object. + OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile []ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion `json:",inline"` + // This field will be present if the value is a + // [[]ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion] // instead of an object. - OfVariant2 []ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion `json:",inline"` - JSON struct { - OfString respjson.Field - OfVariant2 respjson.Field - raw string + OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal []ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile respjson.Field + OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal respjson.Field + raw string } `json:"-"` } @@ -3596,12 +3667,12 @@ func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion) AsStr return } -func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion) AsResponseObjectStreamResponseOutputItemDoneItemMessageContentArray() (v []ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion) { +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion) AsListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile() (v []ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion) AsVariant2() (v []ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion) { +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion) AsListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal() (v []ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -3615,38 +3686,38 @@ func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion) Unma return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion +// ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion // contains all possible properties and values from -// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputText], -// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage], -// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputFile]. +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText], +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage], +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. // // Use the -// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion.AsAny] +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny] // method to switch on the variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion struct { +type ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion struct { // This field is from variant - // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputText]. + // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText]. Text string `json:"text"` // Any of "input_text", "input_image", "input_file". Type string `json:"type"` // This field is from variant - // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage]. - Detail ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetail `json:"detail"` - FileID string `json:"file_id"` + // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]. + Detail string `json:"detail"` + FileID string `json:"file_id"` // This field is from variant - // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage]. + // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]. ImageURL string `json:"image_url"` // This field is from variant - // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputFile]. + // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. FileData string `json:"file_data"` // This field is from variant - // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputFile]. + // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. FileURL string `json:"file_url"` // This field is from variant - // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputFile]. + // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. Filename string `json:"filename"` JSON struct { Text respjson.Field @@ -3661,32 +3732,32 @@ type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion } `json:"-"` } -// anyResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItem is -// implemented by each variant of -// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion] to -// add type safety for the return type of -// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion.AsAny] -type anyResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItem interface { - implResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion() +// anyResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem +// is implemented by each variant of +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion] +// to add type safety for the return type of +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny] +type anyResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem interface { + implResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() } -func (ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputText) implResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion() { +func (ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) implResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { } -func (ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage) implResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion() { +func (ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) implResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { } -func (ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputFile) implResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion() { +func (ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) implResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { } // Use the following switch statement to find the correct variant // -// switch variant := ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion.AsAny().(type) { -// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputText: -// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage: -// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputFile: +// switch variant := ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny().(type) { +// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText: +// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage: +// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile: // default: // fmt.Errorf("no variant present") // } -func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion) AsAny() anyResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItem { +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsAny() anyResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem { switch u.Type { case "input_text": return u.AsInputText() @@ -3698,36 +3769,35 @@ func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUni return nil } -func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion) AsInputText() (v ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputText) { +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputText() (v ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion) AsInputImage() (v ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage) { +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputImage() (v ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion) AsInputFile() (v ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputFile) { +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputFile() (v ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion) RawJSON() string { +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) RawJSON() string { return u.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content for input messages in OpenAI response format. -type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputText struct { - // The text content of the input message +type ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText struct { Text string `json:"text,required"` - // Content type identifier, always "input_text" - Type constant.InputText `json:"type,required"` + // Any of "input_text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -3738,111 +3808,421 @@ type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputT } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputText) RawJSON() string { +func (r ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputText) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Image content for input messages in OpenAI response format. -type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage struct { - // Level of detail for image processing, can be "low", "high", or "auto" - // +type ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage struct { // Any of "low", "high", "auto". - Detail ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetail `json:"detail,required"` - // Content type identifier, always "input_image" - Type constant.InputImage `json:"type,required"` - // (Optional) The ID of the file to be sent to the model. - FileID string `json:"file_id"` - // (Optional) URL of the image content - ImageURL string `json:"image_url"` + Detail string `json:"detail"` + FileID string `json:"file_id,nullable"` + ImageURL string `json:"image_url,nullable"` + // Any of "input_image". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Detail respjson.Field - Type respjson.Field FileID respjson.Field ImageURL respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage) RawJSON() string { +func (r ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetail string +// File content for input messages in OpenAI response format. +type ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile struct { + FileData string `json:"file_data,nullable"` + FileID string `json:"file_id,nullable"` + FileURL string `json:"file_url,nullable"` + Filename string `json:"filename,nullable"` + // Any of "input_file". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + FileData respjson.Field + FileID respjson.Field + FileURL respjson.Field + Filename respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} -const ( - ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetailLow ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetail = "low" - ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetailHigh ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetail = "high" - ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetailAuto ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetail = "auto" -) +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} -// File content for input messages in OpenAI response format. -type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputFile struct { - // The type of the input item. Always `input_file`. - Type constant.InputFile `json:"type,required"` - // The data of the file to be sent to the model. - FileData string `json:"file_data"` - // (Optional) The ID of the file to be sent to the model. - FileID string `json:"file_id"` - // The URL of the file to be sent to the model. - FileURL string `json:"file_url"` - // The name of the file to be sent to the model. +// ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion +// contains all possible properties and values from +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText], +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]. +// +// Use the +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny] +// method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion struct { + // This field is from variant + // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]. + Text string `json:"text"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]. + Annotations []ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion `json:"annotations"` + // Any of "output_text", "refusal". + Type string `json:"type"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]. + Refusal string `json:"refusal"` + JSON struct { + Text respjson.Field + Annotations respjson.Field + Type respjson.Field + Refusal respjson.Field + raw string + } `json:"-"` +} + +// anyResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem +// is implemented by each variant of +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion] +// to add type safety for the return type of +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny] +type anyResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem interface { + implResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() +} + +func (ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) implResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() { +} +func (ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) implResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny().(type) { +// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText: +// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal: +// default: +// fmt.Errorf("no variant present") +// } +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsAny() anyResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem { + switch u.Type { + case "output_text": + return u.AsOutputText() + case "refusal": + return u.AsRefusal() + } + return nil +} + +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsOutputText() (v ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsRefusal() (v ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText struct { + Text string `json:"text,required"` + Annotations []ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion `json:"annotations"` + // Any of "output_text". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Text respjson.Field + Annotations respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion +// contains all possible properties and values from +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation], +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation], +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation], +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath]. +// +// Use the +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny] +// method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion struct { + FileID string `json:"file_id"` Filename string `json:"filename"` + Index int64 `json:"index"` + // Any of "file_citation", "url_citation", "container_file_citation", "file_path". + Type string `json:"type"` + EndIndex int64 `json:"end_index"` + StartIndex int64 `json:"start_index"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]. + Title string `json:"title"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]. + URL string `json:"url"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation]. + ContainerID string `json:"container_id"` + JSON struct { + FileID respjson.Field + Filename respjson.Field + Index respjson.Field + Type respjson.Field + EndIndex respjson.Field + StartIndex respjson.Field + Title respjson.Field + URL respjson.Field + ContainerID respjson.Field + raw string + } `json:"-"` +} + +// anyResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation +// is implemented by each variant of +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion] +// to add type safety for the return type of +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny] +type anyResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation interface { + implResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() +} + +func (ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) implResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} +func (ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) implResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} +func (ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) implResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} +func (ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) implResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny().(type) { +// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation: +// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation: +// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation: +// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath: +// default: +// fmt.Errorf("no variant present") +// } +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsAny() anyResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation { + switch u.Type { + case "file_citation": + return u.AsFileCitation() + case "url_citation": + return u.AsURLCitation() + case "container_file_citation": + return u.AsContainerFileCitation() + case "file_path": + return u.AsFilePath() + } + return nil +} + +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsFileCitation() (v ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsURLCitation() (v ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsContainerFileCitation() (v ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsFilePath() (v ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// File citation annotation for referencing specific files in response content. +type ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation struct { + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Index int64 `json:"index,required"` + // Any of "file_citation". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + FileID respjson.Field + Filename respjson.Field + Index respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// URL citation annotation for referencing external web resources. +type ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation struct { + EndIndex int64 `json:"end_index,required"` + StartIndex int64 `json:"start_index,required"` + Title string `json:"title,required"` + URL string `json:"url,required"` + // Any of "url_citation". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + EndIndex respjson.Field + StartIndex respjson.Field + Title respjson.Field + URL respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation struct { + ContainerID string `json:"container_id,required"` + EndIndex int64 `json:"end_index,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + StartIndex int64 `json:"start_index,required"` + // Any of "container_file_citation". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ContainerID respjson.Field + EndIndex respjson.Field + FileID respjson.Field + Filename respjson.Field + StartIndex respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath struct { + FileID string `json:"file_id,required"` + Index int64 `json:"index,required"` + // Any of "file_path". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + FileID respjson.Field + Index respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Refusal content within a streamed response part. +type ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal struct { + Refusal string `json:"refusal,required"` + // Any of "refusal". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { + Refusal respjson.Field Type respjson.Field - FileData respjson.Field - FileID respjson.Field - FileURL respjson.Field - Filename respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputFile) RawJSON() string { +func (r ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputFile) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemDetail string - -const ( - ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemDetailLow ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemDetail = "low" - ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemDetailHigh ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemDetail = "high" - ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemDetailAuto ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemDetail = "auto" -) - -type ResponseObjectStreamResponseOutputItemDoneItemMessageRole string - -const ( - ResponseObjectStreamResponseOutputItemDoneItemMessageRoleSystem ResponseObjectStreamResponseOutputItemDoneItemMessageRole = "system" - ResponseObjectStreamResponseOutputItemDoneItemMessageRoleDeveloper ResponseObjectStreamResponseOutputItemDoneItemMessageRole = "developer" - ResponseObjectStreamResponseOutputItemDoneItemMessageRoleUser ResponseObjectStreamResponseOutputItemDoneItemMessageRole = "user" - ResponseObjectStreamResponseOutputItemDoneItemMessageRoleAssistant ResponseObjectStreamResponseOutputItemDoneItemMessageRole = "assistant" -) - // Web search tool call output message for OpenAI responses. type ResponseObjectStreamResponseOutputItemDoneItemWebSearchCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // Current status of the web search operation + ID string `json:"id,required"` Status string `json:"status,required"` - // Tool call type identifier, always "web_search_call" - Type constant.WebSearchCall `json:"type,required"` + // Any of "web_search_call". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -3863,23 +4243,19 @@ func (r *ResponseObjectStreamResponseOutputItemDoneItemWebSearchCall) UnmarshalJ // File search tool call output message for OpenAI responses. type ResponseObjectStreamResponseOutputItemDoneItemFileSearchCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // List of search queries executed - Queries []string `json:"queries,required"` - // Current status of the file search operation - Status string `json:"status,required"` - // Tool call type identifier, always "file_search_call" - Type constant.FileSearchCall `json:"type,required"` - // (Optional) Search results returned by the file search operation - Results []ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResult `json:"results"` + ID string `json:"id,required"` + Queries []string `json:"queries,required"` + Status string `json:"status,required"` + Results []ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResult `json:"results,nullable"` + // Any of "file_search_call". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field Queries respjson.Field Status respjson.Field - Type respjson.Field Results respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -3895,16 +4271,11 @@ func (r *ResponseObjectStreamResponseOutputItemDoneItemFileSearchCall) Unmarshal // Search results returned by the file search operation. type ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResult struct { - // (Optional) Key-value attributes associated with the file - Attributes map[string]ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResultAttributeUnion `json:"attributes,required"` - // Unique identifier of the file containing the result - FileID string `json:"file_id,required"` - // Name of the file containing the result - Filename string `json:"filename,required"` - // Relevance score for this search result (between 0 and 1) - Score float64 `json:"score,required"` - // Text content of the search result - Text string `json:"text,required"` + Attributes map[string]any `json:"attributes,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Score float64 `json:"score,required"` + Text string `json:"text,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Attributes respjson.Field @@ -3925,83 +4296,23 @@ func (r *ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResult) Unm return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResultAttributeUnion -// contains all possible properties and values from [bool], [float64], [string], -// [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResultAttributeUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResultAttributeUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResultAttributeUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResultAttributeUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResultAttributeUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResultAttributeUnion) RawJSON() string { - return u.JSON.raw -} - -func (r *ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResultAttributeUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - // Function tool call output message for OpenAI responses. type ResponseObjectStreamResponseOutputItemDoneItemFunctionCall struct { - // JSON string containing the function arguments Arguments string `json:"arguments,required"` - // Unique identifier for the function call - CallID string `json:"call_id,required"` - // Name of the function being called - Name string `json:"name,required"` - // Tool call type identifier, always "function_call" - Type constant.FunctionCall `json:"type,required"` - // (Optional) Additional identifier for the tool call - ID string `json:"id"` - // (Optional) Current status of the function call execution - Status string `json:"status"` + CallID string `json:"call_id,required"` + Name string `json:"name,required"` + ID string `json:"id,nullable"` + Status string `json:"status,nullable"` + // Any of "function_call". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Arguments respjson.Field CallID respjson.Field Name respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -4017,29 +4328,23 @@ func (r *ResponseObjectStreamResponseOutputItemDoneItemFunctionCall) UnmarshalJS // Model Context Protocol (MCP) call output message for OpenAI responses. type ResponseObjectStreamResponseOutputItemDoneItemMcpCall struct { - // Unique identifier for this MCP call - ID string `json:"id,required"` - // JSON string containing the MCP call arguments - Arguments string `json:"arguments,required"` - // Name of the MCP method being called - Name string `json:"name,required"` - // Label identifying the MCP server handling the call + ID string `json:"id,required"` + Arguments string `json:"arguments,required"` + Name string `json:"name,required"` ServerLabel string `json:"server_label,required"` - // Tool call type identifier, always "mcp_call" - Type constant.McpCall `json:"type,required"` - // (Optional) Error message if the MCP call failed - Error string `json:"error"` - // (Optional) Output result from the successful MCP call - Output string `json:"output"` + Error string `json:"error,nullable"` + Output string `json:"output,nullable"` + // Any of "mcp_call". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field Arguments respjson.Field Name respjson.Field ServerLabel respjson.Field - Type respjson.Field Error respjson.Field Output respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -4053,14 +4358,11 @@ func (r *ResponseObjectStreamResponseOutputItemDoneItemMcpCall) UnmarshalJSON(da // MCP list tools output message containing available tools from an MCP server. type ResponseObjectStreamResponseOutputItemDoneItemMcpListTools struct { - // Unique identifier for this MCP list tools operation - ID string `json:"id,required"` - // Label identifying the MCP server providing the tools - ServerLabel string `json:"server_label,required"` - // List of available tools provided by the MCP server - Tools []ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsTool `json:"tools,required"` - // Tool call type identifier, always "mcp_list_tools" - Type constant.McpListTools `json:"type,required"` + ID string `json:"id,required"` + ServerLabel string `json:"server_label,required"` + Tools []ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsTool `json:"tools,required"` + // Any of "mcp_list_tools". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -4082,12 +4384,9 @@ func (r *ResponseObjectStreamResponseOutputItemDoneItemMcpListTools) UnmarshalJS // Tool definition returned by MCP list tools operation. type ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsTool struct { - // JSON schema defining the tool's input parameters - InputSchema map[string]ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion `json:"input_schema,required"` - // Name of the tool - Name string `json:"name,required"` - // (Optional) Description of what the tool does - Description string `json:"description"` + InputSchema map[string]any `json:"input_schema,required"` + Name string `json:"name,required"` + Description string `json:"description,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { InputSchema respjson.Field @@ -4106,68 +4405,14 @@ func (r *ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsTool) Unmarsh return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion -// contains all possible properties and values from [bool], [float64], [string], -// [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion) RawJSON() string { - return u.JSON.raw -} - -func (r *ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - // A request for human approval of a tool invocation. type ResponseObjectStreamResponseOutputItemDoneItemMcpApprovalRequest struct { - ID string `json:"id,required"` - Arguments string `json:"arguments,required"` - Name string `json:"name,required"` - ServerLabel string `json:"server_label,required"` - Type constant.McpApprovalRequest `json:"type,required"` + ID string `json:"id,required"` + Arguments string `json:"arguments,required"` + Name string `json:"name,required"` + ServerLabel string `json:"server_label,required"` + // Any of "mcp_approval_request". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -4188,29 +4433,15 @@ func (r *ResponseObjectStreamResponseOutputItemDoneItemMcpApprovalRequest) Unmar return apijson.UnmarshalRoot(data, r) } -type ResponseObjectStreamResponseOutputItemDoneItemRole string - -const ( - ResponseObjectStreamResponseOutputItemDoneItemRoleSystem ResponseObjectStreamResponseOutputItemDoneItemRole = "system" - ResponseObjectStreamResponseOutputItemDoneItemRoleDeveloper ResponseObjectStreamResponseOutputItemDoneItemRole = "developer" - ResponseObjectStreamResponseOutputItemDoneItemRoleUser ResponseObjectStreamResponseOutputItemDoneItemRole = "user" - ResponseObjectStreamResponseOutputItemDoneItemRoleAssistant ResponseObjectStreamResponseOutputItemDoneItemRole = "assistant" -) - // Streaming event for incremental text content updates. type ResponseObjectStreamResponseOutputTextDelta struct { - // Index position within the text content - ContentIndex int64 `json:"content_index,required"` - // Incremental text content being added - Delta string `json:"delta,required"` - // Unique identifier of the output item being updated - ItemID string `json:"item_id,required"` - // Index position of the item in the output list - OutputIndex int64 `json:"output_index,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Event type identifier, always "response.output_text.delta" - Type constant.ResponseOutputTextDelta `json:"type,required"` + ContentIndex int64 `json:"content_index,required"` + Delta string `json:"delta,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.output_text.delta". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ContentIndex respjson.Field @@ -4232,18 +4463,13 @@ func (r *ResponseObjectStreamResponseOutputTextDelta) UnmarshalJSON(data []byte) // Streaming event for when text output is completed. type ResponseObjectStreamResponseOutputTextDone struct { - // Index position within the text content - ContentIndex int64 `json:"content_index,required"` - // Unique identifier of the completed output item - ItemID string `json:"item_id,required"` - // Index position of the item in the output list - OutputIndex int64 `json:"output_index,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Final complete text content of the output item - Text string `json:"text,required"` - // Event type identifier, always "response.output_text.done" - Type constant.ResponseOutputTextDone `json:"type,required"` + ContentIndex int64 `json:"content_index,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + SequenceNumber int64 `json:"sequence_number,required"` + Text string `json:"text,required"` + // Any of "response.output_text.done". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ContentIndex respjson.Field @@ -4265,16 +4491,12 @@ func (r *ResponseObjectStreamResponseOutputTextDone) UnmarshalJSON(data []byte) // Streaming event for incremental function call argument updates. type ResponseObjectStreamResponseFunctionCallArgumentsDelta struct { - // Incremental function call arguments being added - Delta string `json:"delta,required"` - // Unique identifier of the function call being updated - ItemID string `json:"item_id,required"` - // Index position of the item in the output list - OutputIndex int64 `json:"output_index,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Event type identifier, always "response.function_call_arguments.delta" - Type constant.ResponseFunctionCallArgumentsDelta `json:"type,required"` + Delta string `json:"delta,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.function_call_arguments.delta". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Delta respjson.Field @@ -4295,16 +4517,12 @@ func (r *ResponseObjectStreamResponseFunctionCallArgumentsDelta) UnmarshalJSON(d // Streaming event for when function call arguments are completed. type ResponseObjectStreamResponseFunctionCallArgumentsDone struct { - // Final complete arguments JSON string for the function call - Arguments string `json:"arguments,required"` - // Unique identifier of the completed function call - ItemID string `json:"item_id,required"` - // Index position of the item in the output list - OutputIndex int64 `json:"output_index,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Event type identifier, always "response.function_call_arguments.done" - Type constant.ResponseFunctionCallArgumentsDone `json:"type,required"` + Arguments string `json:"arguments,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.function_call_arguments.done". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Arguments respjson.Field @@ -4325,14 +4543,11 @@ func (r *ResponseObjectStreamResponseFunctionCallArgumentsDone) UnmarshalJSON(da // Streaming event for web search calls in progress. type ResponseObjectStreamResponseWebSearchCallInProgress struct { - // Unique identifier of the web search call - ItemID string `json:"item_id,required"` - // Index position of the item in the output list - OutputIndex int64 `json:"output_index,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Event type identifier, always "response.web_search_call.in_progress" - Type constant.ResponseWebSearchCallInProgress `json:"type,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.web_search_call.in_progress". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ItemID respjson.Field @@ -4351,10 +4566,11 @@ func (r *ResponseObjectStreamResponseWebSearchCallInProgress) UnmarshalJSON(data } type ResponseObjectStreamResponseWebSearchCallSearching struct { - ItemID string `json:"item_id,required"` - OutputIndex int64 `json:"output_index,required"` - SequenceNumber int64 `json:"sequence_number,required"` - Type constant.ResponseWebSearchCallSearching `json:"type,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.web_search_call.searching". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ItemID respjson.Field @@ -4374,14 +4590,11 @@ func (r *ResponseObjectStreamResponseWebSearchCallSearching) UnmarshalJSON(data // Streaming event for completed web search calls. type ResponseObjectStreamResponseWebSearchCallCompleted struct { - // Unique identifier of the completed web search call - ItemID string `json:"item_id,required"` - // Index position of the item in the output list - OutputIndex int64 `json:"output_index,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Event type identifier, always "response.web_search_call.completed" - Type constant.ResponseWebSearchCallCompleted `json:"type,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.web_search_call.completed". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ItemID respjson.Field @@ -4400,8 +4613,9 @@ func (r *ResponseObjectStreamResponseWebSearchCallCompleted) UnmarshalJSON(data } type ResponseObjectStreamResponseMcpListToolsInProgress struct { - SequenceNumber int64 `json:"sequence_number,required"` - Type constant.ResponseMcpListToolsInProgress `json:"type,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.mcp_list_tools.in_progress". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { SequenceNumber respjson.Field @@ -4418,8 +4632,9 @@ func (r *ResponseObjectStreamResponseMcpListToolsInProgress) UnmarshalJSON(data } type ResponseObjectStreamResponseMcpListToolsFailed struct { - SequenceNumber int64 `json:"sequence_number,required"` - Type constant.ResponseMcpListToolsFailed `json:"type,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.mcp_list_tools.failed". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { SequenceNumber respjson.Field @@ -4436,8 +4651,9 @@ func (r *ResponseObjectStreamResponseMcpListToolsFailed) UnmarshalJSON(data []by } type ResponseObjectStreamResponseMcpListToolsCompleted struct { - SequenceNumber int64 `json:"sequence_number,required"` - Type constant.ResponseMcpListToolsCompleted `json:"type,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.mcp_list_tools.completed". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { SequenceNumber respjson.Field @@ -4454,11 +4670,12 @@ func (r *ResponseObjectStreamResponseMcpListToolsCompleted) UnmarshalJSON(data [ } type ResponseObjectStreamResponseMcpCallArgumentsDelta struct { - Delta string `json:"delta,required"` - ItemID string `json:"item_id,required"` - OutputIndex int64 `json:"output_index,required"` - SequenceNumber int64 `json:"sequence_number,required"` - Type constant.ResponseMcpCallArgumentsDelta `json:"type,required"` + Delta string `json:"delta,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.mcp_call.arguments.delta". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Delta respjson.Field @@ -4478,11 +4695,12 @@ func (r *ResponseObjectStreamResponseMcpCallArgumentsDelta) UnmarshalJSON(data [ } type ResponseObjectStreamResponseMcpCallArgumentsDone struct { - Arguments string `json:"arguments,required"` - ItemID string `json:"item_id,required"` - OutputIndex int64 `json:"output_index,required"` - SequenceNumber int64 `json:"sequence_number,required"` - Type constant.ResponseMcpCallArgumentsDone `json:"type,required"` + Arguments string `json:"arguments,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.mcp_call.arguments.done". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Arguments respjson.Field @@ -4503,14 +4721,11 @@ func (r *ResponseObjectStreamResponseMcpCallArgumentsDone) UnmarshalJSON(data [] // Streaming event for MCP calls in progress. type ResponseObjectStreamResponseMcpCallInProgress struct { - // Unique identifier of the MCP call - ItemID string `json:"item_id,required"` - // Index position of the item in the output list - OutputIndex int64 `json:"output_index,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Event type identifier, always "response.mcp_call.in_progress" - Type constant.ResponseMcpCallInProgress `json:"type,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.mcp_call.in_progress". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ItemID respjson.Field @@ -4530,10 +4745,9 @@ func (r *ResponseObjectStreamResponseMcpCallInProgress) UnmarshalJSON(data []byt // Streaming event for failed MCP calls. type ResponseObjectStreamResponseMcpCallFailed struct { - // Sequential number for ordering streaming events SequenceNumber int64 `json:"sequence_number,required"` - // Event type identifier, always "response.mcp_call.failed" - Type constant.ResponseMcpCallFailed `json:"type,required"` + // Any of "response.mcp_call.failed". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { SequenceNumber respjson.Field @@ -4551,10 +4765,9 @@ func (r *ResponseObjectStreamResponseMcpCallFailed) UnmarshalJSON(data []byte) e // Streaming event for completed MCP calls. type ResponseObjectStreamResponseMcpCallCompleted struct { - // Sequential number for ordering streaming events SequenceNumber int64 `json:"sequence_number,required"` - // Event type identifier, always "response.mcp_call.completed" - Type constant.ResponseMcpCallCompleted `json:"type,required"` + // Any of "response.mcp_call.completed". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { SequenceNumber respjson.Field @@ -4572,20 +4785,15 @@ func (r *ResponseObjectStreamResponseMcpCallCompleted) UnmarshalJSON(data []byte // Streaming event for when a new content part is added to a response item. type ResponseObjectStreamResponseContentPartAdded struct { - // Index position of the part within the content array - ContentIndex int64 `json:"content_index,required"` - // Unique identifier of the output item containing this content part - ItemID string `json:"item_id,required"` - // Index position of the output item in the response - OutputIndex int64 `json:"output_index,required"` - // The content part that was added - Part ResponseObjectStreamResponseContentPartAddedPartUnion `json:"part,required"` - // Unique identifier of the response containing this content - ResponseID string `json:"response_id,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Event type identifier, always "response.content_part.added" - Type constant.ResponseContentPartAdded `json:"type,required"` + ContentIndex int64 `json:"content_index,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + // Text content within a streamed response part. + Part ResponseObjectStreamResponseContentPartAddedPartUnion `json:"part,required"` + ResponseID string `json:"response_id,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.content_part.added". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ContentIndex respjson.Field @@ -4617,23 +4825,23 @@ func (r *ResponseObjectStreamResponseContentPartAdded) UnmarshalJSON(data []byte // // Use the methods beginning with 'As' to cast the union to one of its variants. type ResponseObjectStreamResponseContentPartAddedPartUnion struct { + Text string `json:"text"` // This field is from variant // [ResponseObjectStreamResponseContentPartAddedPartOutputText]. Annotations []ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion `json:"annotations"` - Text string `json:"text"` - // Any of "output_text", "refusal", "reasoning_text". - Type string `json:"type"` // This field is from variant // [ResponseObjectStreamResponseContentPartAddedPartOutputText]. - Logprobs []map[string]ResponseObjectStreamResponseContentPartAddedPartOutputTextLogprobUnion `json:"logprobs"` + Logprobs []map[string]any `json:"logprobs"` + // Any of "output_text", "refusal", "reasoning_text". + Type string `json:"type"` // This field is from variant // [ResponseObjectStreamResponseContentPartAddedPartRefusal]. Refusal string `json:"refusal"` JSON struct { - Annotations respjson.Field Text respjson.Field - Type respjson.Field + Annotations respjson.Field Logprobs respjson.Field + Type respjson.Field Refusal respjson.Field raw string } `json:"-"` @@ -4699,20 +4907,17 @@ func (r *ResponseObjectStreamResponseContentPartAddedPartUnion) UnmarshalJSON(da // Text content within a streamed response part. type ResponseObjectStreamResponseContentPartAddedPartOutputText struct { - // Structured annotations associated with the text - Annotations []ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion `json:"annotations,required"` - // Text emitted for this content part - Text string `json:"text,required"` - // Content part type identifier, always "output_text" - Type constant.OutputText `json:"type,required"` - // (Optional) Token log probability details - Logprobs []map[string]ResponseObjectStreamResponseContentPartAddedPartOutputTextLogprobUnion `json:"logprobs"` + Text string `json:"text,required"` + Annotations []ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion `json:"annotations"` + Logprobs []map[string]any `json:"logprobs,nullable"` + // Any of "output_text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Annotations respjson.Field Text respjson.Field - Type respjson.Field + Annotations respjson.Field Logprobs respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -4842,14 +5047,11 @@ func (r *ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUni // File citation annotation for referencing specific files in response content. type ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationFileCitation struct { - // Unique identifier of the referenced file - FileID string `json:"file_id,required"` - // Name of the referenced file + FileID string `json:"file_id,required"` Filename string `json:"filename,required"` - // Position index of the citation within the content - Index int64 `json:"index,required"` - // Annotation type identifier, always "file_citation" - Type constant.FileCitation `json:"type,required"` + Index int64 `json:"index,required"` + // Any of "file_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { FileID respjson.Field @@ -4871,23 +5073,19 @@ func (r *ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationFil // URL citation annotation for referencing external web resources. type ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationURLCitation struct { - // End position of the citation span in the content - EndIndex int64 `json:"end_index,required"` - // Start position of the citation span in the content - StartIndex int64 `json:"start_index,required"` - // Title of the referenced web resource - Title string `json:"title,required"` - // Annotation type identifier, always "url_citation" - Type constant.URLCitation `json:"type,required"` - // URL of the referenced web resource - URL string `json:"url,required"` + EndIndex int64 `json:"end_index,required"` + StartIndex int64 `json:"start_index,required"` + Title string `json:"title,required"` + URL string `json:"url,required"` + // Any of "url_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { EndIndex respjson.Field StartIndex respjson.Field Title respjson.Field - Type respjson.Field URL respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -4902,12 +5100,13 @@ func (r *ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationURL } type ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationContainerFileCitation struct { - ContainerID string `json:"container_id,required"` - EndIndex int64 `json:"end_index,required"` - FileID string `json:"file_id,required"` - Filename string `json:"filename,required"` - StartIndex int64 `json:"start_index,required"` - Type constant.ContainerFileCitation `json:"type,required"` + ContainerID string `json:"container_id,required"` + EndIndex int64 `json:"end_index,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + StartIndex int64 `json:"start_index,required"` + // Any of "container_file_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ContainerID respjson.Field @@ -4930,9 +5129,10 @@ func (r *ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationCon } type ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationFilePath struct { - FileID string `json:"file_id,required"` - Index int64 `json:"index,required"` - Type constant.FilePath `json:"type,required"` + FileID string `json:"file_id,required"` + Index int64 `json:"index,required"` + // Any of "file_path". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { FileID respjson.Field @@ -4951,66 +5151,11 @@ func (r *ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationFil return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamResponseContentPartAddedPartOutputTextLogprobUnion contains -// all possible properties and values from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ResponseObjectStreamResponseContentPartAddedPartOutputTextLogprobUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ResponseObjectStreamResponseContentPartAddedPartOutputTextLogprobUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectStreamResponseContentPartAddedPartOutputTextLogprobUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectStreamResponseContentPartAddedPartOutputTextLogprobUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectStreamResponseContentPartAddedPartOutputTextLogprobUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ResponseObjectStreamResponseContentPartAddedPartOutputTextLogprobUnion) RawJSON() string { - return u.JSON.raw -} - -func (r *ResponseObjectStreamResponseContentPartAddedPartOutputTextLogprobUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - // Refusal content within a streamed response part. type ResponseObjectStreamResponseContentPartAddedPartRefusal struct { - // Refusal text supplied by the model Refusal string `json:"refusal,required"` - // Content part type identifier, always "refusal" - Type constant.Refusal `json:"type,required"` + // Any of "refusal". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Refusal respjson.Field @@ -5028,10 +5173,9 @@ func (r *ResponseObjectStreamResponseContentPartAddedPartRefusal) UnmarshalJSON( // Reasoning text emitted as part of a streamed response. type ResponseObjectStreamResponseContentPartAddedPartReasoningText struct { - // Reasoning text supplied by the model Text string `json:"text,required"` - // Content part type identifier, always "reasoning_text" - Type constant.ReasoningText `json:"type,required"` + // Any of "reasoning_text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -5051,20 +5195,15 @@ func (r *ResponseObjectStreamResponseContentPartAddedPartReasoningText) Unmarsha // Streaming event for when a content part is completed. type ResponseObjectStreamResponseContentPartDone struct { - // Index position of the part within the content array - ContentIndex int64 `json:"content_index,required"` - // Unique identifier of the output item containing this content part - ItemID string `json:"item_id,required"` - // Index position of the output item in the response - OutputIndex int64 `json:"output_index,required"` - // The completed content part - Part ResponseObjectStreamResponseContentPartDonePartUnion `json:"part,required"` - // Unique identifier of the response containing this content - ResponseID string `json:"response_id,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Event type identifier, always "response.content_part.done" - Type constant.ResponseContentPartDone `json:"type,required"` + ContentIndex int64 `json:"content_index,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + // Text content within a streamed response part. + Part ResponseObjectStreamResponseContentPartDonePartUnion `json:"part,required"` + ResponseID string `json:"response_id,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.content_part.done". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ContentIndex respjson.Field @@ -5096,23 +5235,23 @@ func (r *ResponseObjectStreamResponseContentPartDone) UnmarshalJSON(data []byte) // // Use the methods beginning with 'As' to cast the union to one of its variants. type ResponseObjectStreamResponseContentPartDonePartUnion struct { + Text string `json:"text"` // This field is from variant // [ResponseObjectStreamResponseContentPartDonePartOutputText]. Annotations []ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion `json:"annotations"` - Text string `json:"text"` - // Any of "output_text", "refusal", "reasoning_text". - Type string `json:"type"` // This field is from variant // [ResponseObjectStreamResponseContentPartDonePartOutputText]. - Logprobs []map[string]ResponseObjectStreamResponseContentPartDonePartOutputTextLogprobUnion `json:"logprobs"` + Logprobs []map[string]any `json:"logprobs"` + // Any of "output_text", "refusal", "reasoning_text". + Type string `json:"type"` // This field is from variant // [ResponseObjectStreamResponseContentPartDonePartRefusal]. Refusal string `json:"refusal"` JSON struct { - Annotations respjson.Field Text respjson.Field - Type respjson.Field + Annotations respjson.Field Logprobs respjson.Field + Type respjson.Field Refusal respjson.Field raw string } `json:"-"` @@ -5178,20 +5317,17 @@ func (r *ResponseObjectStreamResponseContentPartDonePartUnion) UnmarshalJSON(dat // Text content within a streamed response part. type ResponseObjectStreamResponseContentPartDonePartOutputText struct { - // Structured annotations associated with the text - Annotations []ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion `json:"annotations,required"` - // Text emitted for this content part - Text string `json:"text,required"` - // Content part type identifier, always "output_text" - Type constant.OutputText `json:"type,required"` - // (Optional) Token log probability details - Logprobs []map[string]ResponseObjectStreamResponseContentPartDonePartOutputTextLogprobUnion `json:"logprobs"` + Text string `json:"text,required"` + Annotations []ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion `json:"annotations"` + Logprobs []map[string]any `json:"logprobs,nullable"` + // Any of "output_text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Annotations respjson.Field Text respjson.Field - Type respjson.Field + Annotations respjson.Field Logprobs respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -5321,14 +5457,11 @@ func (r *ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnio // File citation annotation for referencing specific files in response content. type ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationFileCitation struct { - // Unique identifier of the referenced file - FileID string `json:"file_id,required"` - // Name of the referenced file + FileID string `json:"file_id,required"` Filename string `json:"filename,required"` - // Position index of the citation within the content - Index int64 `json:"index,required"` - // Annotation type identifier, always "file_citation" - Type constant.FileCitation `json:"type,required"` + Index int64 `json:"index,required"` + // Any of "file_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { FileID respjson.Field @@ -5350,23 +5483,19 @@ func (r *ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationFile // URL citation annotation for referencing external web resources. type ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationURLCitation struct { - // End position of the citation span in the content - EndIndex int64 `json:"end_index,required"` - // Start position of the citation span in the content - StartIndex int64 `json:"start_index,required"` - // Title of the referenced web resource - Title string `json:"title,required"` - // Annotation type identifier, always "url_citation" - Type constant.URLCitation `json:"type,required"` - // URL of the referenced web resource - URL string `json:"url,required"` + EndIndex int64 `json:"end_index,required"` + StartIndex int64 `json:"start_index,required"` + Title string `json:"title,required"` + URL string `json:"url,required"` + // Any of "url_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { EndIndex respjson.Field StartIndex respjson.Field Title respjson.Field - Type respjson.Field URL respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -5381,12 +5510,13 @@ func (r *ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationURLC } type ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationContainerFileCitation struct { - ContainerID string `json:"container_id,required"` - EndIndex int64 `json:"end_index,required"` - FileID string `json:"file_id,required"` - Filename string `json:"filename,required"` - StartIndex int64 `json:"start_index,required"` - Type constant.ContainerFileCitation `json:"type,required"` + ContainerID string `json:"container_id,required"` + EndIndex int64 `json:"end_index,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + StartIndex int64 `json:"start_index,required"` + // Any of "container_file_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ContainerID respjson.Field @@ -5409,9 +5539,10 @@ func (r *ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationCont } type ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationFilePath struct { - FileID string `json:"file_id,required"` - Index int64 `json:"index,required"` - Type constant.FilePath `json:"type,required"` + FileID string `json:"file_id,required"` + Index int64 `json:"index,required"` + // Any of "file_path". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { FileID respjson.Field @@ -5426,70 +5557,15 @@ type ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationFilePath func (r ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationFilePath) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationFilePath) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ResponseObjectStreamResponseContentPartDonePartOutputTextLogprobUnion contains -// all possible properties and values from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ResponseObjectStreamResponseContentPartDonePartOutputTextLogprobUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ResponseObjectStreamResponseContentPartDonePartOutputTextLogprobUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectStreamResponseContentPartDonePartOutputTextLogprobUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectStreamResponseContentPartDonePartOutputTextLogprobUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectStreamResponseContentPartDonePartOutputTextLogprobUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ResponseObjectStreamResponseContentPartDonePartOutputTextLogprobUnion) RawJSON() string { - return u.JSON.raw -} - -func (r *ResponseObjectStreamResponseContentPartDonePartOutputTextLogprobUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationFilePath) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Refusal content within a streamed response part. type ResponseObjectStreamResponseContentPartDonePartRefusal struct { - // Refusal text supplied by the model Refusal string `json:"refusal,required"` - // Content part type identifier, always "refusal" - Type constant.Refusal `json:"type,required"` + // Any of "refusal". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Refusal respjson.Field @@ -5507,10 +5583,9 @@ func (r *ResponseObjectStreamResponseContentPartDonePartRefusal) UnmarshalJSON(d // Reasoning text emitted as part of a streamed response. type ResponseObjectStreamResponseContentPartDonePartReasoningText struct { - // Reasoning text supplied by the model Text string `json:"text,required"` - // Content part type identifier, always "reasoning_text" - Type constant.ReasoningText `json:"type,required"` + // Any of "reasoning_text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -5530,18 +5605,13 @@ func (r *ResponseObjectStreamResponseContentPartDonePartReasoningText) Unmarshal // Streaming event for incremental reasoning text updates. type ResponseObjectStreamResponseReasoningTextDelta struct { - // Index position of the reasoning content part - ContentIndex int64 `json:"content_index,required"` - // Incremental reasoning text being added - Delta string `json:"delta,required"` - // Unique identifier of the output item being updated - ItemID string `json:"item_id,required"` - // Index position of the item in the output list - OutputIndex int64 `json:"output_index,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Event type identifier, always "response.reasoning_text.delta" - Type constant.ResponseReasoningTextDelta `json:"type,required"` + ContentIndex int64 `json:"content_index,required"` + Delta string `json:"delta,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.reasoning_text.delta". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ContentIndex respjson.Field @@ -5563,18 +5633,13 @@ func (r *ResponseObjectStreamResponseReasoningTextDelta) UnmarshalJSON(data []by // Streaming event for when reasoning text is completed. type ResponseObjectStreamResponseReasoningTextDone struct { - // Index position of the reasoning content part - ContentIndex int64 `json:"content_index,required"` - // Unique identifier of the completed output item - ItemID string `json:"item_id,required"` - // Index position of the item in the output list - OutputIndex int64 `json:"output_index,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Final complete reasoning text - Text string `json:"text,required"` - // Event type identifier, always "response.reasoning_text.done" - Type constant.ResponseReasoningTextDone `json:"type,required"` + ContentIndex int64 `json:"content_index,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + SequenceNumber int64 `json:"sequence_number,required"` + Text string `json:"text,required"` + // Any of "response.reasoning_text.done". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ContentIndex respjson.Field @@ -5596,18 +5661,14 @@ func (r *ResponseObjectStreamResponseReasoningTextDone) UnmarshalJSON(data []byt // Streaming event for when a new reasoning summary part is added. type ResponseObjectStreamResponseReasoningSummaryPartAdded struct { - // Unique identifier of the output item - ItemID string `json:"item_id,required"` - // Index position of the output item - OutputIndex int64 `json:"output_index,required"` - // The summary part that was added - Part ResponseObjectStreamResponseReasoningSummaryPartAddedPart `json:"part,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Index of the summary part within the reasoning summary - SummaryIndex int64 `json:"summary_index,required"` - // Event type identifier, always "response.reasoning_summary_part.added" - Type constant.ResponseReasoningSummaryPartAdded `json:"type,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + // Reasoning summary part in a streamed response. + Part ResponseObjectStreamResponseReasoningSummaryPartAddedPart `json:"part,required"` + SequenceNumber int64 `json:"sequence_number,required"` + SummaryIndex int64 `json:"summary_index,required"` + // Any of "response.reasoning_summary_part.added". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ItemID respjson.Field @@ -5627,12 +5688,11 @@ func (r *ResponseObjectStreamResponseReasoningSummaryPartAdded) UnmarshalJSON(da return apijson.UnmarshalRoot(data, r) } -// The summary part that was added +// Reasoning summary part in a streamed response. type ResponseObjectStreamResponseReasoningSummaryPartAddedPart struct { - // Summary text Text string `json:"text,required"` - // Content part type identifier, always "summary_text" - Type constant.SummaryText `json:"type,required"` + // Any of "summary_text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -5652,18 +5712,14 @@ func (r *ResponseObjectStreamResponseReasoningSummaryPartAddedPart) UnmarshalJSO // Streaming event for when a reasoning summary part is completed. type ResponseObjectStreamResponseReasoningSummaryPartDone struct { - // Unique identifier of the output item - ItemID string `json:"item_id,required"` - // Index position of the output item - OutputIndex int64 `json:"output_index,required"` - // The completed summary part - Part ResponseObjectStreamResponseReasoningSummaryPartDonePart `json:"part,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Index of the summary part within the reasoning summary - SummaryIndex int64 `json:"summary_index,required"` - // Event type identifier, always "response.reasoning_summary_part.done" - Type constant.ResponseReasoningSummaryPartDone `json:"type,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + // Reasoning summary part in a streamed response. + Part ResponseObjectStreamResponseReasoningSummaryPartDonePart `json:"part,required"` + SequenceNumber int64 `json:"sequence_number,required"` + SummaryIndex int64 `json:"summary_index,required"` + // Any of "response.reasoning_summary_part.done". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ItemID respjson.Field @@ -5683,12 +5739,11 @@ func (r *ResponseObjectStreamResponseReasoningSummaryPartDone) UnmarshalJSON(dat return apijson.UnmarshalRoot(data, r) } -// The completed summary part +// Reasoning summary part in a streamed response. type ResponseObjectStreamResponseReasoningSummaryPartDonePart struct { - // Summary text Text string `json:"text,required"` - // Content part type identifier, always "summary_text" - Type constant.SummaryText `json:"type,required"` + // Any of "summary_text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -5706,18 +5761,13 @@ func (r *ResponseObjectStreamResponseReasoningSummaryPartDonePart) UnmarshalJSON // Streaming event for incremental reasoning summary text updates. type ResponseObjectStreamResponseReasoningSummaryTextDelta struct { - // Incremental summary text being added - Delta string `json:"delta,required"` - // Unique identifier of the output item - ItemID string `json:"item_id,required"` - // Index position of the output item - OutputIndex int64 `json:"output_index,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Index of the summary part within the reasoning summary - SummaryIndex int64 `json:"summary_index,required"` - // Event type identifier, always "response.reasoning_summary_text.delta" - Type constant.ResponseReasoningSummaryTextDelta `json:"type,required"` + Delta string `json:"delta,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + SequenceNumber int64 `json:"sequence_number,required"` + SummaryIndex int64 `json:"summary_index,required"` + // Any of "response.reasoning_summary_text.delta". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Delta respjson.Field @@ -5739,18 +5789,13 @@ func (r *ResponseObjectStreamResponseReasoningSummaryTextDelta) UnmarshalJSON(da // Streaming event for when reasoning summary text is completed. type ResponseObjectStreamResponseReasoningSummaryTextDone struct { - // Unique identifier of the output item - ItemID string `json:"item_id,required"` - // Index position of the output item - OutputIndex int64 `json:"output_index,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Index of the summary part within the reasoning summary - SummaryIndex int64 `json:"summary_index,required"` - // Final complete summary text - Text string `json:"text,required"` - // Event type identifier, always "response.reasoning_summary_text.done" - Type constant.ResponseReasoningSummaryTextDone `json:"type,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + SequenceNumber int64 `json:"sequence_number,required"` + SummaryIndex int64 `json:"summary_index,required"` + Text string `json:"text,required"` + // Any of "response.reasoning_summary_text.done". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ItemID respjson.Field @@ -5772,18 +5817,13 @@ func (r *ResponseObjectStreamResponseReasoningSummaryTextDone) UnmarshalJSON(dat // Streaming event for incremental refusal text updates. type ResponseObjectStreamResponseRefusalDelta struct { - // Index position of the content part - ContentIndex int64 `json:"content_index,required"` - // Incremental refusal text being added - Delta string `json:"delta,required"` - // Unique identifier of the output item - ItemID string `json:"item_id,required"` - // Index position of the item in the output list - OutputIndex int64 `json:"output_index,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Event type identifier, always "response.refusal.delta" - Type constant.ResponseRefusalDelta `json:"type,required"` + ContentIndex int64 `json:"content_index,required"` + Delta string `json:"delta,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.refusal.delta". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ContentIndex respjson.Field @@ -5805,18 +5845,13 @@ func (r *ResponseObjectStreamResponseRefusalDelta) UnmarshalJSON(data []byte) er // Streaming event for when refusal text is completed. type ResponseObjectStreamResponseRefusalDone struct { - // Index position of the content part - ContentIndex int64 `json:"content_index,required"` - // Unique identifier of the output item - ItemID string `json:"item_id,required"` - // Index position of the item in the output list - OutputIndex int64 `json:"output_index,required"` - // Final complete refusal text - Refusal string `json:"refusal,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Event type identifier, always "response.refusal.done" - Type constant.ResponseRefusalDone `json:"type,required"` + ContentIndex int64 `json:"content_index,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + Refusal string `json:"refusal,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.refusal.done". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ContentIndex respjson.Field @@ -5838,20 +5873,15 @@ func (r *ResponseObjectStreamResponseRefusalDone) UnmarshalJSON(data []byte) err // Streaming event for when an annotation is added to output text. type ResponseObjectStreamResponseOutputTextAnnotationAdded struct { - // The annotation object being added - Annotation ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationUnion `json:"annotation,required"` - // Index of the annotation within the content part - AnnotationIndex int64 `json:"annotation_index,required"` - // Index position of the content part within the output item - ContentIndex int64 `json:"content_index,required"` - // Unique identifier of the item to which the annotation is being added - ItemID string `json:"item_id,required"` - // Index position of the output item in the response's output array - OutputIndex int64 `json:"output_index,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Event type identifier, always "response.output_text.annotation.added" - Type constant.ResponseOutputTextAnnotationAdded `json:"type,required"` + // File citation annotation for referencing specific files in response content. + Annotation ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationUnion `json:"annotation,required"` + AnnotationIndex int64 `json:"annotation_index,required"` + ContentIndex int64 `json:"content_index,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.output_text.annotation.added". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Annotation respjson.Field @@ -5988,14 +6018,11 @@ func (r *ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationUnion) U // File citation annotation for referencing specific files in response content. type ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationFileCitation struct { - // Unique identifier of the referenced file - FileID string `json:"file_id,required"` - // Name of the referenced file + FileID string `json:"file_id,required"` Filename string `json:"filename,required"` - // Position index of the citation within the content - Index int64 `json:"index,required"` - // Annotation type identifier, always "file_citation" - Type constant.FileCitation `json:"type,required"` + Index int64 `json:"index,required"` + // Any of "file_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { FileID respjson.Field @@ -6017,23 +6044,19 @@ func (r *ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationFileCita // URL citation annotation for referencing external web resources. type ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationURLCitation struct { - // End position of the citation span in the content - EndIndex int64 `json:"end_index,required"` - // Start position of the citation span in the content - StartIndex int64 `json:"start_index,required"` - // Title of the referenced web resource - Title string `json:"title,required"` - // Annotation type identifier, always "url_citation" - Type constant.URLCitation `json:"type,required"` - // URL of the referenced web resource - URL string `json:"url,required"` + EndIndex int64 `json:"end_index,required"` + StartIndex int64 `json:"start_index,required"` + Title string `json:"title,required"` + URL string `json:"url,required"` + // Any of "url_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { EndIndex respjson.Field StartIndex respjson.Field Title respjson.Field - Type respjson.Field URL respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -6048,12 +6071,13 @@ func (r *ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationURLCitat } type ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationContainerFileCitation struct { - ContainerID string `json:"container_id,required"` - EndIndex int64 `json:"end_index,required"` - FileID string `json:"file_id,required"` - Filename string `json:"filename,required"` - StartIndex int64 `json:"start_index,required"` - Type constant.ContainerFileCitation `json:"type,required"` + ContainerID string `json:"container_id,required"` + EndIndex int64 `json:"end_index,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + StartIndex int64 `json:"start_index,required"` + // Any of "container_file_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ContainerID respjson.Field @@ -6076,9 +6100,10 @@ func (r *ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationContaine } type ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationFilePath struct { - FileID string `json:"file_id,required"` - Index int64 `json:"index,required"` - Type constant.FilePath `json:"type,required"` + FileID string `json:"file_id,required"` + Index int64 `json:"index,required"` + // Any of "file_path". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { FileID respjson.Field @@ -6099,14 +6124,11 @@ func (r *ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationFilePath // Streaming event for file search calls in progress. type ResponseObjectStreamResponseFileSearchCallInProgress struct { - // Unique identifier of the file search call - ItemID string `json:"item_id,required"` - // Index position of the item in the output list - OutputIndex int64 `json:"output_index,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Event type identifier, always "response.file_search_call.in_progress" - Type constant.ResponseFileSearchCallInProgress `json:"type,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.file_search_call.in_progress". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ItemID respjson.Field @@ -6126,14 +6148,11 @@ func (r *ResponseObjectStreamResponseFileSearchCallInProgress) UnmarshalJSON(dat // Streaming event for file search currently searching. type ResponseObjectStreamResponseFileSearchCallSearching struct { - // Unique identifier of the file search call - ItemID string `json:"item_id,required"` - // Index position of the item in the output list - OutputIndex int64 `json:"output_index,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Event type identifier, always "response.file_search_call.searching" - Type constant.ResponseFileSearchCallSearching `json:"type,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.file_search_call.searching". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ItemID respjson.Field @@ -6153,14 +6172,11 @@ func (r *ResponseObjectStreamResponseFileSearchCallSearching) UnmarshalJSON(data // Streaming event for completed file search calls. type ResponseObjectStreamResponseFileSearchCallCompleted struct { - // Unique identifier of the completed file search call - ItemID string `json:"item_id,required"` - // Index position of the item in the output list - OutputIndex int64 `json:"output_index,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Event type identifier, always "response.file_search_call.completed" - Type constant.ResponseFileSearchCallCompleted `json:"type,required"` + ItemID string `json:"item_id,required"` + OutputIndex int64 `json:"output_index,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.file_search_call.completed". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ItemID respjson.Field @@ -6180,12 +6196,11 @@ func (r *ResponseObjectStreamResponseFileSearchCallCompleted) UnmarshalJSON(data // Streaming event emitted when a response ends in an incomplete state. type ResponseObjectStreamResponseIncomplete struct { - // Response object describing the incomplete state - Response ResponseObject `json:"response,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Event type identifier, always "response.incomplete" - Type constant.ResponseIncomplete `json:"type,required"` + // Complete OpenAI response object containing generation results and metadata. + Response ResponseObject `json:"response,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.incomplete". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Response respjson.Field @@ -6204,12 +6219,11 @@ func (r *ResponseObjectStreamResponseIncomplete) UnmarshalJSON(data []byte) erro // Streaming event emitted when a response fails. type ResponseObjectStreamResponseFailed struct { - // Response object describing the failure - Response ResponseObject `json:"response,required"` - // Sequential number for ordering streaming events - SequenceNumber int64 `json:"sequence_number,required"` - // Event type identifier, always "response.failed" - Type constant.ResponseFailed `json:"type,required"` + // Complete OpenAI response object containing generation results and metadata. + Response ResponseObject `json:"response,required"` + SequenceNumber int64 `json:"sequence_number,required"` + // Any of "response.failed". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Response respjson.Field @@ -6228,10 +6242,10 @@ func (r *ResponseObjectStreamResponseFailed) UnmarshalJSON(data []byte) error { // Streaming event indicating a response has been completed. type ResponseObjectStreamResponseCompleted struct { - // Completed response object + // Complete OpenAI response object containing generation results and metadata. Response ResponseObject `json:"response,required"` - // Event type identifier, always "response.completed" - Type constant.ResponseCompleted `json:"type,required"` + // Any of "response.completed". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Response respjson.Field @@ -6249,62 +6263,47 @@ func (r *ResponseObjectStreamResponseCompleted) UnmarshalJSON(data []byte) error // OpenAI response object extended with input context information. type ResponseListResponse struct { - // Unique identifier for this response - ID string `json:"id,required"` - // Unix timestamp when the response was created - CreatedAt int64 `json:"created_at,required"` - // List of input items that led to this response - Input []ResponseListResponseInputUnion `json:"input,required"` - // Model identifier used for generation - Model string `json:"model,required"` - // Object type identifier, always "response" - Object constant.Response `json:"object,required"` - // List of generated output items (messages, tool calls, etc.) - Output []ResponseListResponseOutputUnion `json:"output,required"` - // Whether tool calls can be executed in parallel - ParallelToolCalls bool `json:"parallel_tool_calls,required"` - // Current status of the response generation - Status string `json:"status,required"` - // Text formatting configuration for the response - Text ResponseListResponseText `json:"text,required"` - // (Optional) Error details if the response generation failed - Error ResponseListResponseError `json:"error"` - // (Optional) System message inserted into the model's context - Instructions string `json:"instructions"` - // (Optional) Max number of total calls to built-in tools that can be processed in - // a response - MaxToolCalls int64 `json:"max_tool_calls"` - // (Optional) ID of the previous response in a conversation - PreviousResponseID string `json:"previous_response_id"` - // (Optional) Reference to a prompt template and its variables. - Prompt ResponseListResponsePrompt `json:"prompt"` - // (Optional) Sampling temperature used for generation - Temperature float64 `json:"temperature"` - // (Optional) An array of tools the model may call while generating a response. - Tools []ResponseListResponseToolUnion `json:"tools"` - // (Optional) Nucleus sampling parameter used for generation - TopP float64 `json:"top_p"` - // (Optional) Truncation strategy applied to the response - Truncation string `json:"truncation"` - // (Optional) Token usage information for the response - Usage ResponseListResponseUsage `json:"usage"` + ID string `json:"id,required"` + CreatedAt int64 `json:"created_at,required"` + Input []ResponseListResponseInputUnion `json:"input,required"` + Model string `json:"model,required"` + Output []ResponseListResponseOutputUnion `json:"output,required"` + Status string `json:"status,required"` + // Error details for failed OpenAI response requests. + Error ResponseListResponseError `json:"error,nullable"` + Instructions string `json:"instructions,nullable"` + MaxToolCalls int64 `json:"max_tool_calls,nullable"` + // Any of "response". + Object ResponseListResponseObject `json:"object"` + ParallelToolCalls bool `json:"parallel_tool_calls"` + PreviousResponseID string `json:"previous_response_id,nullable"` + // OpenAI compatible Prompt object that is used in OpenAI responses. + Prompt ResponseListResponsePrompt `json:"prompt,nullable"` + Temperature float64 `json:"temperature,nullable"` + // Text response configuration for OpenAI responses. + Text ResponseListResponseText `json:"text"` + Tools []ResponseListResponseToolUnion `json:"tools,nullable"` + TopP float64 `json:"top_p,nullable"` + Truncation string `json:"truncation,nullable"` + // Usage information for OpenAI response. + Usage ResponseListResponseUsage `json:"usage,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field CreatedAt respjson.Field Input respjson.Field Model respjson.Field - Object respjson.Field Output respjson.Field - ParallelToolCalls respjson.Field Status respjson.Field - Text respjson.Field Error respjson.Field Instructions respjson.Field MaxToolCalls respjson.Field + Object respjson.Field + ParallelToolCalls respjson.Field PreviousResponseID respjson.Field Prompt respjson.Field Temperature respjson.Field + Text respjson.Field Tools respjson.Field TopP respjson.Field Truncation respjson.Field @@ -6321,7 +6320,7 @@ func (r *ResponseListResponse) UnmarshalJSON(data []byte) error { } // ResponseListResponseInputUnion contains all possible properties and values from -// [ResponseListResponseInputOpenAIResponseMessage], +// [ResponseListResponseInputOpenAIResponseMessageOutput], // [ResponseListResponseInputOpenAIResponseOutputMessageWebSearchToolCall], // [ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCall], // [ResponseListResponseInputOpenAIResponseOutputMessageFunctionToolCall], @@ -6330,17 +6329,19 @@ func (r *ResponseListResponse) UnmarshalJSON(data []byte) error { // [ResponseListResponseInputOpenAIResponseMcpApprovalRequest], // [ResponseListResponseInputOpenAIResponseInputFunctionToolCallOutput], // [ResponseListResponseInputOpenAIResponseMcpApprovalResponse], -// [ResponseListResponseInputOpenAIResponseMessage]. +// [ResponseListResponseInputOpenAIResponseMessageOutput]. // // Use the methods beginning with 'As' to cast the union to one of its variants. type ResponseListResponseInputUnion struct { - // This field is from variant [ResponseListResponseInputOpenAIResponseMessage]. - Content ResponseListResponseInputOpenAIResponseMessageContentUnion `json:"content"` - // This field is from variant [ResponseListResponseInputOpenAIResponseMessage]. - Role ResponseListResponseInputOpenAIResponseMessageRole `json:"role"` - Type string `json:"type"` - ID string `json:"id"` - Status string `json:"status"` + // This field is from variant + // [ResponseListResponseInputOpenAIResponseMessageOutput]. + Content ResponseListResponseInputOpenAIResponseMessageOutputContentUnion `json:"content"` + // This field is from variant + // [ResponseListResponseInputOpenAIResponseMessageOutput]. + Role string `json:"role"` + ID string `json:"id"` + Status string `json:"status"` + Type string `json:"type"` // This field is from variant // [ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCall]. Queries []string `json:"queries"` @@ -6370,9 +6371,9 @@ type ResponseListResponseInputUnion struct { JSON struct { Content respjson.Field Role respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field Queries respjson.Field Results respjson.Field Arguments respjson.Field @@ -6389,7 +6390,7 @@ type ResponseListResponseInputUnion struct { } `json:"-"` } -func (u ResponseListResponseInputUnion) AsOpenAIResponseMessage() (v ResponseListResponseInputOpenAIResponseMessage) { +func (u ResponseListResponseInputUnion) AsOpenAIResponseMessageOutput() (v ResponseListResponseInputOpenAIResponseMessageOutput) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -6434,7 +6435,7 @@ func (u ResponseListResponseInputUnion) AsOpenAIResponseMcpApprovalResponse() (v return } -func (u ResponseListResponseInputUnion) AsResponseListResponseInputOpenAIResponseMessage() (v ResponseListResponseInputOpenAIResponseMessage) { +func (u ResponseListResponseInputUnion) AsResponseListResponseInputOpenAIResponseMessageOutput() (v ResponseListResponseInputOpenAIResponseMessageOutput) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -6449,194 +6450,501 @@ func (r *ResponseListResponseInputUnion) UnmarshalJSON(data []byte) error { // Corresponds to the various Message types in the Responses API. They are all // under one type because the Responses API gives them all the same "type" value, // and there is no way to tell them apart in certain scenarios. -type ResponseListResponseInputOpenAIResponseMessage struct { - Content ResponseListResponseInputOpenAIResponseMessageContentUnion `json:"content,required"` +type ResponseListResponseInputOpenAIResponseMessageOutput struct { + Content ResponseListResponseInputOpenAIResponseMessageOutputContentUnion `json:"content,required"` // Any of "system", "developer", "user", "assistant". - Role ResponseListResponseInputOpenAIResponseMessageRole `json:"role,required"` - Type constant.Message `json:"type,required"` - ID string `json:"id"` - Status string `json:"status"` + Role string `json:"role,required"` + ID string `json:"id,nullable"` + Status string `json:"status,nullable"` + // Any of "message". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field Role respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseListResponseInputOpenAIResponseMessage) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseInputOpenAIResponseMessage) UnmarshalJSON(data []byte) error { +func (r ResponseListResponseInputOpenAIResponseMessageOutput) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponseInputOpenAIResponseMessageOutput) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseListResponseInputOpenAIResponseMessageContentUnion contains all possible -// properties and values from [string], -// [[]ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion], -// [[]ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion]. +// ResponseListResponseInputOpenAIResponseMessageOutputContentUnion contains all +// possible properties and values from [string], +// [[]ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion], +// [[]ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString OfVariant2] -type ResponseListResponseInputOpenAIResponseMessageContentUnion struct { +// will be valid: OfString +// OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile +// OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal] +type ResponseListResponseInputOpenAIResponseMessageOutputContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion] instead - // of an object. - OfVariant2 []ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion `json:",inline"` - JSON struct { - OfString respjson.Field - OfVariant2 respjson.Field - raw string + // [[]ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion] + // instead of an object. + OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile []ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion `json:",inline"` + // This field will be present if the value is a + // [[]ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion] + // instead of an object. + OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal []ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile respjson.Field + OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal respjson.Field + raw string + } `json:"-"` +} + +func (u ResponseListResponseInputOpenAIResponseMessageOutputContentUnion) AsString() (v string) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseInputOpenAIResponseMessageOutputContentUnion) AsListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile() (v []ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseInputOpenAIResponseMessageOutputContentUnion) AsListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal() (v []ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ResponseListResponseInputOpenAIResponseMessageOutputContentUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *ResponseListResponseInputOpenAIResponseMessageOutputContentUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion +// contains all possible properties and values from +// [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText], +// [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage], +// [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. +// +// Use the +// [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny] +// method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion struct { + // This field is from variant + // [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText]. + Text string `json:"text"` + // Any of "input_text", "input_image", "input_file". + Type string `json:"type"` + // This field is from variant + // [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]. + Detail string `json:"detail"` + FileID string `json:"file_id"` + // This field is from variant + // [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]. + ImageURL string `json:"image_url"` + // This field is from variant + // [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. + FileData string `json:"file_data"` + // This field is from variant + // [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. + FileURL string `json:"file_url"` + // This field is from variant + // [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. + Filename string `json:"filename"` + JSON struct { + Text respjson.Field + Type respjson.Field + Detail respjson.Field + FileID respjson.Field + ImageURL respjson.Field + FileData respjson.Field + FileURL respjson.Field + Filename respjson.Field + raw string } `json:"-"` } -func (u ResponseListResponseInputOpenAIResponseMessageContentUnion) AsString() (v string) { +// anyResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem +// is implemented by each variant of +// [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion] +// to add type safety for the return type of +// [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny] +type anyResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem interface { + implResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() +} + +func (ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) implResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { +} +func (ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) implResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { +} +func (ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) implResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny().(type) { +// case llamastackclient.ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText: +// case llamastackclient.ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage: +// case llamastackclient.ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile: +// default: +// fmt.Errorf("no variant present") +// } +func (u ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsAny() anyResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem { + switch u.Type { + case "input_text": + return u.AsInputText() + case "input_image": + return u.AsInputImage() + case "input_file": + return u.AsInputFile() + } + return nil +} + +func (u ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputText() (v ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputImage() (v ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputFile() (v ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseInputOpenAIResponseMessageContentUnion) AsResponseListResponseInputOpenAIResponseMessageContentArray() (v []ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion) { +// Returns the unmodified JSON received from the API +func (u ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Text content for input messages in OpenAI response format. +type ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText struct { + Text string `json:"text,required"` + // Any of "input_text". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Text respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Image content for input messages in OpenAI response format. +type ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage struct { + // Any of "low", "high", "auto". + Detail string `json:"detail"` + FileID string `json:"file_id,nullable"` + ImageURL string `json:"image_url,nullable"` + // Any of "input_image". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Detail respjson.Field + FileID respjson.Field + ImageURL respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// File content for input messages in OpenAI response format. +type ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile struct { + FileData string `json:"file_data,nullable"` + FileID string `json:"file_id,nullable"` + FileURL string `json:"file_url,nullable"` + Filename string `json:"filename,nullable"` + // Any of "input_file". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + FileData respjson.Field + FileID respjson.Field + FileURL respjson.Field + Filename respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion +// contains all possible properties and values from +// [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText], +// [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]. +// +// Use the +// [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny] +// method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion struct { + // This field is from variant + // [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]. + Text string `json:"text"` + // This field is from variant + // [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]. + Annotations []ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion `json:"annotations"` + // Any of "output_text", "refusal". + Type string `json:"type"` + // This field is from variant + // [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]. + Refusal string `json:"refusal"` + JSON struct { + Text respjson.Field + Annotations respjson.Field + Type respjson.Field + Refusal respjson.Field + raw string + } `json:"-"` +} + +// anyResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem +// is implemented by each variant of +// [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion] +// to add type safety for the return type of +// [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny] +type anyResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem interface { + implResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() +} + +func (ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) implResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() { +} +func (ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) implResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny().(type) { +// case llamastackclient.ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText: +// case llamastackclient.ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal: +// default: +// fmt.Errorf("no variant present") +// } +func (u ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsAny() anyResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem { + switch u.Type { + case "output_text": + return u.AsOutputText() + case "refusal": + return u.AsRefusal() + } + return nil +} + +func (u ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsOutputText() (v ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseInputOpenAIResponseMessageContentUnion) AsVariant2() (v []ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion) { +func (u ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsRefusal() (v ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ResponseListResponseInputOpenAIResponseMessageContentUnion) RawJSON() string { +func (u ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) RawJSON() string { return u.JSON.raw } -func (r *ResponseListResponseInputOpenAIResponseMessageContentUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText struct { + Text string `json:"text,required"` + Annotations []ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion `json:"annotations"` + // Any of "output_text". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Text respjson.Field + Annotations respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion contains all -// possible properties and values from -// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText], -// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage], -// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputFile]. +// ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion +// contains all possible properties and values from +// [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation], +// [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation], +// [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation], +// [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath]. // // Use the -// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion.AsAny] +// [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny] // method to switch on the variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion struct { - // This field is from variant - // [ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText]. - Text string `json:"text"` - // Any of "input_text", "input_image", "input_file". - Type string `json:"type"` - // This field is from variant - // [ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage]. - Detail ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImageDetail `json:"detail"` - FileID string `json:"file_id"` - // This field is from variant - // [ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage]. - ImageURL string `json:"image_url"` +type ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion struct { + FileID string `json:"file_id"` + Filename string `json:"filename"` + Index int64 `json:"index"` + // Any of "file_citation", "url_citation", "container_file_citation", "file_path". + Type string `json:"type"` + EndIndex int64 `json:"end_index"` + StartIndex int64 `json:"start_index"` // This field is from variant - // [ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputFile]. - FileData string `json:"file_data"` + // [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]. + Title string `json:"title"` // This field is from variant - // [ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputFile]. - FileURL string `json:"file_url"` + // [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]. + URL string `json:"url"` // This field is from variant - // [ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputFile]. - Filename string `json:"filename"` - JSON struct { - Text respjson.Field - Type respjson.Field - Detail respjson.Field - FileID respjson.Field - ImageURL respjson.Field - FileData respjson.Field - FileURL respjson.Field - Filename respjson.Field - raw string + // [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation]. + ContainerID string `json:"container_id"` + JSON struct { + FileID respjson.Field + Filename respjson.Field + Index respjson.Field + Type respjson.Field + EndIndex respjson.Field + StartIndex respjson.Field + Title respjson.Field + URL respjson.Field + ContainerID respjson.Field + raw string } `json:"-"` } -// anyResponseListResponseInputOpenAIResponseMessageContentArrayItem is implemented -// by each variant of -// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion] to add -// type safety for the return type of -// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion.AsAny] -type anyResponseListResponseInputOpenAIResponseMessageContentArrayItem interface { - implResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion() +// anyResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation +// is implemented by each variant of +// [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion] +// to add type safety for the return type of +// [ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny] +type anyResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation interface { + implResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() } -func (ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText) implResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion() { +func (ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) implResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { } -func (ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage) implResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion() { +func (ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) implResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { } -func (ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputFile) implResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion() { +func (ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) implResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} +func (ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) implResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { } // Use the following switch statement to find the correct variant // -// switch variant := ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion.AsAny().(type) { -// case llamastackclient.ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText: -// case llamastackclient.ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage: -// case llamastackclient.ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputFile: +// switch variant := ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny().(type) { +// case llamastackclient.ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation: +// case llamastackclient.ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation: +// case llamastackclient.ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation: +// case llamastackclient.ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath: // default: // fmt.Errorf("no variant present") // } -func (u ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion) AsAny() anyResponseListResponseInputOpenAIResponseMessageContentArrayItem { +func (u ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsAny() anyResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation { switch u.Type { - case "input_text": - return u.AsInputText() - case "input_image": - return u.AsInputImage() - case "input_file": - return u.AsInputFile() + case "file_citation": + return u.AsFileCitation() + case "url_citation": + return u.AsURLCitation() + case "container_file_citation": + return u.AsContainerFileCitation() + case "file_path": + return u.AsFilePath() } return nil } -func (u ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion) AsInputText() (v ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText) { +func (u ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsFileCitation() (v ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsURLCitation() (v ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion) AsInputImage() (v ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage) { +func (u ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsContainerFileCitation() (v ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion) AsInputFile() (v ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputFile) { +func (u ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsFilePath() (v ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion) RawJSON() string { +func (u ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) RawJSON() string { return u.JSON.raw } -func (r *ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Text content for input messages in OpenAI response format. -type ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText struct { - // The text content of the input message - Text string `json:"text,required"` - // Content type identifier, always "input_text" - Type constant.InputText `json:"type,required"` +// File citation annotation for referencing specific files in response content. +type ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation struct { + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Index int64 `json:"index,required"` + // Any of "file_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Text respjson.Field + FileID respjson.Field + Filename respjson.Field + Index respjson.Field Type respjson.Field ExtraFields map[string]respjson.Field raw string @@ -6644,111 +6952,121 @@ type ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText str } // Returns the unmodified JSON received from the API -func (r ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText) RawJSON() string { +func (r ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText) UnmarshalJSON(data []byte) error { +func (r *ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Image content for input messages in OpenAI response format. -type ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage struct { - // Level of detail for image processing, can be "low", "high", or "auto" - // - // Any of "low", "high", "auto". - Detail ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImageDetail `json:"detail,required"` - // Content type identifier, always "input_image" - Type constant.InputImage `json:"type,required"` - // (Optional) The ID of the file to be sent to the model. - FileID string `json:"file_id"` - // (Optional) URL of the image content - ImageURL string `json:"image_url"` +// URL citation annotation for referencing external web resources. +type ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation struct { + EndIndex int64 `json:"end_index,required"` + StartIndex int64 `json:"start_index,required"` + Title string `json:"title,required"` + URL string `json:"url,required"` + // Any of "url_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Detail respjson.Field + EndIndex respjson.Field + StartIndex respjson.Field + Title respjson.Field + URL respjson.Field Type respjson.Field - FileID respjson.Field - ImageURL respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage) RawJSON() string { +func (r ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage) UnmarshalJSON(data []byte) error { +func (r *ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImageDetail string - -const ( - ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImageDetailLow ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImageDetail = "low" - ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImageDetailHigh ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImageDetail = "high" - ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImageDetailAuto ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImageDetail = "auto" -) - -// File content for input messages in OpenAI response format. -type ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputFile struct { - // The type of the input item. Always `input_file`. - Type constant.InputFile `json:"type,required"` - // The data of the file to be sent to the model. - FileData string `json:"file_data"` - // (Optional) The ID of the file to be sent to the model. - FileID string `json:"file_id"` - // The URL of the file to be sent to the model. - FileURL string `json:"file_url"` - // The name of the file to be sent to the model. - Filename string `json:"filename"` +type ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation struct { + ContainerID string `json:"container_id,required"` + EndIndex int64 `json:"end_index,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + StartIndex int64 `json:"start_index,required"` + // Any of "container_file_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field - FileData respjson.Field + ContainerID respjson.Field + EndIndex respjson.Field FileID respjson.Field - FileURL respjson.Field Filename respjson.Field + StartIndex respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputFile) RawJSON() string { +func (r ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputFile) UnmarshalJSON(data []byte) error { +func (r *ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ResponseListResponseInputOpenAIResponseMessageContentArrayItemDetail string +type ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath struct { + FileID string `json:"file_id,required"` + Index int64 `json:"index,required"` + // Any of "file_path". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + FileID respjson.Field + Index respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} -const ( - ResponseListResponseInputOpenAIResponseMessageContentArrayItemDetailLow ResponseListResponseInputOpenAIResponseMessageContentArrayItemDetail = "low" - ResponseListResponseInputOpenAIResponseMessageContentArrayItemDetailHigh ResponseListResponseInputOpenAIResponseMessageContentArrayItemDetail = "high" - ResponseListResponseInputOpenAIResponseMessageContentArrayItemDetailAuto ResponseListResponseInputOpenAIResponseMessageContentArrayItemDetail = "auto" -) +// Returns the unmodified JSON received from the API +func (r ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} -type ResponseListResponseInputOpenAIResponseMessageRole string +// Refusal content within a streamed response part. +type ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal struct { + Refusal string `json:"refusal,required"` + // Any of "refusal". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Refusal respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} -const ( - ResponseListResponseInputOpenAIResponseMessageRoleSystem ResponseListResponseInputOpenAIResponseMessageRole = "system" - ResponseListResponseInputOpenAIResponseMessageRoleDeveloper ResponseListResponseInputOpenAIResponseMessageRole = "developer" - ResponseListResponseInputOpenAIResponseMessageRoleUser ResponseListResponseInputOpenAIResponseMessageRole = "user" - ResponseListResponseInputOpenAIResponseMessageRoleAssistant ResponseListResponseInputOpenAIResponseMessageRole = "assistant" -) +// Returns the unmodified JSON received from the API +func (r ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseListResponseInputOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} // Web search tool call output message for OpenAI responses. type ResponseListResponseInputOpenAIResponseOutputMessageWebSearchToolCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // Current status of the web search operation + ID string `json:"id,required"` Status string `json:"status,required"` - // Tool call type identifier, always "web_search_call" - Type constant.WebSearchCall `json:"type,required"` + // Any of "web_search_call". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -6769,23 +7087,19 @@ func (r *ResponseListResponseInputOpenAIResponseOutputMessageWebSearchToolCall) // File search tool call output message for OpenAI responses. type ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // List of search queries executed - Queries []string `json:"queries,required"` - // Current status of the file search operation - Status string `json:"status,required"` - // Tool call type identifier, always "file_search_call" - Type constant.FileSearchCall `json:"type,required"` - // (Optional) Search results returned by the file search operation - Results []ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResult `json:"results"` + ID string `json:"id,required"` + Queries []string `json:"queries,required"` + Status string `json:"status,required"` + Results []ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResult `json:"results,nullable"` + // Any of "file_search_call". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field Queries respjson.Field Status respjson.Field - Type respjson.Field Results respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -6801,16 +7115,11 @@ func (r *ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCall) // Search results returned by the file search operation. type ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResult struct { - // (Optional) Key-value attributes associated with the file - Attributes map[string]ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion `json:"attributes,required"` - // Unique identifier of the file containing the result - FileID string `json:"file_id,required"` - // Name of the file containing the result - Filename string `json:"filename,required"` - // Relevance score for this search result (between 0 and 1) - Score float64 `json:"score,required"` - // Text content of the search result - Text string `json:"text,required"` + Attributes map[string]any `json:"attributes,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Score float64 `json:"score,required"` + Text string `json:"text,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Attributes respjson.Field @@ -6831,83 +7140,23 @@ func (r *ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallR return apijson.UnmarshalRoot(data, r) } -// ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion -// contains all possible properties and values from [bool], [float64], [string], -// [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) RawJSON() string { - return u.JSON.raw -} - -func (r *ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - // Function tool call output message for OpenAI responses. type ResponseListResponseInputOpenAIResponseOutputMessageFunctionToolCall struct { - // JSON string containing the function arguments Arguments string `json:"arguments,required"` - // Unique identifier for the function call - CallID string `json:"call_id,required"` - // Name of the function being called - Name string `json:"name,required"` - // Tool call type identifier, always "function_call" - Type constant.FunctionCall `json:"type,required"` - // (Optional) Additional identifier for the tool call - ID string `json:"id"` - // (Optional) Current status of the function call execution - Status string `json:"status"` + CallID string `json:"call_id,required"` + Name string `json:"name,required"` + ID string `json:"id,nullable"` + Status string `json:"status,nullable"` + // Any of "function_call". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Arguments respjson.Field CallID respjson.Field Name respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -6923,29 +7172,23 @@ func (r *ResponseListResponseInputOpenAIResponseOutputMessageFunctionToolCall) U // Model Context Protocol (MCP) call output message for OpenAI responses. type ResponseListResponseInputOpenAIResponseOutputMessageMcpCall struct { - // Unique identifier for this MCP call - ID string `json:"id,required"` - // JSON string containing the MCP call arguments - Arguments string `json:"arguments,required"` - // Name of the MCP method being called - Name string `json:"name,required"` - // Label identifying the MCP server handling the call + ID string `json:"id,required"` + Arguments string `json:"arguments,required"` + Name string `json:"name,required"` ServerLabel string `json:"server_label,required"` - // Tool call type identifier, always "mcp_call" - Type constant.McpCall `json:"type,required"` - // (Optional) Error message if the MCP call failed - Error string `json:"error"` - // (Optional) Output result from the successful MCP call - Output string `json:"output"` + Error string `json:"error,nullable"` + Output string `json:"output,nullable"` + // Any of "mcp_call". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field Arguments respjson.Field Name respjson.Field ServerLabel respjson.Field - Type respjson.Field Error respjson.Field Output respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -6961,14 +7204,11 @@ func (r *ResponseListResponseInputOpenAIResponseOutputMessageMcpCall) UnmarshalJ // MCP list tools output message containing available tools from an MCP server. type ResponseListResponseInputOpenAIResponseOutputMessageMcpListTools struct { - // Unique identifier for this MCP list tools operation - ID string `json:"id,required"` - // Label identifying the MCP server providing the tools - ServerLabel string `json:"server_label,required"` - // List of available tools provided by the MCP server - Tools []ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsTool `json:"tools,required"` - // Tool call type identifier, always "mcp_list_tools" - Type constant.McpListTools `json:"type,required"` + ID string `json:"id,required"` + ServerLabel string `json:"server_label,required"` + Tools []ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsTool `json:"tools,required"` + // Any of "mcp_list_tools". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -6977,105 +7217,48 @@ type ResponseListResponseInputOpenAIResponseOutputMessageMcpListTools struct { Type respjson.Field ExtraFields map[string]respjson.Field raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ResponseListResponseInputOpenAIResponseOutputMessageMcpListTools) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseListResponseInputOpenAIResponseOutputMessageMcpListTools) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Tool definition returned by MCP list tools operation. -type ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsTool struct { - // JSON schema defining the tool's input parameters - InputSchema map[string]ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion `json:"input_schema,required"` - // Name of the tool - Name string `json:"name,required"` - // (Optional) Description of what the tool does - Description string `json:"description"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - InputSchema respjson.Field - Name respjson.Field - Description respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsTool) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsTool) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion -// contains all possible properties and values from [bool], [float64], [string], -// [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return + } `json:"-"` } -func (u ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Returns the unmodified JSON received from the API +func (r ResponseListResponseInputOpenAIResponseOutputMessageMcpListTools) RawJSON() string { + return r.JSON.raw } - -func (u ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +func (r *ResponseListResponseInputOpenAIResponseOutputMessageMcpListTools) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Tool definition returned by MCP list tools operation. +type ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsTool struct { + InputSchema map[string]any `json:"input_schema,required"` + Name string `json:"name,required"` + Description string `json:"description,nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputSchema respjson.Field + Name respjson.Field + Description respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } // Returns the unmodified JSON received from the API -func (u ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) RawJSON() string { - return u.JSON.raw +func (r ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsTool) RawJSON() string { + return r.JSON.raw } - -func (r *ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsTool) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A request for human approval of a tool invocation. type ResponseListResponseInputOpenAIResponseMcpApprovalRequest struct { - ID string `json:"id,required"` - Arguments string `json:"arguments,required"` - Name string `json:"name,required"` - ServerLabel string `json:"server_label,required"` - Type constant.McpApprovalRequest `json:"type,required"` + ID string `json:"id,required"` + Arguments string `json:"arguments,required"` + Name string `json:"name,required"` + ServerLabel string `json:"server_label,required"` + // Any of "mcp_approval_request". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -7099,18 +7282,19 @@ func (r *ResponseListResponseInputOpenAIResponseMcpApprovalRequest) UnmarshalJSO // This represents the output of a function call that gets passed back to the // model. type ResponseListResponseInputOpenAIResponseInputFunctionToolCallOutput struct { - CallID string `json:"call_id,required"` - Output string `json:"output,required"` - Type constant.FunctionCallOutput `json:"type,required"` - ID string `json:"id"` - Status string `json:"status"` + CallID string `json:"call_id,required"` + Output string `json:"output,required"` + ID string `json:"id,nullable"` + Status string `json:"status,nullable"` + // Any of "function_call_output". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { CallID respjson.Field Output respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -7126,18 +7310,19 @@ func (r *ResponseListResponseInputOpenAIResponseInputFunctionToolCallOutput) Unm // A response to an MCP approval request. type ResponseListResponseInputOpenAIResponseMcpApprovalResponse struct { - ApprovalRequestID string `json:"approval_request_id,required"` - Approve bool `json:"approve,required"` - Type constant.McpApprovalResponse `json:"type,required"` - ID string `json:"id"` - Reason string `json:"reason"` + ApprovalRequestID string `json:"approval_request_id,required"` + Approve bool `json:"approve,required"` + ID string `json:"id,nullable"` + Reason string `json:"reason,nullable"` + // Any of "mcp_approval_response". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ApprovalRequestID respjson.Field Approve respjson.Field - Type respjson.Field ID respjson.Field Reason respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -7151,15 +7336,6 @@ func (r *ResponseListResponseInputOpenAIResponseMcpApprovalResponse) UnmarshalJS return apijson.UnmarshalRoot(data, r) } -type ResponseListResponseInputRole string - -const ( - ResponseListResponseInputRoleSystem ResponseListResponseInputRole = "system" - ResponseListResponseInputRoleDeveloper ResponseListResponseInputRole = "developer" - ResponseListResponseInputRoleUser ResponseListResponseInputRole = "user" - ResponseListResponseInputRoleAssistant ResponseListResponseInputRole = "assistant" -) - // ResponseListResponseOutputUnion contains all possible properties and values from // [ResponseListResponseOutputMessage], [ResponseListResponseOutputWebSearchCall], // [ResponseListResponseOutputFileSearchCall], @@ -7174,12 +7350,12 @@ type ResponseListResponseOutputUnion struct { // This field is from variant [ResponseListResponseOutputMessage]. Content ResponseListResponseOutputMessageContentUnion `json:"content"` // This field is from variant [ResponseListResponseOutputMessage]. - Role ResponseListResponseOutputMessageRole `json:"role"` - // Any of "message", "web_search_call", "file_search_call", "function_call", - // "mcp_call", "mcp_list_tools", "mcp_approval_request". - Type string `json:"type"` + Role string `json:"role"` ID string `json:"id"` Status string `json:"status"` + // Any of "message", "web_search_call", "file_search_call", "function_call", + // "mcp_call", "mcp_list_tools", "mcp_approval_request". + Type string `json:"type"` // This field is from variant [ResponseListResponseOutputFileSearchCall]. Queries []string `json:"queries"` // This field is from variant [ResponseListResponseOutputFileSearchCall]. @@ -7198,9 +7374,9 @@ type ResponseListResponseOutputUnion struct { JSON struct { Content respjson.Field Role respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field Queries respjson.Field Results respjson.Field Arguments respjson.Field @@ -7310,17 +7486,18 @@ func (r *ResponseListResponseOutputUnion) UnmarshalJSON(data []byte) error { type ResponseListResponseOutputMessage struct { Content ResponseListResponseOutputMessageContentUnion `json:"content,required"` // Any of "system", "developer", "user", "assistant". - Role ResponseListResponseOutputMessageRole `json:"role,required"` - Type constant.Message `json:"type,required"` - ID string `json:"id"` - Status string `json:"status"` + Role string `json:"role,required"` + ID string `json:"id,nullable"` + Status string `json:"status,nullable"` + // Any of "message". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field Role respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -7334,23 +7511,31 @@ func (r *ResponseListResponseOutputMessage) UnmarshalJSON(data []byte) error { // ResponseListResponseOutputMessageContentUnion contains all possible properties // and values from [string], -// [[]ResponseListResponseOutputMessageContentArrayItemUnion], -// [[]ResponseListResponseOutputMessageContentArrayItemUnion]. +// [[]ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion], +// [[]ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString OfVariant2] +// will be valid: OfString +// OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile +// OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal] type ResponseListResponseOutputMessageContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ResponseListResponseOutputMessageContentArrayItemUnion] instead of an object. - OfVariant2 []ResponseListResponseOutputMessageContentArrayItemUnion `json:",inline"` - JSON struct { - OfString respjson.Field - OfVariant2 respjson.Field - raw string + // [[]ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion] + // instead of an object. + OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile []ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion `json:",inline"` + // This field will be present if the value is a + // [[]ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion] + // instead of an object. + OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal []ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile respjson.Field + OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal respjson.Field + raw string } `json:"-"` } @@ -7359,12 +7544,12 @@ func (u ResponseListResponseOutputMessageContentUnion) AsString() (v string) { return } -func (u ResponseListResponseOutputMessageContentUnion) AsResponseListResponseOutputMessageContentArray() (v []ResponseListResponseOutputMessageContentArrayItemUnion) { +func (u ResponseListResponseOutputMessageContentUnion) AsListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile() (v []ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseOutputMessageContentUnion) AsVariant2() (v []ResponseListResponseOutputMessageContentArrayItemUnion) { +func (u ResponseListResponseOutputMessageContentUnion) AsListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal() (v []ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -7376,37 +7561,38 @@ func (r *ResponseListResponseOutputMessageContentUnion) UnmarshalJSON(data []byt return apijson.UnmarshalRoot(data, r) } -// ResponseListResponseOutputMessageContentArrayItemUnion contains all possible -// properties and values from -// [ResponseListResponseOutputMessageContentArrayItemInputText], -// [ResponseListResponseOutputMessageContentArrayItemInputImage], -// [ResponseListResponseOutputMessageContentArrayItemInputFile]. +// ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion +// contains all possible properties and values from +// [ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText], +// [ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage], +// [ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. // -// Use the [ResponseListResponseOutputMessageContentArrayItemUnion.AsAny] method to -// switch on the variant. +// Use the +// [ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny] +// method to switch on the variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type ResponseListResponseOutputMessageContentArrayItemUnion struct { +type ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion struct { // This field is from variant - // [ResponseListResponseOutputMessageContentArrayItemInputText]. + // [ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText]. Text string `json:"text"` // Any of "input_text", "input_image", "input_file". Type string `json:"type"` // This field is from variant - // [ResponseListResponseOutputMessageContentArrayItemInputImage]. - Detail ResponseListResponseOutputMessageContentArrayItemInputImageDetail `json:"detail"` - FileID string `json:"file_id"` + // [ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]. + Detail string `json:"detail"` + FileID string `json:"file_id"` // This field is from variant - // [ResponseListResponseOutputMessageContentArrayItemInputImage]. + // [ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]. ImageURL string `json:"image_url"` // This field is from variant - // [ResponseListResponseOutputMessageContentArrayItemInputFile]. + // [ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. FileData string `json:"file_data"` // This field is from variant - // [ResponseListResponseOutputMessageContentArrayItemInputFile]. + // [ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. FileURL string `json:"file_url"` // This field is from variant - // [ResponseListResponseOutputMessageContentArrayItemInputFile]. + // [ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. Filename string `json:"filename"` JSON struct { Text respjson.Field @@ -7421,73 +7607,375 @@ type ResponseListResponseOutputMessageContentArrayItemUnion struct { } `json:"-"` } -// anyResponseListResponseOutputMessageContentArrayItem is implemented by each -// variant of [ResponseListResponseOutputMessageContentArrayItemUnion] to add type -// safety for the return type of -// [ResponseListResponseOutputMessageContentArrayItemUnion.AsAny] -type anyResponseListResponseOutputMessageContentArrayItem interface { - implResponseListResponseOutputMessageContentArrayItemUnion() +// anyResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem +// is implemented by each variant of +// [ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion] +// to add type safety for the return type of +// [ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny] +type anyResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem interface { + implResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() +} + +func (ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) implResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { +} +func (ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) implResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { +} +func (ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) implResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny().(type) { +// case llamastackclient.ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText: +// case llamastackclient.ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage: +// case llamastackclient.ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile: +// default: +// fmt.Errorf("no variant present") +// } +func (u ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsAny() anyResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem { + switch u.Type { + case "input_text": + return u.AsInputText() + case "input_image": + return u.AsInputImage() + case "input_file": + return u.AsInputFile() + } + return nil +} + +func (u ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputText() (v ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputImage() (v ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputFile() (v ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Text content for input messages in OpenAI response format. +type ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText struct { + Text string `json:"text,required"` + // Any of "input_text". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Text respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Image content for input messages in OpenAI response format. +type ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage struct { + // Any of "low", "high", "auto". + Detail string `json:"detail"` + FileID string `json:"file_id,nullable"` + ImageURL string `json:"image_url,nullable"` + // Any of "input_image". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Detail respjson.Field + FileID respjson.Field + ImageURL respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// File content for input messages in OpenAI response format. +type ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile struct { + FileData string `json:"file_data,nullable"` + FileID string `json:"file_id,nullable"` + FileURL string `json:"file_url,nullable"` + Filename string `json:"filename,nullable"` + // Any of "input_file". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + FileData respjson.Field + FileID respjson.Field + FileURL respjson.Field + Filename respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseListResponseOutputMessageContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion +// contains all possible properties and values from +// [ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText], +// [ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]. +// +// Use the +// [ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny] +// method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion struct { + // This field is from variant + // [ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]. + Text string `json:"text"` + // This field is from variant + // [ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]. + Annotations []ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion `json:"annotations"` + // Any of "output_text", "refusal". + Type string `json:"type"` + // This field is from variant + // [ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]. + Refusal string `json:"refusal"` + JSON struct { + Text respjson.Field + Annotations respjson.Field + Type respjson.Field + Refusal respjson.Field + raw string + } `json:"-"` +} + +// anyResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem +// is implemented by each variant of +// [ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion] +// to add type safety for the return type of +// [ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny] +type anyResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem interface { + implResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() +} + +func (ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) implResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() { +} +func (ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) implResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny().(type) { +// case llamastackclient.ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText: +// case llamastackclient.ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal: +// default: +// fmt.Errorf("no variant present") +// } +func (u ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsAny() anyResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem { + switch u.Type { + case "output_text": + return u.AsOutputText() + case "refusal": + return u.AsRefusal() + } + return nil +} + +func (u ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsOutputText() (v ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsRefusal() (v ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText struct { + Text string `json:"text,required"` + Annotations []ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion `json:"annotations"` + // Any of "output_text". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Text respjson.Field + Annotations respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion +// contains all possible properties and values from +// [ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation], +// [ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation], +// [ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation], +// [ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath]. +// +// Use the +// [ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny] +// method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion struct { + FileID string `json:"file_id"` + Filename string `json:"filename"` + Index int64 `json:"index"` + // Any of "file_citation", "url_citation", "container_file_citation", "file_path". + Type string `json:"type"` + EndIndex int64 `json:"end_index"` + StartIndex int64 `json:"start_index"` + // This field is from variant + // [ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]. + Title string `json:"title"` + // This field is from variant + // [ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]. + URL string `json:"url"` + // This field is from variant + // [ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation]. + ContainerID string `json:"container_id"` + JSON struct { + FileID respjson.Field + Filename respjson.Field + Index respjson.Field + Type respjson.Field + EndIndex respjson.Field + StartIndex respjson.Field + Title respjson.Field + URL respjson.Field + ContainerID respjson.Field + raw string + } `json:"-"` +} + +// anyResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation +// is implemented by each variant of +// [ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion] +// to add type safety for the return type of +// [ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny] +type anyResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation interface { + implResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() } -func (ResponseListResponseOutputMessageContentArrayItemInputText) implResponseListResponseOutputMessageContentArrayItemUnion() { +func (ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) implResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} +func (ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) implResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { } -func (ResponseListResponseOutputMessageContentArrayItemInputImage) implResponseListResponseOutputMessageContentArrayItemUnion() { +func (ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) implResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { } -func (ResponseListResponseOutputMessageContentArrayItemInputFile) implResponseListResponseOutputMessageContentArrayItemUnion() { +func (ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) implResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { } // Use the following switch statement to find the correct variant // -// switch variant := ResponseListResponseOutputMessageContentArrayItemUnion.AsAny().(type) { -// case llamastackclient.ResponseListResponseOutputMessageContentArrayItemInputText: -// case llamastackclient.ResponseListResponseOutputMessageContentArrayItemInputImage: -// case llamastackclient.ResponseListResponseOutputMessageContentArrayItemInputFile: +// switch variant := ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny().(type) { +// case llamastackclient.ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation: +// case llamastackclient.ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation: +// case llamastackclient.ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation: +// case llamastackclient.ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath: // default: // fmt.Errorf("no variant present") // } -func (u ResponseListResponseOutputMessageContentArrayItemUnion) AsAny() anyResponseListResponseOutputMessageContentArrayItem { +func (u ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsAny() anyResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation { switch u.Type { - case "input_text": - return u.AsInputText() - case "input_image": - return u.AsInputImage() - case "input_file": - return u.AsInputFile() + case "file_citation": + return u.AsFileCitation() + case "url_citation": + return u.AsURLCitation() + case "container_file_citation": + return u.AsContainerFileCitation() + case "file_path": + return u.AsFilePath() } return nil } -func (u ResponseListResponseOutputMessageContentArrayItemUnion) AsInputText() (v ResponseListResponseOutputMessageContentArrayItemInputText) { +func (u ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsFileCitation() (v ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsURLCitation() (v ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseOutputMessageContentArrayItemUnion) AsInputImage() (v ResponseListResponseOutputMessageContentArrayItemInputImage) { +func (u ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsContainerFileCitation() (v ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseOutputMessageContentArrayItemUnion) AsInputFile() (v ResponseListResponseOutputMessageContentArrayItemInputFile) { +func (u ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsFilePath() (v ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ResponseListResponseOutputMessageContentArrayItemUnion) RawJSON() string { return u.JSON.raw } +func (u ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) RawJSON() string { + return u.JSON.raw +} -func (r *ResponseListResponseOutputMessageContentArrayItemUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Text content for input messages in OpenAI response format. -type ResponseListResponseOutputMessageContentArrayItemInputText struct { - // The text content of the input message - Text string `json:"text,required"` - // Content type identifier, always "input_text" - Type constant.InputText `json:"type,required"` +// File citation annotation for referencing specific files in response content. +type ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation struct { + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Index int64 `json:"index,required"` + // Any of "file_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Text respjson.Field + FileID respjson.Field + Filename respjson.Field + Index respjson.Field Type respjson.Field ExtraFields map[string]respjson.Field raw string @@ -7495,111 +7983,121 @@ type ResponseListResponseOutputMessageContentArrayItemInputText struct { } // Returns the unmodified JSON received from the API -func (r ResponseListResponseOutputMessageContentArrayItemInputText) RawJSON() string { +func (r ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseOutputMessageContentArrayItemInputText) UnmarshalJSON(data []byte) error { +func (r *ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Image content for input messages in OpenAI response format. -type ResponseListResponseOutputMessageContentArrayItemInputImage struct { - // Level of detail for image processing, can be "low", "high", or "auto" - // - // Any of "low", "high", "auto". - Detail ResponseListResponseOutputMessageContentArrayItemInputImageDetail `json:"detail,required"` - // Content type identifier, always "input_image" - Type constant.InputImage `json:"type,required"` - // (Optional) The ID of the file to be sent to the model. - FileID string `json:"file_id"` - // (Optional) URL of the image content - ImageURL string `json:"image_url"` +// URL citation annotation for referencing external web resources. +type ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation struct { + EndIndex int64 `json:"end_index,required"` + StartIndex int64 `json:"start_index,required"` + Title string `json:"title,required"` + URL string `json:"url,required"` + // Any of "url_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Detail respjson.Field + EndIndex respjson.Field + StartIndex respjson.Field + Title respjson.Field + URL respjson.Field Type respjson.Field - FileID respjson.Field - ImageURL respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseListResponseOutputMessageContentArrayItemInputImage) RawJSON() string { +func (r ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseOutputMessageContentArrayItemInputImage) UnmarshalJSON(data []byte) error { +func (r *ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ResponseListResponseOutputMessageContentArrayItemInputImageDetail string - -const ( - ResponseListResponseOutputMessageContentArrayItemInputImageDetailLow ResponseListResponseOutputMessageContentArrayItemInputImageDetail = "low" - ResponseListResponseOutputMessageContentArrayItemInputImageDetailHigh ResponseListResponseOutputMessageContentArrayItemInputImageDetail = "high" - ResponseListResponseOutputMessageContentArrayItemInputImageDetailAuto ResponseListResponseOutputMessageContentArrayItemInputImageDetail = "auto" -) - -// File content for input messages in OpenAI response format. -type ResponseListResponseOutputMessageContentArrayItemInputFile struct { - // The type of the input item. Always `input_file`. - Type constant.InputFile `json:"type,required"` - // The data of the file to be sent to the model. - FileData string `json:"file_data"` - // (Optional) The ID of the file to be sent to the model. - FileID string `json:"file_id"` - // The URL of the file to be sent to the model. - FileURL string `json:"file_url"` - // The name of the file to be sent to the model. - Filename string `json:"filename"` +type ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation struct { + ContainerID string `json:"container_id,required"` + EndIndex int64 `json:"end_index,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + StartIndex int64 `json:"start_index,required"` + // Any of "container_file_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field - FileData respjson.Field + ContainerID respjson.Field + EndIndex respjson.Field FileID respjson.Field - FileURL respjson.Field Filename respjson.Field + StartIndex respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseListResponseOutputMessageContentArrayItemInputFile) RawJSON() string { +func (r ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseOutputMessageContentArrayItemInputFile) UnmarshalJSON(data []byte) error { +func (r *ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ResponseListResponseOutputMessageContentArrayItemDetail string +type ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath struct { + FileID string `json:"file_id,required"` + Index int64 `json:"index,required"` + // Any of "file_path". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + FileID respjson.Field + Index respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} -const ( - ResponseListResponseOutputMessageContentArrayItemDetailLow ResponseListResponseOutputMessageContentArrayItemDetail = "low" - ResponseListResponseOutputMessageContentArrayItemDetailHigh ResponseListResponseOutputMessageContentArrayItemDetail = "high" - ResponseListResponseOutputMessageContentArrayItemDetailAuto ResponseListResponseOutputMessageContentArrayItemDetail = "auto" -) +// Returns the unmodified JSON received from the API +func (r ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} -type ResponseListResponseOutputMessageRole string +// Refusal content within a streamed response part. +type ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal struct { + Refusal string `json:"refusal,required"` + // Any of "refusal". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Refusal respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} -const ( - ResponseListResponseOutputMessageRoleSystem ResponseListResponseOutputMessageRole = "system" - ResponseListResponseOutputMessageRoleDeveloper ResponseListResponseOutputMessageRole = "developer" - ResponseListResponseOutputMessageRoleUser ResponseListResponseOutputMessageRole = "user" - ResponseListResponseOutputMessageRoleAssistant ResponseListResponseOutputMessageRole = "assistant" -) +// Returns the unmodified JSON received from the API +func (r ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseListResponseOutputMessageContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} // Web search tool call output message for OpenAI responses. type ResponseListResponseOutputWebSearchCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // Current status of the web search operation + ID string `json:"id,required"` Status string `json:"status,required"` - // Tool call type identifier, always "web_search_call" - Type constant.WebSearchCall `json:"type,required"` + // Any of "web_search_call". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -7618,23 +8116,19 @@ func (r *ResponseListResponseOutputWebSearchCall) UnmarshalJSON(data []byte) err // File search tool call output message for OpenAI responses. type ResponseListResponseOutputFileSearchCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // List of search queries executed - Queries []string `json:"queries,required"` - // Current status of the file search operation - Status string `json:"status,required"` - // Tool call type identifier, always "file_search_call" - Type constant.FileSearchCall `json:"type,required"` - // (Optional) Search results returned by the file search operation - Results []ResponseListResponseOutputFileSearchCallResult `json:"results"` + ID string `json:"id,required"` + Queries []string `json:"queries,required"` + Status string `json:"status,required"` + Results []ResponseListResponseOutputFileSearchCallResult `json:"results,nullable"` + // Any of "file_search_call". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field Queries respjson.Field Status respjson.Field - Type respjson.Field Results respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -7648,16 +8142,11 @@ func (r *ResponseListResponseOutputFileSearchCall) UnmarshalJSON(data []byte) er // Search results returned by the file search operation. type ResponseListResponseOutputFileSearchCallResult struct { - // (Optional) Key-value attributes associated with the file - Attributes map[string]ResponseListResponseOutputFileSearchCallResultAttributeUnion `json:"attributes,required"` - // Unique identifier of the file containing the result - FileID string `json:"file_id,required"` - // Name of the file containing the result - Filename string `json:"filename,required"` - // Relevance score for this search result (between 0 and 1) - Score float64 `json:"score,required"` - // Text content of the search result - Text string `json:"text,required"` + Attributes map[string]any `json:"attributes,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Score float64 `json:"score,required"` + Text string `json:"text,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Attributes respjson.Field @@ -7676,82 +8165,23 @@ func (r *ResponseListResponseOutputFileSearchCallResult) UnmarshalJSON(data []by return apijson.UnmarshalRoot(data, r) } -// ResponseListResponseOutputFileSearchCallResultAttributeUnion contains all -// possible properties and values from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ResponseListResponseOutputFileSearchCallResultAttributeUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ResponseListResponseOutputFileSearchCallResultAttributeUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseListResponseOutputFileSearchCallResultAttributeUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseListResponseOutputFileSearchCallResultAttributeUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseListResponseOutputFileSearchCallResultAttributeUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ResponseListResponseOutputFileSearchCallResultAttributeUnion) RawJSON() string { - return u.JSON.raw -} - -func (r *ResponseListResponseOutputFileSearchCallResultAttributeUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - // Function tool call output message for OpenAI responses. type ResponseListResponseOutputFunctionCall struct { - // JSON string containing the function arguments Arguments string `json:"arguments,required"` - // Unique identifier for the function call - CallID string `json:"call_id,required"` - // Name of the function being called - Name string `json:"name,required"` - // Tool call type identifier, always "function_call" - Type constant.FunctionCall `json:"type,required"` - // (Optional) Additional identifier for the tool call - ID string `json:"id"` - // (Optional) Current status of the function call execution - Status string `json:"status"` + CallID string `json:"call_id,required"` + Name string `json:"name,required"` + ID string `json:"id,nullable"` + Status string `json:"status,nullable"` + // Any of "function_call". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Arguments respjson.Field CallID respjson.Field Name respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -7765,29 +8195,23 @@ func (r *ResponseListResponseOutputFunctionCall) UnmarshalJSON(data []byte) erro // Model Context Protocol (MCP) call output message for OpenAI responses. type ResponseListResponseOutputMcpCall struct { - // Unique identifier for this MCP call - ID string `json:"id,required"` - // JSON string containing the MCP call arguments - Arguments string `json:"arguments,required"` - // Name of the MCP method being called - Name string `json:"name,required"` - // Label identifying the MCP server handling the call + ID string `json:"id,required"` + Arguments string `json:"arguments,required"` + Name string `json:"name,required"` ServerLabel string `json:"server_label,required"` - // Tool call type identifier, always "mcp_call" - Type constant.McpCall `json:"type,required"` - // (Optional) Error message if the MCP call failed - Error string `json:"error"` - // (Optional) Output result from the successful MCP call - Output string `json:"output"` + Error string `json:"error,nullable"` + Output string `json:"output,nullable"` + // Any of "mcp_call". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field Arguments respjson.Field Name respjson.Field ServerLabel respjson.Field - Type respjson.Field Error respjson.Field Output respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -7801,14 +8225,11 @@ func (r *ResponseListResponseOutputMcpCall) UnmarshalJSON(data []byte) error { // MCP list tools output message containing available tools from an MCP server. type ResponseListResponseOutputMcpListTools struct { - // Unique identifier for this MCP list tools operation - ID string `json:"id,required"` - // Label identifying the MCP server providing the tools - ServerLabel string `json:"server_label,required"` - // List of available tools provided by the MCP server - Tools []ResponseListResponseOutputMcpListToolsTool `json:"tools,required"` - // Tool call type identifier, always "mcp_list_tools" - Type constant.McpListTools `json:"type,required"` + ID string `json:"id,required"` + ServerLabel string `json:"server_label,required"` + Tools []ResponseListResponseOutputMcpListToolsTool `json:"tools,required"` + // Any of "mcp_list_tools". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -7826,236 +8247,56 @@ func (r *ResponseListResponseOutputMcpListTools) UnmarshalJSON(data []byte) erro return apijson.UnmarshalRoot(data, r) } -// Tool definition returned by MCP list tools operation. -type ResponseListResponseOutputMcpListToolsTool struct { - // JSON schema defining the tool's input parameters - InputSchema map[string]ResponseListResponseOutputMcpListToolsToolInputSchemaUnion `json:"input_schema,required"` - // Name of the tool - Name string `json:"name,required"` - // (Optional) Description of what the tool does - Description string `json:"description"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - InputSchema respjson.Field - Name respjson.Field - Description respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ResponseListResponseOutputMcpListToolsTool) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseOutputMcpListToolsTool) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ResponseListResponseOutputMcpListToolsToolInputSchemaUnion contains all possible -// properties and values from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ResponseListResponseOutputMcpListToolsToolInputSchemaUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ResponseListResponseOutputMcpListToolsToolInputSchemaUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseListResponseOutputMcpListToolsToolInputSchemaUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseListResponseOutputMcpListToolsToolInputSchemaUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseListResponseOutputMcpListToolsToolInputSchemaUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ResponseListResponseOutputMcpListToolsToolInputSchemaUnion) RawJSON() string { - return u.JSON.raw -} - -func (r *ResponseListResponseOutputMcpListToolsToolInputSchemaUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A request for human approval of a tool invocation. -type ResponseListResponseOutputMcpApprovalRequest struct { - ID string `json:"id,required"` - Arguments string `json:"arguments,required"` - Name string `json:"name,required"` - ServerLabel string `json:"server_label,required"` - Type constant.McpApprovalRequest `json:"type,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - ID respjson.Field - Arguments respjson.Field - Name respjson.Field - ServerLabel respjson.Field - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ResponseListResponseOutputMcpApprovalRequest) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseOutputMcpApprovalRequest) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type ResponseListResponseOutputRole string - -const ( - ResponseListResponseOutputRoleSystem ResponseListResponseOutputRole = "system" - ResponseListResponseOutputRoleDeveloper ResponseListResponseOutputRole = "developer" - ResponseListResponseOutputRoleUser ResponseListResponseOutputRole = "user" - ResponseListResponseOutputRoleAssistant ResponseListResponseOutputRole = "assistant" -) - -// Text formatting configuration for the response -type ResponseListResponseText struct { - // (Optional) Text format configuration specifying output format requirements - Format ResponseListResponseTextFormat `json:"format"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Format respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ResponseListResponseText) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseText) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// (Optional) Text format configuration specifying output format requirements -type ResponseListResponseTextFormat struct { - // Must be "text", "json_schema", or "json_object" to identify the format type - // - // Any of "text", "json_schema", "json_object". - Type ResponseListResponseTextFormatType `json:"type,required"` - // (Optional) A description of the response format. Only used for json_schema. - Description string `json:"description"` - // The name of the response format. Only used for json_schema. - Name string `json:"name"` - // The JSON schema the response should conform to. In a Python SDK, this is often a - // `pydantic` model. Only used for json_schema. - Schema map[string]ResponseListResponseTextFormatSchemaUnion `json:"schema"` - // (Optional) Whether to strictly enforce the JSON schema. If true, the response - // must match the schema exactly. Only used for json_schema. - Strict bool `json:"strict"` +// Tool definition returned by MCP list tools operation. +type ResponseListResponseOutputMcpListToolsTool struct { + InputSchema map[string]any `json:"input_schema,required"` + Name string `json:"name,required"` + Description string `json:"description,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field - Description respjson.Field + InputSchema respjson.Field Name respjson.Field - Schema respjson.Field - Strict respjson.Field + Description respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseListResponseTextFormat) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseTextFormat) UnmarshalJSON(data []byte) error { +func (r ResponseListResponseOutputMcpListToolsTool) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponseOutputMcpListToolsTool) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Must be "text", "json_schema", or "json_object" to identify the format type -type ResponseListResponseTextFormatType string - -const ( - ResponseListResponseTextFormatTypeText ResponseListResponseTextFormatType = "text" - ResponseListResponseTextFormatTypeJsonSchema ResponseListResponseTextFormatType = "json_schema" - ResponseListResponseTextFormatTypeJsonObject ResponseListResponseTextFormatType = "json_object" -) - -// ResponseListResponseTextFormatSchemaUnion contains all possible properties and -// values from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ResponseListResponseTextFormatSchemaUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string +// A request for human approval of a tool invocation. +type ResponseListResponseOutputMcpApprovalRequest struct { + ID string `json:"id,required"` + Arguments string `json:"arguments,required"` + Name string `json:"name,required"` + ServerLabel string `json:"server_label,required"` + // Any of "mcp_approval_request". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Arguments respjson.Field + Name respjson.Field + ServerLabel respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } -func (u ResponseListResponseTextFormatSchemaUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseListResponseTextFormatSchemaUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseListResponseTextFormatSchemaUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseListResponseTextFormatSchemaUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - // Returns the unmodified JSON received from the API -func (u ResponseListResponseTextFormatSchemaUnion) RawJSON() string { return u.JSON.raw } - -func (r *ResponseListResponseTextFormatSchemaUnion) UnmarshalJSON(data []byte) error { +func (r ResponseListResponseOutputMcpApprovalRequest) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponseOutputMcpApprovalRequest) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// (Optional) Error details if the response generation failed +// Error details for failed OpenAI response requests. type ResponseListResponseError struct { - // Error code identifying the type of failure - Code string `json:"code,required"` - // Human-readable error message describing the failure + Code string `json:"code,required"` Message string `json:"message,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { @@ -8072,16 +8313,17 @@ func (r *ResponseListResponseError) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// (Optional) Reference to a prompt template and its variables. +type ResponseListResponseObject string + +const ( + ResponseListResponseObjectResponse ResponseListResponseObject = "response" +) + +// OpenAI compatible Prompt object that is used in OpenAI responses. type ResponseListResponsePrompt struct { - // Unique identifier of the prompt template - ID string `json:"id,required"` - // Dictionary of variable names to OpenAIResponseInputMessageContent structure for - // template substitution. The substitution values can either be strings, or other - // Response input types like images or files. - Variables map[string]ResponseListResponsePromptVariableUnion `json:"variables"` - // Version number of the prompt to use (defaults to latest if not specified) - Version string `json:"version"` + ID string `json:"id,required"` + Variables map[string]ResponseListResponsePromptVariableUnion `json:"variables,nullable"` + Version string `json:"version,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -8113,8 +8355,8 @@ type ResponseListResponsePromptVariableUnion struct { // Any of "input_text", "input_image", "input_file". Type string `json:"type"` // This field is from variant [ResponseListResponsePromptVariableInputImage]. - Detail ResponseListResponsePromptVariableInputImageDetail `json:"detail"` - FileID string `json:"file_id"` + Detail string `json:"detail"` + FileID string `json:"file_id"` // This field is from variant [ResponseListResponsePromptVariableInputImage]. ImageURL string `json:"image_url"` // This field is from variant [ResponseListResponsePromptVariableInputFile]. @@ -8192,10 +8434,9 @@ func (r *ResponseListResponsePromptVariableUnion) UnmarshalJSON(data []byte) err // Text content for input messages in OpenAI response format. type ResponseListResponsePromptVariableInputText struct { - // The text content of the input message Text string `json:"text,required"` - // Content type identifier, always "input_text" - Type constant.InputText `json:"type,required"` + // Any of "input_text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -8213,22 +8454,18 @@ func (r *ResponseListResponsePromptVariableInputText) UnmarshalJSON(data []byte) // Image content for input messages in OpenAI response format. type ResponseListResponsePromptVariableInputImage struct { - // Level of detail for image processing, can be "low", "high", or "auto" - // // Any of "low", "high", "auto". - Detail ResponseListResponsePromptVariableInputImageDetail `json:"detail,required"` - // Content type identifier, always "input_image" - Type constant.InputImage `json:"type,required"` - // (Optional) The ID of the file to be sent to the model. - FileID string `json:"file_id"` - // (Optional) URL of the image content - ImageURL string `json:"image_url"` + Detail string `json:"detail"` + FileID string `json:"file_id,nullable"` + ImageURL string `json:"image_url,nullable"` + // Any of "input_image". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Detail respjson.Field - Type respjson.Field FileID respjson.Field ImageURL respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -8240,34 +8477,21 @@ func (r *ResponseListResponsePromptVariableInputImage) UnmarshalJSON(data []byte return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ResponseListResponsePromptVariableInputImageDetail string - -const ( - ResponseListResponsePromptVariableInputImageDetailLow ResponseListResponsePromptVariableInputImageDetail = "low" - ResponseListResponsePromptVariableInputImageDetailHigh ResponseListResponsePromptVariableInputImageDetail = "high" - ResponseListResponsePromptVariableInputImageDetailAuto ResponseListResponsePromptVariableInputImageDetail = "auto" -) - // File content for input messages in OpenAI response format. type ResponseListResponsePromptVariableInputFile struct { - // The type of the input item. Always `input_file`. - Type constant.InputFile `json:"type,required"` - // The data of the file to be sent to the model. - FileData string `json:"file_data"` - // (Optional) The ID of the file to be sent to the model. - FileID string `json:"file_id"` - // The URL of the file to be sent to the model. - FileURL string `json:"file_url"` - // The name of the file to be sent to the model. - Filename string `json:"filename"` + FileData string `json:"file_data,nullable"` + FileID string `json:"file_id,nullable"` + FileURL string `json:"file_url,nullable"` + Filename string `json:"filename,nullable"` + // Any of "input_file". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field FileData respjson.Field FileID respjson.Field FileURL respjson.Field Filename respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -8279,14 +8503,49 @@ func (r *ResponseListResponsePromptVariableInputFile) UnmarshalJSON(data []byte) return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ResponseListResponsePromptVariableDetail string +// Text response configuration for OpenAI responses. +type ResponseListResponseText struct { + // Configuration for Responses API text format. + Format ResponseListResponseTextFormat `json:"format,nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Format respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} -const ( - ResponseListResponsePromptVariableDetailLow ResponseListResponsePromptVariableDetail = "low" - ResponseListResponsePromptVariableDetailHigh ResponseListResponsePromptVariableDetail = "high" - ResponseListResponsePromptVariableDetailAuto ResponseListResponsePromptVariableDetail = "auto" -) +// Returns the unmodified JSON received from the API +func (r ResponseListResponseText) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponseText) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Configuration for Responses API text format. +type ResponseListResponseTextFormat struct { + Description string `json:"description,nullable"` + Name string `json:"name,nullable"` + Schema map[string]any `json:"schema,nullable"` + Strict bool `json:"strict,nullable"` + // Any of "text", "json_schema", "json_object". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Description respjson.Field + Name respjson.Field + Schema respjson.Field + Strict respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseListResponseTextFormat) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponseTextFormat) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} // ResponseListResponseToolUnion contains all possible properties and values from // [ResponseListResponseToolOpenAIResponseInputToolWebSearch], @@ -8297,15 +8556,15 @@ const ( // // Use the methods beginning with 'As' to cast the union to one of its variants. type ResponseListResponseToolUnion struct { - // Any of nil, "file_search", "function", "mcp". - Type string `json:"type"` // This field is from variant // [ResponseListResponseToolOpenAIResponseInputToolWebSearch]. SearchContextSize string `json:"search_context_size"` + // Any of nil, "file_search", "function", "mcp". + Type string `json:"type"` // This field is from variant [ResponseListResponseToolFileSearch]. VectorStoreIDs []string `json:"vector_store_ids"` // This field is from variant [ResponseListResponseToolFileSearch]. - Filters map[string]ResponseListResponseToolFileSearchFilterUnion `json:"filters"` + Filters map[string]any `json:"filters"` // This field is from variant [ResponseListResponseToolFileSearch]. MaxNumResults int64 `json:"max_num_results"` // This field is from variant [ResponseListResponseToolFileSearch]. @@ -8313,9 +8572,9 @@ type ResponseListResponseToolUnion struct { // This field is from variant [ResponseListResponseToolFunction]. Name string `json:"name"` // This field is from variant [ResponseListResponseToolFunction]. - Description string `json:"description"` + Parameters map[string]any `json:"parameters"` // This field is from variant [ResponseListResponseToolFunction]. - Parameters map[string]ResponseListResponseToolFunctionParameterUnion `json:"parameters"` + Description string `json:"description"` // This field is from variant [ResponseListResponseToolFunction]. Strict bool `json:"strict"` // This field is from variant [ResponseListResponseToolMcp]. @@ -8323,15 +8582,15 @@ type ResponseListResponseToolUnion struct { // This field is from variant [ResponseListResponseToolMcp]. AllowedTools ResponseListResponseToolMcpAllowedToolsUnion `json:"allowed_tools"` JSON struct { - Type respjson.Field SearchContextSize respjson.Field + Type respjson.Field VectorStoreIDs respjson.Field Filters respjson.Field MaxNumResults respjson.Field RankingOptions respjson.Field Name respjson.Field - Description respjson.Field Parameters respjson.Field + Description respjson.Field Strict respjson.Field ServerLabel respjson.Field AllowedTools respjson.Field @@ -8368,17 +8627,14 @@ func (r *ResponseListResponseToolUnion) UnmarshalJSON(data []byte) error { // Web search tool configuration for OpenAI response inputs. type ResponseListResponseToolOpenAIResponseInputToolWebSearch struct { - // Web search tool type variant to use - // + SearchContextSize string `json:"search_context_size,nullable"` // Any of "web_search", "web_search_preview", "web_search_preview_2025_03_11", // "web_search_2025_08_26". - Type ResponseListResponseToolOpenAIResponseInputToolWebSearchType `json:"type,required"` - // (Optional) Size of search context, must be "low", "medium", or "high" - SearchContextSize string `json:"search_context_size"` + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field SearchContextSize respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -8390,35 +8646,22 @@ func (r *ResponseListResponseToolOpenAIResponseInputToolWebSearch) UnmarshalJSON return apijson.UnmarshalRoot(data, r) } -// Web search tool type variant to use -type ResponseListResponseToolOpenAIResponseInputToolWebSearchType string - -const ( - ResponseListResponseToolOpenAIResponseInputToolWebSearchTypeWebSearch ResponseListResponseToolOpenAIResponseInputToolWebSearchType = "web_search" - ResponseListResponseToolOpenAIResponseInputToolWebSearchTypeWebSearchPreview ResponseListResponseToolOpenAIResponseInputToolWebSearchType = "web_search_preview" - ResponseListResponseToolOpenAIResponseInputToolWebSearchTypeWebSearchPreview2025_03_11 ResponseListResponseToolOpenAIResponseInputToolWebSearchType = "web_search_preview_2025_03_11" - ResponseListResponseToolOpenAIResponseInputToolWebSearchTypeWebSearch2025_08_26 ResponseListResponseToolOpenAIResponseInputToolWebSearchType = "web_search_2025_08_26" -) - // File search tool configuration for OpenAI response inputs. type ResponseListResponseToolFileSearch struct { - // Tool type identifier, always "file_search" - Type constant.FileSearch `json:"type,required"` - // List of vector store identifiers to search within - VectorStoreIDs []string `json:"vector_store_ids,required"` - // (Optional) Additional filters to apply to the search - Filters map[string]ResponseListResponseToolFileSearchFilterUnion `json:"filters"` - // (Optional) Maximum number of search results to return (1-50) - MaxNumResults int64 `json:"max_num_results"` - // (Optional) Options for ranking and scoring search results - RankingOptions ResponseListResponseToolFileSearchRankingOptions `json:"ranking_options"` + VectorStoreIDs []string `json:"vector_store_ids,required"` + Filters map[string]any `json:"filters,nullable"` + MaxNumResults int64 `json:"max_num_results,nullable"` + // Options for ranking and filtering search results. + RankingOptions ResponseListResponseToolFileSearchRankingOptions `json:"ranking_options,nullable"` + // Any of "file_search". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Type respjson.Field VectorStoreIDs respjson.Field Filters respjson.Field MaxNumResults respjson.Field RankingOptions respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -8430,64 +8673,10 @@ func (r *ResponseListResponseToolFileSearch) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseListResponseToolFileSearchFilterUnion contains all possible properties -// and values from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ResponseListResponseToolFileSearchFilterUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ResponseListResponseToolFileSearchFilterUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseListResponseToolFileSearchFilterUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseListResponseToolFileSearchFilterUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseListResponseToolFileSearchFilterUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ResponseListResponseToolFileSearchFilterUnion) RawJSON() string { return u.JSON.raw } - -func (r *ResponseListResponseToolFileSearchFilterUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// (Optional) Options for ranking and scoring search results +// Options for ranking and filtering search results. type ResponseListResponseToolFileSearchRankingOptions struct { - // (Optional) Name of the ranking algorithm to use - Ranker string `json:"ranker"` - // (Optional) Minimum relevance score threshold for results - ScoreThreshold float64 `json:"score_threshold"` + Ranker string `json:"ranker,nullable"` + ScoreThreshold float64 `json:"score_threshold,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Ranker respjson.Field @@ -8505,23 +8694,19 @@ func (r *ResponseListResponseToolFileSearchRankingOptions) UnmarshalJSON(data [] // Function tool configuration for OpenAI response inputs. type ResponseListResponseToolFunction struct { - // Name of the function that can be called - Name string `json:"name,required"` - // Tool type identifier, always "function" - Type constant.Function `json:"type,required"` - // (Optional) Description of what the function does - Description string `json:"description"` - // (Optional) JSON schema defining the function's parameters - Parameters map[string]ResponseListResponseToolFunctionParameterUnion `json:"parameters"` - // (Optional) Whether to enforce strict parameter validation - Strict bool `json:"strict"` + Name string `json:"name,required"` + Parameters map[string]any `json:"parameters,required"` + Description string `json:"description,nullable"` + Strict bool `json:"strict,nullable"` + // Any of "function". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Name respjson.Field - Type respjson.Field - Description respjson.Field Parameters respjson.Field + Description respjson.Field Strict respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -8533,71 +8718,18 @@ func (r *ResponseListResponseToolFunction) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseListResponseToolFunctionParameterUnion contains all possible properties -// and values from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ResponseListResponseToolFunctionParameterUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ResponseListResponseToolFunctionParameterUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseListResponseToolFunctionParameterUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseListResponseToolFunctionParameterUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseListResponseToolFunctionParameterUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ResponseListResponseToolFunctionParameterUnion) RawJSON() string { return u.JSON.raw } - -func (r *ResponseListResponseToolFunctionParameterUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - // Model Context Protocol (MCP) tool configuration for OpenAI response object. type ResponseListResponseToolMcp struct { - // Label to identify this MCP server ServerLabel string `json:"server_label,required"` - // Tool type identifier, always "mcp" - Type constant.Mcp `json:"type,required"` - // (Optional) Restriction on which tools can be used from this server - AllowedTools ResponseListResponseToolMcpAllowedToolsUnion `json:"allowed_tools"` + // Filter configuration for restricting which MCP tools can be used. + AllowedTools ResponseListResponseToolMcpAllowedToolsUnion `json:"allowed_tools,nullable"` + // Any of "mcp". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ServerLabel respjson.Field - Type respjson.Field AllowedTools respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -8616,21 +8748,21 @@ func (r *ResponseListResponseToolMcp) UnmarshalJSON(data []byte) error { // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfStringArray] +// will be valid: OfListString] type ResponseListResponseToolMcpAllowedToolsUnion struct { // This field will be present if the value is a [[]string] instead of an object. - OfStringArray []string `json:",inline"` + OfListString []string `json:",inline"` // This field is from variant // [ResponseListResponseToolMcpAllowedToolsAllowedToolsFilter]. ToolNames []string `json:"tool_names"` JSON struct { - OfStringArray respjson.Field - ToolNames respjson.Field - raw string + OfListString respjson.Field + ToolNames respjson.Field + raw string } `json:"-"` } -func (u ResponseListResponseToolMcpAllowedToolsUnion) AsStringArray() (v []string) { +func (u ResponseListResponseToolMcpAllowedToolsUnion) AsListString() (v []string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -8649,8 +8781,7 @@ func (r *ResponseListResponseToolMcpAllowedToolsUnion) UnmarshalJSON(data []byte // Filter configuration for restricting which MCP tools can be used. type ResponseListResponseToolMcpAllowedToolsAllowedToolsFilter struct { - // (Optional) List of specific tool names that are allowed - ToolNames []string `json:"tool_names"` + ToolNames []string `json:"tool_names,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ToolNames respjson.Field @@ -8667,31 +8798,15 @@ func (r *ResponseListResponseToolMcpAllowedToolsAllowedToolsFilter) UnmarshalJSO return apijson.UnmarshalRoot(data, r) } -// Web search tool type variant to use -type ResponseListResponseToolType string - -const ( - ResponseListResponseToolTypeWebSearch ResponseListResponseToolType = "web_search" - ResponseListResponseToolTypeWebSearchPreview ResponseListResponseToolType = "web_search_preview" - ResponseListResponseToolTypeWebSearchPreview2025_03_11 ResponseListResponseToolType = "web_search_preview_2025_03_11" - ResponseListResponseToolTypeWebSearch2025_08_26 ResponseListResponseToolType = "web_search_2025_08_26" - ResponseListResponseToolTypeFileSearch ResponseListResponseToolType = "file_search" - ResponseListResponseToolTypeFunction ResponseListResponseToolType = "function" - ResponseListResponseToolTypeMcp ResponseListResponseToolType = "mcp" -) - -// (Optional) Token usage information for the response +// Usage information for OpenAI response. type ResponseListResponseUsage struct { - // Number of tokens in the input - InputTokens int64 `json:"input_tokens,required"` - // Number of tokens in the output + InputTokens int64 `json:"input_tokens,required"` OutputTokens int64 `json:"output_tokens,required"` - // Total tokens used (input + output) - TotalTokens int64 `json:"total_tokens,required"` - // Detailed breakdown of input token usage - InputTokensDetails ResponseListResponseUsageInputTokensDetails `json:"input_tokens_details"` - // Detailed breakdown of output token usage - OutputTokensDetails ResponseListResponseUsageOutputTokensDetails `json:"output_tokens_details"` + TotalTokens int64 `json:"total_tokens,required"` + // Token details for input tokens in OpenAI response usage. + InputTokensDetails ResponseListResponseUsageInputTokensDetails `json:"input_tokens_details,nullable"` + // Token details for output tokens in OpenAI response usage. + OutputTokensDetails ResponseListResponseUsageOutputTokensDetails `json:"output_tokens_details,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { InputTokens respjson.Field @@ -8710,10 +8825,9 @@ func (r *ResponseListResponseUsage) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Detailed breakdown of input token usage +// Token details for input tokens in OpenAI response usage. type ResponseListResponseUsageInputTokensDetails struct { - // Number of tokens retrieved from cache - CachedTokens int64 `json:"cached_tokens"` + CachedTokens int64 `json:"cached_tokens,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { CachedTokens respjson.Field @@ -8728,10 +8842,9 @@ func (r *ResponseListResponseUsageInputTokensDetails) UnmarshalJSON(data []byte) return apijson.UnmarshalRoot(data, r) } -// Detailed breakdown of output token usage +// Token details for output tokens in OpenAI response usage. type ResponseListResponseUsageOutputTokensDetails struct { - // Number of tokens used for reasoning (o1/o3 models) - ReasoningTokens int64 `json:"reasoning_tokens"` + ReasoningTokens int64 `json:"reasoning_tokens,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ReasoningTokens respjson.Field @@ -8748,12 +8861,10 @@ func (r *ResponseListResponseUsageOutputTokensDetails) UnmarshalJSON(data []byte // Response object confirming deletion of an OpenAI response. type ResponseDeleteResponse struct { - // Unique identifier of the deleted response - ID string `json:"id,required"` - // Deletion confirmation flag, always True - Deleted bool `json:"deleted,required"` - // Object type identifier, always "response" - Object constant.Response `json:"object,required"` + ID string `json:"id,required"` + Deleted bool `json:"deleted"` + // Any of "response". + Object ResponseDeleteResponseObject `json:"object"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -8770,29 +8881,24 @@ func (r *ResponseDeleteResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +type ResponseDeleteResponseObject string + +const ( + ResponseDeleteResponseObjectResponse ResponseDeleteResponseObject = "response" +) + type ResponseNewParams struct { - // Input message(s) to create the response. - Input ResponseNewParamsInputUnion `json:"input,omitzero,required"` - // The underlying LLM used for completions. - Model string `json:"model,required"` - // (Optional) The ID of a conversation to add the response to. Must begin with - // 'conv\_'. Input and output messages will be automatically added to the - // conversation. - Conversation param.Opt[string] `json:"conversation,omitzero"` - Instructions param.Opt[string] `json:"instructions,omitzero"` - MaxInferIters param.Opt[int64] `json:"max_infer_iters,omitzero"` - // (Optional) Max number of total calls to built-in tools that can be processed in - // a response. - MaxToolCalls param.Opt[int64] `json:"max_tool_calls,omitzero"` - // (Optional) if specified, the new response will be a continuation of the previous - // response. This can be used to easily fork-off new responses from existing - // responses. - PreviousResponseID param.Opt[string] `json:"previous_response_id,omitzero"` - Store param.Opt[bool] `json:"store,omitzero"` - Temperature param.Opt[float64] `json:"temperature,omitzero"` - // (Optional) Additional fields to include in the response. - Include []string `json:"include,omitzero"` - // (Optional) Prompt object with ID, version, and variables. + Input ResponseNewParamsInputUnion `json:"input,omitzero,required"` + Model string `json:"model,required"` + Conversation param.Opt[string] `json:"conversation,omitzero"` + Instructions param.Opt[string] `json:"instructions,omitzero"` + MaxInferIters param.Opt[int64] `json:"max_infer_iters,omitzero"` + MaxToolCalls param.Opt[int64] `json:"max_tool_calls,omitzero"` + PreviousResponseID param.Opt[string] `json:"previous_response_id,omitzero"` + Store param.Opt[bool] `json:"store,omitzero"` + Temperature param.Opt[float64] `json:"temperature,omitzero"` + Include []string `json:"include,omitzero"` + // OpenAI compatible Prompt object that is used in OpenAI responses. Prompt ResponseNewParamsPrompt `json:"prompt,omitzero"` // Text response configuration for OpenAI responses. Text ResponseNewParamsText `json:"text,omitzero"` @@ -8812,13 +8918,13 @@ func (r *ResponseNewParams) UnmarshalJSON(data []byte) error { // // Use [param.IsOmitted] to confirm if a field is set. type ResponseNewParamsInputUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfResponseNewsInputArray []ResponseNewParamsInputArrayItemUnion `json:",omitzero,inline"` + OfString param.Opt[string] `json:",omitzero,inline"` + OfListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutput []ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemUnion `json:",omitzero,inline"` paramUnion } func (u ResponseNewParamsInputUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfResponseNewsInputArray) + return param.MarshalUnion(u, u.OfString, u.OfListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutput) } func (u *ResponseNewParamsInputUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) @@ -8827,8 +8933,8 @@ func (u *ResponseNewParamsInputUnion) UnmarshalJSON(data []byte) error { func (u *ResponseNewParamsInputUnion) asAny() any { if !param.IsOmitted(u.OfString) { return &u.OfString.Value - } else if !param.IsOmitted(u.OfResponseNewsInputArray) { - return &u.OfResponseNewsInputArray + } else if !param.IsOmitted(u.OfListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutput) { + return &u.OfListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutput } return nil } @@ -8836,22 +8942,22 @@ func (u *ResponseNewParamsInputUnion) asAny() any { // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. -type ResponseNewParamsInputArrayItemUnion struct { - OfOpenAIResponseMessage *ResponseNewParamsInputArrayItemOpenAIResponseMessage `json:",omitzero,inline"` - OfOpenAIResponseOutputMessageWebSearchToolCall *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageWebSearchToolCall `json:",omitzero,inline"` - OfOpenAIResponseOutputMessageFileSearchToolCall *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCall `json:",omitzero,inline"` - OfOpenAIResponseOutputMessageFunctionToolCall *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFunctionToolCall `json:",omitzero,inline"` - OfOpenAIResponseOutputMessageMcpCall *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpCall `json:",omitzero,inline"` - OfOpenAIResponseOutputMessageMcpListTools *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListTools `json:",omitzero,inline"` - OfOpenAIResponseMcpApprovalRequest *ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalRequest `json:",omitzero,inline"` - OfOpenAIResponseInputFunctionToolCallOutput *ResponseNewParamsInputArrayItemOpenAIResponseInputFunctionToolCallOutput `json:",omitzero,inline"` - OfOpenAIResponseMcpApprovalResponse *ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalResponse `json:",omitzero,inline"` - OfResponseNewsInputArrayItemOpenAIResponseMessage *ResponseNewParamsInputArrayItemOpenAIResponseMessage `json:",omitzero,inline"` +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemUnion struct { + OfOpenAIResponseMessageInput *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInput `json:",omitzero,inline"` + OfOpenAIResponseOutputMessageWebSearchToolCall *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageWebSearchToolCall `json:",omitzero,inline"` + OfOpenAIResponseOutputMessageFileSearchToolCall *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageFileSearchToolCall `json:",omitzero,inline"` + OfOpenAIResponseOutputMessageFunctionToolCall *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageFunctionToolCall `json:",omitzero,inline"` + OfOpenAIResponseOutputMessageMcpCall *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageMcpCall `json:",omitzero,inline"` + OfOpenAIResponseOutputMessageMcpListTools *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageMcpListTools `json:",omitzero,inline"` + OfOpenAIResponseMcpApprovalRequest *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMcpApprovalRequest `json:",omitzero,inline"` + OfOpenAIResponseInputFunctionToolCallOutput *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseInputFunctionToolCallOutput `json:",omitzero,inline"` + OfOpenAIResponseMcpApprovalResponse *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMcpApprovalResponse `json:",omitzero,inline"` + OfResponseNewsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInput *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInput `json:",omitzero,inline"` paramUnion } -func (u ResponseNewParamsInputArrayItemUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfOpenAIResponseMessage, +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfOpenAIResponseMessageInput, u.OfOpenAIResponseOutputMessageWebSearchToolCall, u.OfOpenAIResponseOutputMessageFileSearchToolCall, u.OfOpenAIResponseOutputMessageFunctionToolCall, @@ -8860,15 +8966,15 @@ func (u ResponseNewParamsInputArrayItemUnion) MarshalJSON() ([]byte, error) { u.OfOpenAIResponseMcpApprovalRequest, u.OfOpenAIResponseInputFunctionToolCallOutput, u.OfOpenAIResponseMcpApprovalResponse, - u.OfResponseNewsInputArrayItemOpenAIResponseMessage) + u.OfResponseNewsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInput) } -func (u *ResponseNewParamsInputArrayItemUnion) UnmarshalJSON(data []byte) error { +func (u *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *ResponseNewParamsInputArrayItemUnion) asAny() any { - if !param.IsOmitted(u.OfOpenAIResponseMessage) { - return u.OfOpenAIResponseMessage +func (u *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemUnion) asAny() any { + if !param.IsOmitted(u.OfOpenAIResponseMessageInput) { + return u.OfOpenAIResponseMessageInput } else if !param.IsOmitted(u.OfOpenAIResponseOutputMessageWebSearchToolCall) { return u.OfOpenAIResponseOutputMessageWebSearchToolCall } else if !param.IsOmitted(u.OfOpenAIResponseOutputMessageFileSearchToolCall) { @@ -8885,14 +8991,14 @@ func (u *ResponseNewParamsInputArrayItemUnion) asAny() any { return u.OfOpenAIResponseInputFunctionToolCallOutput } else if !param.IsOmitted(u.OfOpenAIResponseMcpApprovalResponse) { return u.OfOpenAIResponseMcpApprovalResponse - } else if !param.IsOmitted(u.OfResponseNewsInputArrayItemOpenAIResponseMessage) { - return u.OfResponseNewsInputArrayItemOpenAIResponseMessage + } else if !param.IsOmitted(u.OfResponseNewsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInput) { + return u.OfResponseNewsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInput } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemUnion) GetQueries() []string { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemUnion) GetQueries() []string { if vt := u.OfOpenAIResponseOutputMessageFileSearchToolCall; vt != nil { return vt.Queries } @@ -8900,7 +9006,7 @@ func (u ResponseNewParamsInputArrayItemUnion) GetQueries() []string { } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemUnion) GetResults() []ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCallResult { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemUnion) GetResults() []ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageFileSearchToolCallResult { if vt := u.OfOpenAIResponseOutputMessageFileSearchToolCall; vt != nil { return vt.Results } @@ -8908,7 +9014,7 @@ func (u ResponseNewParamsInputArrayItemUnion) GetResults() []ResponseNewParamsIn } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemUnion) GetError() *string { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemUnion) GetError() *string { if vt := u.OfOpenAIResponseOutputMessageMcpCall; vt != nil && vt.Error.Valid() { return &vt.Error.Value } @@ -8916,7 +9022,7 @@ func (u ResponseNewParamsInputArrayItemUnion) GetError() *string { } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemUnion) GetTools() []ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListToolsTool { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemUnion) GetTools() []ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageMcpListToolsTool { if vt := u.OfOpenAIResponseOutputMessageMcpListTools; vt != nil { return vt.Tools } @@ -8924,7 +9030,7 @@ func (u ResponseNewParamsInputArrayItemUnion) GetTools() []ResponseNewParamsInpu } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemUnion) GetApprovalRequestID() *string { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemUnion) GetApprovalRequestID() *string { if vt := u.OfOpenAIResponseMcpApprovalResponse; vt != nil { return &vt.ApprovalRequestID } @@ -8932,7 +9038,7 @@ func (u ResponseNewParamsInputArrayItemUnion) GetApprovalRequestID() *string { } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemUnion) GetApprove() *bool { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemUnion) GetApprove() *bool { if vt := u.OfOpenAIResponseMcpApprovalResponse; vt != nil { return &vt.Approve } @@ -8940,7 +9046,7 @@ func (u ResponseNewParamsInputArrayItemUnion) GetApprove() *bool { } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemUnion) GetReason() *string { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemUnion) GetReason() *string { if vt := u.OfOpenAIResponseMcpApprovalResponse; vt != nil && vt.Reason.Valid() { return &vt.Reason.Value } @@ -8948,44 +9054,18 @@ func (u ResponseNewParamsInputArrayItemUnion) GetReason() *string { } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemUnion) GetRole() *string { - if vt := u.OfOpenAIResponseMessage; vt != nil { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemUnion) GetRole() *string { + if vt := u.OfOpenAIResponseMessageInput; vt != nil { return (*string)(&vt.Role) - } else if vt := u.OfResponseNewsInputArrayItemOpenAIResponseMessage; vt != nil { + } else if vt := u.OfResponseNewsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInput; vt != nil { return (*string)(&vt.Role) } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemUnion) GetType() *string { - if vt := u.OfOpenAIResponseMessage; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfOpenAIResponseOutputMessageWebSearchToolCall; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfOpenAIResponseOutputMessageFileSearchToolCall; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfOpenAIResponseOutputMessageFunctionToolCall; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfOpenAIResponseOutputMessageMcpCall; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfOpenAIResponseOutputMessageMcpListTools; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfOpenAIResponseMcpApprovalRequest; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfOpenAIResponseInputFunctionToolCallOutput; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfOpenAIResponseMcpApprovalResponse; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfResponseNewsInputArrayItemOpenAIResponseMessage; vt != nil { - return (*string)(&vt.Type) - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemUnion) GetID() *string { - if vt := u.OfOpenAIResponseMessage; vt != nil && vt.ID.Valid() { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemUnion) GetID() *string { + if vt := u.OfOpenAIResponseMessageInput; vt != nil && vt.ID.Valid() { return &vt.ID.Value } else if vt := u.OfOpenAIResponseOutputMessageWebSearchToolCall; vt != nil { return (*string)(&vt.ID) @@ -9003,15 +9083,15 @@ func (u ResponseNewParamsInputArrayItemUnion) GetID() *string { return &vt.ID.Value } else if vt := u.OfOpenAIResponseMcpApprovalResponse; vt != nil && vt.ID.Valid() { return &vt.ID.Value - } else if vt := u.OfResponseNewsInputArrayItemOpenAIResponseMessage; vt != nil && vt.ID.Valid() { + } else if vt := u.OfResponseNewsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInput; vt != nil && vt.ID.Valid() { return &vt.ID.Value } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemUnion) GetStatus() *string { - if vt := u.OfOpenAIResponseMessage; vt != nil && vt.Status.Valid() { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemUnion) GetStatus() *string { + if vt := u.OfOpenAIResponseMessageInput; vt != nil && vt.Status.Valid() { return &vt.Status.Value } else if vt := u.OfOpenAIResponseOutputMessageWebSearchToolCall; vt != nil { return (*string)(&vt.Status) @@ -9021,14 +9101,40 @@ func (u ResponseNewParamsInputArrayItemUnion) GetStatus() *string { return &vt.Status.Value } else if vt := u.OfOpenAIResponseInputFunctionToolCallOutput; vt != nil && vt.Status.Valid() { return &vt.Status.Value - } else if vt := u.OfResponseNewsInputArrayItemOpenAIResponseMessage; vt != nil && vt.Status.Valid() { + } else if vt := u.OfResponseNewsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInput; vt != nil && vt.Status.Valid() { return &vt.Status.Value } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemUnion) GetArguments() *string { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemUnion) GetType() *string { + if vt := u.OfOpenAIResponseMessageInput; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfOpenAIResponseOutputMessageWebSearchToolCall; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfOpenAIResponseOutputMessageFileSearchToolCall; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfOpenAIResponseOutputMessageFunctionToolCall; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfOpenAIResponseOutputMessageMcpCall; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfOpenAIResponseOutputMessageMcpListTools; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfOpenAIResponseMcpApprovalRequest; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfOpenAIResponseInputFunctionToolCallOutput; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfOpenAIResponseMcpApprovalResponse; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfResponseNewsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInput; vt != nil { + return (*string)(&vt.Type) + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemUnion) GetArguments() *string { if vt := u.OfOpenAIResponseOutputMessageFunctionToolCall; vt != nil { return (*string)(&vt.Arguments) } else if vt := u.OfOpenAIResponseOutputMessageMcpCall; vt != nil { @@ -9040,7 +9146,7 @@ func (u ResponseNewParamsInputArrayItemUnion) GetArguments() *string { } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemUnion) GetCallID() *string { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemUnion) GetCallID() *string { if vt := u.OfOpenAIResponseOutputMessageFunctionToolCall; vt != nil { return (*string)(&vt.CallID) } else if vt := u.OfOpenAIResponseInputFunctionToolCallOutput; vt != nil { @@ -9050,7 +9156,7 @@ func (u ResponseNewParamsInputArrayItemUnion) GetCallID() *string { } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemUnion) GetName() *string { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemUnion) GetName() *string { if vt := u.OfOpenAIResponseOutputMessageFunctionToolCall; vt != nil { return (*string)(&vt.Name) } else if vt := u.OfOpenAIResponseOutputMessageMcpCall; vt != nil { @@ -9062,7 +9168,7 @@ func (u ResponseNewParamsInputArrayItemUnion) GetName() *string { } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemUnion) GetServerLabel() *string { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemUnion) GetServerLabel() *string { if vt := u.OfOpenAIResponseOutputMessageMcpCall; vt != nil { return (*string)(&vt.ServerLabel) } else if vt := u.OfOpenAIResponseOutputMessageMcpListTools; vt != nil { @@ -9074,7 +9180,7 @@ func (u ResponseNewParamsInputArrayItemUnion) GetServerLabel() *string { } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemUnion) GetOutput() *string { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemUnion) GetOutput() *string { if vt := u.OfOpenAIResponseOutputMessageMcpCall; vt != nil && vt.Output.Valid() { return &vt.Output.Value } else if vt := u.OfOpenAIResponseInputFunctionToolCallOutput; vt != nil { @@ -9084,10 +9190,10 @@ func (u ResponseNewParamsInputArrayItemUnion) GetOutput() *string { } // Returns a pointer to the underlying variant's Content property, if present. -func (u ResponseNewParamsInputArrayItemUnion) GetContent() *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentUnion { - if vt := u.OfOpenAIResponseMessage; vt != nil { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemUnion) GetContent() *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentUnion { + if vt := u.OfOpenAIResponseMessageInput; vt != nil { return &vt.Content - } else if vt := u.OfResponseNewsInputArrayItemOpenAIResponseMessage; vt != nil { + } else if vt := u.OfResponseNewsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInput; vt != nil { return &vt.Content } return nil @@ -9097,50 +9203,59 @@ func (u ResponseNewParamsInputArrayItemUnion) GetContent() *ResponseNewParamsInp // under one type because the Responses API gives them all the same "type" value, // and there is no way to tell them apart in certain scenarios. // -// The properties Content, Role, Type are required. -type ResponseNewParamsInputArrayItemOpenAIResponseMessage struct { - Content ResponseNewParamsInputArrayItemOpenAIResponseMessageContentUnion `json:"content,omitzero,required"` +// The properties Content, Role are required. +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInput struct { + Content ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentUnion `json:"content,omitzero,required"` // Any of "system", "developer", "user", "assistant". - Role ResponseNewParamsInputArrayItemOpenAIResponseMessageRole `json:"role,omitzero,required"` - ID param.Opt[string] `json:"id,omitzero"` - Status param.Opt[string] `json:"status,omitzero"` - // This field can be elided, and will marshal its zero value as "message". - Type constant.Message `json:"type,required"` + Role string `json:"role,omitzero,required"` + ID param.Opt[string] `json:"id,omitzero"` + Status param.Opt[string] `json:"status,omitzero"` + // Any of "message". + Type string `json:"type,omitzero"` paramObj } -func (r ResponseNewParamsInputArrayItemOpenAIResponseMessage) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsInputArrayItemOpenAIResponseMessage +func (r ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInput) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInput return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ResponseNewParamsInputArrayItemOpenAIResponseMessage) UnmarshalJSON(data []byte) error { +func (r *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInput) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInput]( + "role", "system", "developer", "user", "assistant", + ) + apijson.RegisterFieldValidator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInput]( + "type", "message", + ) +} + // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. -type ResponseNewParamsInputArrayItemOpenAIResponseMessageContentUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfResponseNewsInputArrayItemOpenAIResponseMessageContentArray []ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion `json:",omitzero,inline"` - OfVariant2 []ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion `json:",omitzero,inline"` +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentUnion struct { + OfString param.Opt[string] `json:",omitzero,inline"` + OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile []ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion `json:",omitzero,inline"` + OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal []ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion `json:",omitzero,inline"` paramUnion } -func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfResponseNewsInputArrayItemOpenAIResponseMessageContentArray, u.OfVariant2) +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfString, u.OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile, u.OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal) } -func (u *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentUnion) UnmarshalJSON(data []byte) error { +func (u *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentUnion) asAny() any { +func (u *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentUnion) asAny() any { if !param.IsOmitted(u.OfString) { return &u.OfString.Value - } else if !param.IsOmitted(u.OfResponseNewsInputArrayItemOpenAIResponseMessageContentArray) { - return &u.OfResponseNewsInputArrayItemOpenAIResponseMessageContentArray - } else if !param.IsOmitted(u.OfVariant2) { - return &u.OfVariant2 + } else if !param.IsOmitted(u.OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile) { + return &u.OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile + } else if !param.IsOmitted(u.OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal) { + return &u.OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal } return nil } @@ -9148,21 +9263,21 @@ func (u *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentUnion) asAny // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. -type ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion struct { - OfInputText *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputText `json:",omitzero,inline"` - OfInputImage *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImage `json:",omitzero,inline"` - OfInputFile *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputFile `json:",omitzero,inline"` +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion struct { + OfInputText *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText `json:",omitzero,inline"` + OfInputImage *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage `json:",omitzero,inline"` + OfInputFile *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile `json:",omitzero,inline"` paramUnion } -func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) MarshalJSON() ([]byte, error) { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) MarshalJSON() ([]byte, error) { return param.MarshalUnion(u, u.OfInputText, u.OfInputImage, u.OfInputFile) } -func (u *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) UnmarshalJSON(data []byte) error { +func (u *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) asAny() any { +func (u *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) asAny() any { if !param.IsOmitted(u.OfInputText) { return u.OfInputText } else if !param.IsOmitted(u.OfInputImage) { @@ -9174,7 +9289,7 @@ func (u *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUni } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) GetText() *string { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetText() *string { if vt := u.OfInputText; vt != nil { return &vt.Text } @@ -9182,15 +9297,15 @@ func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnio } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) GetDetail() *string { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetDetail() *string { if vt := u.OfInputImage; vt != nil { - return (*string)(&vt.Detail) + return &vt.Detail } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) GetImageURL() *string { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetImageURL() *string { if vt := u.OfInputImage; vt != nil && vt.ImageURL.Valid() { return &vt.ImageURL.Value } @@ -9198,7 +9313,7 @@ func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnio } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) GetFileData() *string { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetFileData() *string { if vt := u.OfInputFile; vt != nil && vt.FileData.Valid() { return &vt.FileData.Value } @@ -9206,7 +9321,7 @@ func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnio } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) GetFileURL() *string { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetFileURL() *string { if vt := u.OfInputFile; vt != nil && vt.FileURL.Valid() { return &vt.FileURL.Value } @@ -9214,7 +9329,7 @@ func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnio } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) GetFilename() *string { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetFilename() *string { if vt := u.OfInputFile; vt != nil && vt.Filename.Valid() { return &vt.Filename.Value } @@ -9222,7 +9337,7 @@ func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnio } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) GetType() *string { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetType() *string { if vt := u.OfInputText; vt != nil { return (*string)(&vt.Type) } else if vt := u.OfInputImage; vt != nil { @@ -9234,7 +9349,7 @@ func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnio } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) GetFileID() *string { +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) GetFileID() *string { if vt := u.OfInputImage; vt != nil && vt.FileID.Valid() { return &vt.FileID.Value } else if vt := u.OfInputFile; vt != nil && vt.FileID.Valid() { @@ -9244,428 +9359,699 @@ func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnio } func init() { - apijson.RegisterUnion[ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion]( + apijson.RegisterUnion[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion]( "type", - apijson.Discriminator[ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputText]("input_text"), - apijson.Discriminator[ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImage]("input_image"), - apijson.Discriminator[ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputFile]("input_file"), + apijson.Discriminator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText]("input_text"), + apijson.Discriminator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]("input_image"), + apijson.Discriminator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]("input_file"), ) } // Text content for input messages in OpenAI response format. // -// The properties Text, Type are required. -type ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputText struct { - // The text content of the input message +// The property Text is required. +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText struct { Text string `json:"text,required"` - // Content type identifier, always "input_text" - // - // This field can be elided, and will marshal its zero value as "input_text". - Type constant.InputText `json:"type,required"` + // Any of "input_text". + Type string `json:"type,omitzero"` paramObj } -func (r ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputText) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputText +func (r ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputText) UnmarshalJSON(data []byte) error { +func (r *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText]( + "type", "input_text", + ) +} + // Image content for input messages in OpenAI response format. -// -// The properties Detail, Type are required. -type ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImage struct { - // Level of detail for image processing, can be "low", "high", or "auto" - // - // Any of "low", "high", "auto". - Detail ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImageDetail `json:"detail,omitzero,required"` - // (Optional) The ID of the file to be sent to the model. - FileID param.Opt[string] `json:"file_id,omitzero"` - // (Optional) URL of the image content +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage struct { + FileID param.Opt[string] `json:"file_id,omitzero"` ImageURL param.Opt[string] `json:"image_url,omitzero"` - // Content type identifier, always "input_image" - // - // This field can be elided, and will marshal its zero value as "input_image". - Type constant.InputImage `json:"type,required"` + // Any of "low", "high", "auto". + Detail string `json:"detail,omitzero"` + // Any of "input_image". + Type string `json:"type,omitzero"` paramObj } -func (r ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImage) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImage +func (r ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImage) UnmarshalJSON(data []byte) error { +func (r *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImageDetail string - -const ( - ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImageDetailLow ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImageDetail = "low" - ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImageDetailHigh ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImageDetail = "high" - ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImageDetailAuto ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImageDetail = "auto" -) +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]( + "detail", "low", "high", "auto", + ) + apijson.RegisterFieldValidator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]( + "type", "input_image", + ) +} // File content for input messages in OpenAI response format. -// -// The property Type is required. -type ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputFile struct { - // The data of the file to be sent to the model. +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile struct { FileData param.Opt[string] `json:"file_data,omitzero"` - // (Optional) The ID of the file to be sent to the model. - FileID param.Opt[string] `json:"file_id,omitzero"` - // The URL of the file to be sent to the model. - FileURL param.Opt[string] `json:"file_url,omitzero"` - // The name of the file to be sent to the model. + FileID param.Opt[string] `json:"file_id,omitzero"` + FileURL param.Opt[string] `json:"file_url,omitzero"` Filename param.Opt[string] `json:"filename,omitzero"` - // The type of the input item. Always `input_file`. - // - // This field can be elided, and will marshal its zero value as "input_file". - Type constant.InputFile `json:"type,required"` + // Any of "input_file". + Type string `json:"type,omitzero"` paramObj } -func (r ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputFile) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputFile +func (r ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputFile) UnmarshalJSON(data []byte) error { +func (r *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ResponseNewParamsInputArrayItemOpenAIResponseMessageRole string - -const ( - ResponseNewParamsInputArrayItemOpenAIResponseMessageRoleSystem ResponseNewParamsInputArrayItemOpenAIResponseMessageRole = "system" - ResponseNewParamsInputArrayItemOpenAIResponseMessageRoleDeveloper ResponseNewParamsInputArrayItemOpenAIResponseMessageRole = "developer" - ResponseNewParamsInputArrayItemOpenAIResponseMessageRoleUser ResponseNewParamsInputArrayItemOpenAIResponseMessageRole = "user" - ResponseNewParamsInputArrayItemOpenAIResponseMessageRoleAssistant ResponseNewParamsInputArrayItemOpenAIResponseMessageRole = "assistant" -) +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]( + "type", "input_file", + ) +} -// Web search tool call output message for OpenAI responses. +// Only one field can be non-zero. // -// The properties ID, Status, Type are required. -type ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageWebSearchToolCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // Current status of the web search operation - Status string `json:"status,required"` - // Tool call type identifier, always "web_search_call" - // - // This field can be elided, and will marshal its zero value as "web_search_call". - Type constant.WebSearchCall `json:"type,required"` +// Use [param.IsOmitted] to confirm if a field is set. +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion struct { + OfOutputText *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText `json:",omitzero,inline"` + OfRefusal *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal `json:",omitzero,inline"` + paramUnion +} + +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfOutputText, u.OfRefusal) +} +func (u *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) asAny() any { + if !param.IsOmitted(u.OfOutputText) { + return u.OfOutputText + } else if !param.IsOmitted(u.OfRefusal) { + return u.OfRefusal + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) GetText() *string { + if vt := u.OfOutputText; vt != nil { + return &vt.Text + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) GetAnnotations() []ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion { + if vt := u.OfOutputText; vt != nil { + return vt.Annotations + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) GetRefusal() *string { + if vt := u.OfRefusal; vt != nil { + return &vt.Refusal + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) GetType() *string { + if vt := u.OfOutputText; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfRefusal; vt != nil { + return (*string)(&vt.Type) + } + return nil +} + +func init() { + apijson.RegisterUnion[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion]( + "type", + apijson.Discriminator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]("output_text"), + apijson.Discriminator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]("refusal"), + ) +} + +// The property Text is required. +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText struct { + Text string `json:"text,required"` + Annotations []ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion `json:"annotations,omitzero"` + // Any of "output_text". + Type string `json:"type,omitzero"` paramObj } -func (r ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageWebSearchToolCall) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageWebSearchToolCall +func (r ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageWebSearchToolCall) UnmarshalJSON(data []byte) error { +func (r *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// File search tool call output message for OpenAI responses. +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]( + "type", "output_text", + ) +} + +// Only one field can be non-zero. // -// The properties ID, Queries, Status, Type are required. -type ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // List of search queries executed - Queries []string `json:"queries,omitzero,required"` - // Current status of the file search operation - Status string `json:"status,required"` - // (Optional) Search results returned by the file search operation - Results []ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCallResult `json:"results,omitzero"` - // Tool call type identifier, always "file_search_call" - // - // This field can be elided, and will marshal its zero value as "file_search_call". - Type constant.FileSearchCall `json:"type,required"` +// Use [param.IsOmitted] to confirm if a field is set. +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion struct { + OfFileCitation *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation `json:",omitzero,inline"` + OfURLCitation *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation `json:",omitzero,inline"` + OfContainerFileCitation *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation `json:",omitzero,inline"` + OfFilePath *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath `json:",omitzero,inline"` + paramUnion +} + +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfFileCitation, u.OfURLCitation, u.OfContainerFileCitation, u.OfFilePath) +} +func (u *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) asAny() any { + if !param.IsOmitted(u.OfFileCitation) { + return u.OfFileCitation + } else if !param.IsOmitted(u.OfURLCitation) { + return u.OfURLCitation + } else if !param.IsOmitted(u.OfContainerFileCitation) { + return u.OfContainerFileCitation + } else if !param.IsOmitted(u.OfFilePath) { + return u.OfFilePath + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetTitle() *string { + if vt := u.OfURLCitation; vt != nil { + return &vt.Title + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetURL() *string { + if vt := u.OfURLCitation; vt != nil { + return &vt.URL + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetContainerID() *string { + if vt := u.OfContainerFileCitation; vt != nil { + return &vt.ContainerID + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetFileID() *string { + if vt := u.OfFileCitation; vt != nil { + return (*string)(&vt.FileID) + } else if vt := u.OfContainerFileCitation; vt != nil { + return (*string)(&vt.FileID) + } else if vt := u.OfFilePath; vt != nil { + return (*string)(&vt.FileID) + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetFilename() *string { + if vt := u.OfFileCitation; vt != nil { + return (*string)(&vt.Filename) + } else if vt := u.OfContainerFileCitation; vt != nil { + return (*string)(&vt.Filename) + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetIndex() *int64 { + if vt := u.OfFileCitation; vt != nil { + return (*int64)(&vt.Index) + } else if vt := u.OfFilePath; vt != nil { + return (*int64)(&vt.Index) + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetType() *string { + if vt := u.OfFileCitation; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfURLCitation; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfContainerFileCitation; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfFilePath; vt != nil { + return (*string)(&vt.Type) + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetEndIndex() *int64 { + if vt := u.OfURLCitation; vt != nil { + return (*int64)(&vt.EndIndex) + } else if vt := u.OfContainerFileCitation; vt != nil { + return (*int64)(&vt.EndIndex) + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) GetStartIndex() *int64 { + if vt := u.OfURLCitation; vt != nil { + return (*int64)(&vt.StartIndex) + } else if vt := u.OfContainerFileCitation; vt != nil { + return (*int64)(&vt.StartIndex) + } + return nil +} + +func init() { + apijson.RegisterUnion[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion]( + "type", + apijson.Discriminator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation]("file_citation"), + apijson.Discriminator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]("url_citation"), + apijson.Discriminator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation]("container_file_citation"), + apijson.Discriminator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath]("file_path"), + ) +} + +// File citation annotation for referencing specific files in response content. +// +// The properties FileID, Filename, Index are required. +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation struct { + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Index int64 `json:"index,required"` + // Any of "file_citation". + Type string `json:"type,omitzero"` paramObj } -func (r ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCall) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCall +func (r ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCall) UnmarshalJSON(data []byte) error { +func (r *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Search results returned by the file search operation. +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation]( + "type", "file_citation", + ) +} + +// URL citation annotation for referencing external web resources. // -// The properties Attributes, FileID, Filename, Score, Text are required. -type ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCallResult struct { - // (Optional) Key-value attributes associated with the file - Attributes map[string]ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion `json:"attributes,omitzero,required"` - // Unique identifier of the file containing the result +// The properties EndIndex, StartIndex, Title, URL are required. +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation struct { + EndIndex int64 `json:"end_index,required"` + StartIndex int64 `json:"start_index,required"` + Title string `json:"title,required"` + URL string `json:"url,required"` + // Any of "url_citation". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]( + "type", "url_citation", + ) +} + +// The properties ContainerID, EndIndex, FileID, Filename, StartIndex are required. +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation struct { + ContainerID string `json:"container_id,required"` + EndIndex int64 `json:"end_index,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + StartIndex int64 `json:"start_index,required"` + // Any of "container_file_citation". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation]( + "type", "container_file_citation", + ) +} + +// The properties FileID, Index are required. +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath struct { FileID string `json:"file_id,required"` - // Name of the file containing the result - Filename string `json:"filename,required"` - // Relevance score for this search result (between 0 and 1) - Score float64 `json:"score,required"` - // Text content of the search result - Text string `json:"text,required"` + Index int64 `json:"index,required"` + // Any of "file_path". + Type string `json:"type,omitzero"` paramObj } -func (r ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCallResult) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCallResult +func (r ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCallResult) UnmarshalJSON(data []byte) error { +func (r *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath]( + "type", "file_path", + ) +} + +// Refusal content within a streamed response part. // -// Use [param.IsOmitted] to confirm if a field is set. -type ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion +// The property Refusal is required. +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal struct { + Refusal string `json:"refusal,required"` + // Any of "refusal". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMessageInputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]( + "type", "refusal", + ) +} + +// Web search tool call output message for OpenAI responses. +// +// The properties ID, Status are required. +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageWebSearchToolCall struct { + ID string `json:"id,required"` + Status string `json:"status,required"` + // Any of "web_search_call". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageWebSearchToolCall) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageWebSearchToolCall + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageWebSearchToolCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageWebSearchToolCall]( + "type", "web_search_call", + ) +} + +// File search tool call output message for OpenAI responses. +// +// The properties ID, Queries, Status are required. +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageFileSearchToolCall struct { + ID string `json:"id,required"` + Queries []string `json:"queries,omitzero,required"` + Status string `json:"status,required"` + Results []ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageFileSearchToolCallResult `json:"results,omitzero"` + // Any of "file_search_call". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageFileSearchToolCall) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageFileSearchToolCall + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageFileSearchToolCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageFileSearchToolCall]( + "type", "file_search_call", + ) +} + +// Search results returned by the file search operation. +// +// The properties Attributes, FileID, Filename, Score, Text are required. +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageFileSearchToolCallResult struct { + Attributes map[string]any `json:"attributes,omitzero,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Score float64 `json:"score,required"` + Text string `json:"text,required"` + paramObj } -func (u ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) +func (r ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageFileSearchToolCallResult) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageFileSearchToolCallResult + return param.MarshalObject(r, (*shadow)(&r)) } - -func (u *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil +func (r *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageFileSearchToolCallResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } // Function tool call output message for OpenAI responses. // -// The properties Arguments, CallID, Name, Type are required. -type ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFunctionToolCall struct { - // JSON string containing the function arguments - Arguments string `json:"arguments,required"` - // Unique identifier for the function call - CallID string `json:"call_id,required"` - // Name of the function being called - Name string `json:"name,required"` - // (Optional) Additional identifier for the tool call - ID param.Opt[string] `json:"id,omitzero"` - // (Optional) Current status of the function call execution - Status param.Opt[string] `json:"status,omitzero"` - // Tool call type identifier, always "function_call" - // - // This field can be elided, and will marshal its zero value as "function_call". - Type constant.FunctionCall `json:"type,required"` +// The properties Arguments, CallID, Name are required. +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageFunctionToolCall struct { + Arguments string `json:"arguments,required"` + CallID string `json:"call_id,required"` + Name string `json:"name,required"` + ID param.Opt[string] `json:"id,omitzero"` + Status param.Opt[string] `json:"status,omitzero"` + // Any of "function_call". + Type string `json:"type,omitzero"` paramObj } -func (r ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFunctionToolCall) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFunctionToolCall +func (r ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageFunctionToolCall) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageFunctionToolCall return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFunctionToolCall) UnmarshalJSON(data []byte) error { +func (r *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageFunctionToolCall) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageFunctionToolCall]( + "type", "function_call", + ) +} + // Model Context Protocol (MCP) call output message for OpenAI responses. // -// The properties ID, Arguments, Name, ServerLabel, Type are required. -type ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpCall struct { - // Unique identifier for this MCP call - ID string `json:"id,required"` - // JSON string containing the MCP call arguments - Arguments string `json:"arguments,required"` - // Name of the MCP method being called - Name string `json:"name,required"` - // Label identifying the MCP server handling the call - ServerLabel string `json:"server_label,required"` - // (Optional) Error message if the MCP call failed - Error param.Opt[string] `json:"error,omitzero"` - // (Optional) Output result from the successful MCP call - Output param.Opt[string] `json:"output,omitzero"` - // Tool call type identifier, always "mcp_call" - // - // This field can be elided, and will marshal its zero value as "mcp_call". - Type constant.McpCall `json:"type,required"` +// The properties ID, Arguments, Name, ServerLabel are required. +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageMcpCall struct { + ID string `json:"id,required"` + Arguments string `json:"arguments,required"` + Name string `json:"name,required"` + ServerLabel string `json:"server_label,required"` + Error param.Opt[string] `json:"error,omitzero"` + Output param.Opt[string] `json:"output,omitzero"` + // Any of "mcp_call". + Type string `json:"type,omitzero"` paramObj } -func (r ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpCall) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpCall +func (r ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageMcpCall) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageMcpCall return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpCall) UnmarshalJSON(data []byte) error { +func (r *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageMcpCall) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageMcpCall]( + "type", "mcp_call", + ) +} + // MCP list tools output message containing available tools from an MCP server. // -// The properties ID, ServerLabel, Tools, Type are required. -type ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListTools struct { - // Unique identifier for this MCP list tools operation - ID string `json:"id,required"` - // Label identifying the MCP server providing the tools - ServerLabel string `json:"server_label,required"` - // List of available tools provided by the MCP server - Tools []ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListToolsTool `json:"tools,omitzero,required"` - // Tool call type identifier, always "mcp_list_tools" - // - // This field can be elided, and will marshal its zero value as "mcp_list_tools". - Type constant.McpListTools `json:"type,required"` +// The properties ID, ServerLabel, Tools are required. +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageMcpListTools struct { + ID string `json:"id,required"` + ServerLabel string `json:"server_label,required"` + Tools []ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageMcpListToolsTool `json:"tools,omitzero,required"` + // Any of "mcp_list_tools". + Type string `json:"type,omitzero"` paramObj } -func (r ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListTools) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListTools +func (r ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageMcpListTools) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageMcpListTools return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListTools) UnmarshalJSON(data []byte) error { +func (r *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageMcpListTools) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageMcpListTools]( + "type", "mcp_list_tools", + ) +} + // Tool definition returned by MCP list tools operation. // // The properties InputSchema, Name are required. -type ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListToolsTool struct { - // JSON schema defining the tool's input parameters - InputSchema map[string]ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion `json:"input_schema,omitzero,required"` - // Name of the tool - Name string `json:"name,required"` - // (Optional) Description of what the tool does +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageMcpListToolsTool struct { + InputSchema map[string]any `json:"input_schema,omitzero,required"` + Name string `json:"name,required"` Description param.Opt[string] `json:"description,omitzero"` paramObj } -func (r ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListToolsTool) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListToolsTool +func (r ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageMcpListToolsTool) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageMcpListToolsTool return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListToolsTool) UnmarshalJSON(data []byte) error { +func (r *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseOutputMessageMcpListToolsTool) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - // A request for human approval of a tool invocation. // -// The properties ID, Arguments, Name, ServerLabel, Type are required. -type ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalRequest struct { +// The properties ID, Arguments, Name, ServerLabel are required. +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMcpApprovalRequest struct { ID string `json:"id,required"` Arguments string `json:"arguments,required"` Name string `json:"name,required"` ServerLabel string `json:"server_label,required"` - // This field can be elided, and will marshal its zero value as - // "mcp_approval_request". - Type constant.McpApprovalRequest `json:"type,required"` + // Any of "mcp_approval_request". + Type string `json:"type,omitzero"` paramObj } -func (r ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalRequest) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalRequest +func (r ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMcpApprovalRequest) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMcpApprovalRequest return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalRequest) UnmarshalJSON(data []byte) error { +func (r *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMcpApprovalRequest) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMcpApprovalRequest]( + "type", "mcp_approval_request", + ) +} + // This represents the output of a function call that gets passed back to the // model. // -// The properties CallID, Output, Type are required. -type ResponseNewParamsInputArrayItemOpenAIResponseInputFunctionToolCallOutput struct { +// The properties CallID, Output are required. +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseInputFunctionToolCallOutput struct { CallID string `json:"call_id,required"` Output string `json:"output,required"` ID param.Opt[string] `json:"id,omitzero"` Status param.Opt[string] `json:"status,omitzero"` - // This field can be elided, and will marshal its zero value as - // "function_call_output". - Type constant.FunctionCallOutput `json:"type,required"` + // Any of "function_call_output". + Type string `json:"type,omitzero"` paramObj } -func (r ResponseNewParamsInputArrayItemOpenAIResponseInputFunctionToolCallOutput) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsInputArrayItemOpenAIResponseInputFunctionToolCallOutput +func (r ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseInputFunctionToolCallOutput) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseInputFunctionToolCallOutput return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ResponseNewParamsInputArrayItemOpenAIResponseInputFunctionToolCallOutput) UnmarshalJSON(data []byte) error { +func (r *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseInputFunctionToolCallOutput) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseInputFunctionToolCallOutput]( + "type", "function_call_output", + ) +} + // A response to an MCP approval request. // -// The properties ApprovalRequestID, Approve, Type are required. -type ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalResponse struct { +// The properties ApprovalRequestID, Approve are required. +type ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMcpApprovalResponse struct { ApprovalRequestID string `json:"approval_request_id,required"` Approve bool `json:"approve,required"` ID param.Opt[string] `json:"id,omitzero"` Reason param.Opt[string] `json:"reason,omitzero"` - // This field can be elided, and will marshal its zero value as - // "mcp_approval_response". - Type constant.McpApprovalResponse `json:"type,required"` + // Any of "mcp_approval_response". + Type string `json:"type,omitzero"` paramObj } -func (r ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalResponse) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalResponse +func (r ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMcpApprovalResponse) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMcpApprovalResponse return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalResponse) UnmarshalJSON(data []byte) error { +func (r *ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMcpApprovalResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// (Optional) Prompt object with ID, version, and variables. +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsInputListOpenAIResponseMessageUnionOpenAIResponseInputFunctionToolCallOutputItemOpenAIResponseMcpApprovalResponse]( + "type", "mcp_approval_response", + ) +} + +// OpenAI compatible Prompt object that is used in OpenAI responses. // // The property ID is required. type ResponseNewParamsPrompt struct { - // Unique identifier of the prompt template - ID string `json:"id,required"` - // Version number of the prompt to use (defaults to latest if not specified) - Version param.Opt[string] `json:"version,omitzero"` - // Dictionary of variable names to OpenAIResponseInputMessageContent structure for - // template substitution. The substitution values can either be strings, or other - // Response input types like images or files. + ID string `json:"id,required"` + Version param.Opt[string] `json:"version,omitzero"` Variables map[string]ResponseNewParamsPromptVariableUnion `json:"variables,omitzero"` paramObj } @@ -9717,7 +10103,7 @@ func (u ResponseNewParamsPromptVariableUnion) GetText() *string { // Returns a pointer to the underlying variant's property, if present. func (u ResponseNewParamsPromptVariableUnion) GetDetail() *string { if vt := u.OfInputImage; vt != nil { - return (*string)(&vt.Detail) + return &vt.Detail } return nil } @@ -9787,14 +10173,11 @@ func init() { // Text content for input messages in OpenAI response format. // -// The properties Text, Type are required. +// The property Text is required. type ResponseNewParamsPromptVariableInputText struct { - // The text content of the input message Text string `json:"text,required"` - // Content type identifier, always "input_text" - // - // This field can be elided, and will marshal its zero value as "input_text". - Type constant.InputText `json:"type,required"` + // Any of "input_text". + Type string `json:"type,omitzero"` paramObj } @@ -9806,22 +10189,20 @@ func (r *ResponseNewParamsPromptVariableInputText) UnmarshalJSON(data []byte) er return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsPromptVariableInputText]( + "type", "input_text", + ) +} + // Image content for input messages in OpenAI response format. -// -// The properties Detail, Type are required. type ResponseNewParamsPromptVariableInputImage struct { - // Level of detail for image processing, can be "low", "high", or "auto" - // - // Any of "low", "high", "auto". - Detail ResponseNewParamsPromptVariableInputImageDetail `json:"detail,omitzero,required"` - // (Optional) The ID of the file to be sent to the model. - FileID param.Opt[string] `json:"file_id,omitzero"` - // (Optional) URL of the image content + FileID param.Opt[string] `json:"file_id,omitzero"` ImageURL param.Opt[string] `json:"image_url,omitzero"` - // Content type identifier, always "input_image" - // - // This field can be elided, and will marshal its zero value as "input_image". - Type constant.InputImage `json:"type,required"` + // Any of "low", "high", "auto". + Detail string `json:"detail,omitzero"` + // Any of "input_image". + Type string `json:"type,omitzero"` paramObj } @@ -9833,31 +10214,23 @@ func (r *ResponseNewParamsPromptVariableInputImage) UnmarshalJSON(data []byte) e return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ResponseNewParamsPromptVariableInputImageDetail string - -const ( - ResponseNewParamsPromptVariableInputImageDetailLow ResponseNewParamsPromptVariableInputImageDetail = "low" - ResponseNewParamsPromptVariableInputImageDetailHigh ResponseNewParamsPromptVariableInputImageDetail = "high" - ResponseNewParamsPromptVariableInputImageDetailAuto ResponseNewParamsPromptVariableInputImageDetail = "auto" -) +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsPromptVariableInputImage]( + "detail", "low", "high", "auto", + ) + apijson.RegisterFieldValidator[ResponseNewParamsPromptVariableInputImage]( + "type", "input_image", + ) +} // File content for input messages in OpenAI response format. -// -// The property Type is required. type ResponseNewParamsPromptVariableInputFile struct { - // The data of the file to be sent to the model. FileData param.Opt[string] `json:"file_data,omitzero"` - // (Optional) The ID of the file to be sent to the model. - FileID param.Opt[string] `json:"file_id,omitzero"` - // The URL of the file to be sent to the model. - FileURL param.Opt[string] `json:"file_url,omitzero"` - // The name of the file to be sent to the model. + FileID param.Opt[string] `json:"file_id,omitzero"` + FileURL param.Opt[string] `json:"file_url,omitzero"` Filename param.Opt[string] `json:"filename,omitzero"` - // The type of the input item. Always `input_file`. - // - // This field can be elided, and will marshal its zero value as "input_file". - Type constant.InputFile `json:"type,required"` + // Any of "input_file". + Type string `json:"type,omitzero"` paramObj } @@ -9869,9 +10242,15 @@ func (r *ResponseNewParamsPromptVariableInputFile) UnmarshalJSON(data []byte) er return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsPromptVariableInputFile]( + "type", "input_file", + ) +} + // Text response configuration for OpenAI responses. type ResponseNewParamsText struct { - // (Optional) Text format configuration specifying output format requirements + // Configuration for Responses API text format. Format ResponseNewParamsTextFormat `json:"format,omitzero"` paramObj } @@ -9884,24 +10263,14 @@ func (r *ResponseNewParamsText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// (Optional) Text format configuration specifying output format requirements -// -// The property Type is required. +// Configuration for Responses API text format. type ResponseNewParamsTextFormat struct { - // Must be "text", "json_schema", or "json_object" to identify the format type - // - // Any of "text", "json_schema", "json_object". - Type ResponseNewParamsTextFormatType `json:"type,omitzero,required"` - // (Optional) A description of the response format. Only used for json_schema. Description param.Opt[string] `json:"description,omitzero"` - // The name of the response format. Only used for json_schema. - Name param.Opt[string] `json:"name,omitzero"` - // (Optional) Whether to strictly enforce the JSON schema. If true, the response - // must match the schema exactly. Only used for json_schema. - Strict param.Opt[bool] `json:"strict,omitzero"` - // The JSON schema the response should conform to. In a Python SDK, this is often a - // `pydantic` model. Only used for json_schema. - Schema map[string]ResponseNewParamsTextFormatSchemaUnion `json:"schema,omitzero"` + Name param.Opt[string] `json:"name,omitzero"` + Strict param.Opt[bool] `json:"strict,omitzero"` + Schema map[string]any `json:"schema,omitzero"` + // Any of "text", "json_schema", "json_object". + Type string `json:"type,omitzero"` paramObj } @@ -9913,44 +10282,10 @@ func (r *ResponseNewParamsTextFormat) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Must be "text", "json_schema", or "json_object" to identify the format type -type ResponseNewParamsTextFormatType string - -const ( - ResponseNewParamsTextFormatTypeText ResponseNewParamsTextFormatType = "text" - ResponseNewParamsTextFormatTypeJsonSchema ResponseNewParamsTextFormatType = "json_schema" - ResponseNewParamsTextFormatTypeJsonObject ResponseNewParamsTextFormatType = "json_object" -) - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ResponseNewParamsTextFormatSchemaUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u ResponseNewParamsTextFormatSchemaUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *ResponseNewParamsTextFormatSchemaUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ResponseNewParamsTextFormatSchemaUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsTextFormat]( + "type", "text", "json_schema", "json_object", + ) } // Only one field can be non-zero. @@ -10001,7 +10336,7 @@ func (u ResponseNewParamsToolUnion) GetVectorStoreIDs() []string { } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsToolUnion) GetFilters() map[string]ResponseNewParamsToolFileSearchFilterUnion { +func (u ResponseNewParamsToolUnion) GetFilters() map[string]any { if vt := u.OfFileSearch; vt != nil { return vt.Filters } @@ -10033,17 +10368,17 @@ func (u ResponseNewParamsToolUnion) GetName() *string { } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsToolUnion) GetDescription() *string { - if vt := u.OfFunction; vt != nil && vt.Description.Valid() { - return &vt.Description.Value +func (u ResponseNewParamsToolUnion) GetParameters() map[string]any { + if vt := u.OfFunction; vt != nil { + return vt.Parameters } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsToolUnion) GetParameters() map[string]ResponseNewParamsToolFunctionParameterUnion { - if vt := u.OfFunction; vt != nil { - return vt.Parameters +func (u ResponseNewParamsToolUnion) GetDescription() *string { + if vt := u.OfFunction; vt != nil && vt.Description.Valid() { + return &vt.Description.Value } return nil } @@ -10056,14 +10391,6 @@ func (u ResponseNewParamsToolUnion) GetStrict() *bool { return nil } -// Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsToolUnion) GetRequireApproval() *ResponseNewParamsToolMcpRequireApprovalUnion { - if vt := u.OfMcp; vt != nil { - return &vt.RequireApproval - } - return nil -} - // Returns a pointer to the underlying variant's property, if present. func (u ResponseNewParamsToolUnion) GetServerLabel() *string { if vt := u.OfMcp; vt != nil { @@ -10097,13 +10424,21 @@ func (u ResponseNewParamsToolUnion) GetAuthorization() *string { } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsToolUnion) GetHeaders() map[string]ResponseNewParamsToolMcpHeaderUnion { +func (u ResponseNewParamsToolUnion) GetHeaders() map[string]any { if vt := u.OfMcp; vt != nil { return vt.Headers } return nil } +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsToolUnion) GetRequireApproval() *ResponseNewParamsToolMcpRequireApprovalUnion { + if vt := u.OfMcp; vt != nil { + return &vt.RequireApproval + } + return nil +} + // Returns a pointer to the underlying variant's property, if present. func (u ResponseNewParamsToolUnion) GetType() *string { if vt := u.OfOpenAIResponseInputToolWebSearch; vt != nil { @@ -10132,16 +10467,11 @@ func init() { } // Web search tool configuration for OpenAI response inputs. -// -// The property Type is required. type ResponseNewParamsToolOpenAIResponseInputToolWebSearch struct { - // Web search tool type variant to use - // + SearchContextSize param.Opt[string] `json:"search_context_size,omitzero"` // Any of "web_search", "web_search_preview", "web_search_preview_2025_03_11", // "web_search_2025_08_26". - Type ResponseNewParamsToolOpenAIResponseInputToolWebSearchType `json:"type,omitzero,required"` - // (Optional) Size of search context, must be "low", "medium", or "high" - SearchContextSize param.Opt[string] `json:"search_context_size,omitzero"` + Type string `json:"type,omitzero"` paramObj } @@ -10153,32 +10483,23 @@ func (r *ResponseNewParamsToolOpenAIResponseInputToolWebSearch) UnmarshalJSON(da return apijson.UnmarshalRoot(data, r) } -// Web search tool type variant to use -type ResponseNewParamsToolOpenAIResponseInputToolWebSearchType string - -const ( - ResponseNewParamsToolOpenAIResponseInputToolWebSearchTypeWebSearch ResponseNewParamsToolOpenAIResponseInputToolWebSearchType = "web_search" - ResponseNewParamsToolOpenAIResponseInputToolWebSearchTypeWebSearchPreview ResponseNewParamsToolOpenAIResponseInputToolWebSearchType = "web_search_preview" - ResponseNewParamsToolOpenAIResponseInputToolWebSearchTypeWebSearchPreview2025_03_11 ResponseNewParamsToolOpenAIResponseInputToolWebSearchType = "web_search_preview_2025_03_11" - ResponseNewParamsToolOpenAIResponseInputToolWebSearchTypeWebSearch2025_08_26 ResponseNewParamsToolOpenAIResponseInputToolWebSearchType = "web_search_2025_08_26" -) +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsToolOpenAIResponseInputToolWebSearch]( + "type", "web_search", "web_search_preview", "web_search_preview_2025_03_11", "web_search_2025_08_26", + ) +} // File search tool configuration for OpenAI response inputs. // -// The properties Type, VectorStoreIDs are required. +// The property VectorStoreIDs is required. type ResponseNewParamsToolFileSearch struct { - // List of vector store identifiers to search within - VectorStoreIDs []string `json:"vector_store_ids,omitzero,required"` - // (Optional) Maximum number of search results to return (1-50) - MaxNumResults param.Opt[int64] `json:"max_num_results,omitzero"` - // (Optional) Additional filters to apply to the search - Filters map[string]ResponseNewParamsToolFileSearchFilterUnion `json:"filters,omitzero"` - // (Optional) Options for ranking and scoring search results + VectorStoreIDs []string `json:"vector_store_ids,omitzero,required"` + MaxNumResults param.Opt[int64] `json:"max_num_results,omitzero"` + Filters map[string]any `json:"filters,omitzero"` + // Options for ranking and filtering search results. RankingOptions ResponseNewParamsToolFileSearchRankingOptions `json:"ranking_options,omitzero"` - // Tool type identifier, always "file_search" - // - // This field can be elided, and will marshal its zero value as "file_search". - Type constant.FileSearch `json:"type,required"` + // Any of "file_search". + Type string `json:"type,omitzero"` paramObj } @@ -10190,42 +10511,15 @@ func (r *ResponseNewParamsToolFileSearch) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ResponseNewParamsToolFileSearchFilterUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u ResponseNewParamsToolFileSearchFilterUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *ResponseNewParamsToolFileSearchFilterUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ResponseNewParamsToolFileSearchFilterUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsToolFileSearch]( + "type", "file_search", + ) } -// (Optional) Options for ranking and scoring search results +// Options for ranking and filtering search results. type ResponseNewParamsToolFileSearchRankingOptions struct { - // (Optional) Name of the ranking algorithm to use - Ranker param.Opt[string] `json:"ranker,omitzero"` - // (Optional) Minimum relevance score threshold for results + Ranker param.Opt[string] `json:"ranker,omitzero"` ScoreThreshold param.Opt[float64] `json:"score_threshold,omitzero"` paramObj } @@ -10240,20 +10534,14 @@ func (r *ResponseNewParamsToolFileSearchRankingOptions) UnmarshalJSON(data []byt // Function tool configuration for OpenAI response inputs. // -// The properties Name, Type are required. +// The properties Name, Parameters are required. type ResponseNewParamsToolFunction struct { - // Name of the function that can be called - Name string `json:"name,required"` - // (Optional) Description of what the function does + Parameters map[string]any `json:"parameters,omitzero,required"` + Name string `json:"name,required"` Description param.Opt[string] `json:"description,omitzero"` - // (Optional) Whether to enforce strict parameter validation - Strict param.Opt[bool] `json:"strict,omitzero"` - // (Optional) JSON schema defining the function's parameters - Parameters map[string]ResponseNewParamsToolFunctionParameterUnion `json:"parameters,omitzero"` - // Tool type identifier, always "function" - // - // This field can be elided, and will marshal its zero value as "function". - Type constant.Function `json:"type,required"` + Strict param.Opt[bool] `json:"strict,omitzero"` + // Any of "function". + Type string `json:"type,omitzero"` paramObj } @@ -10265,65 +10553,79 @@ func (r *ResponseNewParamsToolFunction) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsToolFunction]( + "type", "function", + ) +} + +// Model Context Protocol (MCP) tool configuration for OpenAI response inputs. +// +// The properties ServerLabel, ServerURL are required. +type ResponseNewParamsToolMcp struct { + ServerLabel string `json:"server_label,required"` + ServerURL string `json:"server_url,required"` + Authorization param.Opt[string] `json:"authorization,omitzero"` + // Filter configuration for restricting which MCP tools can be used. + AllowedTools ResponseNewParamsToolMcpAllowedToolsUnion `json:"allowed_tools,omitzero"` + Headers map[string]any `json:"headers,omitzero"` + // Filter configuration for MCP tool approval requirements. + RequireApproval ResponseNewParamsToolMcpRequireApprovalUnion `json:"require_approval,omitzero"` + // Any of "mcp". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ResponseNewParamsToolMcp) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsToolMcp + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ResponseNewParamsToolMcp) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ResponseNewParamsToolMcp]( + "type", "mcp", + ) +} + // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. -type ResponseNewParamsToolFunctionParameterUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` +type ResponseNewParamsToolMcpAllowedToolsUnion struct { + OfListString []string `json:",omitzero,inline"` + OfAllowedToolsFilter *ResponseNewParamsToolMcpAllowedToolsAllowedToolsFilter `json:",omitzero,inline"` paramUnion } -func (u ResponseNewParamsToolFunctionParameterUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) +func (u ResponseNewParamsToolMcpAllowedToolsUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfListString, u.OfAllowedToolsFilter) } -func (u *ResponseNewParamsToolFunctionParameterUnion) UnmarshalJSON(data []byte) error { +func (u *ResponseNewParamsToolMcpAllowedToolsUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *ResponseNewParamsToolFunctionParameterUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray +func (u *ResponseNewParamsToolMcpAllowedToolsUnion) asAny() any { + if !param.IsOmitted(u.OfListString) { + return &u.OfListString + } else if !param.IsOmitted(u.OfAllowedToolsFilter) { + return u.OfAllowedToolsFilter } return nil } -// Model Context Protocol (MCP) tool configuration for OpenAI response inputs. -// -// The properties RequireApproval, ServerLabel, ServerURL, Type are required. -type ResponseNewParamsToolMcp struct { - // Approval requirement for tool calls ("always", "never", or filter) - RequireApproval ResponseNewParamsToolMcpRequireApprovalUnion `json:"require_approval,omitzero,required"` - // Label to identify this MCP server - ServerLabel string `json:"server_label,required"` - // URL endpoint of the MCP server - ServerURL string `json:"server_url,required"` - // (Optional) OAuth access token for authenticating with the MCP server - Authorization param.Opt[string] `json:"authorization,omitzero"` - // (Optional) Restriction on which tools can be used from this server - AllowedTools ResponseNewParamsToolMcpAllowedToolsUnion `json:"allowed_tools,omitzero"` - // (Optional) HTTP headers to include when connecting to the server - Headers map[string]ResponseNewParamsToolMcpHeaderUnion `json:"headers,omitzero"` - // Tool type identifier, always "mcp" - // - // This field can be elided, and will marshal its zero value as "mcp". - Type constant.Mcp `json:"type,required"` +// Filter configuration for restricting which MCP tools can be used. +type ResponseNewParamsToolMcpAllowedToolsAllowedToolsFilter struct { + ToolNames []string `json:"tool_names,omitzero"` paramObj } -func (r ResponseNewParamsToolMcp) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsToolMcp +func (r ResponseNewParamsToolMcpAllowedToolsAllowedToolsFilter) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsToolMcpAllowedToolsAllowedToolsFilter return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ResponseNewParamsToolMcp) UnmarshalJSON(data []byte) error { +func (r *ResponseNewParamsToolMcpAllowedToolsAllowedToolsFilter) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } @@ -10363,10 +10665,8 @@ const ( // Filter configuration for MCP tool approval requirements. type ResponseNewParamsToolMcpRequireApprovalApprovalFilter struct { - // (Optional) List of tool names that always require approval Always []string `json:"always,omitzero"` - // (Optional) List of tool names that never require approval - Never []string `json:"never,omitzero"` + Never []string `json:"never,omitzero"` paramObj } @@ -10378,85 +10678,11 @@ func (r *ResponseNewParamsToolMcpRequireApprovalApprovalFilter) UnmarshalJSON(da return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ResponseNewParamsToolMcpAllowedToolsUnion struct { - OfStringArray []string `json:",omitzero,inline"` - OfAllowedToolsFilter *ResponseNewParamsToolMcpAllowedToolsAllowedToolsFilter `json:",omitzero,inline"` - paramUnion -} - -func (u ResponseNewParamsToolMcpAllowedToolsUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfStringArray, u.OfAllowedToolsFilter) -} -func (u *ResponseNewParamsToolMcpAllowedToolsUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ResponseNewParamsToolMcpAllowedToolsUnion) asAny() any { - if !param.IsOmitted(u.OfStringArray) { - return &u.OfStringArray - } else if !param.IsOmitted(u.OfAllowedToolsFilter) { - return u.OfAllowedToolsFilter - } - return nil -} - -// Filter configuration for restricting which MCP tools can be used. -type ResponseNewParamsToolMcpAllowedToolsAllowedToolsFilter struct { - // (Optional) List of specific tool names that are allowed - ToolNames []string `json:"tool_names,omitzero"` - paramObj -} - -func (r ResponseNewParamsToolMcpAllowedToolsAllowedToolsFilter) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsToolMcpAllowedToolsAllowedToolsFilter - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *ResponseNewParamsToolMcpAllowedToolsAllowedToolsFilter) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ResponseNewParamsToolMcpHeaderUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u ResponseNewParamsToolMcpHeaderUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *ResponseNewParamsToolMcpHeaderUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ResponseNewParamsToolMcpHeaderUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - type ResponseListParams struct { - // The ID of the last response to return. After param.Opt[string] `query:"after,omitzero" json:"-"` - // The number of responses to return. - Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` - // The model to filter responses by. + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` Model param.Opt[string] `query:"model,omitzero" json:"-"` - // The order to sort responses by when sorted by created_at ('asc' or 'desc'). + // Sort order for paginated responses. // // Any of "asc", "desc". Order ResponseListParamsOrder `query:"order,omitzero" json:"-"` @@ -10471,7 +10697,7 @@ func (r ResponseListParams) URLQuery() (v url.Values, err error) { }) } -// The order to sort responses by when sorted by created_at ('asc' or 'desc'). +// Sort order for paginated responses. type ResponseListParamsOrder string const ( diff --git a/response_test.go b/response_test.go index d4206af..ceae9c2 100644 --- a/response_test.go +++ b/response_test.go @@ -47,6 +47,7 @@ func TestResponseNewWithOptionalParams(t *testing.T) { "foo": { OfInputText: &llamastackclient.ResponseNewParamsPromptVariableInputText{ Text: "text", + Type: "input_text", }, }, }, @@ -56,21 +57,19 @@ func TestResponseNewWithOptionalParams(t *testing.T) { Temperature: llamastackclient.Float(0), Text: llamastackclient.ResponseNewParamsText{ Format: llamastackclient.ResponseNewParamsTextFormat{ - Type: llamastackclient.ResponseNewParamsTextFormatTypeText, Description: llamastackclient.String("description"), Name: llamastackclient.String("name"), - Schema: map[string]llamastackclient.ResponseNewParamsTextFormatSchemaUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + Schema: map[string]any{ + "foo": "bar", }, Strict: llamastackclient.Bool(true), + Type: "text", }, }, Tools: []llamastackclient.ResponseNewParamsToolUnion{{ OfOpenAIResponseInputToolWebSearch: &llamastackclient.ResponseNewParamsToolOpenAIResponseInputToolWebSearch{ - Type: llamastackclient.ResponseNewParamsToolOpenAIResponseInputToolWebSearchTypeWebSearch, - SearchContextSize: llamastackclient.String("search_context_size"), + SearchContextSize: llamastackclient.String("S?oC\"high"), + Type: "web_search", }, }}, }) diff --git a/responseinputitem.go b/responseinputitem.go index 2a41410..2c725e1 100644 --- a/responseinputitem.go +++ b/responseinputitem.go @@ -23,7 +23,6 @@ import ( "github.com/llamastack/llama-stack-client-go/option" "github.com/llamastack/llama-stack-client-go/packages/param" "github.com/llamastack/llama-stack-client-go/packages/respjson" - "github.com/llamastack/llama-stack-client-go/shared/constant" ) // ResponseInputItemService contains methods and other services that help with @@ -59,10 +58,9 @@ func (r *ResponseInputItemService) List(ctx context.Context, responseID string, // List container for OpenAI response input items. type ResponseInputItemListResponse struct { - // List of input items Data []ResponseInputItemListResponseDataUnion `json:"data,required"` - // Object type identifier, always "list" - Object constant.List `json:"object,required"` + // Any of "list". + Object ResponseInputItemListResponseObject `json:"object"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Data respjson.Field @@ -79,7 +77,7 @@ func (r *ResponseInputItemListResponse) UnmarshalJSON(data []byte) error { } // ResponseInputItemListResponseDataUnion contains all possible properties and -// values from [ResponseInputItemListResponseDataOpenAIResponseMessage], +// values from [ResponseInputItemListResponseDataOpenAIResponseMessageOutput], // [ResponseInputItemListResponseDataOpenAIResponseOutputMessageWebSearchToolCall], // [ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCall], // [ResponseInputItemListResponseDataOpenAIResponseOutputMessageFunctionToolCall], @@ -88,19 +86,19 @@ func (r *ResponseInputItemListResponse) UnmarshalJSON(data []byte) error { // [ResponseInputItemListResponseDataOpenAIResponseMcpApprovalRequest], // [ResponseInputItemListResponseDataOpenAIResponseInputFunctionToolCallOutput], // [ResponseInputItemListResponseDataOpenAIResponseMcpApprovalResponse], -// [ResponseInputItemListResponseDataOpenAIResponseMessage]. +// [ResponseInputItemListResponseDataOpenAIResponseMessageOutput]. // // Use the methods beginning with 'As' to cast the union to one of its variants. type ResponseInputItemListResponseDataUnion struct { // This field is from variant - // [ResponseInputItemListResponseDataOpenAIResponseMessage]. - Content ResponseInputItemListResponseDataOpenAIResponseMessageContentUnion `json:"content"` + // [ResponseInputItemListResponseDataOpenAIResponseMessageOutput]. + Content ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentUnion `json:"content"` // This field is from variant - // [ResponseInputItemListResponseDataOpenAIResponseMessage]. - Role ResponseInputItemListResponseDataOpenAIResponseMessageRole `json:"role"` - Type string `json:"type"` - ID string `json:"id"` - Status string `json:"status"` + // [ResponseInputItemListResponseDataOpenAIResponseMessageOutput]. + Role string `json:"role"` + ID string `json:"id"` + Status string `json:"status"` + Type string `json:"type"` // This field is from variant // [ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCall]. Queries []string `json:"queries"` @@ -130,9 +128,9 @@ type ResponseInputItemListResponseDataUnion struct { JSON struct { Content respjson.Field Role respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field Queries respjson.Field Results respjson.Field Arguments respjson.Field @@ -149,7 +147,7 @@ type ResponseInputItemListResponseDataUnion struct { } `json:"-"` } -func (u ResponseInputItemListResponseDataUnion) AsOpenAIResponseMessage() (v ResponseInputItemListResponseDataOpenAIResponseMessage) { +func (u ResponseInputItemListResponseDataUnion) AsOpenAIResponseMessageOutput() (v ResponseInputItemListResponseDataOpenAIResponseMessageOutput) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -194,7 +192,7 @@ func (u ResponseInputItemListResponseDataUnion) AsOpenAIResponseMcpApprovalRespo return } -func (u ResponseInputItemListResponseDataUnion) AsResponseInputItemListResponseDataOpenAIResponseMessage() (v ResponseInputItemListResponseDataOpenAIResponseMessage) { +func (u ResponseInputItemListResponseDataUnion) AsResponseInputItemListResponseDataOpenAIResponseMessageOutput() (v ResponseInputItemListResponseDataOpenAIResponseMessageOutput) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -209,110 +207,120 @@ func (r *ResponseInputItemListResponseDataUnion) UnmarshalJSON(data []byte) erro // Corresponds to the various Message types in the Responses API. They are all // under one type because the Responses API gives them all the same "type" value, // and there is no way to tell them apart in certain scenarios. -type ResponseInputItemListResponseDataOpenAIResponseMessage struct { - Content ResponseInputItemListResponseDataOpenAIResponseMessageContentUnion `json:"content,required"` +type ResponseInputItemListResponseDataOpenAIResponseMessageOutput struct { + Content ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentUnion `json:"content,required"` // Any of "system", "developer", "user", "assistant". - Role ResponseInputItemListResponseDataOpenAIResponseMessageRole `json:"role,required"` - Type constant.Message `json:"type,required"` - ID string `json:"id"` - Status string `json:"status"` + Role string `json:"role,required"` + ID string `json:"id,nullable"` + Status string `json:"status,nullable"` + // Any of "message". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field Role respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseInputItemListResponseDataOpenAIResponseMessage) RawJSON() string { return r.JSON.raw } -func (r *ResponseInputItemListResponseDataOpenAIResponseMessage) UnmarshalJSON(data []byte) error { +func (r ResponseInputItemListResponseDataOpenAIResponseMessageOutput) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseInputItemListResponseDataOpenAIResponseMessageOutput) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseInputItemListResponseDataOpenAIResponseMessageContentUnion contains all -// possible properties and values from [string], -// [[]ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion], -// [[]ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion]. +// ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentUnion +// contains all possible properties and values from [string], +// [[]ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion], +// [[]ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfString OfVariant2] -type ResponseInputItemListResponseDataOpenAIResponseMessageContentUnion struct { +// will be valid: OfString +// OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile +// OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal] +type ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` // This field will be present if the value is a - // [[]ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion] + // [[]ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion] // instead of an object. - OfVariant2 []ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion `json:",inline"` - JSON struct { - OfString respjson.Field - OfVariant2 respjson.Field - raw string + OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile []ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion `json:",inline"` + // This field will be present if the value is a + // [[]ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion] + // instead of an object. + OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal []ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion `json:",inline"` + JSON struct { + OfString respjson.Field + OfListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile respjson.Field + OfListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal respjson.Field + raw string } `json:"-"` } -func (u ResponseInputItemListResponseDataOpenAIResponseMessageContentUnion) AsString() (v string) { +func (u ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseInputItemListResponseDataOpenAIResponseMessageContentUnion) AsResponseInputItemListResponseDataOpenAIResponseMessageContentArray() (v []ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion) { +func (u ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentUnion) AsListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFile() (v []ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseInputItemListResponseDataOpenAIResponseMessageContentUnion) AsVariant2() (v []ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion) { +func (u ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentUnion) AsListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusal() (v []ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ResponseInputItemListResponseDataOpenAIResponseMessageContentUnion) RawJSON() string { +func (u ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentUnion) RawJSON() string { return u.JSON.raw } -func (r *ResponseInputItemListResponseDataOpenAIResponseMessageContentUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion +// ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion // contains all possible properties and values from -// [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputText], -// [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImage], -// [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputFile]. +// [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText], +// [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage], +// [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. // // Use the -// [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion.AsAny] +// [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny] // method to switch on the variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion struct { +type ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion struct { // This field is from variant - // [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputText]. + // [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText]. Text string `json:"text"` // Any of "input_text", "input_image", "input_file". Type string `json:"type"` // This field is from variant - // [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImage]. - Detail ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImageDetail `json:"detail"` - FileID string `json:"file_id"` + // [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]. + Detail string `json:"detail"` + FileID string `json:"file_id"` // This field is from variant - // [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImage]. + // [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage]. ImageURL string `json:"image_url"` // This field is from variant - // [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputFile]. + // [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. FileData string `json:"file_data"` // This field is from variant - // [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputFile]. + // [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. FileURL string `json:"file_url"` // This field is from variant - // [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputFile]. + // [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile]. Filename string `json:"filename"` JSON struct { Text respjson.Field @@ -327,32 +335,32 @@ type ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion } `json:"-"` } -// anyResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItem is -// implemented by each variant of -// [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion] to -// add type safety for the return type of -// [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion.AsAny] -type anyResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItem interface { - implResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion() +// anyResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem +// is implemented by each variant of +// [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion] +// to add type safety for the return type of +// [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny] +type anyResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem interface { + implResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() } -func (ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputText) implResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion() { +func (ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) implResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { } -func (ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImage) implResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion() { +func (ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) implResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { } -func (ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputFile) implResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion() { +func (ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) implResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion() { } // Use the following switch statement to find the correct variant // -// switch variant := ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion.AsAny().(type) { -// case llamastackclient.ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputText: -// case llamastackclient.ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImage: -// case llamastackclient.ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputFile: +// switch variant := ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion.AsAny().(type) { +// case llamastackclient.ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText: +// case llamastackclient.ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage: +// case llamastackclient.ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile: // default: // fmt.Errorf("no variant present") // } -func (u ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion) AsAny() anyResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItem { +func (u ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsAny() anyResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItem { switch u.Type { case "input_text": return u.AsInputText() @@ -364,36 +372,35 @@ func (u ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUn return nil } -func (u ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion) AsInputText() (v ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputText) { +func (u ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputText() (v ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion) AsInputImage() (v ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImage) { +func (u ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputImage() (v ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion) AsInputFile() (v ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputFile) { +func (u ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) AsInputFile() (v ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion) RawJSON() string { +func (u ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) RawJSON() string { return u.JSON.raw } -func (r *ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content for input messages in OpenAI response format. -type ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputText struct { - // The text content of the input message +type ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText struct { Text string `json:"text,required"` - // Content type identifier, always "input_text" - Type constant.InputText `json:"type,required"` + // Any of "input_text". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -404,111 +411,421 @@ type ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInput } // Returns the unmodified JSON received from the API -func (r ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputText) RawJSON() string { +func (r ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) RawJSON() string { return r.JSON.raw } -func (r *ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputText) UnmarshalJSON(data []byte) error { +func (r *ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Image content for input messages in OpenAI response format. -type ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImage struct { - // Level of detail for image processing, can be "low", "high", or "auto" - // +type ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage struct { // Any of "low", "high", "auto". - Detail ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImageDetail `json:"detail,required"` - // Content type identifier, always "input_image" - Type constant.InputImage `json:"type,required"` - // (Optional) The ID of the file to be sent to the model. - FileID string `json:"file_id"` - // (Optional) URL of the image content - ImageURL string `json:"image_url"` + Detail string `json:"detail"` + FileID string `json:"file_id,nullable"` + ImageURL string `json:"image_url,nullable"` + // Any of "input_image". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Detail respjson.Field - Type respjson.Field FileID respjson.Field ImageURL respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImage) RawJSON() string { +func (r ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) RawJSON() string { return r.JSON.raw } -func (r *ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImage) UnmarshalJSON(data []byte) error { +func (r *ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputImage) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImageDetail string +// File content for input messages in OpenAI response format. +type ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile struct { + FileData string `json:"file_data,nullable"` + FileID string `json:"file_id,nullable"` + FileURL string `json:"file_url,nullable"` + Filename string `json:"filename,nullable"` + // Any of "input_file". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + FileData respjson.Field + FileID respjson.Field + FileURL respjson.Field + Filename respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} -const ( - ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImageDetailLow ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImageDetail = "low" - ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImageDetailHigh ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImageDetail = "high" - ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImageDetailAuto ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImageDetail = "auto" -) +// Returns the unmodified JSON received from the API +func (r ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseInputMessageContentTextOpenAIResponseInputMessageContentImageOpenAIResponseInputMessageContentFileItemInputFile) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} -// File content for input messages in OpenAI response format. -type ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputFile struct { - // The type of the input item. Always `input_file`. - Type constant.InputFile `json:"type,required"` - // The data of the file to be sent to the model. - FileData string `json:"file_data"` - // (Optional) The ID of the file to be sent to the model. - FileID string `json:"file_id"` - // The URL of the file to be sent to the model. - FileURL string `json:"file_url"` - // The name of the file to be sent to the model. +// ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion +// contains all possible properties and values from +// [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText], +// [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]. +// +// Use the +// [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny] +// method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion struct { + // This field is from variant + // [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]. + Text string `json:"text"` + // This field is from variant + // [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText]. + Annotations []ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion `json:"annotations"` + // Any of "output_text", "refusal". + Type string `json:"type"` + // This field is from variant + // [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal]. + Refusal string `json:"refusal"` + JSON struct { + Text respjson.Field + Annotations respjson.Field + Type respjson.Field + Refusal respjson.Field + raw string + } `json:"-"` +} + +// anyResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem +// is implemented by each variant of +// [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion] +// to add type safety for the return type of +// [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny] +type anyResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem interface { + implResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() +} + +func (ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) implResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() { +} +func (ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) implResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion.AsAny().(type) { +// case llamastackclient.ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText: +// case llamastackclient.ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal: +// default: +// fmt.Errorf("no variant present") +// } +func (u ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsAny() anyResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItem { + switch u.Type { + case "output_text": + return u.AsOutputText() + case "refusal": + return u.AsRefusal() + } + return nil +} + +func (u ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsOutputText() (v ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) AsRefusal() (v ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText struct { + Text string `json:"text,required"` + Annotations []ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion `json:"annotations"` + // Any of "output_text". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Text respjson.Field + Annotations respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputText) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion +// contains all possible properties and values from +// [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation], +// [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation], +// [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation], +// [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath]. +// +// Use the +// [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny] +// method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion struct { + FileID string `json:"file_id"` Filename string `json:"filename"` + Index int64 `json:"index"` + // Any of "file_citation", "url_citation", "container_file_citation", "file_path". + Type string `json:"type"` + EndIndex int64 `json:"end_index"` + StartIndex int64 `json:"start_index"` + // This field is from variant + // [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]. + Title string `json:"title"` + // This field is from variant + // [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation]. + URL string `json:"url"` + // This field is from variant + // [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation]. + ContainerID string `json:"container_id"` + JSON struct { + FileID respjson.Field + Filename respjson.Field + Index respjson.Field + Type respjson.Field + EndIndex respjson.Field + StartIndex respjson.Field + Title respjson.Field + URL respjson.Field + ContainerID respjson.Field + raw string + } `json:"-"` +} + +// anyResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation +// is implemented by each variant of +// [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion] +// to add type safety for the return type of +// [ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny] +type anyResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation interface { + implResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() +} + +func (ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) implResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} +func (ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) implResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} +func (ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) implResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} +func (ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) implResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion.AsAny().(type) { +// case llamastackclient.ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation: +// case llamastackclient.ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation: +// case llamastackclient.ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation: +// case llamastackclient.ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath: +// default: +// fmt.Errorf("no variant present") +// } +func (u ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsAny() anyResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotation { + switch u.Type { + case "file_citation": + return u.AsFileCitation() + case "url_citation": + return u.AsURLCitation() + case "container_file_citation": + return u.AsContainerFileCitation() + case "file_path": + return u.AsFilePath() + } + return nil +} + +func (u ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsFileCitation() (v ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsURLCitation() (v ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsContainerFileCitation() (v ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) AsFilePath() (v ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// File citation annotation for referencing specific files in response content. +type ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation struct { + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Index int64 `json:"index,required"` + // Any of "file_citation". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { + FileID respjson.Field + Filename respjson.Field + Index respjson.Field Type respjson.Field - FileData respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFileCitation) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// URL citation annotation for referencing external web resources. +type ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation struct { + EndIndex int64 `json:"end_index,required"` + StartIndex int64 `json:"start_index,required"` + Title string `json:"title,required"` + URL string `json:"url,required"` + // Any of "url_citation". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + EndIndex respjson.Field + StartIndex respjson.Field + Title respjson.Field + URL respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationURLCitation) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation struct { + ContainerID string `json:"container_id,required"` + EndIndex int64 `json:"end_index,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + StartIndex int64 `json:"start_index,required"` + // Any of "container_file_citation". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ContainerID respjson.Field + EndIndex respjson.Field FileID respjson.Field - FileURL respjson.Field Filename respjson.Field + StartIndex respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputFile) RawJSON() string { +func (r ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) RawJSON() string { return r.JSON.raw } -func (r *ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputFile) UnmarshalJSON(data []byte) error { +func (r *ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Level of detail for image processing, can be "low", "high", or "auto" -type ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemDetail string +type ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath struct { + FileID string `json:"file_id,required"` + Index int64 `json:"index,required"` + // Any of "file_path". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + FileID respjson.Field + Index respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} -const ( - ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemDetailLow ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemDetail = "low" - ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemDetailHigh ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemDetail = "high" - ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemDetailAuto ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemDetail = "auto" -) +// Returns the unmodified JSON received from the API +func (r ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemOutputTextAnnotationFilePath) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} -type ResponseInputItemListResponseDataOpenAIResponseMessageRole string +// Refusal content within a streamed response part. +type ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal struct { + Refusal string `json:"refusal,required"` + // Any of "refusal". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Refusal respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} -const ( - ResponseInputItemListResponseDataOpenAIResponseMessageRoleSystem ResponseInputItemListResponseDataOpenAIResponseMessageRole = "system" - ResponseInputItemListResponseDataOpenAIResponseMessageRoleDeveloper ResponseInputItemListResponseDataOpenAIResponseMessageRole = "developer" - ResponseInputItemListResponseDataOpenAIResponseMessageRoleUser ResponseInputItemListResponseDataOpenAIResponseMessageRole = "user" - ResponseInputItemListResponseDataOpenAIResponseMessageRoleAssistant ResponseInputItemListResponseDataOpenAIResponseMessageRole = "assistant" -) +// Returns the unmodified JSON received from the API +func (r ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseInputItemListResponseDataOpenAIResponseMessageOutputContentListOpenAIResponseOutputMessageContentOutputTextOpenAIResponseContentPartRefusalItemRefusal) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} // Web search tool call output message for OpenAI responses. type ResponseInputItemListResponseDataOpenAIResponseOutputMessageWebSearchToolCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // Current status of the web search operation + ID string `json:"id,required"` Status string `json:"status,required"` - // Tool call type identifier, always "web_search_call" - Type constant.WebSearchCall `json:"type,required"` + // Any of "web_search_call". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -529,23 +846,19 @@ func (r *ResponseInputItemListResponseDataOpenAIResponseOutputMessageWebSearchTo // File search tool call output message for OpenAI responses. type ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCall struct { - // Unique identifier for this tool call - ID string `json:"id,required"` - // List of search queries executed - Queries []string `json:"queries,required"` - // Current status of the file search operation - Status string `json:"status,required"` - // Tool call type identifier, always "file_search_call" - Type constant.FileSearchCall `json:"type,required"` - // (Optional) Search results returned by the file search operation - Results []ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResult `json:"results"` + ID string `json:"id,required"` + Queries []string `json:"queries,required"` + Status string `json:"status,required"` + Results []ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResult `json:"results,nullable"` + // Any of "file_search_call". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field Queries respjson.Field Status respjson.Field - Type respjson.Field Results respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -561,16 +874,11 @@ func (r *ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchT // Search results returned by the file search operation. type ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResult struct { - // (Optional) Key-value attributes associated with the file - Attributes map[string]ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion `json:"attributes,required"` - // Unique identifier of the file containing the result - FileID string `json:"file_id,required"` - // Name of the file containing the result - Filename string `json:"filename,required"` - // Relevance score for this search result (between 0 and 1) - Score float64 `json:"score,required"` - // Text content of the search result - Text string `json:"text,required"` + Attributes map[string]any `json:"attributes,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Score float64 `json:"score,required"` + Text string `json:"text,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Attributes respjson.Field @@ -591,83 +899,23 @@ func (r *ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchT return apijson.UnmarshalRoot(data, r) } -// ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion -// contains all possible properties and values from [bool], [float64], [string], -// [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) RawJSON() string { - return u.JSON.raw -} - -func (r *ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - // Function tool call output message for OpenAI responses. type ResponseInputItemListResponseDataOpenAIResponseOutputMessageFunctionToolCall struct { - // JSON string containing the function arguments Arguments string `json:"arguments,required"` - // Unique identifier for the function call - CallID string `json:"call_id,required"` - // Name of the function being called - Name string `json:"name,required"` - // Tool call type identifier, always "function_call" - Type constant.FunctionCall `json:"type,required"` - // (Optional) Additional identifier for the tool call - ID string `json:"id"` - // (Optional) Current status of the function call execution - Status string `json:"status"` + CallID string `json:"call_id,required"` + Name string `json:"name,required"` + ID string `json:"id,nullable"` + Status string `json:"status,nullable"` + // Any of "function_call". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Arguments respjson.Field CallID respjson.Field Name respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -683,29 +931,23 @@ func (r *ResponseInputItemListResponseDataOpenAIResponseOutputMessageFunctionToo // Model Context Protocol (MCP) call output message for OpenAI responses. type ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpCall struct { - // Unique identifier for this MCP call - ID string `json:"id,required"` - // JSON string containing the MCP call arguments - Arguments string `json:"arguments,required"` - // Name of the MCP method being called - Name string `json:"name,required"` - // Label identifying the MCP server handling the call + ID string `json:"id,required"` + Arguments string `json:"arguments,required"` + Name string `json:"name,required"` ServerLabel string `json:"server_label,required"` - // Tool call type identifier, always "mcp_call" - Type constant.McpCall `json:"type,required"` - // (Optional) Error message if the MCP call failed - Error string `json:"error"` - // (Optional) Output result from the successful MCP call - Output string `json:"output"` + Error string `json:"error,nullable"` + Output string `json:"output,nullable"` + // Any of "mcp_call". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field Arguments respjson.Field Name respjson.Field ServerLabel respjson.Field - Type respjson.Field Error respjson.Field Output respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -721,14 +963,11 @@ func (r *ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpCall) Un // MCP list tools output message containing available tools from an MCP server. type ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpListTools struct { - // Unique identifier for this MCP list tools operation - ID string `json:"id,required"` - // Label identifying the MCP server providing the tools - ServerLabel string `json:"server_label,required"` - // List of available tools provided by the MCP server - Tools []ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpListToolsTool `json:"tools,required"` - // Tool call type identifier, always "mcp_list_tools" - Type constant.McpListTools `json:"type,required"` + ID string `json:"id,required"` + ServerLabel string `json:"server_label,required"` + Tools []ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpListToolsTool `json:"tools,required"` + // Any of "mcp_list_tools". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -750,12 +989,9 @@ func (r *ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpListTool // Tool definition returned by MCP list tools operation. type ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpListToolsTool struct { - // JSON schema defining the tool's input parameters - InputSchema map[string]ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion `json:"input_schema,required"` - // Name of the tool - Name string `json:"name,required"` - // (Optional) Description of what the tool does - Description string `json:"description"` + InputSchema map[string]any `json:"input_schema,required"` + Name string `json:"name,required"` + Description string `json:"description,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { InputSchema respjson.Field @@ -774,68 +1010,14 @@ func (r *ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpListTool return apijson.UnmarshalRoot(data, r) } -// ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion -// contains all possible properties and values from [bool], [float64], [string], -// [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) RawJSON() string { - return u.JSON.raw -} - -func (r *ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - // A request for human approval of a tool invocation. type ResponseInputItemListResponseDataOpenAIResponseMcpApprovalRequest struct { - ID string `json:"id,required"` - Arguments string `json:"arguments,required"` - Name string `json:"name,required"` - ServerLabel string `json:"server_label,required"` - Type constant.McpApprovalRequest `json:"type,required"` + ID string `json:"id,required"` + Arguments string `json:"arguments,required"` + Name string `json:"name,required"` + ServerLabel string `json:"server_label,required"` + // Any of "mcp_approval_request". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -859,18 +1041,19 @@ func (r *ResponseInputItemListResponseDataOpenAIResponseMcpApprovalRequest) Unma // This represents the output of a function call that gets passed back to the // model. type ResponseInputItemListResponseDataOpenAIResponseInputFunctionToolCallOutput struct { - CallID string `json:"call_id,required"` - Output string `json:"output,required"` - Type constant.FunctionCallOutput `json:"type,required"` - ID string `json:"id"` - Status string `json:"status"` + CallID string `json:"call_id,required"` + Output string `json:"output,required"` + ID string `json:"id,nullable"` + Status string `json:"status,nullable"` + // Any of "function_call_output". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { CallID respjson.Field Output respjson.Field - Type respjson.Field ID respjson.Field Status respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -886,18 +1069,19 @@ func (r *ResponseInputItemListResponseDataOpenAIResponseInputFunctionToolCallOut // A response to an MCP approval request. type ResponseInputItemListResponseDataOpenAIResponseMcpApprovalResponse struct { - ApprovalRequestID string `json:"approval_request_id,required"` - Approve bool `json:"approve,required"` - Type constant.McpApprovalResponse `json:"type,required"` - ID string `json:"id"` - Reason string `json:"reason"` + ApprovalRequestID string `json:"approval_request_id,required"` + Approve bool `json:"approve,required"` + ID string `json:"id,nullable"` + Reason string `json:"reason,nullable"` + // Any of "mcp_approval_response". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ApprovalRequestID respjson.Field Approve respjson.Field - Type respjson.Field ID respjson.Field Reason respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -911,26 +1095,18 @@ func (r *ResponseInputItemListResponseDataOpenAIResponseMcpApprovalResponse) Unm return apijson.UnmarshalRoot(data, r) } -type ResponseInputItemListResponseDataRole string +type ResponseInputItemListResponseObject string const ( - ResponseInputItemListResponseDataRoleSystem ResponseInputItemListResponseDataRole = "system" - ResponseInputItemListResponseDataRoleDeveloper ResponseInputItemListResponseDataRole = "developer" - ResponseInputItemListResponseDataRoleUser ResponseInputItemListResponseDataRole = "user" - ResponseInputItemListResponseDataRoleAssistant ResponseInputItemListResponseDataRole = "assistant" + ResponseInputItemListResponseObjectList ResponseInputItemListResponseObject = "list" ) type ResponseInputItemListParams struct { - // An item ID to list items after, used for pagination. - After param.Opt[string] `query:"after,omitzero" json:"-"` - // An item ID to list items before, used for pagination. - Before param.Opt[string] `query:"before,omitzero" json:"-"` - // A limit on the number of objects to be returned. Limit can range between 1 and - // 100, and the default is 20. - Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` - // Additional fields to include in the response. - Include []string `query:"include,omitzero" json:"-"` - // The order to return the input items in. Default is desc. + After param.Opt[string] `query:"after,omitzero" json:"-"` + Before param.Opt[string] `query:"before,omitzero" json:"-"` + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + Include []string `query:"include,omitzero" json:"-"` + // Sort order for paginated responses. // // Any of "asc", "desc". Order ResponseInputItemListParamsOrder `query:"order,omitzero" json:"-"` @@ -946,7 +1122,7 @@ func (r ResponseInputItemListParams) URLQuery() (v url.Values, err error) { }) } -// The order to return the input items in. Default is desc. +// Sort order for paginated responses. type ResponseInputItemListParamsOrder string const ( diff --git a/route.go b/route.go index d3cc821..0bf1335 100644 --- a/route.go +++ b/route.go @@ -40,8 +40,9 @@ func NewRouteService(opts ...option.RequestOption) (r RouteService) { return } -// List routes. List all available API routes with their methods and implementing -// providers. +// List routes. +// +// List all available API routes with their methods and implementing providers. func (r *RouteService) List(ctx context.Context, query RouteListParams, opts ...option.RequestOption) (res *[]RouteInfo, err error) { var env ListRoutesResponse opts = slices.Concat(r.Options, opts) @@ -56,7 +57,6 @@ func (r *RouteService) List(ctx context.Context, query RouteListParams, opts ... // Response containing a list of all available API routes. type ListRoutesResponse struct { - // List of available route information objects Data []RouteInfo `json:"data,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { @@ -73,11 +73,6 @@ func (r *ListRoutesResponse) UnmarshalJSON(data []byte) error { } type RouteListParams struct { - // Optional filter to control which routes are returned. Can be an API level ('v1', - // 'v1alpha', 'v1beta') to show non-deprecated routes at that level, or - // 'deprecated' to show deprecated routes across all levels. If not specified, - // returns all non-deprecated routes. - // // Any of "v1", "v1alpha", "v1beta", "deprecated". APIFilter RouteListParamsAPIFilter `query:"api_filter,omitzero" json:"-"` paramObj @@ -91,10 +86,6 @@ func (r RouteListParams) URLQuery() (v url.Values, err error) { }) } -// Optional filter to control which routes are returned. Can be an API level ('v1', -// 'v1alpha', 'v1beta') to show non-deprecated routes at that level, or -// 'deprecated' to show deprecated routes across all levels. If not specified, -// returns all non-deprecated routes. type RouteListParamsAPIFilter string const ( diff --git a/safety.go b/safety.go index 32d79d8..ce96ac6 100644 --- a/safety.go +++ b/safety.go @@ -18,7 +18,6 @@ import ( "github.com/llamastack/llama-stack-client-go/option" "github.com/llamastack/llama-stack-client-go/packages/param" "github.com/llamastack/llama-stack-client-go/packages/respjson" - "github.com/llamastack/llama-stack-client-go/shared/constant" ) // SafetyService contains methods and other services that help with interacting @@ -40,7 +39,9 @@ func NewSafetyService(opts ...option.RequestOption) (r SafetyService) { return } -// Run shield. Run a shield. +// Run shield. +// +// Run a shield. func (r *SafetyService) RunShield(ctx context.Context, body SafetyRunShieldParams, opts ...option.RequestOption) (res *RunShieldResponse, err error) { opts = slices.Concat(r.Options, opts) path := "v1/safety/run-shield" @@ -50,8 +51,8 @@ func (r *SafetyService) RunShield(ctx context.Context, body SafetyRunShieldParam // Response from running a safety shield. type RunShieldResponse struct { - // (Optional) Safety violation detected by the shield, if any - Violation SafetyViolation `json:"violation"` + // Details of a safety violation detected by content moderation. + Violation SafetyViolation `json:"violation,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Violation respjson.Field @@ -67,12 +68,9 @@ func (r *RunShieldResponse) UnmarshalJSON(data []byte) error { } type SafetyRunShieldParams struct { - // The messages to run the shield on. Messages []SafetyRunShieldParamsMessageUnion `json:"messages,omitzero,required"` - // The parameters of the shield. - Params map[string]SafetyRunShieldParamsParamUnion `json:"params,omitzero,required"` - // The identifier of the shield to run. - ShieldID string `json:"shield_id,required"` + Params map[string]any `json:"params,omitzero,required"` + ShieldID string `json:"shield_id,required"` paramObj } @@ -138,6 +136,20 @@ func (u SafetyRunShieldParamsMessageUnion) GetToolCallID() *string { return nil } +// Returns a pointer to the underlying variant's property, if present. +func (u SafetyRunShieldParamsMessageUnion) GetName() *string { + if vt := u.OfUser; vt != nil && vt.Name.Valid() { + return &vt.Name.Value + } else if vt := u.OfSystem; vt != nil && vt.Name.Valid() { + return &vt.Name.Value + } else if vt := u.OfAssistant; vt != nil && vt.Name.Valid() { + return &vt.Name.Value + } else if vt := u.OfDeveloper; vt != nil && vt.Name.Valid() { + return &vt.Name.Value + } + return nil +} + // Returns a pointer to the underlying variant's property, if present. func (u SafetyRunShieldParamsMessageUnion) GetRole() *string { if vt := u.OfUser; vt != nil { @@ -154,20 +166,6 @@ func (u SafetyRunShieldParamsMessageUnion) GetRole() *string { return nil } -// Returns a pointer to the underlying variant's property, if present. -func (u SafetyRunShieldParamsMessageUnion) GetName() *string { - if vt := u.OfUser; vt != nil && vt.Name.Valid() { - return &vt.Name.Value - } else if vt := u.OfSystem; vt != nil && vt.Name.Valid() { - return &vt.Name.Value - } else if vt := u.OfAssistant; vt != nil && vt.Name.Valid() { - return &vt.Name.Value - } else if vt := u.OfDeveloper; vt != nil && vt.Name.Valid() { - return &vt.Name.Value - } - return nil -} - // Returns a subunion which exports methods to access subproperties // // Or use AsAny() to get the underlying value @@ -187,22 +185,22 @@ func (u SafetyRunShieldParamsMessageUnion) GetContent() (res safetyRunShieldPara } // Can have the runtime types [*string], -// [_[]SafetyRunShieldParamsMessageUserContentArrayItemUnion], -// [_[]SafetyRunShieldParamsMessageSystemContentArrayItem], -// [_[]SafetyRunShieldParamsMessageAssistantContentArrayItem], -// [_[]SafetyRunShieldParamsMessageToolContentArrayItem], -// [\*[]SafetyRunShieldParamsMessageDeveloperContentArrayItem] +// [_[]SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion], +// [_[]SafetyRunShieldParamsMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem], +// [_[]SafetyRunShieldParamsMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem], +// [_[]SafetyRunShieldParamsMessageToolContentListOpenAIChatCompletionContentPartTextParamItem], +// [\*[]SafetyRunShieldParamsMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem] type safetyRunShieldParamsMessageUnionContent struct{ any } // Use the following switch statement to get the type of the union: // // switch u.AsAny().(type) { // case *string: -// case *[]llamastackclient.SafetyRunShieldParamsMessageUserContentArrayItemUnion: -// case *[]llamastackclient.SafetyRunShieldParamsMessageSystemContentArrayItem: -// case *[]llamastackclient.SafetyRunShieldParamsMessageAssistantContentArrayItem: -// case *[]llamastackclient.SafetyRunShieldParamsMessageToolContentArrayItem: -// case *[]llamastackclient.SafetyRunShieldParamsMessageDeveloperContentArrayItem: +// case *[]llamastackclient.SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion: +// case *[]llamastackclient.SafetyRunShieldParamsMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem: +// case *[]llamastackclient.SafetyRunShieldParamsMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem: +// case *[]llamastackclient.SafetyRunShieldParamsMessageToolContentListOpenAIChatCompletionContentPartTextParamItem: +// case *[]llamastackclient.SafetyRunShieldParamsMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem: // default: // fmt.Errorf("not present") // } @@ -221,16 +219,12 @@ func init() { // A message from the user in an OpenAI-compatible chat completion request. // -// The properties Content, Role are required. +// The property Content is required. type SafetyRunShieldParamsMessageUser struct { - // The content of the message, which can include text and other media Content SafetyRunShieldParamsMessageUserContentUnion `json:"content,omitzero,required"` - // (Optional) The name of the user message participant. - Name param.Opt[string] `json:"name,omitzero"` - // Must be "user" to identify this as a user message - // - // This field can be elided, and will marshal its zero value as "user". - Role constant.User `json:"role,required"` + Name param.Opt[string] `json:"name,omitzero"` + // Any of "user". + Role string `json:"role,omitzero"` paramObj } @@ -242,17 +236,23 @@ func (r *SafetyRunShieldParamsMessageUser) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[SafetyRunShieldParamsMessageUser]( + "role", "user", + ) +} + // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. type SafetyRunShieldParamsMessageUserContentUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfSafetyRunShieldsMessageUserContentArray []SafetyRunShieldParamsMessageUserContentArrayItemUnion `json:",omitzero,inline"` + OfString param.Opt[string] `json:",omitzero,inline"` + OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile []SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion `json:",omitzero,inline"` paramUnion } func (u SafetyRunShieldParamsMessageUserContentUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfSafetyRunShieldsMessageUserContentArray) + return param.MarshalUnion(u, u.OfString, u.OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile) } func (u *SafetyRunShieldParamsMessageUserContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) @@ -261,8 +261,8 @@ func (u *SafetyRunShieldParamsMessageUserContentUnion) UnmarshalJSON(data []byte func (u *SafetyRunShieldParamsMessageUserContentUnion) asAny() any { if !param.IsOmitted(u.OfString) { return &u.OfString.Value - } else if !param.IsOmitted(u.OfSafetyRunShieldsMessageUserContentArray) { - return &u.OfSafetyRunShieldsMessageUserContentArray + } else if !param.IsOmitted(u.OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile) { + return &u.OfListOpenAIChatCompletionContentPartTextOpenAIChatCompletionContentPartImageParamOpenAIFile } return nil } @@ -270,21 +270,21 @@ func (u *SafetyRunShieldParamsMessageUserContentUnion) asAny() any { // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. -type SafetyRunShieldParamsMessageUserContentArrayItemUnion struct { - OfText *SafetyRunShieldParamsMessageUserContentArrayItemText `json:",omitzero,inline"` - OfImageURL *SafetyRunShieldParamsMessageUserContentArrayItemImageURL `json:",omitzero,inline"` - OfFile *SafetyRunShieldParamsMessageUserContentArrayItemFile `json:",omitzero,inline"` +type SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion struct { + OfText *SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText `json:",omitzero,inline"` + OfImageURL *SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL `json:",omitzero,inline"` + OfFile *SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile `json:",omitzero,inline"` paramUnion } -func (u SafetyRunShieldParamsMessageUserContentArrayItemUnion) MarshalJSON() ([]byte, error) { +func (u SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) MarshalJSON() ([]byte, error) { return param.MarshalUnion(u, u.OfText, u.OfImageURL, u.OfFile) } -func (u *SafetyRunShieldParamsMessageUserContentArrayItemUnion) UnmarshalJSON(data []byte) error { +func (u *SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *SafetyRunShieldParamsMessageUserContentArrayItemUnion) asAny() any { +func (u *SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) asAny() any { if !param.IsOmitted(u.OfText) { return u.OfText } else if !param.IsOmitted(u.OfImageURL) { @@ -296,7 +296,7 @@ func (u *SafetyRunShieldParamsMessageUserContentArrayItemUnion) asAny() any { } // Returns a pointer to the underlying variant's property, if present. -func (u SafetyRunShieldParamsMessageUserContentArrayItemUnion) GetText() *string { +func (u SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) GetText() *string { if vt := u.OfText; vt != nil { return &vt.Text } @@ -304,7 +304,7 @@ func (u SafetyRunShieldParamsMessageUserContentArrayItemUnion) GetText() *string } // Returns a pointer to the underlying variant's property, if present. -func (u SafetyRunShieldParamsMessageUserContentArrayItemUnion) GetImageURL() *SafetyRunShieldParamsMessageUserContentArrayItemImageURLImageURL { +func (u SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) GetImageURL() *SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL { if vt := u.OfImageURL; vt != nil { return &vt.ImageURL } @@ -312,7 +312,7 @@ func (u SafetyRunShieldParamsMessageUserContentArrayItemUnion) GetImageURL() *Sa } // Returns a pointer to the underlying variant's property, if present. -func (u SafetyRunShieldParamsMessageUserContentArrayItemUnion) GetFile() *SafetyRunShieldParamsMessageUserContentArrayItemFileFile { +func (u SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) GetFile() *SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile { if vt := u.OfFile; vt != nil { return &vt.File } @@ -320,7 +320,7 @@ func (u SafetyRunShieldParamsMessageUserContentArrayItemUnion) GetFile() *Safety } // Returns a pointer to the underlying variant's property, if present. -func (u SafetyRunShieldParamsMessageUserContentArrayItemUnion) GetType() *string { +func (u SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion) GetType() *string { if vt := u.OfText; vt != nil { return (*string)(&vt.Type) } else if vt := u.OfImageURL; vt != nil { @@ -332,120 +332,125 @@ func (u SafetyRunShieldParamsMessageUserContentArrayItemUnion) GetType() *string } func init() { - apijson.RegisterUnion[SafetyRunShieldParamsMessageUserContentArrayItemUnion]( + apijson.RegisterUnion[SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemUnion]( "type", - apijson.Discriminator[SafetyRunShieldParamsMessageUserContentArrayItemText]("text"), - apijson.Discriminator[SafetyRunShieldParamsMessageUserContentArrayItemImageURL]("image_url"), - apijson.Discriminator[SafetyRunShieldParamsMessageUserContentArrayItemFile]("file"), + apijson.Discriminator[SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText]("text"), + apijson.Discriminator[SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL]("image_url"), + apijson.Discriminator[SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile]("file"), ) } // Text content part for OpenAI-compatible chat completion messages. // -// The properties Text, Type are required. -type SafetyRunShieldParamsMessageUserContentArrayItemText struct { - // The text content of the message +// The property Text is required. +type SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - // - // This field can be elided, and will marshal its zero value as "text". - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type,omitzero"` paramObj } -func (r SafetyRunShieldParamsMessageUserContentArrayItemText) MarshalJSON() (data []byte, err error) { - type shadow SafetyRunShieldParamsMessageUserContentArrayItemText +func (r SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText return param.MarshalObject(r, (*shadow)(&r)) } -func (r *SafetyRunShieldParamsMessageUserContentArrayItemText) UnmarshalJSON(data []byte) error { +func (r *SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemText]( + "type", "text", + ) +} + // Image content part for OpenAI-compatible chat completion messages. // -// The properties ImageURL, Type are required. -type SafetyRunShieldParamsMessageUserContentArrayItemImageURL struct { - // Image URL specification and processing details - ImageURL SafetyRunShieldParamsMessageUserContentArrayItemImageURLImageURL `json:"image_url,omitzero,required"` - // Must be "image_url" to identify this as image content - // - // This field can be elided, and will marshal its zero value as "image_url". - Type constant.ImageURL `json:"type,required"` +// The property ImageURL is required. +type SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL struct { + // Image URL specification for OpenAI-compatible chat completion messages. + ImageURL SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL `json:"image_url,omitzero,required"` + // Any of "image_url". + Type string `json:"type,omitzero"` paramObj } -func (r SafetyRunShieldParamsMessageUserContentArrayItemImageURL) MarshalJSON() (data []byte, err error) { - type shadow SafetyRunShieldParamsMessageUserContentArrayItemImageURL +func (r SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL return param.MarshalObject(r, (*shadow)(&r)) } -func (r *SafetyRunShieldParamsMessageUserContentArrayItemImageURL) UnmarshalJSON(data []byte) error { +func (r *SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Image URL specification and processing details +func init() { + apijson.RegisterFieldValidator[SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURL]( + "type", "image_url", + ) +} + +// Image URL specification for OpenAI-compatible chat completion messages. // // The property URL is required. -type SafetyRunShieldParamsMessageUserContentArrayItemImageURLImageURL struct { - // URL of the image to include in the message - URL string `json:"url,required"` - // (Optional) Level of detail for image processing. Can be "low", "high", or "auto" +type SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL struct { + URL string `json:"url,required"` Detail param.Opt[string] `json:"detail,omitzero"` paramObj } -func (r SafetyRunShieldParamsMessageUserContentArrayItemImageURLImageURL) MarshalJSON() (data []byte, err error) { - type shadow SafetyRunShieldParamsMessageUserContentArrayItemImageURLImageURL +func (r SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL return param.MarshalObject(r, (*shadow)(&r)) } -func (r *SafetyRunShieldParamsMessageUserContentArrayItemImageURLImageURL) UnmarshalJSON(data []byte) error { +func (r *SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemImageURLImageURL) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// The properties File, Type are required. -type SafetyRunShieldParamsMessageUserContentArrayItemFile struct { - File SafetyRunShieldParamsMessageUserContentArrayItemFileFile `json:"file,omitzero,required"` - // This field can be elided, and will marshal its zero value as "file". - Type constant.File `json:"type,required"` +// The property File is required. +type SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile struct { + File SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile `json:"file,omitzero,required"` + // Any of "file". + Type string `json:"type,omitzero"` paramObj } -func (r SafetyRunShieldParamsMessageUserContentArrayItemFile) MarshalJSON() (data []byte, err error) { - type shadow SafetyRunShieldParamsMessageUserContentArrayItemFile +func (r SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile return param.MarshalObject(r, (*shadow)(&r)) } -func (r *SafetyRunShieldParamsMessageUserContentArrayItemFile) UnmarshalJSON(data []byte) error { +func (r *SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type SafetyRunShieldParamsMessageUserContentArrayItemFileFile struct { +func init() { + apijson.RegisterFieldValidator[SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFile]( + "type", "file", + ) +} + +type SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile struct { FileData param.Opt[string] `json:"file_data,omitzero"` FileID param.Opt[string] `json:"file_id,omitzero"` Filename param.Opt[string] `json:"filename,omitzero"` paramObj } -func (r SafetyRunShieldParamsMessageUserContentArrayItemFileFile) MarshalJSON() (data []byte, err error) { - type shadow SafetyRunShieldParamsMessageUserContentArrayItemFileFile +func (r SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile return param.MarshalObject(r, (*shadow)(&r)) } -func (r *SafetyRunShieldParamsMessageUserContentArrayItemFileFile) UnmarshalJSON(data []byte) error { +func (r *SafetyRunShieldParamsMessageUserContentListOpenAIChatCompletionContentPartTextParamOpenAIChatCompletionContentPartImageParamOpenAIFileItemFileFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A system message providing instructions or context to the model. // -// The properties Content, Role are required. +// The property Content is required. type SafetyRunShieldParamsMessageSystem struct { - // The content of the "system prompt". If multiple system messages are provided, - // they are concatenated. The underlying Llama Stack code may also add other system - // messages (for example, for formatting tool definitions). Content SafetyRunShieldParamsMessageSystemContentUnion `json:"content,omitzero,required"` - // (Optional) The name of the system message participant. - Name param.Opt[string] `json:"name,omitzero"` - // Must be "system" to identify this as a system message - // - // This field can be elided, and will marshal its zero value as "system". - Role constant.System `json:"role,required"` + Name param.Opt[string] `json:"name,omitzero"` + // Any of "system". + Role string `json:"role,omitzero"` paramObj } @@ -457,17 +462,23 @@ func (r *SafetyRunShieldParamsMessageSystem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[SafetyRunShieldParamsMessageSystem]( + "role", "system", + ) +} + // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. type SafetyRunShieldParamsMessageSystemContentUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfSafetyRunShieldsMessageSystemContentArray []SafetyRunShieldParamsMessageSystemContentArrayItem `json:",omitzero,inline"` + OfString param.Opt[string] `json:",omitzero,inline"` + OfListOpenAIChatCompletionContentPartText []SafetyRunShieldParamsMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem `json:",omitzero,inline"` paramUnion } func (u SafetyRunShieldParamsMessageSystemContentUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfSafetyRunShieldsMessageSystemContentArray) + return param.MarshalUnion(u, u.OfString, u.OfListOpenAIChatCompletionContentPartText) } func (u *SafetyRunShieldParamsMessageSystemContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) @@ -476,48 +487,44 @@ func (u *SafetyRunShieldParamsMessageSystemContentUnion) UnmarshalJSON(data []by func (u *SafetyRunShieldParamsMessageSystemContentUnion) asAny() any { if !param.IsOmitted(u.OfString) { return &u.OfString.Value - } else if !param.IsOmitted(u.OfSafetyRunShieldsMessageSystemContentArray) { - return &u.OfSafetyRunShieldsMessageSystemContentArray + } else if !param.IsOmitted(u.OfListOpenAIChatCompletionContentPartText) { + return &u.OfListOpenAIChatCompletionContentPartText } return nil } // Text content part for OpenAI-compatible chat completion messages. // -// The properties Text, Type are required. -type SafetyRunShieldParamsMessageSystemContentArrayItem struct { - // The text content of the message +// The property Text is required. +type SafetyRunShieldParamsMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - // - // This field can be elided, and will marshal its zero value as "text". - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type,omitzero"` paramObj } -func (r SafetyRunShieldParamsMessageSystemContentArrayItem) MarshalJSON() (data []byte, err error) { - type shadow SafetyRunShieldParamsMessageSystemContentArrayItem +func (r SafetyRunShieldParamsMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem return param.MarshalObject(r, (*shadow)(&r)) } -func (r *SafetyRunShieldParamsMessageSystemContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *SafetyRunShieldParamsMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[SafetyRunShieldParamsMessageSystemContentListOpenAIChatCompletionContentPartTextParamItem]( + "type", "text", + ) +} + // A message containing the model's (assistant) response in an OpenAI-compatible // chat completion request. -// -// The property Role is required. type SafetyRunShieldParamsMessageAssistant struct { - // (Optional) The name of the assistant message participant. - Name param.Opt[string] `json:"name,omitzero"` - // The content of the model's response - Content SafetyRunShieldParamsMessageAssistantContentUnion `json:"content,omitzero"` - // List of tool calls. Each tool call is an OpenAIChatCompletionToolCall object. - ToolCalls []SafetyRunShieldParamsMessageAssistantToolCall `json:"tool_calls,omitzero"` - // Must be "assistant" to identify this as the model's response - // - // This field can be elided, and will marshal its zero value as "assistant". - Role constant.Assistant `json:"role,required"` + Name param.Opt[string] `json:"name,omitzero"` + Content SafetyRunShieldParamsMessageAssistantContentUnion `json:"content,omitzero"` + ToolCalls []SafetyRunShieldParamsMessageAssistantToolCall `json:"tool_calls,omitzero"` + // Any of "assistant". + Role string `json:"role,omitzero"` paramObj } @@ -529,17 +536,23 @@ func (r *SafetyRunShieldParamsMessageAssistant) UnmarshalJSON(data []byte) error return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[SafetyRunShieldParamsMessageAssistant]( + "role", "assistant", + ) +} + // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. type SafetyRunShieldParamsMessageAssistantContentUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfSafetyRunShieldsMessageAssistantContentArray []SafetyRunShieldParamsMessageAssistantContentArrayItem `json:",omitzero,inline"` + OfString param.Opt[string] `json:",omitzero,inline"` + OfListOpenAIChatCompletionContentPartText []SafetyRunShieldParamsMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem `json:",omitzero,inline"` paramUnion } func (u SafetyRunShieldParamsMessageAssistantContentUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfSafetyRunShieldsMessageAssistantContentArray) + return param.MarshalUnion(u, u.OfString, u.OfListOpenAIChatCompletionContentPartText) } func (u *SafetyRunShieldParamsMessageAssistantContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) @@ -548,47 +561,44 @@ func (u *SafetyRunShieldParamsMessageAssistantContentUnion) UnmarshalJSON(data [ func (u *SafetyRunShieldParamsMessageAssistantContentUnion) asAny() any { if !param.IsOmitted(u.OfString) { return &u.OfString.Value - } else if !param.IsOmitted(u.OfSafetyRunShieldsMessageAssistantContentArray) { - return &u.OfSafetyRunShieldsMessageAssistantContentArray + } else if !param.IsOmitted(u.OfListOpenAIChatCompletionContentPartText) { + return &u.OfListOpenAIChatCompletionContentPartText } return nil } // Text content part for OpenAI-compatible chat completion messages. // -// The properties Text, Type are required. -type SafetyRunShieldParamsMessageAssistantContentArrayItem struct { - // The text content of the message +// The property Text is required. +type SafetyRunShieldParamsMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - // - // This field can be elided, and will marshal its zero value as "text". - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type,omitzero"` paramObj } -func (r SafetyRunShieldParamsMessageAssistantContentArrayItem) MarshalJSON() (data []byte, err error) { - type shadow SafetyRunShieldParamsMessageAssistantContentArrayItem +func (r SafetyRunShieldParamsMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem return param.MarshalObject(r, (*shadow)(&r)) } -func (r *SafetyRunShieldParamsMessageAssistantContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *SafetyRunShieldParamsMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[SafetyRunShieldParamsMessageAssistantContentListOpenAIChatCompletionContentPartTextParamItem]( + "type", "text", + ) +} + // Tool call specification for OpenAI-compatible chat completion responses. -// -// The property Type is required. type SafetyRunShieldParamsMessageAssistantToolCall struct { - // (Optional) Unique identifier for the tool call - ID param.Opt[string] `json:"id,omitzero"` - // (Optional) Index of the tool call in the list - Index param.Opt[int64] `json:"index,omitzero"` - // (Optional) Function call details + ID param.Opt[string] `json:"id,omitzero"` + Index param.Opt[int64] `json:"index,omitzero"` + // Function call details for OpenAI-compatible tool calls. Function SafetyRunShieldParamsMessageAssistantToolCallFunction `json:"function,omitzero"` - // Must be "function" to identify this as a function call - // - // This field can be elided, and will marshal its zero value as "function". - Type constant.Function `json:"type,required"` + // Any of "function". + Type string `json:"type,omitzero"` paramObj } @@ -600,12 +610,16 @@ func (r *SafetyRunShieldParamsMessageAssistantToolCall) UnmarshalJSON(data []byt return apijson.UnmarshalRoot(data, r) } -// (Optional) Function call details +func init() { + apijson.RegisterFieldValidator[SafetyRunShieldParamsMessageAssistantToolCall]( + "type", "function", + ) +} + +// Function call details for OpenAI-compatible tool calls. type SafetyRunShieldParamsMessageAssistantToolCallFunction struct { - // (Optional) Arguments to pass to the function as a JSON string Arguments param.Opt[string] `json:"arguments,omitzero"` - // (Optional) Name of the function to call - Name param.Opt[string] `json:"name,omitzero"` + Name param.Opt[string] `json:"name,omitzero"` paramObj } @@ -620,16 +634,12 @@ func (r *SafetyRunShieldParamsMessageAssistantToolCallFunction) UnmarshalJSON(da // A message representing the result of a tool invocation in an OpenAI-compatible // chat completion request. // -// The properties Content, Role, ToolCallID are required. +// The properties Content, ToolCallID are required. type SafetyRunShieldParamsMessageTool struct { - // The response content from the tool - Content SafetyRunShieldParamsMessageToolContentUnion `json:"content,omitzero,required"` - // Unique identifier for the tool call this response is for - ToolCallID string `json:"tool_call_id,required"` - // Must be "tool" to identify this as a tool response - // - // This field can be elided, and will marshal its zero value as "tool". - Role constant.Tool `json:"role,required"` + Content SafetyRunShieldParamsMessageToolContentUnion `json:"content,omitzero,required"` + ToolCallID string `json:"tool_call_id,required"` + // Any of "tool". + Role string `json:"role,omitzero"` paramObj } @@ -641,17 +651,23 @@ func (r *SafetyRunShieldParamsMessageTool) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[SafetyRunShieldParamsMessageTool]( + "role", "tool", + ) +} + // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. type SafetyRunShieldParamsMessageToolContentUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfSafetyRunShieldsMessageToolContentArray []SafetyRunShieldParamsMessageToolContentArrayItem `json:",omitzero,inline"` + OfString param.Opt[string] `json:",omitzero,inline"` + OfListOpenAIChatCompletionContentPartText []SafetyRunShieldParamsMessageToolContentListOpenAIChatCompletionContentPartTextParamItem `json:",omitzero,inline"` paramUnion } func (u SafetyRunShieldParamsMessageToolContentUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfSafetyRunShieldsMessageToolContentArray) + return param.MarshalUnion(u, u.OfString, u.OfListOpenAIChatCompletionContentPartText) } func (u *SafetyRunShieldParamsMessageToolContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) @@ -660,45 +676,44 @@ func (u *SafetyRunShieldParamsMessageToolContentUnion) UnmarshalJSON(data []byte func (u *SafetyRunShieldParamsMessageToolContentUnion) asAny() any { if !param.IsOmitted(u.OfString) { return &u.OfString.Value - } else if !param.IsOmitted(u.OfSafetyRunShieldsMessageToolContentArray) { - return &u.OfSafetyRunShieldsMessageToolContentArray + } else if !param.IsOmitted(u.OfListOpenAIChatCompletionContentPartText) { + return &u.OfListOpenAIChatCompletionContentPartText } return nil } // Text content part for OpenAI-compatible chat completion messages. // -// The properties Text, Type are required. -type SafetyRunShieldParamsMessageToolContentArrayItem struct { - // The text content of the message +// The property Text is required. +type SafetyRunShieldParamsMessageToolContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - // - // This field can be elided, and will marshal its zero value as "text". - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type,omitzero"` paramObj } -func (r SafetyRunShieldParamsMessageToolContentArrayItem) MarshalJSON() (data []byte, err error) { - type shadow SafetyRunShieldParamsMessageToolContentArrayItem +func (r SafetyRunShieldParamsMessageToolContentListOpenAIChatCompletionContentPartTextParamItem) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageToolContentListOpenAIChatCompletionContentPartTextParamItem return param.MarshalObject(r, (*shadow)(&r)) } -func (r *SafetyRunShieldParamsMessageToolContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *SafetyRunShieldParamsMessageToolContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[SafetyRunShieldParamsMessageToolContentListOpenAIChatCompletionContentPartTextParamItem]( + "type", "text", + ) +} + // A message from the developer in an OpenAI-compatible chat completion request. // -// The properties Content, Role are required. +// The property Content is required. type SafetyRunShieldParamsMessageDeveloper struct { - // The content of the developer message Content SafetyRunShieldParamsMessageDeveloperContentUnion `json:"content,omitzero,required"` - // (Optional) The name of the developer message participant. - Name param.Opt[string] `json:"name,omitzero"` - // Must be "developer" to identify this as a developer message - // - // This field can be elided, and will marshal its zero value as "developer". - Role constant.Developer `json:"role,required"` + Name param.Opt[string] `json:"name,omitzero"` + // Any of "developer". + Role string `json:"role,omitzero"` paramObj } @@ -710,17 +725,23 @@ func (r *SafetyRunShieldParamsMessageDeveloper) UnmarshalJSON(data []byte) error return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[SafetyRunShieldParamsMessageDeveloper]( + "role", "developer", + ) +} + // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. type SafetyRunShieldParamsMessageDeveloperContentUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfSafetyRunShieldsMessageDeveloperContentArray []SafetyRunShieldParamsMessageDeveloperContentArrayItem `json:",omitzero,inline"` + OfString param.Opt[string] `json:",omitzero,inline"` + OfListOpenAIChatCompletionContentPartText []SafetyRunShieldParamsMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem `json:",omitzero,inline"` paramUnion } func (u SafetyRunShieldParamsMessageDeveloperContentUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfSafetyRunShieldsMessageDeveloperContentArray) + return param.MarshalUnion(u, u.OfString, u.OfListOpenAIChatCompletionContentPartText) } func (u *SafetyRunShieldParamsMessageDeveloperContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) @@ -729,60 +750,32 @@ func (u *SafetyRunShieldParamsMessageDeveloperContentUnion) UnmarshalJSON(data [ func (u *SafetyRunShieldParamsMessageDeveloperContentUnion) asAny() any { if !param.IsOmitted(u.OfString) { return &u.OfString.Value - } else if !param.IsOmitted(u.OfSafetyRunShieldsMessageDeveloperContentArray) { - return &u.OfSafetyRunShieldsMessageDeveloperContentArray + } else if !param.IsOmitted(u.OfListOpenAIChatCompletionContentPartText) { + return &u.OfListOpenAIChatCompletionContentPartText } return nil } // Text content part for OpenAI-compatible chat completion messages. // -// The properties Text, Type are required. -type SafetyRunShieldParamsMessageDeveloperContentArrayItem struct { - // The text content of the message +// The property Text is required. +type SafetyRunShieldParamsMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem struct { Text string `json:"text,required"` - // Must be "text" to identify this as text content - // - // This field can be elided, and will marshal its zero value as "text". - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type,omitzero"` paramObj } -func (r SafetyRunShieldParamsMessageDeveloperContentArrayItem) MarshalJSON() (data []byte, err error) { - type shadow SafetyRunShieldParamsMessageDeveloperContentArrayItem +func (r SafetyRunShieldParamsMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem return param.MarshalObject(r, (*shadow)(&r)) } -func (r *SafetyRunShieldParamsMessageDeveloperContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *SafetyRunShieldParamsMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type SafetyRunShieldParamsParamUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u SafetyRunShieldParamsParamUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *SafetyRunShieldParamsParamUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *SafetyRunShieldParamsParamUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil +func init() { + apijson.RegisterFieldValidator[SafetyRunShieldParamsMessageDeveloperContentListOpenAIChatCompletionContentPartTextParamItem]( + "type", "text", + ) } diff --git a/safety_test.go b/safety_test.go index db56629..345df79 100644 --- a/safety_test.go +++ b/safety_test.go @@ -37,12 +37,11 @@ func TestSafetyRunShield(t *testing.T) { OfString: llamastackclient.String("string"), }, Name: llamastackclient.String("name"), + Role: "user", }, }}, - Params: map[string]llamastackclient.SafetyRunShieldParamsParamUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + Params: map[string]any{ + "foo": "bar", }, ShieldID: "shield_id", }) diff --git a/scoring.go b/scoring.go index 953dedf..2128f4d 100644 --- a/scoring.go +++ b/scoring.go @@ -57,7 +57,6 @@ func (r *ScoringService) ScoreBatch(ctx context.Context, body ScoringScoreBatchP // The response from scoring. type ScoringScoreResponse struct { - // A map of scoring function name to ScoringResult. Results map[string]ScoringResult `json:"results,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { @@ -75,10 +74,8 @@ func (r *ScoringScoreResponse) UnmarshalJSON(data []byte) error { // Response from batch scoring operations on datasets. type ScoringScoreBatchResponse struct { - // A map of scoring function name to ScoringResult - Results map[string]ScoringResult `json:"results,required"` - // (Optional) The identifier of the dataset that was scored - DatasetID string `json:"dataset_id"` + Results map[string]ScoringResult `json:"results,required"` + DatasetID string `json:"dataset_id,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Results respjson.Field @@ -95,10 +92,8 @@ func (r *ScoringScoreBatchResponse) UnmarshalJSON(data []byte) error { } type ScoringScoreParams struct { - // The rows to score. - InputRows []map[string]ScoringScoreParamsInputRowUnion `json:"input_rows,omitzero,required"` - // The scoring functions to use for the scoring. - ScoringFunctions map[string]ScoringFnParamsUnion `json:"scoring_functions,omitzero,required"` + InputRows []map[string]any `json:"input_rows,omitzero,required"` + ScoringFunctions map[string]ScoringScoreParamsScoringFunctionUnion `json:"scoring_functions,omitzero,required"` paramObj } @@ -113,41 +108,184 @@ func (r *ScoringScoreParams) UnmarshalJSON(data []byte) error { // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. -type ScoringScoreParamsInputRowUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` +type ScoringScoreParamsScoringFunctionUnion struct { + OfLlmAsJudge *ScoringScoreParamsScoringFunctionLlmAsJudge `json:",omitzero,inline"` + OfRegexParser *ScoringScoreParamsScoringFunctionRegexParser `json:",omitzero,inline"` + OfBasic *ScoringScoreParamsScoringFunctionBasic `json:",omitzero,inline"` paramUnion } -func (u ScoringScoreParamsInputRowUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) +func (u ScoringScoreParamsScoringFunctionUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfLlmAsJudge, u.OfRegexParser, u.OfBasic) } -func (u *ScoringScoreParamsInputRowUnion) UnmarshalJSON(data []byte) error { +func (u *ScoringScoreParamsScoringFunctionUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *ScoringScoreParamsInputRowUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray +func (u *ScoringScoreParamsScoringFunctionUnion) asAny() any { + if !param.IsOmitted(u.OfLlmAsJudge) { + return u.OfLlmAsJudge + } else if !param.IsOmitted(u.OfRegexParser) { + return u.OfRegexParser + } else if !param.IsOmitted(u.OfBasic) { + return u.OfBasic + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ScoringScoreParamsScoringFunctionUnion) GetJudgeModel() *string { + if vt := u.OfLlmAsJudge; vt != nil { + return &vt.JudgeModel + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ScoringScoreParamsScoringFunctionUnion) GetJudgeScoreRegexes() []string { + if vt := u.OfLlmAsJudge; vt != nil { + return vt.JudgeScoreRegexes + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ScoringScoreParamsScoringFunctionUnion) GetPromptTemplate() *string { + if vt := u.OfLlmAsJudge; vt != nil && vt.PromptTemplate.Valid() { + return &vt.PromptTemplate.Value + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ScoringScoreParamsScoringFunctionUnion) GetParsingRegexes() []string { + if vt := u.OfRegexParser; vt != nil { + return vt.ParsingRegexes } return nil } +// Returns a pointer to the underlying variant's property, if present. +func (u ScoringScoreParamsScoringFunctionUnion) GetType() *string { + if vt := u.OfLlmAsJudge; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfRegexParser; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfBasic; vt != nil { + return (*string)(&vt.Type) + } + return nil +} + +// Returns a pointer to the underlying variant's AggregationFunctions property, if +// present. +func (u ScoringScoreParamsScoringFunctionUnion) GetAggregationFunctions() []string { + if vt := u.OfLlmAsJudge; vt != nil { + return vt.AggregationFunctions + } else if vt := u.OfRegexParser; vt != nil { + return vt.AggregationFunctions + } else if vt := u.OfBasic; vt != nil { + return vt.AggregationFunctions + } + return nil +} + +func init() { + apijson.RegisterUnion[ScoringScoreParamsScoringFunctionUnion]( + "type", + apijson.Discriminator[ScoringScoreParamsScoringFunctionLlmAsJudge]("llm_as_judge"), + apijson.Discriminator[ScoringScoreParamsScoringFunctionRegexParser]("regex_parser"), + apijson.Discriminator[ScoringScoreParamsScoringFunctionBasic]("basic"), + ) +} + +// Parameters for LLM-as-judge scoring function configuration. +// +// The property JudgeModel is required. +type ScoringScoreParamsScoringFunctionLlmAsJudge struct { + JudgeModel string `json:"judge_model,required"` + PromptTemplate param.Opt[string] `json:"prompt_template,omitzero"` + // Aggregation functions to apply to the scores of each row + // + // Any of "average", "weighted_average", "median", "categorical_count", "accuracy". + AggregationFunctions []string `json:"aggregation_functions,omitzero"` + // Regexes to extract the answer from generated response + JudgeScoreRegexes []string `json:"judge_score_regexes,omitzero"` + // Any of "llm_as_judge". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ScoringScoreParamsScoringFunctionLlmAsJudge) MarshalJSON() (data []byte, err error) { + type shadow ScoringScoreParamsScoringFunctionLlmAsJudge + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ScoringScoreParamsScoringFunctionLlmAsJudge) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ScoringScoreParamsScoringFunctionLlmAsJudge]( + "type", "llm_as_judge", + ) +} + +// Parameters for regex parser scoring function configuration. +type ScoringScoreParamsScoringFunctionRegexParser struct { + // Aggregation functions to apply to the scores of each row + // + // Any of "average", "weighted_average", "median", "categorical_count", "accuracy". + AggregationFunctions []string `json:"aggregation_functions,omitzero"` + // Regex to extract the answer from generated response + ParsingRegexes []string `json:"parsing_regexes,omitzero"` + // Any of "regex_parser". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ScoringScoreParamsScoringFunctionRegexParser) MarshalJSON() (data []byte, err error) { + type shadow ScoringScoreParamsScoringFunctionRegexParser + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ScoringScoreParamsScoringFunctionRegexParser) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ScoringScoreParamsScoringFunctionRegexParser]( + "type", "regex_parser", + ) +} + +// Parameters for basic scoring function configuration. +type ScoringScoreParamsScoringFunctionBasic struct { + // Aggregation functions to apply to the scores of each row + // + // Any of "average", "weighted_average", "median", "categorical_count", "accuracy". + AggregationFunctions []string `json:"aggregation_functions,omitzero"` + // Any of "basic". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ScoringScoreParamsScoringFunctionBasic) MarshalJSON() (data []byte, err error) { + type shadow ScoringScoreParamsScoringFunctionBasic + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ScoringScoreParamsScoringFunctionBasic) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ScoringScoreParamsScoringFunctionBasic]( + "type", "basic", + ) +} + type ScoringScoreBatchParams struct { - // The ID of the dataset to score. - DatasetID string `json:"dataset_id,required"` - // Whether to save the results to a dataset. - SaveResultsDataset bool `json:"save_results_dataset,required"` - // The scoring functions to use for the scoring. - ScoringFunctions map[string]ScoringFnParamsUnion `json:"scoring_functions,omitzero,required"` + DatasetID string `json:"dataset_id,required"` + ScoringFunctions map[string]ScoringScoreBatchParamsScoringFunctionUnion `json:"scoring_functions,omitzero,required"` + SaveResultsDataset param.Opt[bool] `json:"save_results_dataset,omitzero"` paramObj } @@ -158,3 +296,180 @@ func (r ScoringScoreBatchParams) MarshalJSON() (data []byte, err error) { func (r *ScoringScoreBatchParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } + +// Only one field can be non-zero. +// +// Use [param.IsOmitted] to confirm if a field is set. +type ScoringScoreBatchParamsScoringFunctionUnion struct { + OfLlmAsJudge *ScoringScoreBatchParamsScoringFunctionLlmAsJudge `json:",omitzero,inline"` + OfRegexParser *ScoringScoreBatchParamsScoringFunctionRegexParser `json:",omitzero,inline"` + OfBasic *ScoringScoreBatchParamsScoringFunctionBasic `json:",omitzero,inline"` + paramUnion +} + +func (u ScoringScoreBatchParamsScoringFunctionUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfLlmAsJudge, u.OfRegexParser, u.OfBasic) +} +func (u *ScoringScoreBatchParamsScoringFunctionUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *ScoringScoreBatchParamsScoringFunctionUnion) asAny() any { + if !param.IsOmitted(u.OfLlmAsJudge) { + return u.OfLlmAsJudge + } else if !param.IsOmitted(u.OfRegexParser) { + return u.OfRegexParser + } else if !param.IsOmitted(u.OfBasic) { + return u.OfBasic + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ScoringScoreBatchParamsScoringFunctionUnion) GetJudgeModel() *string { + if vt := u.OfLlmAsJudge; vt != nil { + return &vt.JudgeModel + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ScoringScoreBatchParamsScoringFunctionUnion) GetJudgeScoreRegexes() []string { + if vt := u.OfLlmAsJudge; vt != nil { + return vt.JudgeScoreRegexes + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ScoringScoreBatchParamsScoringFunctionUnion) GetPromptTemplate() *string { + if vt := u.OfLlmAsJudge; vt != nil && vt.PromptTemplate.Valid() { + return &vt.PromptTemplate.Value + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ScoringScoreBatchParamsScoringFunctionUnion) GetParsingRegexes() []string { + if vt := u.OfRegexParser; vt != nil { + return vt.ParsingRegexes + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ScoringScoreBatchParamsScoringFunctionUnion) GetType() *string { + if vt := u.OfLlmAsJudge; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfRegexParser; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfBasic; vt != nil { + return (*string)(&vt.Type) + } + return nil +} + +// Returns a pointer to the underlying variant's AggregationFunctions property, if +// present. +func (u ScoringScoreBatchParamsScoringFunctionUnion) GetAggregationFunctions() []string { + if vt := u.OfLlmAsJudge; vt != nil { + return vt.AggregationFunctions + } else if vt := u.OfRegexParser; vt != nil { + return vt.AggregationFunctions + } else if vt := u.OfBasic; vt != nil { + return vt.AggregationFunctions + } + return nil +} + +func init() { + apijson.RegisterUnion[ScoringScoreBatchParamsScoringFunctionUnion]( + "type", + apijson.Discriminator[ScoringScoreBatchParamsScoringFunctionLlmAsJudge]("llm_as_judge"), + apijson.Discriminator[ScoringScoreBatchParamsScoringFunctionRegexParser]("regex_parser"), + apijson.Discriminator[ScoringScoreBatchParamsScoringFunctionBasic]("basic"), + ) +} + +// Parameters for LLM-as-judge scoring function configuration. +// +// The property JudgeModel is required. +type ScoringScoreBatchParamsScoringFunctionLlmAsJudge struct { + JudgeModel string `json:"judge_model,required"` + PromptTemplate param.Opt[string] `json:"prompt_template,omitzero"` + // Aggregation functions to apply to the scores of each row + // + // Any of "average", "weighted_average", "median", "categorical_count", "accuracy". + AggregationFunctions []string `json:"aggregation_functions,omitzero"` + // Regexes to extract the answer from generated response + JudgeScoreRegexes []string `json:"judge_score_regexes,omitzero"` + // Any of "llm_as_judge". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ScoringScoreBatchParamsScoringFunctionLlmAsJudge) MarshalJSON() (data []byte, err error) { + type shadow ScoringScoreBatchParamsScoringFunctionLlmAsJudge + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ScoringScoreBatchParamsScoringFunctionLlmAsJudge) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ScoringScoreBatchParamsScoringFunctionLlmAsJudge]( + "type", "llm_as_judge", + ) +} + +// Parameters for regex parser scoring function configuration. +type ScoringScoreBatchParamsScoringFunctionRegexParser struct { + // Aggregation functions to apply to the scores of each row + // + // Any of "average", "weighted_average", "median", "categorical_count", "accuracy". + AggregationFunctions []string `json:"aggregation_functions,omitzero"` + // Regex to extract the answer from generated response + ParsingRegexes []string `json:"parsing_regexes,omitzero"` + // Any of "regex_parser". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ScoringScoreBatchParamsScoringFunctionRegexParser) MarshalJSON() (data []byte, err error) { + type shadow ScoringScoreBatchParamsScoringFunctionRegexParser + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ScoringScoreBatchParamsScoringFunctionRegexParser) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ScoringScoreBatchParamsScoringFunctionRegexParser]( + "type", "regex_parser", + ) +} + +// Parameters for basic scoring function configuration. +type ScoringScoreBatchParamsScoringFunctionBasic struct { + // Aggregation functions to apply to the scores of each row + // + // Any of "average", "weighted_average", "median", "categorical_count", "accuracy". + AggregationFunctions []string `json:"aggregation_functions,omitzero"` + // Any of "basic". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ScoringScoreBatchParamsScoringFunctionBasic) MarshalJSON() (data []byte, err error) { + type shadow ScoringScoreBatchParamsScoringFunctionBasic + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ScoringScoreBatchParamsScoringFunctionBasic) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ScoringScoreBatchParamsScoringFunctionBasic]( + "type", "basic", + ) +} diff --git a/scoring_test.go b/scoring_test.go index f7b2001..853370e 100644 --- a/scoring_test.go +++ b/scoring_test.go @@ -31,18 +31,17 @@ func TestScoringScore(t *testing.T) { option.WithBaseURL(baseURL), ) _, err := client.Scoring.Score(context.TODO(), llamastackclient.ScoringScoreParams{ - InputRows: []map[string]llamastackclient.ScoringScoreParamsInputRowUnion{{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + InputRows: []map[string]any{{ + "foo": "bar", }}, - ScoringFunctions: map[string]llamastackclient.ScoringFnParamsUnion{ + ScoringFunctions: map[string]llamastackclient.ScoringScoreParamsScoringFunctionUnion{ "foo": { - OfLlmAsJudge: &llamastackclient.ScoringFnParamsLlmAsJudge{ - AggregationFunctions: []string{"average"}, + OfLlmAsJudge: &llamastackclient.ScoringScoreParamsScoringFunctionLlmAsJudge{ JudgeModel: "judge_model", + AggregationFunctions: []string{"average"}, JudgeScoreRegexes: []string{"string"}, PromptTemplate: llamastackclient.String("prompt_template"), + Type: "llm_as_judge", }, }, }, @@ -56,7 +55,7 @@ func TestScoringScore(t *testing.T) { } } -func TestScoringScoreBatch(t *testing.T) { +func TestScoringScoreBatchWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -68,18 +67,19 @@ func TestScoringScoreBatch(t *testing.T) { option.WithBaseURL(baseURL), ) _, err := client.Scoring.ScoreBatch(context.TODO(), llamastackclient.ScoringScoreBatchParams{ - DatasetID: "dataset_id", - SaveResultsDataset: true, - ScoringFunctions: map[string]llamastackclient.ScoringFnParamsUnion{ + DatasetID: "dataset_id", + ScoringFunctions: map[string]llamastackclient.ScoringScoreBatchParamsScoringFunctionUnion{ "foo": { - OfLlmAsJudge: &llamastackclient.ScoringFnParamsLlmAsJudge{ - AggregationFunctions: []string{"average"}, + OfLlmAsJudge: &llamastackclient.ScoringScoreBatchParamsScoringFunctionLlmAsJudge{ JudgeModel: "judge_model", + AggregationFunctions: []string{"average"}, JudgeScoreRegexes: []string{"string"}, PromptTemplate: llamastackclient.String("prompt_template"), + Type: "llm_as_judge", }, }, }, + SaveResultsDataset: llamastackclient.Bool(true), }) if err != nil { var apierr *llamastackclient.Error diff --git a/scoringfunction.go b/scoringfunction.go index 1f28d7a..f2aac5b 100644 --- a/scoringfunction.go +++ b/scoringfunction.go @@ -21,7 +21,6 @@ import ( "github.com/llamastack/llama-stack-client-go/option" "github.com/llamastack/llama-stack-client-go/packages/param" "github.com/llamastack/llama-stack-client-go/packages/respjson" - "github.com/llamastack/llama-stack-client-go/shared/constant" ) // ScoringFunctionService contains methods and other services that help with @@ -79,6 +78,21 @@ func (r *ScoringFunctionService) Register(ctx context.Context, body ScoringFunct return } +// Unregister a scoring function. +// +// Deprecated: deprecated +func (r *ScoringFunctionService) Unregister(ctx context.Context, scoringFnID string, opts ...option.RequestOption) (err error) { + opts = slices.Concat(r.Options, opts) + opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + if scoringFnID == "" { + err = errors.New("missing required scoring_fn_id parameter") + return + } + path := fmt.Sprintf("v1/scoring-functions/%s", scoringFnID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...) + return +} + type ListScoringFunctionsResponse struct { Data []ScoringFn `json:"data,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. @@ -97,26 +111,31 @@ func (r *ListScoringFunctionsResponse) UnmarshalJSON(data []byte) error { // A scoring function resource for evaluating model outputs. type ScoringFn struct { - Identifier string `json:"identifier,required"` - Metadata map[string]ScoringFnMetadataUnion `json:"metadata,required"` - ProviderID string `json:"provider_id,required"` - ReturnType ScoringFnReturnType `json:"return_type,required"` - // The resource type, always scoring_function - Type constant.ScoringFunction `json:"type,required"` - Description string `json:"description"` - // Parameters for LLM-as-judge scoring function configuration. - Params ScoringFnParamsUnionResp `json:"params"` - ProviderResourceID string `json:"provider_resource_id"` + // Unique identifier for this resource in llama stack + Identifier string `json:"identifier,required"` + // ID of the provider that owns this resource + ProviderID string `json:"provider_id,required"` + ReturnType ScoringFnReturnType `json:"return_type,required"` + Description string `json:"description,nullable"` + // Any additional metadata for this definition + Metadata map[string]any `json:"metadata"` + // The parameters for the scoring function for benchmark eval, these can be + // overridden for app eval + Params ScoringFnParamsUnion `json:"params,nullable"` + // Unique identifier for this resource in the provider + ProviderResourceID string `json:"provider_resource_id,nullable"` + // Any of "scoring_function". + Type ScoringFnType `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Identifier respjson.Field - Metadata respjson.Field ProviderID respjson.Field ReturnType respjson.Field - Type respjson.Field Description respjson.Field + Metadata respjson.Field Params respjson.Field ProviderResourceID respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -128,58 +147,6 @@ func (r *ScoringFn) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ScoringFnMetadataUnion contains all possible properties and values from [bool], -// [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ScoringFnMetadataUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ScoringFnMetadataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ScoringFnMetadataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ScoringFnMetadataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ScoringFnMetadataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ScoringFnMetadataUnion) RawJSON() string { return u.JSON.raw } - -func (r *ScoringFnMetadataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - type ScoringFnReturnType struct { // Any of "string", "number", "boolean", "array", "object", "json", "union", // "chat_completion_input", "completion_input", "agent_turn_input". @@ -198,57 +165,56 @@ func (r *ScoringFnReturnType) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ScoringFnParamsUnionResp contains all possible properties and values from -// [ScoringFnParamsLlmAsJudgeResp], [ScoringFnParamsRegexParserResp], -// [ScoringFnParamsBasicResp]. +// ScoringFnParamsUnion contains all possible properties and values from +// [ScoringFnParamsLlmAsJudge], [ScoringFnParamsRegexParser], +// [ScoringFnParamsBasic]. // -// Use the [ScoringFnParamsUnionResp.AsAny] method to switch on the variant. +// Use the [ScoringFnParamsUnion.AsAny] method to switch on the variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type ScoringFnParamsUnionResp struct { +type ScoringFnParamsUnion struct { + // This field is from variant [ScoringFnParamsLlmAsJudge]. + JudgeModel string `json:"judge_model"` AggregationFunctions []string `json:"aggregation_functions"` - // This field is from variant [ScoringFnParamsLlmAsJudgeResp]. - JudgeModel string `json:"judge_model"` - // This field is from variant [ScoringFnParamsLlmAsJudgeResp]. + // This field is from variant [ScoringFnParamsLlmAsJudge]. JudgeScoreRegexes []string `json:"judge_score_regexes"` + // This field is from variant [ScoringFnParamsLlmAsJudge]. + PromptTemplate string `json:"prompt_template"` // Any of "llm_as_judge", "regex_parser", "basic". Type string `json:"type"` - // This field is from variant [ScoringFnParamsLlmAsJudgeResp]. - PromptTemplate string `json:"prompt_template"` - // This field is from variant [ScoringFnParamsRegexParserResp]. + // This field is from variant [ScoringFnParamsRegexParser]. ParsingRegexes []string `json:"parsing_regexes"` JSON struct { - AggregationFunctions respjson.Field JudgeModel respjson.Field + AggregationFunctions respjson.Field JudgeScoreRegexes respjson.Field - Type respjson.Field PromptTemplate respjson.Field + Type respjson.Field ParsingRegexes respjson.Field raw string } `json:"-"` } -// anyScoringFnParamsResp is implemented by each variant of -// [ScoringFnParamsUnionResp] to add type safety for the return type of -// [ScoringFnParamsUnionResp.AsAny] -type anyScoringFnParamsResp interface { - implScoringFnParamsUnionResp() +// anyScoringFnParams is implemented by each variant of [ScoringFnParamsUnion] to +// add type safety for the return type of [ScoringFnParamsUnion.AsAny] +type anyScoringFnParams interface { + implScoringFnParamsUnion() } -func (ScoringFnParamsLlmAsJudgeResp) implScoringFnParamsUnionResp() {} -func (ScoringFnParamsRegexParserResp) implScoringFnParamsUnionResp() {} -func (ScoringFnParamsBasicResp) implScoringFnParamsUnionResp() {} +func (ScoringFnParamsLlmAsJudge) implScoringFnParamsUnion() {} +func (ScoringFnParamsRegexParser) implScoringFnParamsUnion() {} +func (ScoringFnParamsBasic) implScoringFnParamsUnion() {} // Use the following switch statement to find the correct variant // -// switch variant := ScoringFnParamsUnionResp.AsAny().(type) { -// case llamastackclient.ScoringFnParamsLlmAsJudgeResp: -// case llamastackclient.ScoringFnParamsRegexParserResp: -// case llamastackclient.ScoringFnParamsBasicResp: +// switch variant := ScoringFnParamsUnion.AsAny().(type) { +// case llamastackclient.ScoringFnParamsLlmAsJudge: +// case llamastackclient.ScoringFnParamsRegexParser: +// case llamastackclient.ScoringFnParamsBasic: // default: // fmt.Errorf("no variant present") // } -func (u ScoringFnParamsUnionResp) AsAny() anyScoringFnParamsResp { +func (u ScoringFnParamsUnion) AsAny() anyScoringFnParams { switch u.Type { case "llm_as_judge": return u.AsLlmAsJudge() @@ -260,79 +226,68 @@ func (u ScoringFnParamsUnionResp) AsAny() anyScoringFnParamsResp { return nil } -func (u ScoringFnParamsUnionResp) AsLlmAsJudge() (v ScoringFnParamsLlmAsJudgeResp) { +func (u ScoringFnParamsUnion) AsLlmAsJudge() (v ScoringFnParamsLlmAsJudge) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ScoringFnParamsUnionResp) AsRegexParser() (v ScoringFnParamsRegexParserResp) { +func (u ScoringFnParamsUnion) AsRegexParser() (v ScoringFnParamsRegexParser) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ScoringFnParamsUnionResp) AsBasic() (v ScoringFnParamsBasicResp) { +func (u ScoringFnParamsUnion) AsBasic() (v ScoringFnParamsBasic) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ScoringFnParamsUnionResp) RawJSON() string { return u.JSON.raw } +func (u ScoringFnParamsUnion) RawJSON() string { return u.JSON.raw } -func (r *ScoringFnParamsUnionResp) UnmarshalJSON(data []byte) error { +func (r *ScoringFnParamsUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ToParam converts this ScoringFnParamsUnionResp to a ScoringFnParamsUnion. -// -// Warning: the fields of the param type will not be present. ToParam should only -// be used at the last possible moment before sending a request. Test for this with -// ScoringFnParamsUnion.Overrides() -func (r ScoringFnParamsUnionResp) ToParam() ScoringFnParamsUnion { - return param.Override[ScoringFnParamsUnion](json.RawMessage(r.RawJSON())) -} - // Parameters for LLM-as-judge scoring function configuration. -type ScoringFnParamsLlmAsJudgeResp struct { +type ScoringFnParamsLlmAsJudge struct { + JudgeModel string `json:"judge_model,required"` // Aggregation functions to apply to the scores of each row // // Any of "average", "weighted_average", "median", "categorical_count", "accuracy". - AggregationFunctions []string `json:"aggregation_functions,required"` - // Identifier of the LLM model to use as a judge for scoring - JudgeModel string `json:"judge_model,required"` + AggregationFunctions []string `json:"aggregation_functions"` // Regexes to extract the answer from generated response - JudgeScoreRegexes []string `json:"judge_score_regexes,required"` - // The type of scoring function parameters, always llm_as_judge - Type constant.LlmAsJudge `json:"type,required"` - // (Optional) Custom prompt template for the judge model - PromptTemplate string `json:"prompt_template"` + JudgeScoreRegexes []string `json:"judge_score_regexes"` + PromptTemplate string `json:"prompt_template,nullable"` + // Any of "llm_as_judge". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - AggregationFunctions respjson.Field JudgeModel respjson.Field + AggregationFunctions respjson.Field JudgeScoreRegexes respjson.Field - Type respjson.Field PromptTemplate respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ScoringFnParamsLlmAsJudgeResp) RawJSON() string { return r.JSON.raw } -func (r *ScoringFnParamsLlmAsJudgeResp) UnmarshalJSON(data []byte) error { +func (r ScoringFnParamsLlmAsJudge) RawJSON() string { return r.JSON.raw } +func (r *ScoringFnParamsLlmAsJudge) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Parameters for regex parser scoring function configuration. -type ScoringFnParamsRegexParserResp struct { +type ScoringFnParamsRegexParser struct { // Aggregation functions to apply to the scores of each row // // Any of "average", "weighted_average", "median", "categorical_count", "accuracy". - AggregationFunctions []string `json:"aggregation_functions,required"` + AggregationFunctions []string `json:"aggregation_functions"` // Regex to extract the answer from generated response - ParsingRegexes []string `json:"parsing_regexes,required"` - // The type of scoring function parameters, always regex_parser - Type constant.RegexParser `json:"type,required"` + ParsingRegexes []string `json:"parsing_regexes"` + // Any of "regex_parser". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { AggregationFunctions respjson.Field @@ -344,19 +299,19 @@ type ScoringFnParamsRegexParserResp struct { } // Returns the unmodified JSON received from the API -func (r ScoringFnParamsRegexParserResp) RawJSON() string { return r.JSON.raw } -func (r *ScoringFnParamsRegexParserResp) UnmarshalJSON(data []byte) error { +func (r ScoringFnParamsRegexParser) RawJSON() string { return r.JSON.raw } +func (r *ScoringFnParamsRegexParser) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Parameters for basic scoring function configuration. -type ScoringFnParamsBasicResp struct { +type ScoringFnParamsBasic struct { // Aggregation functions to apply to the scores of each row // // Any of "average", "weighted_average", "median", "categorical_count", "accuracy". - AggregationFunctions []string `json:"aggregation_functions,required"` - // The type of scoring function parameters, always basic - Type constant.Basic `json:"type,required"` + AggregationFunctions []string `json:"aggregation_functions"` + // Any of "basic". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { AggregationFunctions respjson.Field @@ -367,217 +322,24 @@ type ScoringFnParamsBasicResp struct { } // Returns the unmodified JSON received from the API -func (r ScoringFnParamsBasicResp) RawJSON() string { return r.JSON.raw } -func (r *ScoringFnParamsBasicResp) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -func ScoringFnParamsOfLlmAsJudge(aggregationFunctions []string, judgeModel string, judgeScoreRegexes []string) ScoringFnParamsUnion { - var llmAsJudge ScoringFnParamsLlmAsJudge - llmAsJudge.AggregationFunctions = aggregationFunctions - llmAsJudge.JudgeModel = judgeModel - llmAsJudge.JudgeScoreRegexes = judgeScoreRegexes - return ScoringFnParamsUnion{OfLlmAsJudge: &llmAsJudge} -} - -func ScoringFnParamsOfRegexParser(aggregationFunctions []string, parsingRegexes []string) ScoringFnParamsUnion { - var regexParser ScoringFnParamsRegexParser - regexParser.AggregationFunctions = aggregationFunctions - regexParser.ParsingRegexes = parsingRegexes - return ScoringFnParamsUnion{OfRegexParser: ®exParser} -} - -func ScoringFnParamsOfBasic(aggregationFunctions []string) ScoringFnParamsUnion { - var basic ScoringFnParamsBasic - basic.AggregationFunctions = aggregationFunctions - return ScoringFnParamsUnion{OfBasic: &basic} -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ScoringFnParamsUnion struct { - OfLlmAsJudge *ScoringFnParamsLlmAsJudge `json:",omitzero,inline"` - OfRegexParser *ScoringFnParamsRegexParser `json:",omitzero,inline"` - OfBasic *ScoringFnParamsBasic `json:",omitzero,inline"` - paramUnion -} - -func (u ScoringFnParamsUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfLlmAsJudge, u.OfRegexParser, u.OfBasic) -} -func (u *ScoringFnParamsUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ScoringFnParamsUnion) asAny() any { - if !param.IsOmitted(u.OfLlmAsJudge) { - return u.OfLlmAsJudge - } else if !param.IsOmitted(u.OfRegexParser) { - return u.OfRegexParser - } else if !param.IsOmitted(u.OfBasic) { - return u.OfBasic - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u ScoringFnParamsUnion) GetJudgeModel() *string { - if vt := u.OfLlmAsJudge; vt != nil { - return &vt.JudgeModel - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u ScoringFnParamsUnion) GetJudgeScoreRegexes() []string { - if vt := u.OfLlmAsJudge; vt != nil { - return vt.JudgeScoreRegexes - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u ScoringFnParamsUnion) GetPromptTemplate() *string { - if vt := u.OfLlmAsJudge; vt != nil && vt.PromptTemplate.Valid() { - return &vt.PromptTemplate.Value - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u ScoringFnParamsUnion) GetParsingRegexes() []string { - if vt := u.OfRegexParser; vt != nil { - return vt.ParsingRegexes - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u ScoringFnParamsUnion) GetType() *string { - if vt := u.OfLlmAsJudge; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfRegexParser; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfBasic; vt != nil { - return (*string)(&vt.Type) - } - return nil -} - -// Returns a pointer to the underlying variant's AggregationFunctions property, if -// present. -func (u ScoringFnParamsUnion) GetAggregationFunctions() []string { - if vt := u.OfLlmAsJudge; vt != nil { - return vt.AggregationFunctions - } else if vt := u.OfRegexParser; vt != nil { - return vt.AggregationFunctions - } else if vt := u.OfBasic; vt != nil { - return vt.AggregationFunctions - } - return nil -} - -func init() { - apijson.RegisterUnion[ScoringFnParamsUnion]( - "type", - apijson.Discriminator[ScoringFnParamsLlmAsJudge]("llm_as_judge"), - apijson.Discriminator[ScoringFnParamsRegexParser]("regex_parser"), - apijson.Discriminator[ScoringFnParamsBasic]("basic"), - ) -} - -// Parameters for LLM-as-judge scoring function configuration. -// -// The properties AggregationFunctions, JudgeModel, JudgeScoreRegexes, Type are -// required. -type ScoringFnParamsLlmAsJudge struct { - // Aggregation functions to apply to the scores of each row - // - // Any of "average", "weighted_average", "median", "categorical_count", "accuracy". - AggregationFunctions []string `json:"aggregation_functions,omitzero,required"` - // Identifier of the LLM model to use as a judge for scoring - JudgeModel string `json:"judge_model,required"` - // Regexes to extract the answer from generated response - JudgeScoreRegexes []string `json:"judge_score_regexes,omitzero,required"` - // (Optional) Custom prompt template for the judge model - PromptTemplate param.Opt[string] `json:"prompt_template,omitzero"` - // The type of scoring function parameters, always llm_as_judge - // - // This field can be elided, and will marshal its zero value as "llm_as_judge". - Type constant.LlmAsJudge `json:"type,required"` - paramObj -} - -func (r ScoringFnParamsLlmAsJudge) MarshalJSON() (data []byte, err error) { - type shadow ScoringFnParamsLlmAsJudge - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *ScoringFnParamsLlmAsJudge) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Parameters for regex parser scoring function configuration. -// -// The properties AggregationFunctions, ParsingRegexes, Type are required. -type ScoringFnParamsRegexParser struct { - // Aggregation functions to apply to the scores of each row - // - // Any of "average", "weighted_average", "median", "categorical_count", "accuracy". - AggregationFunctions []string `json:"aggregation_functions,omitzero,required"` - // Regex to extract the answer from generated response - ParsingRegexes []string `json:"parsing_regexes,omitzero,required"` - // The type of scoring function parameters, always regex_parser - // - // This field can be elided, and will marshal its zero value as "regex_parser". - Type constant.RegexParser `json:"type,required"` - paramObj -} - -func (r ScoringFnParamsRegexParser) MarshalJSON() (data []byte, err error) { - type shadow ScoringFnParamsRegexParser - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *ScoringFnParamsRegexParser) UnmarshalJSON(data []byte) error { +func (r ScoringFnParamsBasic) RawJSON() string { return r.JSON.raw } +func (r *ScoringFnParamsBasic) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Parameters for basic scoring function configuration. -// -// The properties AggregationFunctions, Type are required. -type ScoringFnParamsBasic struct { - // Aggregation functions to apply to the scores of each row - // - // Any of "average", "weighted_average", "median", "categorical_count", "accuracy". - AggregationFunctions []string `json:"aggregation_functions,omitzero,required"` - // The type of scoring function parameters, always basic - // - // This field can be elided, and will marshal its zero value as "basic". - Type constant.Basic `json:"type,required"` - paramObj -} +type ScoringFnType string -func (r ScoringFnParamsBasic) MarshalJSON() (data []byte, err error) { - type shadow ScoringFnParamsBasic - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *ScoringFnParamsBasic) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} +const ( + ScoringFnTypeScoringFunction ScoringFnType = "scoring_function" +) type ScoringFunctionRegisterParams struct { - // The description of the scoring function. - Description string `json:"description,required"` - ReturnType ScoringFunctionRegisterParamsReturnType `json:"return_type,omitzero,required"` - // The ID of the scoring function to register. - ScoringFnID string `json:"scoring_fn_id,required"` - // The ID of the provider to use for the scoring function. - ProviderID param.Opt[string] `json:"provider_id,omitzero"` - // The ID of the provider scoring function to use for the scoring function. - ProviderScoringFnID param.Opt[string] `json:"provider_scoring_fn_id,omitzero"` - // The parameters for the scoring function for benchmark eval, these can be - // overridden for app eval. - Params ScoringFnParamsUnion `json:"params,omitzero"` + Description any `json:"description,omitzero,required"` + ReturnType any `json:"return_type,omitzero,required"` + ScoringFnID any `json:"scoring_fn_id,omitzero,required"` + Params any `json:"params,omitzero"` + ProviderID any `json:"provider_id,omitzero"` + ProviderScoringFnID any `json:"provider_scoring_fn_id,omitzero"` paramObj } @@ -588,25 +350,3 @@ func (r ScoringFunctionRegisterParams) MarshalJSON() (data []byte, err error) { func (r *ScoringFunctionRegisterParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } - -// The property Type is required. -type ScoringFunctionRegisterParamsReturnType struct { - // Any of "string", "number", "boolean", "array", "object", "json", "union", - // "chat_completion_input", "completion_input", "agent_turn_input". - Type string `json:"type,omitzero,required"` - paramObj -} - -func (r ScoringFunctionRegisterParamsReturnType) MarshalJSON() (data []byte, err error) { - type shadow ScoringFunctionRegisterParamsReturnType - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *ScoringFunctionRegisterParamsReturnType) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -func init() { - apijson.RegisterFieldValidator[ScoringFunctionRegisterParamsReturnType]( - "type", "string", "number", "boolean", "array", "object", "json", "union", "chat_completion_input", "completion_input", "agent_turn_input", - ) -} diff --git a/scoringfunction_test.go b/scoringfunction_test.go index f661c97..cde50ce 100644 --- a/scoringfunction_test.go +++ b/scoringfunction_test.go @@ -73,21 +73,12 @@ func TestScoringFunctionRegisterWithOptionalParams(t *testing.T) { option.WithBaseURL(baseURL), ) err := client.ScoringFunctions.Register(context.TODO(), llamastackclient.ScoringFunctionRegisterParams{ - Description: "description", - ReturnType: llamastackclient.ScoringFunctionRegisterParamsReturnType{ - Type: "string", - }, - ScoringFnID: "scoring_fn_id", - Params: llamastackclient.ScoringFnParamsUnion{ - OfLlmAsJudge: &llamastackclient.ScoringFnParamsLlmAsJudge{ - AggregationFunctions: []string{"average"}, - JudgeModel: "judge_model", - JudgeScoreRegexes: []string{"string"}, - PromptTemplate: llamastackclient.String("prompt_template"), - }, - }, - ProviderID: llamastackclient.String("provider_id"), - ProviderScoringFnID: llamastackclient.String("provider_scoring_fn_id"), + Description: map[string]interface{}{}, + ReturnType: map[string]interface{}{}, + ScoringFnID: map[string]interface{}{}, + Params: map[string]interface{}{}, + ProviderID: map[string]interface{}{}, + ProviderScoringFnID: map[string]interface{}{}, }) if err != nil { var apierr *llamastackclient.Error @@ -97,3 +88,24 @@ func TestScoringFunctionRegisterWithOptionalParams(t *testing.T) { t.Fatalf("err should be nil: %s", err.Error()) } } + +func TestScoringFunctionUnregister(t *testing.T) { + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := llamastackclient.NewClient( + option.WithBaseURL(baseURL), + ) + err := client.ScoringFunctions.Unregister(context.TODO(), "scoring_fn_id") + if err != nil { + var apierr *llamastackclient.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} diff --git a/shared.go b/shared.go index 6f5db9e..3409fdd 100644 --- a/shared.go +++ b/shared.go @@ -9,1020 +9,532 @@ package llamastackclient import ( - "encoding/json" - "github.com/llamastack/llama-stack-client-go/internal/apijson" "github.com/llamastack/llama-stack-client-go/packages/param" "github.com/llamastack/llama-stack-client-go/packages/respjson" - "github.com/llamastack/llama-stack-client-go/shared/constant" ) -// InterleavedContentUnion contains all possible properties and values from -// [string], [InterleavedContentImageContentItem], -// [InterleavedContentTextContentItem], [[]InterleavedContentItemUnion]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfString OfInterleavedContentItemArray] -type InterleavedContentUnion struct { - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]InterleavedContentItemUnion] - // instead of an object. - OfInterleavedContentItemArray []InterleavedContentItemUnion `json:",inline"` - // This field is from variant [InterleavedContentImageContentItem]. - Image InterleavedContentImageContentItemImage `json:"image"` - Type string `json:"type"` - // This field is from variant [InterleavedContentTextContentItem]. - Text string `json:"text"` - JSON struct { - OfString respjson.Field - OfInterleavedContentItemArray respjson.Field - Image respjson.Field - Type respjson.Field - Text respjson.Field - raw string - } `json:"-"` -} - -func (u InterleavedContentUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} +// aliased to make [param.APIUnion] private when embedding +type paramUnion = param.APIUnion -func (u InterleavedContentUnion) AsImageContentItem() (v InterleavedContentImageContentItem) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u InterleavedContentUnion) AsTextContentItem() (v InterleavedContentTextContentItem) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u InterleavedContentUnion) AsInterleavedContentItemArray() (v []InterleavedContentItemUnion) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u InterleavedContentUnion) RawJSON() string { return u.JSON.raw } +// aliased to make [param.APIObject] private when embedding +type paramObj = param.APIObject -func (r *InterleavedContentUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ToParam converts this InterleavedContentUnion to a InterleavedContentUnionParam. -// -// Warning: the fields of the param type will not be present. ToParam should only -// be used at the last possible moment before sending a request. Test for this with -// InterleavedContentUnionParam.Overrides() -func (r InterleavedContentUnion) ToParam() InterleavedContentUnionParam { - return param.Override[InterleavedContentUnionParam](json.RawMessage(r.RawJSON())) -} - -// A image content item -type InterleavedContentImageContentItem struct { - // Image as a base64 encoded string or an URL - Image InterleavedContentImageContentItemImage `json:"image,required"` - // Discriminator type of the content item. Always "image" - Type constant.Image `json:"type,required"` +// Details of a safety violation detected by content moderation. +type SafetyViolation struct { + // Severity level of a safety violation. + // + // Any of "info", "warn", "error". + ViolationLevel SafetyViolationViolationLevel `json:"violation_level,required"` + Metadata map[string]any `json:"metadata"` + UserMessage string `json:"user_message,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Image respjson.Field - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string + ViolationLevel respjson.Field + Metadata respjson.Field + UserMessage respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r InterleavedContentImageContentItem) RawJSON() string { return r.JSON.raw } -func (r *InterleavedContentImageContentItem) UnmarshalJSON(data []byte) error { +func (r SafetyViolation) RawJSON() string { return r.JSON.raw } +func (r *SafetyViolation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Image as a base64 encoded string or an URL -type InterleavedContentImageContentItemImage struct { - // base64 encoded image data as string - Data string `json:"data"` - // A URL of the image or data URL in the format of data:image/{type};base64,{data}. - // Note that URL could have length limits. - URL InterleavedContentImageContentItemImageURL `json:"url"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Data respjson.Field - URL respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r InterleavedContentImageContentItemImage) RawJSON() string { return r.JSON.raw } -func (r *InterleavedContentImageContentItemImage) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} +// Severity level of a safety violation. +type SafetyViolationViolationLevel string -// A URL of the image or data URL in the format of data:image/{type};base64,{data}. -// Note that URL could have length limits. -type InterleavedContentImageContentItemImageURL struct { - // The URL string pointing to the resource - Uri string `json:"uri,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Uri respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} +const ( + SafetyViolationViolationLevelInfo SafetyViolationViolationLevel = "info" + SafetyViolationViolationLevelWarn SafetyViolationViolationLevel = "warn" + SafetyViolationViolationLevelError SafetyViolationViolationLevel = "error" +) -// Returns the unmodified JSON received from the API -func (r InterleavedContentImageContentItemImageURL) RawJSON() string { return r.JSON.raw } -func (r *InterleavedContentImageContentItemImageURL) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) +// Sampling parameters. +type SamplingParams struct { + MaxTokens param.Opt[int64] `json:"max_tokens,omitzero"` + RepetitionPenalty param.Opt[float64] `json:"repetition_penalty,omitzero"` + Stop []string `json:"stop,omitzero"` + // Greedy sampling strategy that selects the highest probability token at each + // step. + Strategy SamplingParamsStrategyUnion `json:"strategy,omitzero"` + paramObj } -// A text content item -type InterleavedContentTextContentItem struct { - // Text content - Text string `json:"text,required"` - // Discriminator type of the content item. Always "text" - Type constant.Text `json:"type,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Text respjson.Field - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` +func (r SamplingParams) MarshalJSON() (data []byte, err error) { + type shadow SamplingParams + return param.MarshalObject(r, (*shadow)(&r)) } - -// Returns the unmodified JSON received from the API -func (r InterleavedContentTextContentItem) RawJSON() string { return r.JSON.raw } -func (r *InterleavedContentTextContentItem) UnmarshalJSON(data []byte) error { +func (r *SamplingParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -func InterleavedContentParamOfImageContentItem(image InterleavedContentImageContentItemImageParam) InterleavedContentUnionParam { - var variant InterleavedContentImageContentItemParam - variant.Image = image - return InterleavedContentUnionParam{OfImageContentItem: &variant} -} - -func InterleavedContentParamOfTextContentItem(text string) InterleavedContentUnionParam { - var variant InterleavedContentTextContentItemParam - variant.Text = text - return InterleavedContentUnionParam{OfTextContentItem: &variant} -} - // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. -type InterleavedContentUnionParam struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfImageContentItem *InterleavedContentImageContentItemParam `json:",omitzero,inline"` - OfTextContentItem *InterleavedContentTextContentItemParam `json:",omitzero,inline"` - OfInterleavedContentItemArray []InterleavedContentItemUnionParam `json:",omitzero,inline"` +type SamplingParamsStrategyUnion struct { + OfGreedy *SamplingParamsStrategyGreedy `json:",omitzero,inline"` + OfTopP *SamplingParamsStrategyTopP `json:",omitzero,inline"` + OfTopK *SamplingParamsStrategyTopK `json:",omitzero,inline"` paramUnion } -func (u InterleavedContentUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfImageContentItem, u.OfTextContentItem, u.OfInterleavedContentItemArray) +func (u SamplingParamsStrategyUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfGreedy, u.OfTopP, u.OfTopK) } -func (u *InterleavedContentUnionParam) UnmarshalJSON(data []byte) error { +func (u *SamplingParamsStrategyUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *InterleavedContentUnionParam) asAny() any { - if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfImageContentItem) { - return u.OfImageContentItem - } else if !param.IsOmitted(u.OfTextContentItem) { - return u.OfTextContentItem - } else if !param.IsOmitted(u.OfInterleavedContentItemArray) { - return &u.OfInterleavedContentItemArray +func (u *SamplingParamsStrategyUnion) asAny() any { + if !param.IsOmitted(u.OfGreedy) { + return u.OfGreedy + } else if !param.IsOmitted(u.OfTopP) { + return u.OfTopP + } else if !param.IsOmitted(u.OfTopK) { + return u.OfTopK } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u InterleavedContentUnionParam) GetImage() *InterleavedContentImageContentItemImageParam { - if vt := u.OfImageContentItem; vt != nil { - return &vt.Image +func (u SamplingParamsStrategyUnion) GetTemperature() *float64 { + if vt := u.OfTopP; vt != nil && vt.Temperature.Valid() { + return &vt.Temperature.Value } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u InterleavedContentUnionParam) GetText() *string { - if vt := u.OfTextContentItem; vt != nil { - return &vt.Text +func (u SamplingParamsStrategyUnion) GetTopP() *float64 { + if vt := u.OfTopP; vt != nil && vt.TopP.Valid() { + return &vt.TopP.Value } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u InterleavedContentUnionParam) GetType() *string { - if vt := u.OfImageContentItem; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfTextContentItem; vt != nil { - return (*string)(&vt.Type) +func (u SamplingParamsStrategyUnion) GetTopK() *int64 { + if vt := u.OfTopK; vt != nil { + return &vt.TopK } return nil } -// A image content item -// -// The properties Image, Type are required. -type InterleavedContentImageContentItemParam struct { - // Image as a base64 encoded string or an URL - Image InterleavedContentImageContentItemImageParam `json:"image,omitzero,required"` - // Discriminator type of the content item. Always "image" - // - // This field can be elided, and will marshal its zero value as "image". - Type constant.Image `json:"type,required"` - paramObj +// Returns a pointer to the underlying variant's property, if present. +func (u SamplingParamsStrategyUnion) GetType() *string { + if vt := u.OfGreedy; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfTopP; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfTopK; vt != nil { + return (*string)(&vt.Type) + } + return nil } -func (r InterleavedContentImageContentItemParam) MarshalJSON() (data []byte, err error) { - type shadow InterleavedContentImageContentItemParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *InterleavedContentImageContentItemParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) +func init() { + apijson.RegisterUnion[SamplingParamsStrategyUnion]( + "type", + apijson.Discriminator[SamplingParamsStrategyGreedy]("greedy"), + apijson.Discriminator[SamplingParamsStrategyTopP]("top_p"), + apijson.Discriminator[SamplingParamsStrategyTopK]("top_k"), + ) } -// Image as a base64 encoded string or an URL -type InterleavedContentImageContentItemImageParam struct { - // base64 encoded image data as string - Data param.Opt[string] `json:"data,omitzero"` - // A URL of the image or data URL in the format of data:image/{type};base64,{data}. - // Note that URL could have length limits. - URL InterleavedContentImageContentItemImageURLParam `json:"url,omitzero"` +// Greedy sampling strategy that selects the highest probability token at each +// step. +type SamplingParamsStrategyGreedy struct { + // Any of "greedy". + Type string `json:"type,omitzero"` paramObj } -func (r InterleavedContentImageContentItemImageParam) MarshalJSON() (data []byte, err error) { - type shadow InterleavedContentImageContentItemImageParam +func (r SamplingParamsStrategyGreedy) MarshalJSON() (data []byte, err error) { + type shadow SamplingParamsStrategyGreedy return param.MarshalObject(r, (*shadow)(&r)) } -func (r *InterleavedContentImageContentItemImageParam) UnmarshalJSON(data []byte) error { +func (r *SamplingParamsStrategyGreedy) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// A URL of the image or data URL in the format of data:image/{type};base64,{data}. -// Note that URL could have length limits. -// -// The property Uri is required. -type InterleavedContentImageContentItemImageURLParam struct { - // The URL string pointing to the resource - Uri string `json:"uri,required"` - paramObj -} - -func (r InterleavedContentImageContentItemImageURLParam) MarshalJSON() (data []byte, err error) { - type shadow InterleavedContentImageContentItemImageURLParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *InterleavedContentImageContentItemImageURLParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) +func init() { + apijson.RegisterFieldValidator[SamplingParamsStrategyGreedy]( + "type", "greedy", + ) } -// A text content item +// Top-p (nucleus) sampling strategy that samples from the smallest set of tokens +// with cumulative probability >= p. // -// The properties Text, Type are required. -type InterleavedContentTextContentItemParam struct { - // Text content - Text string `json:"text,required"` - // Discriminator type of the content item. Always "text" - // - // This field can be elided, and will marshal its zero value as "text". - Type constant.Text `json:"type,required"` +// The property Temperature is required. +type SamplingParamsStrategyTopP struct { + Temperature param.Opt[float64] `json:"temperature,omitzero,required"` + TopP param.Opt[float64] `json:"top_p,omitzero"` + // Any of "top_p". + Type string `json:"type,omitzero"` paramObj } -func (r InterleavedContentTextContentItemParam) MarshalJSON() (data []byte, err error) { - type shadow InterleavedContentTextContentItemParam +func (r SamplingParamsStrategyTopP) MarshalJSON() (data []byte, err error) { + type shadow SamplingParamsStrategyTopP return param.MarshalObject(r, (*shadow)(&r)) } -func (r *InterleavedContentTextContentItemParam) UnmarshalJSON(data []byte) error { +func (r *SamplingParamsStrategyTopP) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// InterleavedContentItemUnion contains all possible properties and values from -// [InterleavedContentItemImage], [InterleavedContentItemText]. -// -// Use the [InterleavedContentItemUnion.AsAny] method to switch on the variant. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -type InterleavedContentItemUnion struct { - // This field is from variant [InterleavedContentItemImage]. - Image InterleavedContentItemImageImage `json:"image"` - // Any of "image", "text". - Type string `json:"type"` - // This field is from variant [InterleavedContentItemText]. - Text string `json:"text"` - JSON struct { - Image respjson.Field - Type respjson.Field - Text respjson.Field - raw string - } `json:"-"` -} - -// anyInterleavedContentItem is implemented by each variant of -// [InterleavedContentItemUnion] to add type safety for the return type of -// [InterleavedContentItemUnion.AsAny] -type anyInterleavedContentItem interface { - implInterleavedContentItemUnion() +func init() { + apijson.RegisterFieldValidator[SamplingParamsStrategyTopP]( + "type", "top_p", + ) } -// Use the following switch statement to find the correct variant +// Top-k sampling strategy that restricts sampling to the k most likely tokens. // -// switch variant := InterleavedContentItemUnion.AsAny().(type) { -// case llamastackclient.InterleavedContentItemImage: -// case llamastackclient.InterleavedContentItemText: -// default: -// fmt.Errorf("no variant present") -// } -func (u InterleavedContentItemUnion) AsAny() anyInterleavedContentItem { - switch u.Type { - case "image": - return u.AsImage() - case "text": - return u.AsText() - } - return nil -} - -func (u InterleavedContentItemUnion) AsImage() (v InterleavedContentItemImage) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// The property TopK is required. +type SamplingParamsStrategyTopK struct { + TopK int64 `json:"top_k,required"` + // Any of "top_k". + Type string `json:"type,omitzero"` + paramObj } -func (u InterleavedContentItemUnion) AsText() (v InterleavedContentItemText) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +func (r SamplingParamsStrategyTopK) MarshalJSON() (data []byte, err error) { + type shadow SamplingParamsStrategyTopK + return param.MarshalObject(r, (*shadow)(&r)) } - -// Returns the unmodified JSON received from the API -func (u InterleavedContentItemUnion) RawJSON() string { return u.JSON.raw } - -func (r *InterleavedContentItemUnion) UnmarshalJSON(data []byte) error { +func (r *SamplingParamsStrategyTopK) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ToParam converts this InterleavedContentItemUnion to a -// InterleavedContentItemUnionParam. -// -// Warning: the fields of the param type will not be present. ToParam should only -// be used at the last possible moment before sending a request. Test for this with -// InterleavedContentItemUnionParam.Overrides() -func (r InterleavedContentItemUnion) ToParam() InterleavedContentItemUnionParam { - return param.Override[InterleavedContentItemUnionParam](json.RawMessage(r.RawJSON())) -} - -// A image content item -type InterleavedContentItemImage struct { - // Image as a base64 encoded string or an URL - Image InterleavedContentItemImageImage `json:"image,required"` - // Discriminator type of the content item. Always "image" - Type constant.Image `json:"type,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Image respjson.Field - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r InterleavedContentItemImage) RawJSON() string { return r.JSON.raw } -func (r *InterleavedContentItemImage) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) +func init() { + apijson.RegisterFieldValidator[SamplingParamsStrategyTopK]( + "type", "top_k", + ) } -func (InterleavedContentItemImage) implInterleavedContentItemUnion() {} - -// Image as a base64 encoded string or an URL -type InterleavedContentItemImageImage struct { - // base64 encoded image data as string - Data string `json:"data"` - // A URL of the image or data URL in the format of data:image/{type};base64,{data}. - // Note that URL could have length limits. - URL InterleavedContentItemImageImageURL `json:"url"` +// A scoring result for a single row. +type ScoringResult struct { + AggregatedResults map[string]any `json:"aggregated_results,required"` + ScoreRows []map[string]any `json:"score_rows,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Data respjson.Field - URL respjson.Field - ExtraFields map[string]respjson.Field - raw string + AggregatedResults respjson.Field + ScoreRows respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r InterleavedContentItemImageImage) RawJSON() string { return r.JSON.raw } -func (r *InterleavedContentItemImageImage) UnmarshalJSON(data []byte) error { +func (r ScoringResult) RawJSON() string { return r.JSON.raw } +func (r *ScoringResult) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// A URL of the image or data URL in the format of data:image/{type};base64,{data}. -// Note that URL could have length limits. -type InterleavedContentItemImageImageURL struct { - // The URL string pointing to the resource - Uri string `json:"uri,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Uri respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r InterleavedContentItemImageImageURL) RawJSON() string { return r.JSON.raw } -func (r *InterleavedContentItemImageImageURL) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) +// A system message providing instructions or context to the model. +// +// The property Content is required. +type SystemMessageParam struct { + // A image content item + Content SystemMessageContentUnionParam `json:"content,omitzero,required"` + // Any of "system". + Role SystemMessageRole `json:"role,omitzero"` + paramObj } -// A text content item -type InterleavedContentItemText struct { - // Text content - Text string `json:"text,required"` - // Discriminator type of the content item. Always "text" - Type constant.Text `json:"type,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Text respjson.Field - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` +func (r SystemMessageParam) MarshalJSON() (data []byte, err error) { + type shadow SystemMessageParam + return param.MarshalObject(r, (*shadow)(&r)) } - -// Returns the unmodified JSON received from the API -func (r InterleavedContentItemText) RawJSON() string { return r.JSON.raw } -func (r *InterleavedContentItemText) UnmarshalJSON(data []byte) error { +func (r *SystemMessageParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -func (InterleavedContentItemText) implInterleavedContentItemUnion() {} - -func InterleavedContentItemParamOfImage(image InterleavedContentItemImageImageParam) InterleavedContentItemUnionParam { - var variant InterleavedContentItemImageParam - variant.Image = image - return InterleavedContentItemUnionParam{OfImage: &variant} -} - -func InterleavedContentItemParamOfText(text string) InterleavedContentItemUnionParam { - var variant InterleavedContentItemTextParam - variant.Text = text - return InterleavedContentItemUnionParam{OfText: &variant} -} - // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. -type InterleavedContentItemUnionParam struct { - OfImage *InterleavedContentItemImageParam `json:",omitzero,inline"` - OfText *InterleavedContentItemTextParam `json:",omitzero,inline"` +type SystemMessageContentUnionParam struct { + OfString param.Opt[string] `json:",omitzero,inline"` + OfImageContentItemInput *SystemMessageContentImageContentItemInputParam `json:",omitzero,inline"` + OfTextContentItem *SystemMessageContentTextContentItemParam `json:",omitzero,inline"` + OfListImageContentItemInputTextContentItem []SystemMessageContentListImageContentItemInputTextContentItemItemUnionParam `json:",omitzero,inline"` paramUnion } -func (u InterleavedContentItemUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfImage, u.OfText) +func (u SystemMessageContentUnionParam) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfString, u.OfImageContentItemInput, u.OfTextContentItem, u.OfListImageContentItemInputTextContentItem) } -func (u *InterleavedContentItemUnionParam) UnmarshalJSON(data []byte) error { +func (u *SystemMessageContentUnionParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *InterleavedContentItemUnionParam) asAny() any { - if !param.IsOmitted(u.OfImage) { - return u.OfImage - } else if !param.IsOmitted(u.OfText) { - return u.OfText +func (u *SystemMessageContentUnionParam) asAny() any { + if !param.IsOmitted(u.OfString) { + return &u.OfString.Value + } else if !param.IsOmitted(u.OfImageContentItemInput) { + return u.OfImageContentItemInput + } else if !param.IsOmitted(u.OfTextContentItem) { + return u.OfTextContentItem + } else if !param.IsOmitted(u.OfListImageContentItemInputTextContentItem) { + return &u.OfListImageContentItemInputTextContentItem } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u InterleavedContentItemUnionParam) GetImage() *InterleavedContentItemImageImageParam { - if vt := u.OfImage; vt != nil { +func (u SystemMessageContentUnionParam) GetImage() *SystemMessageContentImageContentItemInputImageParam { + if vt := u.OfImageContentItemInput; vt != nil { return &vt.Image } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u InterleavedContentItemUnionParam) GetText() *string { - if vt := u.OfText; vt != nil { +func (u SystemMessageContentUnionParam) GetText() *string { + if vt := u.OfTextContentItem; vt != nil { return &vt.Text } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u InterleavedContentItemUnionParam) GetType() *string { - if vt := u.OfImage; vt != nil { +func (u SystemMessageContentUnionParam) GetType() *string { + if vt := u.OfImageContentItemInput; vt != nil { return (*string)(&vt.Type) - } else if vt := u.OfText; vt != nil { + } else if vt := u.OfTextContentItem; vt != nil { return (*string)(&vt.Type) } return nil } -func init() { - apijson.RegisterUnion[InterleavedContentItemUnionParam]( - "type", - apijson.Discriminator[InterleavedContentItemImageParam]("image"), - apijson.Discriminator[InterleavedContentItemTextParam]("text"), - ) -} - // A image content item // -// The properties Image, Type are required. -type InterleavedContentItemImageParam struct { - // Image as a base64 encoded string or an URL - Image InterleavedContentItemImageImageParam `json:"image,omitzero,required"` - // Discriminator type of the content item. Always "image" - // - // This field can be elided, and will marshal its zero value as "image". - Type constant.Image `json:"type,required"` +// The property Image is required. +type SystemMessageContentImageContentItemInputParam struct { + // A URL or a base64 encoded string + Image SystemMessageContentImageContentItemInputImageParam `json:"image,omitzero,required"` + // Any of "image". + Type string `json:"type,omitzero"` paramObj } -func (r InterleavedContentItemImageParam) MarshalJSON() (data []byte, err error) { - type shadow InterleavedContentItemImageParam +func (r SystemMessageContentImageContentItemInputParam) MarshalJSON() (data []byte, err error) { + type shadow SystemMessageContentImageContentItemInputParam return param.MarshalObject(r, (*shadow)(&r)) } -func (r *InterleavedContentItemImageParam) UnmarshalJSON(data []byte) error { +func (r *SystemMessageContentImageContentItemInputParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Image as a base64 encoded string or an URL -type InterleavedContentItemImageImageParam struct { - // base64 encoded image data as string +func init() { + apijson.RegisterFieldValidator[SystemMessageContentImageContentItemInputParam]( + "type", "image", + ) +} + +// A URL or a base64 encoded string +type SystemMessageContentImageContentItemInputImageParam struct { Data param.Opt[string] `json:"data,omitzero"` - // A URL of the image or data URL in the format of data:image/{type};base64,{data}. - // Note that URL could have length limits. - URL InterleavedContentItemImageImageURLParam `json:"url,omitzero"` + // A URL reference to external content. + URL SystemMessageContentImageContentItemInputImageURLParam `json:"url,omitzero"` paramObj } -func (r InterleavedContentItemImageImageParam) MarshalJSON() (data []byte, err error) { - type shadow InterleavedContentItemImageImageParam +func (r SystemMessageContentImageContentItemInputImageParam) MarshalJSON() (data []byte, err error) { + type shadow SystemMessageContentImageContentItemInputImageParam return param.MarshalObject(r, (*shadow)(&r)) } -func (r *InterleavedContentItemImageImageParam) UnmarshalJSON(data []byte) error { +func (r *SystemMessageContentImageContentItemInputImageParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// A URL of the image or data URL in the format of data:image/{type};base64,{data}. -// Note that URL could have length limits. +// A URL reference to external content. // // The property Uri is required. -type InterleavedContentItemImageImageURLParam struct { - // The URL string pointing to the resource +type SystemMessageContentImageContentItemInputImageURLParam struct { Uri string `json:"uri,required"` paramObj } -func (r InterleavedContentItemImageImageURLParam) MarshalJSON() (data []byte, err error) { - type shadow InterleavedContentItemImageImageURLParam +func (r SystemMessageContentImageContentItemInputImageURLParam) MarshalJSON() (data []byte, err error) { + type shadow SystemMessageContentImageContentItemInputImageURLParam return param.MarshalObject(r, (*shadow)(&r)) } -func (r *InterleavedContentItemImageImageURLParam) UnmarshalJSON(data []byte) error { +func (r *SystemMessageContentImageContentItemInputImageURLParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A text content item // -// The properties Text, Type are required. -type InterleavedContentItemTextParam struct { - // Text content +// The property Text is required. +type SystemMessageContentTextContentItemParam struct { Text string `json:"text,required"` - // Discriminator type of the content item. Always "text" - // - // This field can be elided, and will marshal its zero value as "text". - Type constant.Text `json:"type,required"` + // Any of "text". + Type string `json:"type,omitzero"` paramObj } -func (r InterleavedContentItemTextParam) MarshalJSON() (data []byte, err error) { - type shadow InterleavedContentItemTextParam +func (r SystemMessageContentTextContentItemParam) MarshalJSON() (data []byte, err error) { + type shadow SystemMessageContentTextContentItemParam return param.MarshalObject(r, (*shadow)(&r)) } -func (r *InterleavedContentItemTextParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Details of a safety violation detected by content moderation. -type SafetyViolation struct { - // Additional metadata including specific violation codes for debugging and - // telemetry - Metadata map[string]SafetyViolationMetadataUnion `json:"metadata,required"` - // Severity level of the violation - // - // Any of "info", "warn", "error". - ViolationLevel SafetyViolationViolationLevel `json:"violation_level,required"` - // (Optional) Message to convey to the user about the violation - UserMessage string `json:"user_message"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Metadata respjson.Field - ViolationLevel respjson.Field - UserMessage respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r SafetyViolation) RawJSON() string { return r.JSON.raw } -func (r *SafetyViolation) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// SafetyViolationMetadataUnion contains all possible properties and values from -// [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type SafetyViolationMetadataUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u SafetyViolationMetadataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u SafetyViolationMetadataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u SafetyViolationMetadataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u SafetyViolationMetadataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u SafetyViolationMetadataUnion) RawJSON() string { return u.JSON.raw } - -func (r *SafetyViolationMetadataUnion) UnmarshalJSON(data []byte) error { +func (r *SystemMessageContentTextContentItemParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Severity level of the violation -type SafetyViolationViolationLevel string - -const ( - SafetyViolationViolationLevelInfo SafetyViolationViolationLevel = "info" - SafetyViolationViolationLevelWarn SafetyViolationViolationLevel = "warn" - SafetyViolationViolationLevelError SafetyViolationViolationLevel = "error" -) - -// Sampling parameters. -// -// The property Strategy is required. -type SamplingParams struct { - // The sampling strategy. - Strategy SamplingParamsStrategyUnion `json:"strategy,omitzero,required"` - // The maximum number of tokens that can be generated in the completion. The token - // count of your prompt plus max_tokens cannot exceed the model's context length. - MaxTokens param.Opt[int64] `json:"max_tokens,omitzero"` - // Number between -2.0 and 2.0. Positive values penalize new tokens based on - // whether they appear in the text so far, increasing the model's likelihood to - // talk about new topics. - RepetitionPenalty param.Opt[float64] `json:"repetition_penalty,omitzero"` - // Up to 4 sequences where the API will stop generating further tokens. The - // returned text will not contain the stop sequence. - Stop []string `json:"stop,omitzero"` - paramObj -} - -func (r SamplingParams) MarshalJSON() (data []byte, err error) { - type shadow SamplingParams - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *SamplingParams) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) +func init() { + apijson.RegisterFieldValidator[SystemMessageContentTextContentItemParam]( + "type", "text", + ) } // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. -type SamplingParamsStrategyUnion struct { - OfGreedy *SamplingParamsStrategyGreedy `json:",omitzero,inline"` - OfTopP *SamplingParamsStrategyTopP `json:",omitzero,inline"` - OfTopK *SamplingParamsStrategyTopK `json:",omitzero,inline"` +type SystemMessageContentListImageContentItemInputTextContentItemItemUnionParam struct { + OfImage *SystemMessageContentListImageContentItemInputTextContentItemItemImageParam `json:",omitzero,inline"` + OfText *SystemMessageContentListImageContentItemInputTextContentItemItemTextParam `json:",omitzero,inline"` paramUnion } -func (u SamplingParamsStrategyUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfGreedy, u.OfTopP, u.OfTopK) +func (u SystemMessageContentListImageContentItemInputTextContentItemItemUnionParam) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfImage, u.OfText) } -func (u *SamplingParamsStrategyUnion) UnmarshalJSON(data []byte) error { +func (u *SystemMessageContentListImageContentItemInputTextContentItemItemUnionParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *SamplingParamsStrategyUnion) asAny() any { - if !param.IsOmitted(u.OfGreedy) { - return u.OfGreedy - } else if !param.IsOmitted(u.OfTopP) { - return u.OfTopP - } else if !param.IsOmitted(u.OfTopK) { - return u.OfTopK - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u SamplingParamsStrategyUnion) GetTemperature() *float64 { - if vt := u.OfTopP; vt != nil && vt.Temperature.Valid() { - return &vt.Temperature.Value +func (u *SystemMessageContentListImageContentItemInputTextContentItemItemUnionParam) asAny() any { + if !param.IsOmitted(u.OfImage) { + return u.OfImage + } else if !param.IsOmitted(u.OfText) { + return u.OfText } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u SamplingParamsStrategyUnion) GetTopP() *float64 { - if vt := u.OfTopP; vt != nil && vt.TopP.Valid() { - return &vt.TopP.Value +func (u SystemMessageContentListImageContentItemInputTextContentItemItemUnionParam) GetImage() *SystemMessageContentListImageContentItemInputTextContentItemItemImageImageParam { + if vt := u.OfImage; vt != nil { + return &vt.Image } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u SamplingParamsStrategyUnion) GetTopK() *int64 { - if vt := u.OfTopK; vt != nil { - return &vt.TopK +func (u SystemMessageContentListImageContentItemInputTextContentItemItemUnionParam) GetText() *string { + if vt := u.OfText; vt != nil { + return &vt.Text } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u SamplingParamsStrategyUnion) GetType() *string { - if vt := u.OfGreedy; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfTopP; vt != nil { +func (u SystemMessageContentListImageContentItemInputTextContentItemItemUnionParam) GetType() *string { + if vt := u.OfImage; vt != nil { return (*string)(&vt.Type) - } else if vt := u.OfTopK; vt != nil { + } else if vt := u.OfText; vt != nil { return (*string)(&vt.Type) } return nil } func init() { - apijson.RegisterUnion[SamplingParamsStrategyUnion]( + apijson.RegisterUnion[SystemMessageContentListImageContentItemInputTextContentItemItemUnionParam]( "type", - apijson.Discriminator[SamplingParamsStrategyGreedy]("greedy"), - apijson.Discriminator[SamplingParamsStrategyTopP]("top_p"), - apijson.Discriminator[SamplingParamsStrategyTopK]("top_k"), + apijson.Discriminator[SystemMessageContentListImageContentItemInputTextContentItemItemImageParam]("image"), + apijson.Discriminator[SystemMessageContentListImageContentItemInputTextContentItemItemTextParam]("text"), ) } -func NewSamplingParamsStrategyGreedy() SamplingParamsStrategyGreedy { - return SamplingParamsStrategyGreedy{ - Type: "greedy", - } -} - -// Greedy sampling strategy that selects the highest probability token at each -// step. +// A image content item // -// This struct has a constant value, construct it with -// [NewSamplingParamsStrategyGreedy]. -type SamplingParamsStrategyGreedy struct { - // Must be "greedy" to identify this sampling strategy - Type constant.Greedy `json:"type,required"` +// The property Image is required. +type SystemMessageContentListImageContentItemInputTextContentItemItemImageParam struct { + // A URL or a base64 encoded string + Image SystemMessageContentListImageContentItemInputTextContentItemItemImageImageParam `json:"image,omitzero,required"` + // Any of "image". + Type string `json:"type,omitzero"` paramObj } -func (r SamplingParamsStrategyGreedy) MarshalJSON() (data []byte, err error) { - type shadow SamplingParamsStrategyGreedy +func (r SystemMessageContentListImageContentItemInputTextContentItemItemImageParam) MarshalJSON() (data []byte, err error) { + type shadow SystemMessageContentListImageContentItemInputTextContentItemItemImageParam return param.MarshalObject(r, (*shadow)(&r)) } -func (r *SamplingParamsStrategyGreedy) UnmarshalJSON(data []byte) error { +func (r *SystemMessageContentListImageContentItemInputTextContentItemItemImageParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Top-p (nucleus) sampling strategy that samples from the smallest set of tokens -// with cumulative probability >= p. -// -// The property Type is required. -type SamplingParamsStrategyTopP struct { - // Controls randomness in sampling. Higher values increase randomness - Temperature param.Opt[float64] `json:"temperature,omitzero"` - // Cumulative probability threshold for nucleus sampling. Defaults to 0.95 - TopP param.Opt[float64] `json:"top_p,omitzero"` - // Must be "top_p" to identify this sampling strategy - // - // This field can be elided, and will marshal its zero value as "top_p". - Type constant.TopP `json:"type,required"` +func init() { + apijson.RegisterFieldValidator[SystemMessageContentListImageContentItemInputTextContentItemItemImageParam]( + "type", "image", + ) +} + +// A URL or a base64 encoded string +type SystemMessageContentListImageContentItemInputTextContentItemItemImageImageParam struct { + Data param.Opt[string] `json:"data,omitzero"` + // A URL reference to external content. + URL SystemMessageContentListImageContentItemInputTextContentItemItemImageImageURLParam `json:"url,omitzero"` paramObj } -func (r SamplingParamsStrategyTopP) MarshalJSON() (data []byte, err error) { - type shadow SamplingParamsStrategyTopP +func (r SystemMessageContentListImageContentItemInputTextContentItemItemImageImageParam) MarshalJSON() (data []byte, err error) { + type shadow SystemMessageContentListImageContentItemInputTextContentItemItemImageImageParam return param.MarshalObject(r, (*shadow)(&r)) } -func (r *SamplingParamsStrategyTopP) UnmarshalJSON(data []byte) error { +func (r *SystemMessageContentListImageContentItemInputTextContentItemItemImageImageParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Top-k sampling strategy that restricts sampling to the k most likely tokens. +// A URL reference to external content. // -// The properties TopK, Type are required. -type SamplingParamsStrategyTopK struct { - // Number of top tokens to consider for sampling. Must be at least 1 - TopK int64 `json:"top_k,required"` - // Must be "top_k" to identify this sampling strategy - // - // This field can be elided, and will marshal its zero value as "top_k". - Type constant.TopK `json:"type,required"` +// The property Uri is required. +type SystemMessageContentListImageContentItemInputTextContentItemItemImageImageURLParam struct { + Uri string `json:"uri,required"` paramObj } -func (r SamplingParamsStrategyTopK) MarshalJSON() (data []byte, err error) { - type shadow SamplingParamsStrategyTopK +func (r SystemMessageContentListImageContentItemInputTextContentItemItemImageImageURLParam) MarshalJSON() (data []byte, err error) { + type shadow SystemMessageContentListImageContentItemInputTextContentItemItemImageImageURLParam return param.MarshalObject(r, (*shadow)(&r)) } -func (r *SamplingParamsStrategyTopK) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A scoring result for a single row. -type ScoringResult struct { - // Map of metric name to aggregated value - AggregatedResults map[string]ScoringResultAggregatedResultUnion `json:"aggregated_results,required"` - // The scoring result for each row. Each row is a map of column name to value. - ScoreRows []map[string]ScoringResultScoreRowUnion `json:"score_rows,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - AggregatedResults respjson.Field - ScoreRows respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ScoringResult) RawJSON() string { return r.JSON.raw } -func (r *ScoringResult) UnmarshalJSON(data []byte) error { +func (r *SystemMessageContentListImageContentItemInputTextContentItemItemImageImageURLParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ScoringResultAggregatedResultUnion contains all possible properties and values -// from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. +// A text content item // -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ScoringResultAggregatedResultUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ScoringResultAggregatedResultUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ScoringResultAggregatedResultUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ScoringResultAggregatedResultUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// The property Text is required. +type SystemMessageContentListImageContentItemInputTextContentItemItemTextParam struct { + Text string `json:"text,required"` + // Any of "text". + Type string `json:"type,omitzero"` + paramObj } -func (u ScoringResultAggregatedResultUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +func (r SystemMessageContentListImageContentItemInputTextContentItemItemTextParam) MarshalJSON() (data []byte, err error) { + type shadow SystemMessageContentListImageContentItemInputTextContentItemItemTextParam + return param.MarshalObject(r, (*shadow)(&r)) } - -// Returns the unmodified JSON received from the API -func (u ScoringResultAggregatedResultUnion) RawJSON() string { return u.JSON.raw } - -func (r *ScoringResultAggregatedResultUnion) UnmarshalJSON(data []byte) error { +func (r *SystemMessageContentListImageContentItemInputTextContentItemItemTextParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ScoringResultScoreRowUnion contains all possible properties and values from -// [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ScoringResultScoreRowUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ScoringResultScoreRowUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ScoringResultScoreRowUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ScoringResultScoreRowUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ScoringResultScoreRowUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +func init() { + apijson.RegisterFieldValidator[SystemMessageContentListImageContentItemInputTextContentItemItemTextParam]( + "type", "text", + ) } -// Returns the unmodified JSON received from the API -func (u ScoringResultScoreRowUnion) RawJSON() string { return u.JSON.raw } +type SystemMessageRole string -func (r *ScoringResultScoreRowUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A system message providing instructions or context to the model. -// -// The properties Content, Role are required. -type SystemMessageParam struct { - // The content of the "system prompt". If multiple system messages are provided, - // they are concatenated. The underlying Llama Stack code may also add other system - // messages (for example, for formatting tool definitions). - Content InterleavedContentUnionParam `json:"content,omitzero,required"` - // Must be "system" to identify this as a system message - // - // This field can be elided, and will marshal its zero value as "system". - Role constant.System `json:"role,required"` - paramObj -} - -func (r SystemMessageParam) MarshalJSON() (data []byte, err error) { - type shadow SystemMessageParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *SystemMessageParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} +const ( + SystemMessageRoleSystem SystemMessageRole = "system" +) diff --git a/shared/constant/constants.go b/shared/constant/constants.go index 0fd3fb1..efe6932 100644 --- a/shared/constant/constants.go +++ b/shared/constant/constants.go @@ -24,380 +24,20 @@ func ValueOf[T Constant[T]]() T { return t.Default() } -type Array string // Always "array" -type Assistant string // Always "assistant" -type Auto string // Always "auto" -type Basic string // Always "basic" -type Benchmark string // Always "benchmark" -type Boolean string // Always "boolean" -type ChatCompletionInput string // Always "chat_completion_input" -type ChatCompletion string // Always "chat.completion" -type ChatCompletionChunk string // Always "chat.completion.chunk" -type CompletionInput string // Always "completion_input" -type ContainerFileCitation string // Always "container_file_citation" -type Conversation string // Always "conversation" -type CreatedAt string // Always "created_at" -type Dataset string // Always "dataset" -type Developer string // Always "developer" -type Embedding string // Always "embedding" -type File string // Always "file" -type FileCitation string // Always "file_citation" -type FilePath string // Always "file_path" -type FileSearch string // Always "file_search" -type FileSearchCall string // Always "file_search_call" -type Function string // Always "function" -type FunctionCall string // Always "function_call" -type FunctionCallOutput string // Always "function_call_output" -type Greedy string // Always "greedy" -type Image string // Always "image" -type ImageURL string // Always "image_url" -type InputFile string // Always "input_file" -type InputImage string // Always "input_image" -type InputText string // Always "input_text" -type Json string // Always "json" -type JsonObject string // Always "json_object" -type JsonSchema string // Always "json_schema" -type List string // Always "list" -type LlmAsJudge string // Always "llm_as_judge" -type LoRa string // Always "LoRA" -type Mcp string // Always "mcp" -type McpApprovalRequest string // Always "mcp_approval_request" -type McpApprovalResponse string // Always "mcp_approval_response" -type McpCall string // Always "mcp_call" -type McpListTools string // Always "mcp_list_tools" -type Message string // Always "message" -type Model string // Always "model" -type Number string // Always "number" -type Object string // Always "object" -type OutputText string // Always "output_text" -type Qat string // Always "QAT" -type ReasoningText string // Always "reasoning_text" -type Refusal string // Always "refusal" -type RegexParser string // Always "regex_parser" -type Response string // Always "response" -type ResponseCompleted string // Always "response.completed" -type ResponseContentPartAdded string // Always "response.content_part.added" -type ResponseContentPartDone string // Always "response.content_part.done" -type ResponseCreated string // Always "response.created" -type ResponseFailed string // Always "response.failed" -type ResponseFileSearchCallCompleted string // Always "response.file_search_call.completed" -type ResponseFileSearchCallInProgress string // Always "response.file_search_call.in_progress" -type ResponseFileSearchCallSearching string // Always "response.file_search_call.searching" -type ResponseFunctionCallArgumentsDelta string // Always "response.function_call_arguments.delta" -type ResponseFunctionCallArgumentsDone string // Always "response.function_call_arguments.done" -type ResponseInProgress string // Always "response.in_progress" -type ResponseIncomplete string // Always "response.incomplete" -type ResponseMcpCallArgumentsDelta string // Always "response.mcp_call.arguments.delta" -type ResponseMcpCallArgumentsDone string // Always "response.mcp_call.arguments.done" -type ResponseMcpCallCompleted string // Always "response.mcp_call.completed" -type ResponseMcpCallFailed string // Always "response.mcp_call.failed" -type ResponseMcpCallInProgress string // Always "response.mcp_call.in_progress" -type ResponseMcpListToolsCompleted string // Always "response.mcp_list_tools.completed" -type ResponseMcpListToolsFailed string // Always "response.mcp_list_tools.failed" -type ResponseMcpListToolsInProgress string // Always "response.mcp_list_tools.in_progress" -type ResponseOutputItemAdded string // Always "response.output_item.added" -type ResponseOutputItemDone string // Always "response.output_item.done" -type ResponseOutputTextAnnotationAdded string // Always "response.output_text.annotation.added" -type ResponseOutputTextDelta string // Always "response.output_text.delta" -type ResponseOutputTextDone string // Always "response.output_text.done" -type ResponseReasoningSummaryPartAdded string // Always "response.reasoning_summary_part.added" -type ResponseReasoningSummaryPartDone string // Always "response.reasoning_summary_part.done" -type ResponseReasoningSummaryTextDelta string // Always "response.reasoning_summary_text.delta" -type ResponseReasoningSummaryTextDone string // Always "response.reasoning_summary_text.done" -type ResponseReasoningTextDelta string // Always "response.reasoning_text.delta" -type ResponseReasoningTextDone string // Always "response.reasoning_text.done" -type ResponseRefusalDelta string // Always "response.refusal.delta" -type ResponseRefusalDone string // Always "response.refusal.done" -type ResponseWebSearchCallCompleted string // Always "response.web_search_call.completed" -type ResponseWebSearchCallInProgress string // Always "response.web_search_call.in_progress" -type ResponseWebSearchCallSearching string // Always "response.web_search_call.searching" -type Rows string // Always "rows" -type ScoringFunction string // Always "scoring_function" -type Shield string // Always "shield" -type Static string // Always "static" -type String string // Always "string" -type SummaryText string // Always "summary_text" -type System string // Always "system" -type Text string // Always "text" -type TextCompletion string // Always "text_completion" -type Tool string // Always "tool" -type ToolGroup string // Always "tool_group" -type TopK string // Always "top_k" -type TopP string // Always "top_p" -type Union string // Always "union" -type Uri string // Always "uri" -type URLCitation string // Always "url_citation" -type User string // Always "user" -type VectorStoreFileContentPage string // Always "vector_store.file_content.page" -type WebSearchCall string // Always "web_search_call" - -func (c Array) Default() Array { return "array" } -func (c Assistant) Default() Assistant { return "assistant" } -func (c Auto) Default() Auto { return "auto" } -func (c Basic) Default() Basic { return "basic" } -func (c Benchmark) Default() Benchmark { return "benchmark" } -func (c Boolean) Default() Boolean { return "boolean" } -func (c ChatCompletionInput) Default() ChatCompletionInput { return "chat_completion_input" } -func (c ChatCompletion) Default() ChatCompletion { return "chat.completion" } -func (c ChatCompletionChunk) Default() ChatCompletionChunk { return "chat.completion.chunk" } -func (c CompletionInput) Default() CompletionInput { return "completion_input" } -func (c ContainerFileCitation) Default() ContainerFileCitation { return "container_file_citation" } -func (c Conversation) Default() Conversation { return "conversation" } -func (c CreatedAt) Default() CreatedAt { return "created_at" } -func (c Dataset) Default() Dataset { return "dataset" } -func (c Developer) Default() Developer { return "developer" } -func (c Embedding) Default() Embedding { return "embedding" } -func (c File) Default() File { return "file" } -func (c FileCitation) Default() FileCitation { return "file_citation" } -func (c FilePath) Default() FilePath { return "file_path" } -func (c FileSearch) Default() FileSearch { return "file_search" } -func (c FileSearchCall) Default() FileSearchCall { return "file_search_call" } -func (c Function) Default() Function { return "function" } -func (c FunctionCall) Default() FunctionCall { return "function_call" } -func (c FunctionCallOutput) Default() FunctionCallOutput { return "function_call_output" } -func (c Greedy) Default() Greedy { return "greedy" } -func (c Image) Default() Image { return "image" } -func (c ImageURL) Default() ImageURL { return "image_url" } -func (c InputFile) Default() InputFile { return "input_file" } -func (c InputImage) Default() InputImage { return "input_image" } -func (c InputText) Default() InputText { return "input_text" } -func (c Json) Default() Json { return "json" } -func (c JsonObject) Default() JsonObject { return "json_object" } -func (c JsonSchema) Default() JsonSchema { return "json_schema" } -func (c List) Default() List { return "list" } -func (c LlmAsJudge) Default() LlmAsJudge { return "llm_as_judge" } -func (c LoRa) Default() LoRa { return "LoRA" } -func (c Mcp) Default() Mcp { return "mcp" } -func (c McpApprovalRequest) Default() McpApprovalRequest { return "mcp_approval_request" } -func (c McpApprovalResponse) Default() McpApprovalResponse { return "mcp_approval_response" } -func (c McpCall) Default() McpCall { return "mcp_call" } -func (c McpListTools) Default() McpListTools { return "mcp_list_tools" } -func (c Message) Default() Message { return "message" } -func (c Model) Default() Model { return "model" } -func (c Number) Default() Number { return "number" } -func (c Object) Default() Object { return "object" } -func (c OutputText) Default() OutputText { return "output_text" } -func (c Qat) Default() Qat { return "QAT" } -func (c ReasoningText) Default() ReasoningText { return "reasoning_text" } -func (c Refusal) Default() Refusal { return "refusal" } -func (c RegexParser) Default() RegexParser { return "regex_parser" } -func (c Response) Default() Response { return "response" } -func (c ResponseCompleted) Default() ResponseCompleted { return "response.completed" } -func (c ResponseContentPartAdded) Default() ResponseContentPartAdded { - return "response.content_part.added" -} -func (c ResponseContentPartDone) Default() ResponseContentPartDone { - return "response.content_part.done" -} -func (c ResponseCreated) Default() ResponseCreated { return "response.created" } -func (c ResponseFailed) Default() ResponseFailed { return "response.failed" } -func (c ResponseFileSearchCallCompleted) Default() ResponseFileSearchCallCompleted { - return "response.file_search_call.completed" -} -func (c ResponseFileSearchCallInProgress) Default() ResponseFileSearchCallInProgress { - return "response.file_search_call.in_progress" -} -func (c ResponseFileSearchCallSearching) Default() ResponseFileSearchCallSearching { - return "response.file_search_call.searching" -} -func (c ResponseFunctionCallArgumentsDelta) Default() ResponseFunctionCallArgumentsDelta { - return "response.function_call_arguments.delta" -} -func (c ResponseFunctionCallArgumentsDone) Default() ResponseFunctionCallArgumentsDone { - return "response.function_call_arguments.done" -} -func (c ResponseInProgress) Default() ResponseInProgress { return "response.in_progress" } -func (c ResponseIncomplete) Default() ResponseIncomplete { return "response.incomplete" } -func (c ResponseMcpCallArgumentsDelta) Default() ResponseMcpCallArgumentsDelta { - return "response.mcp_call.arguments.delta" -} -func (c ResponseMcpCallArgumentsDone) Default() ResponseMcpCallArgumentsDone { - return "response.mcp_call.arguments.done" -} -func (c ResponseMcpCallCompleted) Default() ResponseMcpCallCompleted { - return "response.mcp_call.completed" -} -func (c ResponseMcpCallFailed) Default() ResponseMcpCallFailed { return "response.mcp_call.failed" } -func (c ResponseMcpCallInProgress) Default() ResponseMcpCallInProgress { - return "response.mcp_call.in_progress" -} -func (c ResponseMcpListToolsCompleted) Default() ResponseMcpListToolsCompleted { - return "response.mcp_list_tools.completed" -} -func (c ResponseMcpListToolsFailed) Default() ResponseMcpListToolsFailed { - return "response.mcp_list_tools.failed" -} -func (c ResponseMcpListToolsInProgress) Default() ResponseMcpListToolsInProgress { - return "response.mcp_list_tools.in_progress" -} -func (c ResponseOutputItemAdded) Default() ResponseOutputItemAdded { - return "response.output_item.added" -} -func (c ResponseOutputItemDone) Default() ResponseOutputItemDone { return "response.output_item.done" } -func (c ResponseOutputTextAnnotationAdded) Default() ResponseOutputTextAnnotationAdded { - return "response.output_text.annotation.added" -} -func (c ResponseOutputTextDelta) Default() ResponseOutputTextDelta { - return "response.output_text.delta" -} -func (c ResponseOutputTextDone) Default() ResponseOutputTextDone { return "response.output_text.done" } -func (c ResponseReasoningSummaryPartAdded) Default() ResponseReasoningSummaryPartAdded { - return "response.reasoning_summary_part.added" -} -func (c ResponseReasoningSummaryPartDone) Default() ResponseReasoningSummaryPartDone { - return "response.reasoning_summary_part.done" -} -func (c ResponseReasoningSummaryTextDelta) Default() ResponseReasoningSummaryTextDelta { - return "response.reasoning_summary_text.delta" -} -func (c ResponseReasoningSummaryTextDone) Default() ResponseReasoningSummaryTextDone { - return "response.reasoning_summary_text.done" -} -func (c ResponseReasoningTextDelta) Default() ResponseReasoningTextDelta { - return "response.reasoning_text.delta" -} -func (c ResponseReasoningTextDone) Default() ResponseReasoningTextDone { - return "response.reasoning_text.done" -} -func (c ResponseRefusalDelta) Default() ResponseRefusalDelta { return "response.refusal.delta" } -func (c ResponseRefusalDone) Default() ResponseRefusalDone { return "response.refusal.done" } -func (c ResponseWebSearchCallCompleted) Default() ResponseWebSearchCallCompleted { - return "response.web_search_call.completed" -} -func (c ResponseWebSearchCallInProgress) Default() ResponseWebSearchCallInProgress { - return "response.web_search_call.in_progress" -} -func (c ResponseWebSearchCallSearching) Default() ResponseWebSearchCallSearching { - return "response.web_search_call.searching" -} -func (c Rows) Default() Rows { return "rows" } -func (c ScoringFunction) Default() ScoringFunction { return "scoring_function" } -func (c Shield) Default() Shield { return "shield" } -func (c Static) Default() Static { return "static" } -func (c String) Default() String { return "string" } -func (c SummaryText) Default() SummaryText { return "summary_text" } -func (c System) Default() System { return "system" } -func (c Text) Default() Text { return "text" } -func (c TextCompletion) Default() TextCompletion { return "text_completion" } -func (c Tool) Default() Tool { return "tool" } -func (c ToolGroup) Default() ToolGroup { return "tool_group" } -func (c TopK) Default() TopK { return "top_k" } -func (c TopP) Default() TopP { return "top_p" } -func (c Union) Default() Union { return "union" } -func (c Uri) Default() Uri { return "uri" } -func (c URLCitation) Default() URLCitation { return "url_citation" } -func (c User) Default() User { return "user" } -func (c VectorStoreFileContentPage) Default() VectorStoreFileContentPage { - return "vector_store.file_content.page" -} -func (c WebSearchCall) Default() WebSearchCall { return "web_search_call" } - -func (c Array) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Assistant) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Auto) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Basic) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Benchmark) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Boolean) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ChatCompletionInput) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ChatCompletion) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ChatCompletionChunk) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c CompletionInput) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ContainerFileCitation) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Conversation) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c CreatedAt) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Dataset) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Developer) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Embedding) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c File) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c FileCitation) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c FilePath) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c FileSearch) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c FileSearchCall) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Function) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c FunctionCall) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c FunctionCallOutput) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Greedy) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Image) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ImageURL) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c InputFile) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c InputImage) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c InputText) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Json) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c JsonObject) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c JsonSchema) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c List) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c LlmAsJudge) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c LoRa) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Mcp) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c McpApprovalRequest) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c McpApprovalResponse) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c McpCall) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c McpListTools) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Message) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Model) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Number) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Object) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c OutputText) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Qat) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ReasoningText) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Refusal) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c RegexParser) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Response) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseCompleted) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseContentPartAdded) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseContentPartDone) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseCreated) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseFailed) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseFileSearchCallCompleted) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseFileSearchCallInProgress) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseFileSearchCallSearching) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseFunctionCallArgumentsDelta) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseFunctionCallArgumentsDone) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseInProgress) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseIncomplete) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseMcpCallArgumentsDelta) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseMcpCallArgumentsDone) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseMcpCallCompleted) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseMcpCallFailed) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseMcpCallInProgress) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseMcpListToolsCompleted) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseMcpListToolsFailed) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseMcpListToolsInProgress) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseOutputItemAdded) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseOutputItemDone) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseOutputTextAnnotationAdded) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseOutputTextDelta) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseOutputTextDone) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseReasoningSummaryPartAdded) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseReasoningSummaryPartDone) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseReasoningSummaryTextDelta) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseReasoningSummaryTextDone) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseReasoningTextDelta) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseReasoningTextDone) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseRefusalDelta) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseRefusalDone) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseWebSearchCallCompleted) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseWebSearchCallInProgress) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ResponseWebSearchCallSearching) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Rows) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ScoringFunction) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Shield) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Static) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c String) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c SummaryText) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c System) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Text) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c TextCompletion) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Tool) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ToolGroup) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c TopK) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c TopP) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Union) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Uri) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c URLCitation) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c User) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c VectorStoreFileContentPage) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c WebSearchCall) MarshalJSON() ([]byte, error) { return marshalString(c) } +type String24h string // Always "24h" +type Batch string // Always "batch" +type CreatedAt string // Always "created_at" +type Text string // Always "text" + +func (c String24h) Default() String24h { return "24h" } +func (c Batch) Default() Batch { return "batch" } +func (c CreatedAt) Default() CreatedAt { return "created_at" } +func (c Text) Default() Text { return "text" } + +func (c String24h) MarshalJSON() ([]byte, error) { return marshalString(c) } +func (c Batch) MarshalJSON() ([]byte, error) { return marshalString(c) } +func (c CreatedAt) MarshalJSON() ([]byte, error) { return marshalString(c) } +func (c Text) MarshalJSON() ([]byte, error) { return marshalString(c) } type constant[T any] interface { Constant[T] diff --git a/shield.go b/shield.go index d604ece..64f592e 100644 --- a/shield.go +++ b/shield.go @@ -10,7 +10,6 @@ package llamastackclient import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -21,7 +20,6 @@ import ( "github.com/llamastack/llama-stack-client-go/option" "github.com/llamastack/llama-stack-client-go/packages/param" "github.com/llamastack/llama-stack-client-go/packages/respjson" - "github.com/llamastack/llama-stack-client-go/shared/constant" ) // ShieldService contains methods and other services that help with interacting @@ -111,20 +109,22 @@ func (r *ListShieldsResponse) UnmarshalJSON(data []byte) error { // A safety shield resource that can be used to check content. type Shield struct { + // Unique identifier for this resource in llama stack Identifier string `json:"identifier,required"` - ProviderID string `json:"provider_id,required"` - // The resource type, always shield - Type constant.Shield `json:"type,required"` - // (Optional) Configuration parameters for the shield - Params map[string]ShieldParamUnion `json:"params"` - ProviderResourceID string `json:"provider_resource_id"` + // ID of the provider that owns this resource + ProviderID string `json:"provider_id,required"` + Params map[string]any `json:"params,nullable"` + // Unique identifier for this resource in the provider + ProviderResourceID string `json:"provider_resource_id,nullable"` + // Any of "shield". + Type ShieldType `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Identifier respjson.Field ProviderID respjson.Field - Type respjson.Field Params respjson.Field ProviderResourceID respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -136,67 +136,17 @@ func (r *Shield) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ShieldParamUnion contains all possible properties and values from [bool], -// [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ShieldParamUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ShieldParamUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ShieldParamUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ShieldParamUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ShieldParamUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ShieldParamUnion) RawJSON() string { return u.JSON.raw } +type ShieldType string -func (r *ShieldParamUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} +const ( + ShieldTypeShield ShieldType = "shield" +) type ShieldRegisterParams struct { - // The identifier of the shield to register. - ShieldID string `json:"shield_id,required"` - // The identifier of the provider. - ProviderID param.Opt[string] `json:"provider_id,omitzero"` - // The identifier of the shield in the provider. + ShieldID string `json:"shield_id,required"` + ProviderID param.Opt[string] `json:"provider_id,omitzero"` ProviderShieldID param.Opt[string] `json:"provider_shield_id,omitzero"` - // The parameters of the shield. - Params map[string]ShieldRegisterParamsParamUnion `json:"params,omitzero"` + Params map[string]any `json:"params,omitzero"` paramObj } @@ -207,34 +157,3 @@ func (r ShieldRegisterParams) MarshalJSON() (data []byte, err error) { func (r *ShieldRegisterParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ShieldRegisterParamsParamUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u ShieldRegisterParamsParamUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *ShieldRegisterParamsParamUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ShieldRegisterParamsParamUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} diff --git a/shield_test.go b/shield_test.go index eca9cf2..18c296b 100644 --- a/shield_test.go +++ b/shield_test.go @@ -95,10 +95,8 @@ func TestShieldRegisterWithOptionalParams(t *testing.T) { ) _, err := client.Shields.Register(context.TODO(), llamastackclient.ShieldRegisterParams{ ShieldID: "shield_id", - Params: map[string]llamastackclient.ShieldRegisterParamsParamUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + Params: map[string]any{ + "foo": "bar", }, ProviderID: llamastackclient.String("provider_id"), ProviderShieldID: llamastackclient.String("provider_shield_id"), diff --git a/tool.go b/tool.go index e659f56..3245fe8 100644 --- a/tool.go +++ b/tool.go @@ -69,7 +69,6 @@ func (r *ToolService) Get(ctx context.Context, toolName string, opts ...option.R } type ToolListParams struct { - // The ID of the tool group to list tools for. ToolgroupID param.Opt[string] `query:"toolgroup_id,omitzero" json:"-"` paramObj } @@ -84,7 +83,6 @@ func (r ToolListParams) URLQuery() (v url.Values, err error) { // Response containing a list of tool definitions. type ToolListResponseEnvelope struct { - // List of tool definitions Data []ToolDef `json:"data,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { diff --git a/toolgroup.go b/toolgroup.go index 934ab6d..6328263 100644 --- a/toolgroup.go +++ b/toolgroup.go @@ -10,7 +10,6 @@ package llamastackclient import ( "context" - "encoding/json" "errors" "fmt" "net/http" @@ -21,7 +20,6 @@ import ( "github.com/llamastack/llama-stack-client-go/option" "github.com/llamastack/llama-stack-client-go/packages/param" "github.com/llamastack/llama-stack-client-go/packages/respjson" - "github.com/llamastack/llama-stack-client-go/shared/constant" ) // ToolgroupService contains methods and other services that help with interacting @@ -96,7 +94,6 @@ func (r *ToolgroupService) Unregister(ctx context.Context, toolgroupID string, o // Response containing a list of tool groups. type ListToolGroupsResponse struct { - // List of tool groups Data []ToolGroup `json:"data,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { @@ -114,23 +111,25 @@ func (r *ListToolGroupsResponse) UnmarshalJSON(data []byte) error { // A group of related tools managed together. type ToolGroup struct { + // Unique identifier for this resource in llama stack Identifier string `json:"identifier,required"` - ProviderID string `json:"provider_id,required"` - // Type of resource, always 'tool_group' - Type constant.ToolGroup `json:"type,required"` - // (Optional) Additional arguments for the tool group - Args map[string]ToolGroupArgUnion `json:"args"` - // (Optional) Model Context Protocol endpoint for remote tools - McpEndpoint ToolGroupMcpEndpoint `json:"mcp_endpoint"` - ProviderResourceID string `json:"provider_resource_id"` + // ID of the provider that owns this resource + ProviderID string `json:"provider_id,required"` + Args map[string]any `json:"args,nullable"` + // A URL reference to external content. + McpEndpoint ToolGroupMcpEndpoint `json:"mcp_endpoint,nullable"` + // Unique identifier for this resource in the provider + ProviderResourceID string `json:"provider_resource_id,nullable"` + // Any of "tool_group". + Type ToolGroupType `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Identifier respjson.Field ProviderID respjson.Field - Type respjson.Field Args respjson.Field McpEndpoint respjson.Field ProviderResourceID respjson.Field + Type respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -142,61 +141,8 @@ func (r *ToolGroup) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ToolGroupArgUnion contains all possible properties and values from [bool], -// [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ToolGroupArgUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u ToolGroupArgUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ToolGroupArgUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ToolGroupArgUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ToolGroupArgUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ToolGroupArgUnion) RawJSON() string { return u.JSON.raw } - -func (r *ToolGroupArgUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// (Optional) Model Context Protocol endpoint for remote tools +// A URL reference to external content. type ToolGroupMcpEndpoint struct { - // The URL string pointing to the resource Uri string `json:"uri,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { @@ -212,14 +158,17 @@ func (r *ToolGroupMcpEndpoint) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +type ToolGroupType string + +const ( + ToolGroupTypeToolGroup ToolGroupType = "tool_group" +) + type ToolgroupRegisterParams struct { - // The ID of the provider to use for the tool group. - ProviderID string `json:"provider_id,required"` - // The ID of the tool group to register. - ToolgroupID string `json:"toolgroup_id,required"` - // A dictionary of arguments to pass to the tool group. - Args map[string]ToolgroupRegisterParamsArgUnion `json:"args,omitzero"` - // The MCP endpoint to use for the tool group. + ProviderID string `json:"provider_id,required"` + ToolgroupID string `json:"toolgroup_id,required"` + Args map[string]any `json:"args,omitzero"` + // A URL reference to external content. McpEndpoint ToolgroupRegisterParamsMcpEndpoint `json:"mcp_endpoint,omitzero"` paramObj } @@ -232,42 +181,10 @@ func (r *ToolgroupRegisterParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ToolgroupRegisterParamsArgUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u ToolgroupRegisterParamsArgUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *ToolgroupRegisterParamsArgUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ToolgroupRegisterParamsArgUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - -// The MCP endpoint to use for the tool group. +// A URL reference to external content. // // The property Uri is required. type ToolgroupRegisterParamsMcpEndpoint struct { - // The URL string pointing to the resource Uri string `json:"uri,required"` paramObj } diff --git a/toolgroup_test.go b/toolgroup_test.go index f705111..7ff0d46 100644 --- a/toolgroup_test.go +++ b/toolgroup_test.go @@ -75,10 +75,8 @@ func TestToolgroupRegisterWithOptionalParams(t *testing.T) { err := client.Toolgroups.Register(context.TODO(), llamastackclient.ToolgroupRegisterParams{ ProviderID: "provider_id", ToolgroupID: "toolgroup_id", - Args: map[string]llamastackclient.ToolgroupRegisterParamsArgUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + Args: map[string]any{ + "foo": "bar", }, McpEndpoint: llamastackclient.ToolgroupRegisterParamsMcpEndpoint{ Uri: "uri", diff --git a/toolruntime.go b/toolruntime.go index d51e0d8..6341935 100644 --- a/toolruntime.go +++ b/toolruntime.go @@ -31,7 +31,6 @@ import ( // the [NewToolRuntimeService] method instead. type ToolRuntimeService struct { Options []option.RequestOption - RagTool ToolRuntimeRagToolService } // NewToolRuntimeService generates a new service that applies the given options to @@ -40,7 +39,6 @@ type ToolRuntimeService struct { func NewToolRuntimeService(opts ...option.RequestOption) (r ToolRuntimeService) { r = ToolRuntimeService{} r.Options = opts - r.RagTool = NewToolRuntimeRagToolService(opts...) return } @@ -67,18 +65,12 @@ func (r *ToolRuntimeService) ListTools(ctx context.Context, query ToolRuntimeLis // Tool definition used in runtime contexts. type ToolDef struct { - // Name of the tool - Name string `json:"name,required"` - // (Optional) Human-readable description of what the tool does - Description string `json:"description"` - // (Optional) JSON Schema for tool inputs (MCP inputSchema) - InputSchema map[string]ToolDefInputSchemaUnion `json:"input_schema"` - // (Optional) Additional metadata about the tool - Metadata map[string]ToolDefMetadataUnion `json:"metadata"` - // (Optional) JSON Schema for tool outputs (MCP outputSchema) - OutputSchema map[string]ToolDefOutputSchemaUnion `json:"output_schema"` - // (Optional) ID of the tool group this tool belongs to - ToolgroupID string `json:"toolgroup_id"` + Name string `json:"name,required"` + Description string `json:"description,nullable"` + InputSchema map[string]any `json:"input_schema,nullable"` + Metadata map[string]any `json:"metadata,nullable"` + OutputSchema map[string]any `json:"output_schema,nullable"` + ToolgroupID string `json:"toolgroup_id,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Name respjson.Field @@ -98,247 +90,335 @@ func (r *ToolDef) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ToolDefInputSchemaUnion contains all possible properties and values from [bool], -// [float64], [string], [[]any]. +// Result of a tool invocation. +type ToolInvocationResult struct { + // A image content item + Content ToolInvocationResultContentUnion `json:"content,nullable"` + ErrorCode int64 `json:"error_code,nullable"` + ErrorMessage string `json:"error_message,nullable"` + Metadata map[string]any `json:"metadata,nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Content respjson.Field + ErrorCode respjson.Field + ErrorMessage respjson.Field + Metadata respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ToolInvocationResult) RawJSON() string { return r.JSON.raw } +func (r *ToolInvocationResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ToolInvocationResultContentUnion contains all possible properties and values +// from [string], [ToolInvocationResultContentImageContentItemOutput], +// [ToolInvocationResultContentTextContentItem], +// [[]ToolInvocationResultContentListImageContentItemOutputTextContentItemItemUnion]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ToolDefInputSchemaUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` +// will be valid: OfString OfListImageContentItemOutputTextContentItem] +type ToolInvocationResultContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string + // This field will be present if the value is a + // [[]ToolInvocationResultContentListImageContentItemOutputTextContentItemItemUnion] + // instead of an object. + OfListImageContentItemOutputTextContentItem []ToolInvocationResultContentListImageContentItemOutputTextContentItemItemUnion `json:",inline"` + // This field is from variant [ToolInvocationResultContentImageContentItemOutput]. + Image ToolInvocationResultContentImageContentItemOutputImage `json:"image"` + Type string `json:"type"` + // This field is from variant [ToolInvocationResultContentTextContentItem]. + Text string `json:"text"` + JSON struct { + OfString respjson.Field + OfListImageContentItemOutputTextContentItem respjson.Field + Image respjson.Field + Type respjson.Field + Text respjson.Field + raw string } `json:"-"` } -func (u ToolDefInputSchemaUnion) AsBool() (v bool) { +func (u ToolInvocationResultContentUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ToolDefInputSchemaUnion) AsFloat() (v float64) { +func (u ToolInvocationResultContentUnion) AsImageContentItemOutput() (v ToolInvocationResultContentImageContentItemOutput) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ToolDefInputSchemaUnion) AsString() (v string) { +func (u ToolInvocationResultContentUnion) AsTextContentItem() (v ToolInvocationResultContentTextContentItem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ToolDefInputSchemaUnion) AsAnyArray() (v []any) { +func (u ToolInvocationResultContentUnion) AsListImageContentItemOutputTextContentItem() (v []ToolInvocationResultContentListImageContentItemOutputTextContentItemItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ToolDefInputSchemaUnion) RawJSON() string { return u.JSON.raw } +func (u ToolInvocationResultContentUnion) RawJSON() string { return u.JSON.raw } -func (r *ToolDefInputSchemaUnion) UnmarshalJSON(data []byte) error { +func (r *ToolInvocationResultContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ToolDefMetadataUnion contains all possible properties and values from [bool], -// [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ToolDefMetadataUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string +// A image content item +type ToolInvocationResultContentImageContentItemOutput struct { + // A URL or a base64 encoded string + Image ToolInvocationResultContentImageContentItemOutputImage `json:"image,required"` + // Any of "image". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Image respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } -func (u ToolDefMetadataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Returns the unmodified JSON received from the API +func (r ToolInvocationResultContentImageContentItemOutput) RawJSON() string { return r.JSON.raw } +func (r *ToolInvocationResultContentImageContentItemOutput) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ToolDefMetadataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// A URL or a base64 encoded string +type ToolInvocationResultContentImageContentItemOutputImage struct { + Data string `json:"data,nullable"` + // A URL reference to external content. + URL ToolInvocationResultContentImageContentItemOutputImageURL `json:"url,nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Data respjson.Field + URL respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } -func (u ToolDefMetadataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Returns the unmodified JSON received from the API +func (r ToolInvocationResultContentImageContentItemOutputImage) RawJSON() string { return r.JSON.raw } +func (r *ToolInvocationResultContentImageContentItemOutputImage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ToolDefMetadataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// A URL reference to external content. +type ToolInvocationResultContentImageContentItemOutputImageURL struct { + Uri string `json:"uri,required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Uri respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } // Returns the unmodified JSON received from the API -func (u ToolDefMetadataUnion) RawJSON() string { return u.JSON.raw } +func (r ToolInvocationResultContentImageContentItemOutputImageURL) RawJSON() string { + return r.JSON.raw +} +func (r *ToolInvocationResultContentImageContentItemOutputImageURL) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} -func (r *ToolDefMetadataUnion) UnmarshalJSON(data []byte) error { +// A text content item +type ToolInvocationResultContentTextContentItem struct { + Text string `json:"text,required"` + // Any of "text". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Text respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ToolInvocationResultContentTextContentItem) RawJSON() string { return r.JSON.raw } +func (r *ToolInvocationResultContentTextContentItem) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ToolDefOutputSchemaUnion contains all possible properties and values from -// [bool], [float64], [string], [[]any]. +// ToolInvocationResultContentListImageContentItemOutputTextContentItemItemUnion +// contains all possible properties and values from +// [ToolInvocationResultContentListImageContentItemOutputTextContentItemItemImage], +// [ToolInvocationResultContentListImageContentItemOutputTextContentItemItemText]. // -// Use the methods beginning with 'As' to cast the union to one of its variants. +// Use the +// [ToolInvocationResultContentListImageContentItemOutputTextContentItemItemUnion.AsAny] +// method to switch on the variant. // -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ToolDefOutputSchemaUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ToolInvocationResultContentListImageContentItemOutputTextContentItemItemUnion struct { + // This field is from variant + // [ToolInvocationResultContentListImageContentItemOutputTextContentItemItemImage]. + Image ToolInvocationResultContentListImageContentItemOutputTextContentItemItemImageImage `json:"image"` + // Any of "image", "text". + Type string `json:"type"` + // This field is from variant + // [ToolInvocationResultContentListImageContentItemOutputTextContentItemItemText]. + Text string `json:"text"` + JSON struct { + Image respjson.Field + Type respjson.Field + Text respjson.Field + raw string } `json:"-"` } -func (u ToolDefOutputSchemaUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// anyToolInvocationResultContentListImageContentItemOutputTextContentItemItem is +// implemented by each variant of +// [ToolInvocationResultContentListImageContentItemOutputTextContentItemItemUnion] +// to add type safety for the return type of +// [ToolInvocationResultContentListImageContentItemOutputTextContentItemItemUnion.AsAny] +type anyToolInvocationResultContentListImageContentItemOutputTextContentItemItem interface { + implToolInvocationResultContentListImageContentItemOutputTextContentItemItemUnion() } -func (u ToolDefOutputSchemaUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +func (ToolInvocationResultContentListImageContentItemOutputTextContentItemItemImage) implToolInvocationResultContentListImageContentItemOutputTextContentItemItemUnion() { +} +func (ToolInvocationResultContentListImageContentItemOutputTextContentItemItemText) implToolInvocationResultContentListImageContentItemOutputTextContentItemItemUnion() { } -func (u ToolDefOutputSchemaUnion) AsString() (v string) { +// Use the following switch statement to find the correct variant +// +// switch variant := ToolInvocationResultContentListImageContentItemOutputTextContentItemItemUnion.AsAny().(type) { +// case llamastackclient.ToolInvocationResultContentListImageContentItemOutputTextContentItemItemImage: +// case llamastackclient.ToolInvocationResultContentListImageContentItemOutputTextContentItemItemText: +// default: +// fmt.Errorf("no variant present") +// } +func (u ToolInvocationResultContentListImageContentItemOutputTextContentItemItemUnion) AsAny() anyToolInvocationResultContentListImageContentItemOutputTextContentItemItem { + switch u.Type { + case "image": + return u.AsImage() + case "text": + return u.AsText() + } + return nil +} + +func (u ToolInvocationResultContentListImageContentItemOutputTextContentItemItemUnion) AsImage() (v ToolInvocationResultContentListImageContentItemOutputTextContentItemItemImage) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ToolDefOutputSchemaUnion) AsAnyArray() (v []any) { +func (u ToolInvocationResultContentListImageContentItemOutputTextContentItemItemUnion) AsText() (v ToolInvocationResultContentListImageContentItemOutputTextContentItemItemText) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ToolDefOutputSchemaUnion) RawJSON() string { return u.JSON.raw } +func (u ToolInvocationResultContentListImageContentItemOutputTextContentItemItemUnion) RawJSON() string { + return u.JSON.raw +} -func (r *ToolDefOutputSchemaUnion) UnmarshalJSON(data []byte) error { +func (r *ToolInvocationResultContentListImageContentItemOutputTextContentItemItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Result of a tool invocation. -type ToolInvocationResult struct { - // (Optional) The output content from the tool execution - Content InterleavedContentUnion `json:"content"` - // (Optional) Numeric error code if the tool execution failed - ErrorCode int64 `json:"error_code"` - // (Optional) Error message if the tool execution failed - ErrorMessage string `json:"error_message"` - // (Optional) Additional metadata about the tool execution - Metadata map[string]ToolInvocationResultMetadataUnion `json:"metadata"` +// A image content item +type ToolInvocationResultContentListImageContentItemOutputTextContentItemItemImage struct { + // A URL or a base64 encoded string + Image ToolInvocationResultContentListImageContentItemOutputTextContentItemItemImageImage `json:"image,required"` + // Any of "image". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Content respjson.Field - ErrorCode respjson.Field - ErrorMessage respjson.Field - Metadata respjson.Field - ExtraFields map[string]respjson.Field - raw string + Image respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ToolInvocationResult) RawJSON() string { return r.JSON.raw } -func (r *ToolInvocationResult) UnmarshalJSON(data []byte) error { +func (r ToolInvocationResultContentListImageContentItemOutputTextContentItemItemImage) RawJSON() string { + return r.JSON.raw +} +func (r *ToolInvocationResultContentListImageContentItemOutputTextContentItemItemImage) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ToolInvocationResultMetadataUnion contains all possible properties and values -// from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type ToolInvocationResultMetadataUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string +// A URL or a base64 encoded string +type ToolInvocationResultContentListImageContentItemOutputTextContentItemItemImageImage struct { + Data string `json:"data,nullable"` + // A URL reference to external content. + URL ToolInvocationResultContentListImageContentItemOutputTextContentItemItemImageImageURL `json:"url,nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Data respjson.Field + URL respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } -func (u ToolInvocationResultMetadataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Returns the unmodified JSON received from the API +func (r ToolInvocationResultContentListImageContentItemOutputTextContentItemItemImageImage) RawJSON() string { + return r.JSON.raw +} +func (r *ToolInvocationResultContentListImageContentItemOutputTextContentItemItemImageImage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ToolInvocationResultMetadataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// A URL reference to external content. +type ToolInvocationResultContentListImageContentItemOutputTextContentItemItemImageImageURL struct { + Uri string `json:"uri,required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Uri respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } -func (u ToolInvocationResultMetadataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Returns the unmodified JSON received from the API +func (r ToolInvocationResultContentListImageContentItemOutputTextContentItemItemImageImageURL) RawJSON() string { + return r.JSON.raw +} +func (r *ToolInvocationResultContentListImageContentItemOutputTextContentItemItemImageImageURL) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ToolInvocationResultMetadataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// A text content item +type ToolInvocationResultContentListImageContentItemOutputTextContentItemItemText struct { + Text string `json:"text,required"` + // Any of "text". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Text respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } // Returns the unmodified JSON received from the API -func (u ToolInvocationResultMetadataUnion) RawJSON() string { return u.JSON.raw } - -func (r *ToolInvocationResultMetadataUnion) UnmarshalJSON(data []byte) error { +func (r ToolInvocationResultContentListImageContentItemOutputTextContentItemItemText) RawJSON() string { + return r.JSON.raw +} +func (r *ToolInvocationResultContentListImageContentItemOutputTextContentItemItemText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } type ToolRuntimeInvokeToolParams struct { - // A dictionary of arguments to pass to the tool. - Kwargs map[string]ToolRuntimeInvokeToolParamsKwargUnion `json:"kwargs,omitzero,required"` - // The name of the tool to invoke. - ToolName string `json:"tool_name,required"` - // (Optional) OAuth access token for authenticating with the MCP server. + Kwargs map[string]any `json:"kwargs,omitzero,required"` + ToolName string `json:"tool_name,required"` Authorization param.Opt[string] `json:"authorization,omitzero"` paramObj } @@ -351,43 +431,10 @@ func (r *ToolRuntimeInvokeToolParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ToolRuntimeInvokeToolParamsKwargUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u ToolRuntimeInvokeToolParamsKwargUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *ToolRuntimeInvokeToolParamsKwargUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ToolRuntimeInvokeToolParamsKwargUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - type ToolRuntimeListToolsParams struct { - // (Optional) OAuth access token for authenticating with the MCP server. Authorization param.Opt[string] `query:"authorization,omitzero" json:"-"` - // The ID of the tool group to list tools for. - ToolGroupID param.Opt[string] `query:"tool_group_id,omitzero" json:"-"` - // The MCP endpoint to use for the tool group. + ToolGroupID param.Opt[string] `query:"tool_group_id,omitzero" json:"-"` + // A URL reference to external content. McpEndpoint ToolRuntimeListToolsParamsMcpEndpoint `query:"mcp_endpoint,omitzero" json:"-"` paramObj } @@ -401,11 +448,10 @@ func (r ToolRuntimeListToolsParams) URLQuery() (v url.Values, err error) { }) } -// The MCP endpoint to use for the tool group. +// A URL reference to external content. // // The property Uri is required. type ToolRuntimeListToolsParamsMcpEndpoint struct { - // The URL string pointing to the resource Uri string `query:"uri,required" json:"-"` paramObj } @@ -421,7 +467,6 @@ func (r ToolRuntimeListToolsParamsMcpEndpoint) URLQuery() (v url.Values, err err // Response containing a list of tool definitions. type ToolRuntimeListToolsResponseEnvelope struct { - // List of tool definitions Data []ToolDef `json:"data,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { diff --git a/toolruntime_test.go b/toolruntime_test.go index d183229..eef1fe0 100644 --- a/toolruntime_test.go +++ b/toolruntime_test.go @@ -31,10 +31,8 @@ func TestToolRuntimeInvokeToolWithOptionalParams(t *testing.T) { option.WithBaseURL(baseURL), ) _, err := client.ToolRuntime.InvokeTool(context.TODO(), llamastackclient.ToolRuntimeInvokeToolParams{ - Kwargs: map[string]llamastackclient.ToolRuntimeInvokeToolParamsKwargUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + Kwargs: map[string]any{ + "foo": "bar", }, ToolName: "tool_name", Authorization: llamastackclient.String("authorization"), diff --git a/toolruntimeragtool.go b/toolruntimeragtool.go deleted file mode 100644 index 1834df2..0000000 --- a/toolruntimeragtool.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Meta Platforms, Inc. and affiliates. -// All rights reserved. -// -// This source code is licensed under the terms described in the LICENSE file in -// the root directory of this source tree. -// -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package llamastackclient - -import ( - "github.com/llamastack/llama-stack-client-go/option" -) - -// ToolRuntimeRagToolService contains methods and other services that help with -// interacting with the llama-stack-client API. -// -// Note, unlike clients, this service does not read variables from the environment -// automatically. You should not instantiate this service directly, and instead use -// the [NewToolRuntimeRagToolService] method instead. -type ToolRuntimeRagToolService struct { - Options []option.RequestOption -} - -// NewToolRuntimeRagToolService generates a new service that applies the given -// options to each request. These options are applied after the parent client's -// options (if there is one), and before any request-specific options. -func NewToolRuntimeRagToolService(opts ...option.RequestOption) (r ToolRuntimeRagToolService) { - r = ToolRuntimeRagToolService{} - r.Options = opts - return -} diff --git a/usage_test.go b/usage_test.go index b4bd603..ce72ae7 100644 --- a/usage_test.go +++ b/usage_test.go @@ -29,11 +29,9 @@ func TestUsage(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - response, err := client.Models.Register(context.TODO(), llamastackclient.ModelRegisterParams{ - ModelID: "model_id", - }) + models, err := client.Models.List(context.TODO()) if err != nil { t.Fatalf("err should be nil: %s", err.Error()) } - t.Logf("%+v\n", response.Identifier) + t.Logf("%+v\n", models) } diff --git a/vectorio.go b/vectorio.go index 5b271d1..b61f961 100644 --- a/vectorio.go +++ b/vectorio.go @@ -59,10 +59,8 @@ func (r *VectorIoService) Query(ctx context.Context, body VectorIoQueryParams, o // Response from querying chunks in a vector database. type QueryChunksResponse struct { - // List of content chunks returned from the query Chunks []QueryChunksResponseChunk `json:"chunks,required"` - // Relevance scores corresponding to each returned chunk - Scores []float64 `json:"scores,required"` + Scores []float64 `json:"scores,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Chunks respjson.Field @@ -80,25 +78,25 @@ func (r *QueryChunksResponse) UnmarshalJSON(data []byte) error { // A chunk of content that can be inserted into a vector database. type QueryChunksResponseChunk struct { - // Unique identifier for the chunk. Must be provided explicitly. ChunkID string `json:"chunk_id,required"` - // The content of the chunk, which can be interleaved text, images, or other types. - Content InterleavedContentUnion `json:"content,required"` - // Metadata associated with the chunk that will be used in the model context during - // inference. - Metadata map[string]QueryChunksResponseChunkMetadataUnion `json:"metadata,required"` - // Metadata for the chunk that will NOT be used in the context during inference. - // The `chunk_metadata` is required backend functionality. - ChunkMetadata QueryChunksResponseChunkChunkMetadata `json:"chunk_metadata"` - // Optional embedding for the chunk. If not provided, it will be computed later. - Embedding []float64 `json:"embedding"` + // A image content item + Content QueryChunksResponseChunkContentUnion `json:"content,required"` + // `ChunkMetadata` is backend metadata for a `Chunk` that is used to store + // additional information about the chunk that will not be used in the context + // during inference, but is required for backend functionality. The `ChunkMetadata` + // is set during chunk creation in `MemoryToolRuntimeImpl().insert()`and is not + // expected to change after. Use `Chunk.metadata` for metadata that will be used in + // the context during inference. + ChunkMetadata QueryChunksResponseChunkChunkMetadata `json:"chunk_metadata,nullable"` + Embedding []float64 `json:"embedding,nullable"` + Metadata map[string]any `json:"metadata"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ChunkID respjson.Field Content respjson.Field - Metadata respjson.Field ChunkMetadata respjson.Field Embedding respjson.Field + Metadata respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -110,84 +108,329 @@ func (r *QueryChunksResponseChunk) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// QueryChunksResponseChunkMetadataUnion contains all possible properties and -// values from [bool], [float64], [string], [[]any]. +// QueryChunksResponseChunkContentUnion contains all possible properties and values +// from [string], [QueryChunksResponseChunkContentImageContentItemOutput], +// [QueryChunksResponseChunkContentTextContentItem], +// [[]QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemUnion]. // // Use the methods beginning with 'As' to cast the union to one of its variants. // // If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type QueryChunksResponseChunkMetadataUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` +// will be valid: OfString OfListImageContentItemOutputTextContentItem] +type QueryChunksResponseChunkContentUnion struct { // This field will be present if the value is a [string] instead of an object. OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string + // This field will be present if the value is a + // [[]QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemUnion] + // instead of an object. + OfListImageContentItemOutputTextContentItem []QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemUnion `json:",inline"` + // This field is from variant + // [QueryChunksResponseChunkContentImageContentItemOutput]. + Image QueryChunksResponseChunkContentImageContentItemOutputImage `json:"image"` + Type string `json:"type"` + // This field is from variant [QueryChunksResponseChunkContentTextContentItem]. + Text string `json:"text"` + JSON struct { + OfString respjson.Field + OfListImageContentItemOutputTextContentItem respjson.Field + Image respjson.Field + Type respjson.Field + Text respjson.Field + raw string } `json:"-"` } -func (u QueryChunksResponseChunkMetadataUnion) AsBool() (v bool) { +func (u QueryChunksResponseChunkContentUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u QueryChunksResponseChunkMetadataUnion) AsFloat() (v float64) { +func (u QueryChunksResponseChunkContentUnion) AsImageContentItemOutput() (v QueryChunksResponseChunkContentImageContentItemOutput) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u QueryChunksResponseChunkMetadataUnion) AsString() (v string) { +func (u QueryChunksResponseChunkContentUnion) AsTextContentItem() (v QueryChunksResponseChunkContentTextContentItem) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u QueryChunksResponseChunkMetadataUnion) AsAnyArray() (v []any) { +func (u QueryChunksResponseChunkContentUnion) AsListImageContentItemOutputTextContentItem() (v []QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u QueryChunksResponseChunkMetadataUnion) RawJSON() string { return u.JSON.raw } +func (u QueryChunksResponseChunkContentUnion) RawJSON() string { return u.JSON.raw } + +func (r *QueryChunksResponseChunkContentUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// A image content item +type QueryChunksResponseChunkContentImageContentItemOutput struct { + // A URL or a base64 encoded string + Image QueryChunksResponseChunkContentImageContentItemOutputImage `json:"image,required"` + // Any of "image". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Image respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r QueryChunksResponseChunkContentImageContentItemOutput) RawJSON() string { return r.JSON.raw } +func (r *QueryChunksResponseChunkContentImageContentItemOutput) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// A URL or a base64 encoded string +type QueryChunksResponseChunkContentImageContentItemOutputImage struct { + Data string `json:"data,nullable"` + // A URL reference to external content. + URL QueryChunksResponseChunkContentImageContentItemOutputImageURL `json:"url,nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Data respjson.Field + URL respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r QueryChunksResponseChunkContentImageContentItemOutputImage) RawJSON() string { + return r.JSON.raw +} +func (r *QueryChunksResponseChunkContentImageContentItemOutputImage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// A URL reference to external content. +type QueryChunksResponseChunkContentImageContentItemOutputImageURL struct { + Uri string `json:"uri,required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Uri respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r QueryChunksResponseChunkContentImageContentItemOutputImageURL) RawJSON() string { + return r.JSON.raw +} +func (r *QueryChunksResponseChunkContentImageContentItemOutputImageURL) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// A text content item +type QueryChunksResponseChunkContentTextContentItem struct { + Text string `json:"text,required"` + // Any of "text". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Text respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r QueryChunksResponseChunkContentTextContentItem) RawJSON() string { return r.JSON.raw } +func (r *QueryChunksResponseChunkContentTextContentItem) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemUnion +// contains all possible properties and values from +// [QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemImage], +// [QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemText]. +// +// Use the +// [QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemUnion.AsAny] +// method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemUnion struct { + // This field is from variant + // [QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemImage]. + Image QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemImageImage `json:"image"` + // Any of "image", "text". + Type string `json:"type"` + // This field is from variant + // [QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemText]. + Text string `json:"text"` + JSON struct { + Image respjson.Field + Type respjson.Field + Text respjson.Field + raw string + } `json:"-"` +} + +// anyQueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItem +// is implemented by each variant of +// [QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemUnion] +// to add type safety for the return type of +// [QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemUnion.AsAny] +type anyQueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItem interface { + implQueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemUnion() +} + +func (QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemImage) implQueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemUnion() { +} +func (QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemText) implQueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemUnion.AsAny().(type) { +// case llamastackclient.QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemImage: +// case llamastackclient.QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemText: +// default: +// fmt.Errorf("no variant present") +// } +func (u QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemUnion) AsAny() anyQueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItem { + switch u.Type { + case "image": + return u.AsImage() + case "text": + return u.AsText() + } + return nil +} + +func (u QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemUnion) AsImage() (v QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemImage) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemUnion) AsText() (v QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemText) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// A image content item +type QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemImage struct { + // A URL or a base64 encoded string + Image QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemImageImage `json:"image,required"` + // Any of "image". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Image respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemImage) RawJSON() string { + return r.JSON.raw +} +func (r *QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemImage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// A URL or a base64 encoded string +type QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemImageImage struct { + Data string `json:"data,nullable"` + // A URL reference to external content. + URL QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemImageImageURL `json:"url,nullable"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Data respjson.Field + URL respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemImageImage) RawJSON() string { + return r.JSON.raw +} +func (r *QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemImageImage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// A URL reference to external content. +type QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemImageImageURL struct { + Uri string `json:"uri,required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Uri respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemImageImageURL) RawJSON() string { + return r.JSON.raw +} +func (r *QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemImageImageURL) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// A text content item +type QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemText struct { + Text string `json:"text,required"` + // Any of "text". + Type string `json:"type"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Text respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} -func (r *QueryChunksResponseChunkMetadataUnion) UnmarshalJSON(data []byte) error { +// Returns the unmodified JSON received from the API +func (r QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemText) RawJSON() string { + return r.JSON.raw +} +func (r *QueryChunksResponseChunkContentListImageContentItemOutputTextContentItemItemText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Metadata for the chunk that will NOT be used in the context during inference. -// The `chunk_metadata` is required backend functionality. +// `ChunkMetadata` is backend metadata for a `Chunk` that is used to store +// additional information about the chunk that will not be used in the context +// during inference, but is required for backend functionality. The `ChunkMetadata` +// is set during chunk creation in `MemoryToolRuntimeImpl().insert()`and is not +// expected to change after. Use `Chunk.metadata` for metadata that will be used in +// the context during inference. type QueryChunksResponseChunkChunkMetadata struct { - // The dimension of the embedding vector for the chunk. - ChunkEmbeddingDimension int64 `json:"chunk_embedding_dimension"` - // The embedding model used to create the chunk's embedding. - ChunkEmbeddingModel string `json:"chunk_embedding_model"` - // The ID of the chunk. If not set, it will be generated based on the document ID - // and content. - ChunkID string `json:"chunk_id"` - // The tokenizer used to create the chunk. Default is Tiktoken. - ChunkTokenizer string `json:"chunk_tokenizer"` - // The window of the chunk, which can be used to group related chunks together. - ChunkWindow string `json:"chunk_window"` - // The number of tokens in the content of the chunk. - ContentTokenCount int64 `json:"content_token_count"` - // An optional timestamp indicating when the chunk was created. - CreatedTimestamp int64 `json:"created_timestamp"` - // The ID of the document this chunk belongs to. - DocumentID string `json:"document_id"` - // The number of tokens in the metadata of the chunk. - MetadataTokenCount int64 `json:"metadata_token_count"` - // The source of the content, such as a URL, file path, or other identifier. - Source string `json:"source"` - // An optional timestamp indicating when the chunk was last updated. - UpdatedTimestamp int64 `json:"updated_timestamp"` + ChunkEmbeddingDimension int64 `json:"chunk_embedding_dimension,nullable"` + ChunkEmbeddingModel string `json:"chunk_embedding_model,nullable"` + ChunkID string `json:"chunk_id,nullable"` + ChunkTokenizer string `json:"chunk_tokenizer,nullable"` + ChunkWindow string `json:"chunk_window,nullable"` + ContentTokenCount int64 `json:"content_token_count,nullable"` + CreatedTimestamp int64 `json:"created_timestamp,nullable"` + DocumentID string `json:"document_id,nullable"` + MetadataTokenCount int64 `json:"metadata_token_count,nullable"` + Source string `json:"source,nullable"` + UpdatedTimestamp int64 `json:"updated_timestamp,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ChunkEmbeddingDimension respjson.Field @@ -213,16 +456,9 @@ func (r *QueryChunksResponseChunkChunkMetadata) UnmarshalJSON(data []byte) error } type VectorIoInsertParams struct { - // The chunks to insert. Each `Chunk` should contain content which can be - // interleaved text, images, or other types. `metadata`: `dict[str, Any]` and - // `embedding`: `List[float]` are optional. If `metadata` is provided, you - // configure how Llama Stack formats the chunk during generation. If `embedding` is - // not provided, it will be computed later. - Chunks []VectorIoInsertParamsChunk `json:"chunks,omitzero,required"` - // The identifier of the vector database to insert the chunks into. - VectorStoreID string `json:"vector_store_id,required"` - // The time to live of the chunks. - TtlSeconds param.Opt[int64] `json:"ttl_seconds,omitzero"` + Chunks []VectorIoInsertParamsChunk `json:"chunks,omitzero,required"` + VectorStoreID string `json:"vector_store_id,required"` + TtlSeconds param.Opt[int64] `json:"ttl_seconds,omitzero"` paramObj } @@ -236,20 +472,20 @@ func (r *VectorIoInsertParams) UnmarshalJSON(data []byte) error { // A chunk of content that can be inserted into a vector database. // -// The properties ChunkID, Content, Metadata are required. +// The properties ChunkID, Content are required. type VectorIoInsertParamsChunk struct { - // Unique identifier for the chunk. Must be provided explicitly. ChunkID string `json:"chunk_id,required"` - // The content of the chunk, which can be interleaved text, images, or other types. - Content InterleavedContentUnionParam `json:"content,omitzero,required"` - // Metadata associated with the chunk that will be used in the model context during - // inference. - Metadata map[string]VectorIoInsertParamsChunkMetadataUnion `json:"metadata,omitzero,required"` - // Metadata for the chunk that will NOT be used in the context during inference. - // The `chunk_metadata` is required backend functionality. + // A image content item + Content VectorIoInsertParamsChunkContentUnion `json:"content,omitzero,required"` + // `ChunkMetadata` is backend metadata for a `Chunk` that is used to store + // additional information about the chunk that will not be used in the context + // during inference, but is required for backend functionality. The `ChunkMetadata` + // is set during chunk creation in `MemoryToolRuntimeImpl().insert()`and is not + // expected to change after. Use `Chunk.metadata` for metadata that will be used in + // the context during inference. ChunkMetadata VectorIoInsertParamsChunkChunkMetadata `json:"chunk_metadata,omitzero"` - // Optional embedding for the chunk. If not provided, it will be computed later. - Embedding []float64 `json:"embedding,omitzero"` + Embedding []float64 `json:"embedding,omitzero"` + Metadata map[string]any `json:"metadata,omitzero"` paramObj } @@ -264,60 +500,299 @@ func (r *VectorIoInsertParamsChunk) UnmarshalJSON(data []byte) error { // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. -type VectorIoInsertParamsChunkMetadataUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` +type VectorIoInsertParamsChunkContentUnion struct { + OfString param.Opt[string] `json:",omitzero,inline"` + OfImageContentItemInput *VectorIoInsertParamsChunkContentImageContentItemInput `json:",omitzero,inline"` + OfTextContentItem *VectorIoInsertParamsChunkContentTextContentItem `json:",omitzero,inline"` + OfListImageContentItemInputTextContentItem []VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemUnion `json:",omitzero,inline"` paramUnion } -func (u VectorIoInsertParamsChunkMetadataUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) +func (u VectorIoInsertParamsChunkContentUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfString, u.OfImageContentItemInput, u.OfTextContentItem, u.OfListImageContentItemInputTextContentItem) } -func (u *VectorIoInsertParamsChunkMetadataUnion) UnmarshalJSON(data []byte) error { +func (u *VectorIoInsertParamsChunkContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *VectorIoInsertParamsChunkMetadataUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { +func (u *VectorIoInsertParamsChunkContentUnion) asAny() any { + if !param.IsOmitted(u.OfString) { return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray + } else if !param.IsOmitted(u.OfImageContentItemInput) { + return u.OfImageContentItemInput + } else if !param.IsOmitted(u.OfTextContentItem) { + return u.OfTextContentItem + } else if !param.IsOmitted(u.OfListImageContentItemInputTextContentItem) { + return &u.OfListImageContentItemInputTextContentItem + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u VectorIoInsertParamsChunkContentUnion) GetImage() *VectorIoInsertParamsChunkContentImageContentItemInputImage { + if vt := u.OfImageContentItemInput; vt != nil { + return &vt.Image + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u VectorIoInsertParamsChunkContentUnion) GetText() *string { + if vt := u.OfTextContentItem; vt != nil { + return &vt.Text + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u VectorIoInsertParamsChunkContentUnion) GetType() *string { + if vt := u.OfImageContentItemInput; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfTextContentItem; vt != nil { + return (*string)(&vt.Type) + } + return nil +} + +// A image content item +// +// The property Image is required. +type VectorIoInsertParamsChunkContentImageContentItemInput struct { + // A URL or a base64 encoded string + Image VectorIoInsertParamsChunkContentImageContentItemInputImage `json:"image,omitzero,required"` + // Any of "image". + Type string `json:"type,omitzero"` + paramObj +} + +func (r VectorIoInsertParamsChunkContentImageContentItemInput) MarshalJSON() (data []byte, err error) { + type shadow VectorIoInsertParamsChunkContentImageContentItemInput + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *VectorIoInsertParamsChunkContentImageContentItemInput) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[VectorIoInsertParamsChunkContentImageContentItemInput]( + "type", "image", + ) +} + +// A URL or a base64 encoded string +type VectorIoInsertParamsChunkContentImageContentItemInputImage struct { + Data param.Opt[string] `json:"data,omitzero"` + // A URL reference to external content. + URL VectorIoInsertParamsChunkContentImageContentItemInputImageURL `json:"url,omitzero"` + paramObj +} + +func (r VectorIoInsertParamsChunkContentImageContentItemInputImage) MarshalJSON() (data []byte, err error) { + type shadow VectorIoInsertParamsChunkContentImageContentItemInputImage + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *VectorIoInsertParamsChunkContentImageContentItemInputImage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// A URL reference to external content. +// +// The property Uri is required. +type VectorIoInsertParamsChunkContentImageContentItemInputImageURL struct { + Uri string `json:"uri,required"` + paramObj +} + +func (r VectorIoInsertParamsChunkContentImageContentItemInputImageURL) MarshalJSON() (data []byte, err error) { + type shadow VectorIoInsertParamsChunkContentImageContentItemInputImageURL + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *VectorIoInsertParamsChunkContentImageContentItemInputImageURL) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// A text content item +// +// The property Text is required. +type VectorIoInsertParamsChunkContentTextContentItem struct { + Text string `json:"text,required"` + // Any of "text". + Type string `json:"type,omitzero"` + paramObj +} + +func (r VectorIoInsertParamsChunkContentTextContentItem) MarshalJSON() (data []byte, err error) { + type shadow VectorIoInsertParamsChunkContentTextContentItem + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *VectorIoInsertParamsChunkContentTextContentItem) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[VectorIoInsertParamsChunkContentTextContentItem]( + "type", "text", + ) +} + +// Only one field can be non-zero. +// +// Use [param.IsOmitted] to confirm if a field is set. +type VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemUnion struct { + OfImage *VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemImage `json:",omitzero,inline"` + OfText *VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemText `json:",omitzero,inline"` + paramUnion +} + +func (u VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfImage, u.OfText) +} +func (u *VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemUnion) asAny() any { + if !param.IsOmitted(u.OfImage) { + return u.OfImage + } else if !param.IsOmitted(u.OfText) { + return u.OfText + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemUnion) GetImage() *VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemImageImage { + if vt := u.OfImage; vt != nil { + return &vt.Image + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemUnion) GetText() *string { + if vt := u.OfText; vt != nil { + return &vt.Text + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemUnion) GetType() *string { + if vt := u.OfImage; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfText; vt != nil { + return (*string)(&vt.Type) } return nil } -// Metadata for the chunk that will NOT be used in the context during inference. -// The `chunk_metadata` is required backend functionality. +func init() { + apijson.RegisterUnion[VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemUnion]( + "type", + apijson.Discriminator[VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemImage]("image"), + apijson.Discriminator[VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemText]("text"), + ) +} + +// A image content item +// +// The property Image is required. +type VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemImage struct { + // A URL or a base64 encoded string + Image VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemImageImage `json:"image,omitzero,required"` + // Any of "image". + Type string `json:"type,omitzero"` + paramObj +} + +func (r VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemImage) MarshalJSON() (data []byte, err error) { + type shadow VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemImage + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemImage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemImage]( + "type", "image", + ) +} + +// A URL or a base64 encoded string +type VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemImageImage struct { + Data param.Opt[string] `json:"data,omitzero"` + // A URL reference to external content. + URL VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemImageImageURL `json:"url,omitzero"` + paramObj +} + +func (r VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemImageImage) MarshalJSON() (data []byte, err error) { + type shadow VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemImageImage + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemImageImage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// A URL reference to external content. +// +// The property Uri is required. +type VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemImageImageURL struct { + Uri string `json:"uri,required"` + paramObj +} + +func (r VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemImageImageURL) MarshalJSON() (data []byte, err error) { + type shadow VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemImageImageURL + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemImageImageURL) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// A text content item +// +// The property Text is required. +type VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemText struct { + Text string `json:"text,required"` + // Any of "text". + Type string `json:"type,omitzero"` + paramObj +} + +func (r VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemText) MarshalJSON() (data []byte, err error) { + type shadow VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemText + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemText) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[VectorIoInsertParamsChunkContentListImageContentItemInputTextContentItemItemText]( + "type", "text", + ) +} + +// `ChunkMetadata` is backend metadata for a `Chunk` that is used to store +// additional information about the chunk that will not be used in the context +// during inference, but is required for backend functionality. The `ChunkMetadata` +// is set during chunk creation in `MemoryToolRuntimeImpl().insert()`and is not +// expected to change after. Use `Chunk.metadata` for metadata that will be used in +// the context during inference. type VectorIoInsertParamsChunkChunkMetadata struct { - // The dimension of the embedding vector for the chunk. - ChunkEmbeddingDimension param.Opt[int64] `json:"chunk_embedding_dimension,omitzero"` - // The embedding model used to create the chunk's embedding. - ChunkEmbeddingModel param.Opt[string] `json:"chunk_embedding_model,omitzero"` - // The ID of the chunk. If not set, it will be generated based on the document ID - // and content. - ChunkID param.Opt[string] `json:"chunk_id,omitzero"` - // The tokenizer used to create the chunk. Default is Tiktoken. - ChunkTokenizer param.Opt[string] `json:"chunk_tokenizer,omitzero"` - // The window of the chunk, which can be used to group related chunks together. - ChunkWindow param.Opt[string] `json:"chunk_window,omitzero"` - // The number of tokens in the content of the chunk. - ContentTokenCount param.Opt[int64] `json:"content_token_count,omitzero"` - // An optional timestamp indicating when the chunk was created. - CreatedTimestamp param.Opt[int64] `json:"created_timestamp,omitzero"` - // The ID of the document this chunk belongs to. - DocumentID param.Opt[string] `json:"document_id,omitzero"` - // The number of tokens in the metadata of the chunk. - MetadataTokenCount param.Opt[int64] `json:"metadata_token_count,omitzero"` - // The source of the content, such as a URL, file path, or other identifier. - Source param.Opt[string] `json:"source,omitzero"` - // An optional timestamp indicating when the chunk was last updated. - UpdatedTimestamp param.Opt[int64] `json:"updated_timestamp,omitzero"` + ChunkEmbeddingDimension param.Opt[int64] `json:"chunk_embedding_dimension,omitzero"` + ChunkEmbeddingModel param.Opt[string] `json:"chunk_embedding_model,omitzero"` + ChunkID param.Opt[string] `json:"chunk_id,omitzero"` + ChunkTokenizer param.Opt[string] `json:"chunk_tokenizer,omitzero"` + ChunkWindow param.Opt[string] `json:"chunk_window,omitzero"` + ContentTokenCount param.Opt[int64] `json:"content_token_count,omitzero"` + CreatedTimestamp param.Opt[int64] `json:"created_timestamp,omitzero"` + DocumentID param.Opt[string] `json:"document_id,omitzero"` + MetadataTokenCount param.Opt[int64] `json:"metadata_token_count,omitzero"` + Source param.Opt[string] `json:"source,omitzero"` + UpdatedTimestamp param.Opt[int64] `json:"updated_timestamp,omitzero"` paramObj } @@ -330,12 +805,10 @@ func (r *VectorIoInsertParamsChunkChunkMetadata) UnmarshalJSON(data []byte) erro } type VectorIoQueryParams struct { - // The query to search for. - Query InterleavedContentUnionParam `json:"query,omitzero,required"` - // The identifier of the vector database to query. - VectorStoreID string `json:"vector_store_id,required"` - // The parameters of the query. - Params map[string]VectorIoQueryParamsParamUnion `json:"params,omitzero"` + // A image content item + Query VectorIoQueryParamsQueryUnion `json:"query,omitzero,required"` + VectorStoreID string `json:"vector_store_id,required"` + Params map[string]any `json:"params,omitzero"` paramObj } @@ -350,30 +823,277 @@ func (r *VectorIoQueryParams) UnmarshalJSON(data []byte) error { // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. -type VectorIoQueryParamsParamUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` +type VectorIoQueryParamsQueryUnion struct { + OfString param.Opt[string] `json:",omitzero,inline"` + OfImageContentItemInput *VectorIoQueryParamsQueryImageContentItemInput `json:",omitzero,inline"` + OfTextContentItem *VectorIoQueryParamsQueryTextContentItem `json:",omitzero,inline"` + OfListImageContentItemInputTextContentItem []VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemUnion `json:",omitzero,inline"` paramUnion } -func (u VectorIoQueryParamsParamUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) +func (u VectorIoQueryParamsQueryUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfString, u.OfImageContentItemInput, u.OfTextContentItem, u.OfListImageContentItemInputTextContentItem) } -func (u *VectorIoQueryParamsParamUnion) UnmarshalJSON(data []byte) error { +func (u *VectorIoQueryParamsQueryUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *VectorIoQueryParamsParamUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { +func (u *VectorIoQueryParamsQueryUnion) asAny() any { + if !param.IsOmitted(u.OfString) { return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray + } else if !param.IsOmitted(u.OfImageContentItemInput) { + return u.OfImageContentItemInput + } else if !param.IsOmitted(u.OfTextContentItem) { + return u.OfTextContentItem + } else if !param.IsOmitted(u.OfListImageContentItemInputTextContentItem) { + return &u.OfListImageContentItemInputTextContentItem + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u VectorIoQueryParamsQueryUnion) GetImage() *VectorIoQueryParamsQueryImageContentItemInputImage { + if vt := u.OfImageContentItemInput; vt != nil { + return &vt.Image + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u VectorIoQueryParamsQueryUnion) GetText() *string { + if vt := u.OfTextContentItem; vt != nil { + return &vt.Text + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u VectorIoQueryParamsQueryUnion) GetType() *string { + if vt := u.OfImageContentItemInput; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfTextContentItem; vt != nil { + return (*string)(&vt.Type) + } + return nil +} + +// A image content item +// +// The property Image is required. +type VectorIoQueryParamsQueryImageContentItemInput struct { + // A URL or a base64 encoded string + Image VectorIoQueryParamsQueryImageContentItemInputImage `json:"image,omitzero,required"` + // Any of "image". + Type string `json:"type,omitzero"` + paramObj +} + +func (r VectorIoQueryParamsQueryImageContentItemInput) MarshalJSON() (data []byte, err error) { + type shadow VectorIoQueryParamsQueryImageContentItemInput + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *VectorIoQueryParamsQueryImageContentItemInput) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[VectorIoQueryParamsQueryImageContentItemInput]( + "type", "image", + ) +} + +// A URL or a base64 encoded string +type VectorIoQueryParamsQueryImageContentItemInputImage struct { + Data param.Opt[string] `json:"data,omitzero"` + // A URL reference to external content. + URL VectorIoQueryParamsQueryImageContentItemInputImageURL `json:"url,omitzero"` + paramObj +} + +func (r VectorIoQueryParamsQueryImageContentItemInputImage) MarshalJSON() (data []byte, err error) { + type shadow VectorIoQueryParamsQueryImageContentItemInputImage + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *VectorIoQueryParamsQueryImageContentItemInputImage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// A URL reference to external content. +// +// The property Uri is required. +type VectorIoQueryParamsQueryImageContentItemInputImageURL struct { + Uri string `json:"uri,required"` + paramObj +} + +func (r VectorIoQueryParamsQueryImageContentItemInputImageURL) MarshalJSON() (data []byte, err error) { + type shadow VectorIoQueryParamsQueryImageContentItemInputImageURL + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *VectorIoQueryParamsQueryImageContentItemInputImageURL) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// A text content item +// +// The property Text is required. +type VectorIoQueryParamsQueryTextContentItem struct { + Text string `json:"text,required"` + // Any of "text". + Type string `json:"type,omitzero"` + paramObj +} + +func (r VectorIoQueryParamsQueryTextContentItem) MarshalJSON() (data []byte, err error) { + type shadow VectorIoQueryParamsQueryTextContentItem + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *VectorIoQueryParamsQueryTextContentItem) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[VectorIoQueryParamsQueryTextContentItem]( + "type", "text", + ) +} + +// Only one field can be non-zero. +// +// Use [param.IsOmitted] to confirm if a field is set. +type VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemUnion struct { + OfImage *VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemImage `json:",omitzero,inline"` + OfText *VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemText `json:",omitzero,inline"` + paramUnion +} + +func (u VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfImage, u.OfText) +} +func (u *VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemUnion) asAny() any { + if !param.IsOmitted(u.OfImage) { + return u.OfImage + } else if !param.IsOmitted(u.OfText) { + return u.OfText + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemUnion) GetImage() *VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemImageImage { + if vt := u.OfImage; vt != nil { + return &vt.Image + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemUnion) GetText() *string { + if vt := u.OfText; vt != nil { + return &vt.Text } return nil } + +// Returns a pointer to the underlying variant's property, if present. +func (u VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemUnion) GetType() *string { + if vt := u.OfImage; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfText; vt != nil { + return (*string)(&vt.Type) + } + return nil +} + +func init() { + apijson.RegisterUnion[VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemUnion]( + "type", + apijson.Discriminator[VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemImage]("image"), + apijson.Discriminator[VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemText]("text"), + ) +} + +// A image content item +// +// The property Image is required. +type VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemImage struct { + // A URL or a base64 encoded string + Image VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemImageImage `json:"image,omitzero,required"` + // Any of "image". + Type string `json:"type,omitzero"` + paramObj +} + +func (r VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemImage) MarshalJSON() (data []byte, err error) { + type shadow VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemImage + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemImage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemImage]( + "type", "image", + ) +} + +// A URL or a base64 encoded string +type VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemImageImage struct { + Data param.Opt[string] `json:"data,omitzero"` + // A URL reference to external content. + URL VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemImageImageURL `json:"url,omitzero"` + paramObj +} + +func (r VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemImageImage) MarshalJSON() (data []byte, err error) { + type shadow VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemImageImage + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemImageImage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// A URL reference to external content. +// +// The property Uri is required. +type VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemImageImageURL struct { + Uri string `json:"uri,required"` + paramObj +} + +func (r VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemImageImageURL) MarshalJSON() (data []byte, err error) { + type shadow VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemImageImageURL + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemImageImageURL) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// A text content item +// +// The property Text is required. +type VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemText struct { + Text string `json:"text,required"` + // Any of "text". + Type string `json:"type,omitzero"` + paramObj +} + +func (r VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemText) MarshalJSON() (data []byte, err error) { + type shadow VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemText + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemText) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[VectorIoQueryParamsQueryListImageContentItemInputTextContentItemItemText]( + "type", "text", + ) +} diff --git a/vectorio_test.go b/vectorio_test.go index 1c1973b..2026114 100644 --- a/vectorio_test.go +++ b/vectorio_test.go @@ -33,14 +33,9 @@ func TestVectorIoInsertWithOptionalParams(t *testing.T) { err := client.VectorIo.Insert(context.TODO(), llamastackclient.VectorIoInsertParams{ Chunks: []llamastackclient.VectorIoInsertParamsChunk{{ ChunkID: "chunk_id", - Content: llamastackclient.InterleavedContentUnionParam{ + Content: llamastackclient.VectorIoInsertParamsChunkContentUnion{ OfString: llamastackclient.String("string"), }, - Metadata: map[string]llamastackclient.VectorIoInsertParamsChunkMetadataUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, - }, ChunkMetadata: llamastackclient.VectorIoInsertParamsChunkChunkMetadata{ ChunkEmbeddingDimension: llamastackclient.Int(0), ChunkEmbeddingModel: llamastackclient.String("chunk_embedding_model"), @@ -55,6 +50,9 @@ func TestVectorIoInsertWithOptionalParams(t *testing.T) { UpdatedTimestamp: llamastackclient.Int(0), }, Embedding: []float64{0}, + Metadata: map[string]any{ + "foo": "bar", + }, }}, VectorStoreID: "vector_store_id", TtlSeconds: llamastackclient.Int(0), @@ -80,14 +78,12 @@ func TestVectorIoQueryWithOptionalParams(t *testing.T) { option.WithBaseURL(baseURL), ) _, err := client.VectorIo.Query(context.TODO(), llamastackclient.VectorIoQueryParams{ - Query: llamastackclient.InterleavedContentUnionParam{ + Query: llamastackclient.VectorIoQueryParamsQueryUnion{ OfString: llamastackclient.String("string"), }, VectorStoreID: "vector_store_id", - Params: map[string]llamastackclient.VectorIoQueryParamsParamUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + Params: map[string]any{ + "foo": "bar", }, }) if err != nil { diff --git a/vectorstore.go b/vectorstore.go index a621236..b5e97e0 100644 --- a/vectorstore.go +++ b/vectorstore.go @@ -50,8 +50,9 @@ func NewVectorStoreService(opts ...option.RequestOption) (r VectorStoreService) return } -// Creates a vector store. Generate an OpenAI-compatible vector store with the -// given parameters. +// Creates a vector store. +// +// Generate an OpenAI-compatible vector store with the given parameters. func (r *VectorStoreService) New(ctx context.Context, body VectorStoreNewParams, opts ...option.RequestOption) (res *VectorStore, err error) { opts = slices.Concat(r.Options, opts) path := "v1/vector_stores" @@ -118,8 +119,10 @@ func (r *VectorStoreService) Delete(ctx context.Context, vectorStoreID string, o return } -// Search for chunks in a vector store. Searches a vector store for relevant chunks -// based on a query and optional file attribute filters. +// Search for chunks in a vector store. +// +// Searches a vector store for relevant chunks based on a query and optional file +// attribute filters. func (r *VectorStoreService) Search(ctx context.Context, vectorStoreID string, body VectorStoreSearchParams, opts ...option.RequestOption) (res *VectorStoreSearchResponse, err error) { opts = slices.Concat(r.Options, opts) if vectorStoreID == "" { @@ -133,23 +136,18 @@ func (r *VectorStoreService) Search(ctx context.Context, vectorStoreID string, b // Response from listing vector stores. type ListVectorStoresResponse struct { - // List of vector store objects - Data []VectorStore `json:"data,required"` - // Whether there are more vector stores available beyond this page - HasMore bool `json:"has_more,required"` - // Object type identifier, always "list" - Object string `json:"object,required"` - // (Optional) ID of the first vector store in the list for pagination - FirstID string `json:"first_id"` - // (Optional) ID of the last vector store in the list for pagination - LastID string `json:"last_id"` + Data []VectorStore `json:"data,required"` + FirstID string `json:"first_id,nullable"` + HasMore bool `json:"has_more"` + LastID string `json:"last_id,nullable"` + Object string `json:"object"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Data respjson.Field - HasMore respjson.Field - Object respjson.Field FirstID respjson.Field + HasMore respjson.Field LastID respjson.Field + Object respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -163,41 +161,31 @@ func (r *ListVectorStoresResponse) UnmarshalJSON(data []byte) error { // OpenAI Vector Store object. type VectorStore struct { - // Unique identifier for the vector store - ID string `json:"id,required"` - // Timestamp when the vector store was created - CreatedAt int64 `json:"created_at,required"` - // File processing status counts for the vector store - FileCounts VectorStoreFileCounts `json:"file_counts,required"` - // Set of key-value pairs that can be attached to the vector store - Metadata map[string]VectorStoreMetadataUnion `json:"metadata,required"` - // Object type identifier, always "vector_store" - Object string `json:"object,required"` - // Current status of the vector store - Status string `json:"status,required"` - // Storage space used by the vector store in bytes - UsageBytes int64 `json:"usage_bytes,required"` - // (Optional) Expiration policy for the vector store - ExpiresAfter map[string]VectorStoreExpiresAfterUnion `json:"expires_after"` - // (Optional) Timestamp when the vector store will expire - ExpiresAt int64 `json:"expires_at"` - // (Optional) Timestamp of last activity on the vector store - LastActiveAt int64 `json:"last_active_at"` - // (Optional) Name of the vector store - Name string `json:"name"` + ID string `json:"id,required"` + CreatedAt int64 `json:"created_at,required"` + // File processing status counts for a vector store. + FileCounts VectorStoreFileCounts `json:"file_counts,required"` + ExpiresAfter map[string]any `json:"expires_after,nullable"` + ExpiresAt int64 `json:"expires_at,nullable"` + LastActiveAt int64 `json:"last_active_at,nullable"` + Metadata map[string]any `json:"metadata"` + Name string `json:"name,nullable"` + Object string `json:"object"` + Status string `json:"status"` + UsageBytes int64 `json:"usage_bytes"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field CreatedAt respjson.Field FileCounts respjson.Field - Metadata respjson.Field - Object respjson.Field - Status respjson.Field - UsageBytes respjson.Field ExpiresAfter respjson.Field ExpiresAt respjson.Field LastActiveAt respjson.Field + Metadata respjson.Field Name respjson.Field + Object respjson.Field + Status respjson.Field + UsageBytes respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -209,18 +197,13 @@ func (r *VectorStore) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// File processing status counts for the vector store +// File processing status counts for a vector store. type VectorStoreFileCounts struct { - // Number of files that had their processing cancelled - Cancelled int64 `json:"cancelled,required"` - // Number of files that have been successfully processed - Completed int64 `json:"completed,required"` - // Number of files that failed to process - Failed int64 `json:"failed,required"` - // Number of files currently being processed + Cancelled int64 `json:"cancelled,required"` + Completed int64 `json:"completed,required"` + Failed int64 `json:"failed,required"` InProgress int64 `json:"in_progress,required"` - // Total number of files in the vector store - Total int64 `json:"total,required"` + Total int64 `json:"total,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Cancelled respjson.Field @@ -239,118 +222,11 @@ func (r *VectorStoreFileCounts) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// VectorStoreMetadataUnion contains all possible properties and values from -// [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type VectorStoreMetadataUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u VectorStoreMetadataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u VectorStoreMetadataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u VectorStoreMetadataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u VectorStoreMetadataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u VectorStoreMetadataUnion) RawJSON() string { return u.JSON.raw } - -func (r *VectorStoreMetadataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// VectorStoreExpiresAfterUnion contains all possible properties and values from -// [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type VectorStoreExpiresAfterUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u VectorStoreExpiresAfterUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u VectorStoreExpiresAfterUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u VectorStoreExpiresAfterUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u VectorStoreExpiresAfterUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u VectorStoreExpiresAfterUnion) RawJSON() string { return u.JSON.raw } - -func (r *VectorStoreExpiresAfterUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - // Response from deleting a vector store. type VectorStoreDeleteResponse struct { - // Unique identifier of the deleted vector store - ID string `json:"id,required"` - // Whether the deletion operation was successful - Deleted bool `json:"deleted,required"` - // Object type identifier for the deletion response - Object string `json:"object,required"` + ID string `json:"id,required"` + Deleted bool `json:"deleted"` + Object string `json:"object"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -369,23 +245,18 @@ func (r *VectorStoreDeleteResponse) UnmarshalJSON(data []byte) error { // Paginated response from searching a vector store. type VectorStoreSearchResponse struct { - // List of search result objects - Data []VectorStoreSearchResponseData `json:"data,required"` - // Whether there are more results available beyond this page - HasMore bool `json:"has_more,required"` - // Object type identifier for the search results page - Object string `json:"object,required"` - // The original search query that was executed - SearchQuery []string `json:"search_query,required"` - // (Optional) Token for retrieving the next page of results - NextPage string `json:"next_page"` + Data []VectorStoreSearchResponseData `json:"data,required"` + SearchQuery []string `json:"search_query,required"` + HasMore bool `json:"has_more"` + NextPage string `json:"next_page,nullable"` + Object string `json:"object"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Data respjson.Field - HasMore respjson.Field - Object respjson.Field SearchQuery respjson.Field + HasMore respjson.Field NextPage respjson.Field + Object respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -399,16 +270,11 @@ func (r *VectorStoreSearchResponse) UnmarshalJSON(data []byte) error { // Response from searching a vector store. type VectorStoreSearchResponseData struct { - // List of content items matching the search query - Content []VectorStoreSearchResponseDataContent `json:"content,required"` - // Unique identifier of the file containing the result - FileID string `json:"file_id,required"` - // Name of the file containing the result - Filename string `json:"filename,required"` - // Relevance score for this search result - Score float64 `json:"score,required"` - // (Optional) Key-value attributes associated with the file - Attributes map[string]VectorStoreSearchResponseDataAttributeUnion `json:"attributes"` + Content []VectorStoreSearchResponseDataContent `json:"content,required"` + FileID string `json:"file_id,required"` + Filename string `json:"filename,required"` + Score float64 `json:"score,required"` + Attributes map[string]VectorStoreSearchResponseDataAttributeUnion `json:"attributes,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field @@ -429,16 +295,17 @@ func (r *VectorStoreSearchResponseData) UnmarshalJSON(data []byte) error { // Content item from a vector store file or search result. type VectorStoreSearchResponseDataContent struct { - // The actual text content - Text string `json:"text,required"` - // Content type, currently only "text" is supported + Text string `json:"text,required"` Type constant.Text `json:"type,required"` - // Optional chunk metadata - ChunkMetadata VectorStoreSearchResponseDataContentChunkMetadata `json:"chunk_metadata"` - // Optional embedding vector for this content chunk - Embedding []float64 `json:"embedding"` - // Optional user-defined metadata - Metadata map[string]VectorStoreSearchResponseDataContentMetadataUnion `json:"metadata"` + // `ChunkMetadata` is backend metadata for a `Chunk` that is used to store + // additional information about the chunk that will not be used in the context + // during inference, but is required for backend functionality. The `ChunkMetadata` + // is set during chunk creation in `MemoryToolRuntimeImpl().insert()`and is not + // expected to change after. Use `Chunk.metadata` for metadata that will be used in + // the context during inference. + ChunkMetadata VectorStoreSearchResponseDataContentChunkMetadata `json:"chunk_metadata,nullable"` + Embedding []float64 `json:"embedding,nullable"` + Metadata map[string]any `json:"metadata,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -457,31 +324,24 @@ func (r *VectorStoreSearchResponseDataContent) UnmarshalJSON(data []byte) error return apijson.UnmarshalRoot(data, r) } -// Optional chunk metadata +// `ChunkMetadata` is backend metadata for a `Chunk` that is used to store +// additional information about the chunk that will not be used in the context +// during inference, but is required for backend functionality. The `ChunkMetadata` +// is set during chunk creation in `MemoryToolRuntimeImpl().insert()`and is not +// expected to change after. Use `Chunk.metadata` for metadata that will be used in +// the context during inference. type VectorStoreSearchResponseDataContentChunkMetadata struct { - // The dimension of the embedding vector for the chunk. - ChunkEmbeddingDimension int64 `json:"chunk_embedding_dimension"` - // The embedding model used to create the chunk's embedding. - ChunkEmbeddingModel string `json:"chunk_embedding_model"` - // The ID of the chunk. If not set, it will be generated based on the document ID - // and content. - ChunkID string `json:"chunk_id"` - // The tokenizer used to create the chunk. Default is Tiktoken. - ChunkTokenizer string `json:"chunk_tokenizer"` - // The window of the chunk, which can be used to group related chunks together. - ChunkWindow string `json:"chunk_window"` - // The number of tokens in the content of the chunk. - ContentTokenCount int64 `json:"content_token_count"` - // An optional timestamp indicating when the chunk was created. - CreatedTimestamp int64 `json:"created_timestamp"` - // The ID of the document this chunk belongs to. - DocumentID string `json:"document_id"` - // The number of tokens in the metadata of the chunk. - MetadataTokenCount int64 `json:"metadata_token_count"` - // The source of the content, such as a URL, file path, or other identifier. - Source string `json:"source"` - // An optional timestamp indicating when the chunk was last updated. - UpdatedTimestamp int64 `json:"updated_timestamp"` + ChunkEmbeddingDimension int64 `json:"chunk_embedding_dimension,nullable"` + ChunkEmbeddingModel string `json:"chunk_embedding_model,nullable"` + ChunkID string `json:"chunk_id,nullable"` + ChunkTokenizer string `json:"chunk_tokenizer,nullable"` + ChunkWindow string `json:"chunk_window,nullable"` + ContentTokenCount int64 `json:"content_token_count,nullable"` + CreatedTimestamp int64 `json:"created_timestamp,nullable"` + DocumentID string `json:"document_id,nullable"` + MetadataTokenCount int64 `json:"metadata_token_count,nullable"` + Source string `json:"source,nullable"` + UpdatedTimestamp int64 `json:"updated_timestamp,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ChunkEmbeddingDimension respjson.Field @@ -506,58 +366,6 @@ func (r *VectorStoreSearchResponseDataContentChunkMetadata) UnmarshalJSON(data [ return apijson.UnmarshalRoot(data, r) } -// VectorStoreSearchResponseDataContentMetadataUnion contains all possible -// properties and values from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type VectorStoreSearchResponseDataContentMetadataUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u VectorStoreSearchResponseDataContentMetadataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u VectorStoreSearchResponseDataContentMetadataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u VectorStoreSearchResponseDataContentMetadataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u VectorStoreSearchResponseDataContentMetadataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u VectorStoreSearchResponseDataContentMetadataUnion) RawJSON() string { return u.JSON.raw } - -func (r *VectorStoreSearchResponseDataContentMetadataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - // VectorStoreSearchResponseDataAttributeUnion contains all possible properties and // values from [string], [float64], [bool]. // @@ -603,16 +411,12 @@ func (r *VectorStoreSearchResponseDataAttributeUnion) UnmarshalJSON(data []byte) } type VectorStoreNewParams struct { - // (Optional) A name for the vector store Name param.Opt[string] `json:"name,omitzero"` - // (Optional) Strategy for splitting files into chunks + // Automatic chunking strategy for vector store files. ChunkingStrategy VectorStoreNewParamsChunkingStrategyUnion `json:"chunking_strategy,omitzero"` - // (Optional) Expiration policy for the vector store - ExpiresAfter map[string]VectorStoreNewParamsExpiresAfterUnion `json:"expires_after,omitzero"` - // List of file IDs to include in the vector store - FileIDs []string `json:"file_ids,omitzero"` - // Set of key-value pairs that can be attached to the vector store - Metadata map[string]VectorStoreNewParamsMetadataUnion `json:"metadata,omitzero"` + ExpiresAfter map[string]any `json:"expires_after,omitzero"` + FileIDs []string `json:"file_ids,omitzero"` + Metadata map[string]any `json:"metadata,omitzero"` paramObj } @@ -675,19 +479,10 @@ func init() { ) } -func NewVectorStoreNewParamsChunkingStrategyAuto() VectorStoreNewParamsChunkingStrategyAuto { - return VectorStoreNewParamsChunkingStrategyAuto{ - Type: "auto", - } -} - // Automatic chunking strategy for vector store files. -// -// This struct has a constant value, construct it with -// [NewVectorStoreNewParamsChunkingStrategyAuto]. type VectorStoreNewParamsChunkingStrategyAuto struct { - // Strategy type, always "auto" for automatic chunking - Type constant.Auto `json:"type,required"` + // Any of "auto". + Type string `json:"type,omitzero"` paramObj } @@ -699,16 +494,20 @@ func (r *VectorStoreNewParamsChunkingStrategyAuto) UnmarshalJSON(data []byte) er return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[VectorStoreNewParamsChunkingStrategyAuto]( + "type", "auto", + ) +} + // Static chunking strategy with configurable parameters. // -// The properties Static, Type are required. +// The property Static is required. type VectorStoreNewParamsChunkingStrategyStatic struct { - // Configuration parameters for the static chunking strategy + // Configuration for static chunking strategy. Static VectorStoreNewParamsChunkingStrategyStaticStatic `json:"static,omitzero,required"` - // Strategy type, always "static" for static chunking - // - // This field can be elided, and will marshal its zero value as "static". - Type constant.Static `json:"type,required"` + // Any of "static". + Type string `json:"type,omitzero"` paramObj } @@ -720,14 +519,16 @@ func (r *VectorStoreNewParamsChunkingStrategyStatic) UnmarshalJSON(data []byte) return apijson.UnmarshalRoot(data, r) } -// Configuration parameters for the static chunking strategy -// -// The properties ChunkOverlapTokens, MaxChunkSizeTokens are required. +func init() { + apijson.RegisterFieldValidator[VectorStoreNewParamsChunkingStrategyStatic]( + "type", "static", + ) +} + +// Configuration for static chunking strategy. type VectorStoreNewParamsChunkingStrategyStaticStatic struct { - // Number of tokens to overlap between adjacent chunks - ChunkOverlapTokens int64 `json:"chunk_overlap_tokens,required"` - // Maximum number of tokens per chunk, must be between 100 and 4096 - MaxChunkSizeTokens int64 `json:"max_chunk_size_tokens,required"` + ChunkOverlapTokens param.Opt[int64] `json:"chunk_overlap_tokens,omitzero"` + MaxChunkSizeTokens param.Opt[int64] `json:"max_chunk_size_tokens,omitzero"` paramObj } @@ -739,75 +540,10 @@ func (r *VectorStoreNewParamsChunkingStrategyStaticStatic) UnmarshalJSON(data [] return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type VectorStoreNewParamsExpiresAfterUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u VectorStoreNewParamsExpiresAfterUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *VectorStoreNewParamsExpiresAfterUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *VectorStoreNewParamsExpiresAfterUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type VectorStoreNewParamsMetadataUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u VectorStoreNewParamsMetadataUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *VectorStoreNewParamsMetadataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *VectorStoreNewParamsMetadataUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - type VectorStoreUpdateParams struct { - // The name of the vector store. - Name param.Opt[string] `json:"name,omitzero"` - // The expiration policy for a vector store. - ExpiresAfter map[string]VectorStoreUpdateParamsExpiresAfterUnion `json:"expires_after,omitzero"` - // Set of 16 key-value pairs that can be attached to an object. - Metadata map[string]VectorStoreUpdateParamsMetadataUnion `json:"metadata,omitzero"` + Name param.Opt[string] `json:"name,omitzero"` + ExpiresAfter map[string]any `json:"expires_after,omitzero"` + Metadata map[string]any `json:"metadata,omitzero"` paramObj } @@ -819,81 +555,11 @@ func (r *VectorStoreUpdateParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type VectorStoreUpdateParamsExpiresAfterUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u VectorStoreUpdateParamsExpiresAfterUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *VectorStoreUpdateParamsExpiresAfterUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *VectorStoreUpdateParamsExpiresAfterUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type VectorStoreUpdateParamsMetadataUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u VectorStoreUpdateParamsMetadataUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *VectorStoreUpdateParamsMetadataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *VectorStoreUpdateParamsMetadataUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - type VectorStoreListParams struct { - // A cursor for use in pagination. `after` is an object ID that defines your place - // in the list. - After param.Opt[string] `query:"after,omitzero" json:"-"` - // A cursor for use in pagination. `before` is an object ID that defines your place - // in the list. + After param.Opt[string] `query:"after,omitzero" json:"-"` Before param.Opt[string] `query:"before,omitzero" json:"-"` - // A limit on the number of objects to be returned. Limit can range between 1 and - // 100, and the default is 20. - Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` - // Sort order by the `created_at` timestamp of the objects. `asc` for ascending - // order and `desc` for descending order. - Order param.Opt[string] `query:"order,omitzero" json:"-"` + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + Order param.Opt[string] `query:"order,omitzero" json:"-"` paramObj } @@ -906,17 +572,12 @@ func (r VectorStoreListParams) URLQuery() (v url.Values, err error) { } type VectorStoreSearchParams struct { - // The query string or array for performing the search. - Query VectorStoreSearchParamsQueryUnion `json:"query,omitzero,required"` - // Maximum number of results to return (1 to 50 inclusive, default 10). - MaxNumResults param.Opt[int64] `json:"max_num_results,omitzero"` - // Whether to rewrite the natural language query for vector search (default false) - RewriteQuery param.Opt[bool] `json:"rewrite_query,omitzero"` - // The search mode to use - "keyword", "vector", or "hybrid" (default "vector") - SearchMode param.Opt[string] `json:"search_mode,omitzero"` - // Filters based on file attributes to narrow the search results. - Filters map[string]VectorStoreSearchParamsFilterUnion `json:"filters,omitzero"` - // Ranking options for fine-tuning the search results. + Query VectorStoreSearchParamsQueryUnion `json:"query,omitzero,required"` + MaxNumResults param.Opt[int64] `json:"max_num_results,omitzero"` + RewriteQuery param.Opt[bool] `json:"rewrite_query,omitzero"` + SearchMode param.Opt[string] `json:"search_mode,omitzero"` + Filters map[string]any `json:"filters,omitzero"` + // Options for ranking and filtering search results. RankingOptions VectorStoreSearchParamsRankingOptions `json:"ranking_options,omitzero"` paramObj } @@ -933,13 +594,13 @@ func (r *VectorStoreSearchParams) UnmarshalJSON(data []byte) error { // // Use [param.IsOmitted] to confirm if a field is set. type VectorStoreSearchParamsQueryUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfStringArray []string `json:",omitzero,inline"` + OfString param.Opt[string] `json:",omitzero,inline"` + OfListString []string `json:",omitzero,inline"` paramUnion } func (u VectorStoreSearchParamsQueryUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfStringArray) + return param.MarshalUnion(u, u.OfString, u.OfListString) } func (u *VectorStoreSearchParamsQueryUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) @@ -948,48 +609,15 @@ func (u *VectorStoreSearchParamsQueryUnion) UnmarshalJSON(data []byte) error { func (u *VectorStoreSearchParamsQueryUnion) asAny() any { if !param.IsOmitted(u.OfString) { return &u.OfString.Value - } else if !param.IsOmitted(u.OfStringArray) { - return &u.OfStringArray - } - return nil -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type VectorStoreSearchParamsFilterUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u VectorStoreSearchParamsFilterUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *VectorStoreSearchParamsFilterUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *VectorStoreSearchParamsFilterUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray + } else if !param.IsOmitted(u.OfListString) { + return &u.OfListString } return nil } -// Ranking options for fine-tuning the search results. +// Options for ranking and filtering search results. type VectorStoreSearchParamsRankingOptions struct { - // (Optional) Name of the ranking algorithm to use - Ranker param.Opt[string] `json:"ranker,omitzero"` - // (Optional) Minimum relevance score threshold for results + Ranker param.Opt[string] `json:"ranker,omitzero"` ScoreThreshold param.Opt[float64] `json:"score_threshold,omitzero"` paramObj } diff --git a/vectorstore_test.go b/vectorstore_test.go index 6872e9a..359fc87 100644 --- a/vectorstore_test.go +++ b/vectorstore_test.go @@ -32,18 +32,16 @@ func TestVectorStoreNewWithOptionalParams(t *testing.T) { ) _, err := client.VectorStores.New(context.TODO(), llamastackclient.VectorStoreNewParams{ ChunkingStrategy: llamastackclient.VectorStoreNewParamsChunkingStrategyUnion{ - OfAuto: &llamastackclient.VectorStoreNewParamsChunkingStrategyAuto{}, - }, - ExpiresAfter: map[string]llamastackclient.VectorStoreNewParamsExpiresAfterUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), + OfAuto: &llamastackclient.VectorStoreNewParamsChunkingStrategyAuto{ + Type: "auto", }, }, + ExpiresAfter: map[string]any{ + "foo": "bar", + }, FileIDs: []string{"string"}, - Metadata: map[string]llamastackclient.VectorStoreNewParamsMetadataUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + Metadata: map[string]any{ + "foo": "bar", }, Name: llamastackclient.String("name"), }) @@ -92,15 +90,11 @@ func TestVectorStoreUpdateWithOptionalParams(t *testing.T) { context.TODO(), "vector_store_id", llamastackclient.VectorStoreUpdateParams{ - ExpiresAfter: map[string]llamastackclient.VectorStoreUpdateParamsExpiresAfterUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + ExpiresAfter: map[string]any{ + "foo": "bar", }, - Metadata: map[string]llamastackclient.VectorStoreUpdateParamsMetadataUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + Metadata: map[string]any{ + "foo": "bar", }, Name: llamastackclient.String("name"), }, @@ -179,10 +173,8 @@ func TestVectorStoreSearchWithOptionalParams(t *testing.T) { Query: llamastackclient.VectorStoreSearchParamsQueryUnion{ OfString: llamastackclient.String("string"), }, - Filters: map[string]llamastackclient.VectorStoreSearchParamsFilterUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + Filters: map[string]any{ + "foo": "bar", }, MaxNumResults: llamastackclient.Int(0), RankingOptions: llamastackclient.VectorStoreSearchParamsRankingOptions{ diff --git a/vectorstorefile.go b/vectorstorefile.go index c716302..ce82d4b 100644 --- a/vectorstorefile.go +++ b/vectorstorefile.go @@ -151,37 +151,29 @@ func (r *VectorStoreFileService) Content(ctx context.Context, fileID string, par // OpenAI Vector Store File object. type VectorStoreFile struct { - // Unique identifier for the file ID string `json:"id,required"` - // Key-value attributes associated with the file - Attributes map[string]VectorStoreFileAttributeUnion `json:"attributes,required"` - // Strategy used for splitting the file into chunks + // Automatic chunking strategy for vector store files. ChunkingStrategy VectorStoreFileChunkingStrategyUnion `json:"chunking_strategy,required"` - // Timestamp when the file was added to the vector store - CreatedAt int64 `json:"created_at,required"` - // Object type identifier, always "vector_store.file" - Object string `json:"object,required"` - // Current processing status of the file - // + CreatedAt int64 `json:"created_at,required"` // Any of "completed", "in_progress", "cancelled", "failed". - Status VectorStoreFileStatus `json:"status,required"` - // Storage space used by this file in bytes - UsageBytes int64 `json:"usage_bytes,required"` - // ID of the vector store containing this file - VectorStoreID string `json:"vector_store_id,required"` - // (Optional) Error information if file processing failed - LastError VectorStoreFileLastError `json:"last_error"` + Status VectorStoreFileStatus `json:"status,required"` + VectorStoreID string `json:"vector_store_id,required"` + Attributes map[string]any `json:"attributes"` + // Error information for failed vector store file processing. + LastError VectorStoreFileLastError `json:"last_error,nullable"` + Object string `json:"object"` + UsageBytes int64 `json:"usage_bytes"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field - Attributes respjson.Field ChunkingStrategy respjson.Field CreatedAt respjson.Field - Object respjson.Field Status respjson.Field - UsageBytes respjson.Field VectorStoreID respjson.Field + Attributes respjson.Field LastError respjson.Field + Object respjson.Field + UsageBytes respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -193,58 +185,6 @@ func (r *VectorStoreFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// VectorStoreFileAttributeUnion contains all possible properties and values from -// [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type VectorStoreFileAttributeUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u VectorStoreFileAttributeUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u VectorStoreFileAttributeUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u VectorStoreFileAttributeUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u VectorStoreFileAttributeUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u VectorStoreFileAttributeUnion) RawJSON() string { return u.JSON.raw } - -func (r *VectorStoreFileAttributeUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - // VectorStoreFileChunkingStrategyUnion contains all possible properties and values // from [VectorStoreFileChunkingStrategyAuto], // [VectorStoreFileChunkingStrategyStatic]. @@ -312,8 +252,8 @@ func (r *VectorStoreFileChunkingStrategyUnion) UnmarshalJSON(data []byte) error // Automatic chunking strategy for vector store files. type VectorStoreFileChunkingStrategyAuto struct { - // Strategy type, always "auto" for automatic chunking - Type constant.Auto `json:"type,required"` + // Any of "auto". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Type respjson.Field @@ -330,10 +270,10 @@ func (r *VectorStoreFileChunkingStrategyAuto) UnmarshalJSON(data []byte) error { // Static chunking strategy with configurable parameters. type VectorStoreFileChunkingStrategyStatic struct { - // Configuration parameters for the static chunking strategy + // Configuration for static chunking strategy. Static VectorStoreFileChunkingStrategyStaticStatic `json:"static,required"` - // Strategy type, always "static" for static chunking - Type constant.Static `json:"type,required"` + // Any of "static". + Type string `json:"type"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Static respjson.Field @@ -349,12 +289,10 @@ func (r *VectorStoreFileChunkingStrategyStatic) UnmarshalJSON(data []byte) error return apijson.UnmarshalRoot(data, r) } -// Configuration parameters for the static chunking strategy +// Configuration for static chunking strategy. type VectorStoreFileChunkingStrategyStaticStatic struct { - // Number of tokens to overlap between adjacent chunks - ChunkOverlapTokens int64 `json:"chunk_overlap_tokens,required"` - // Maximum number of tokens per chunk, must be between 100 and 4096 - MaxChunkSizeTokens int64 `json:"max_chunk_size_tokens,required"` + ChunkOverlapTokens int64 `json:"chunk_overlap_tokens"` + MaxChunkSizeTokens int64 `json:"max_chunk_size_tokens"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ChunkOverlapTokens respjson.Field @@ -370,7 +308,6 @@ func (r *VectorStoreFileChunkingStrategyStaticStatic) UnmarshalJSON(data []byte) return apijson.UnmarshalRoot(data, r) } -// Current processing status of the file type VectorStoreFileStatus string const ( @@ -380,13 +317,10 @@ const ( VectorStoreFileStatusFailed VectorStoreFileStatus = "failed" ) -// (Optional) Error information if file processing failed +// Error information for failed vector store file processing. type VectorStoreFileLastError struct { - // Error code indicating the type of failure - // // Any of "server_error", "rate_limit_exceeded". - Code VectorStoreFileLastErrorCode `json:"code,required"` - // Human-readable error message describing the failure + Code string `json:"code,required"` Message string `json:"message,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { @@ -403,22 +337,11 @@ func (r *VectorStoreFileLastError) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Error code indicating the type of failure -type VectorStoreFileLastErrorCode string - -const ( - VectorStoreFileLastErrorCodeServerError VectorStoreFileLastErrorCode = "server_error" - VectorStoreFileLastErrorCodeRateLimitExceeded VectorStoreFileLastErrorCode = "rate_limit_exceeded" -) - // Response from deleting a vector store file. type VectorStoreFileDeleteResponse struct { - // Unique identifier of the deleted file - ID string `json:"id,required"` - // Whether the deletion operation was successful - Deleted bool `json:"deleted,required"` - // Object type identifier for the deletion response - Object string `json:"object,required"` + ID string `json:"id,required"` + Deleted bool `json:"deleted"` + Object string `json:"object"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -437,20 +360,17 @@ func (r *VectorStoreFileDeleteResponse) UnmarshalJSON(data []byte) error { // Represents the parsed content of a vector store file. type VectorStoreFileContentResponse struct { - // Parsed content of the file - Data []VectorStoreFileContentResponseData `json:"data,required"` - // Indicates if there are more content pages to fetch - HasMore bool `json:"has_more,required"` - // The object type, which is always `vector_store.file_content.page` - Object constant.VectorStoreFileContentPage `json:"object,required"` - // The token for the next page, if any - NextPage string `json:"next_page"` + Data []VectorStoreFileContentResponseData `json:"data,required"` + HasMore bool `json:"has_more"` + NextPage string `json:"next_page,nullable"` + // Any of "vector_store.file_content.page". + Object VectorStoreFileContentResponseObject `json:"object"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Data respjson.Field HasMore respjson.Field - Object respjson.Field NextPage respjson.Field + Object respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -464,16 +384,17 @@ func (r *VectorStoreFileContentResponse) UnmarshalJSON(data []byte) error { // Content item from a vector store file or search result. type VectorStoreFileContentResponseData struct { - // The actual text content - Text string `json:"text,required"` - // Content type, currently only "text" is supported + Text string `json:"text,required"` Type constant.Text `json:"type,required"` - // Optional chunk metadata - ChunkMetadata VectorStoreFileContentResponseDataChunkMetadata `json:"chunk_metadata"` - // Optional embedding vector for this content chunk - Embedding []float64 `json:"embedding"` - // Optional user-defined metadata - Metadata map[string]VectorStoreFileContentResponseDataMetadataUnion `json:"metadata"` + // `ChunkMetadata` is backend metadata for a `Chunk` that is used to store + // additional information about the chunk that will not be used in the context + // during inference, but is required for backend functionality. The `ChunkMetadata` + // is set during chunk creation in `MemoryToolRuntimeImpl().insert()`and is not + // expected to change after. Use `Chunk.metadata` for metadata that will be used in + // the context during inference. + ChunkMetadata VectorStoreFileContentResponseDataChunkMetadata `json:"chunk_metadata,nullable"` + Embedding []float64 `json:"embedding,nullable"` + Metadata map[string]any `json:"metadata,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Text respjson.Field @@ -492,31 +413,24 @@ func (r *VectorStoreFileContentResponseData) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Optional chunk metadata +// `ChunkMetadata` is backend metadata for a `Chunk` that is used to store +// additional information about the chunk that will not be used in the context +// during inference, but is required for backend functionality. The `ChunkMetadata` +// is set during chunk creation in `MemoryToolRuntimeImpl().insert()`and is not +// expected to change after. Use `Chunk.metadata` for metadata that will be used in +// the context during inference. type VectorStoreFileContentResponseDataChunkMetadata struct { - // The dimension of the embedding vector for the chunk. - ChunkEmbeddingDimension int64 `json:"chunk_embedding_dimension"` - // The embedding model used to create the chunk's embedding. - ChunkEmbeddingModel string `json:"chunk_embedding_model"` - // The ID of the chunk. If not set, it will be generated based on the document ID - // and content. - ChunkID string `json:"chunk_id"` - // The tokenizer used to create the chunk. Default is Tiktoken. - ChunkTokenizer string `json:"chunk_tokenizer"` - // The window of the chunk, which can be used to group related chunks together. - ChunkWindow string `json:"chunk_window"` - // The number of tokens in the content of the chunk. - ContentTokenCount int64 `json:"content_token_count"` - // An optional timestamp indicating when the chunk was created. - CreatedTimestamp int64 `json:"created_timestamp"` - // The ID of the document this chunk belongs to. - DocumentID string `json:"document_id"` - // The number of tokens in the metadata of the chunk. - MetadataTokenCount int64 `json:"metadata_token_count"` - // The source of the content, such as a URL, file path, or other identifier. - Source string `json:"source"` - // An optional timestamp indicating when the chunk was last updated. - UpdatedTimestamp int64 `json:"updated_timestamp"` + ChunkEmbeddingDimension int64 `json:"chunk_embedding_dimension,nullable"` + ChunkEmbeddingModel string `json:"chunk_embedding_model,nullable"` + ChunkID string `json:"chunk_id,nullable"` + ChunkTokenizer string `json:"chunk_tokenizer,nullable"` + ChunkWindow string `json:"chunk_window,nullable"` + ContentTokenCount int64 `json:"content_token_count,nullable"` + CreatedTimestamp int64 `json:"created_timestamp,nullable"` + DocumentID string `json:"document_id,nullable"` + MetadataTokenCount int64 `json:"metadata_token_count,nullable"` + Source string `json:"source,nullable"` + UpdatedTimestamp int64 `json:"updated_timestamp,nullable"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ChunkEmbeddingDimension respjson.Field @@ -541,64 +455,16 @@ func (r *VectorStoreFileContentResponseDataChunkMetadata) UnmarshalJSON(data []b return apijson.UnmarshalRoot(data, r) } -// VectorStoreFileContentResponseDataMetadataUnion contains all possible properties -// and values from [bool], [float64], [string], [[]any]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -// -// If the underlying value is not a json object, one of the following properties -// will be valid: OfBool OfFloat OfString OfAnyArray] -type VectorStoreFileContentResponseDataMetadataUnion struct { - // This field will be present if the value is a [bool] instead of an object. - OfBool bool `json:",inline"` - // This field will be present if the value is a [float64] instead of an object. - OfFloat float64 `json:",inline"` - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field will be present if the value is a [[]any] instead of an object. - OfAnyArray []any `json:",inline"` - JSON struct { - OfBool respjson.Field - OfFloat respjson.Field - OfString respjson.Field - OfAnyArray respjson.Field - raw string - } `json:"-"` -} - -func (u VectorStoreFileContentResponseDataMetadataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u VectorStoreFileContentResponseDataMetadataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u VectorStoreFileContentResponseDataMetadataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u VectorStoreFileContentResponseDataMetadataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} +type VectorStoreFileContentResponseObject string -// Returns the unmodified JSON received from the API -func (u VectorStoreFileContentResponseDataMetadataUnion) RawJSON() string { return u.JSON.raw } - -func (r *VectorStoreFileContentResponseDataMetadataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} +const ( + VectorStoreFileContentResponseObjectVectorStoreFileContentPage VectorStoreFileContentResponseObject = "vector_store.file_content.page" +) type VectorStoreFileNewParams struct { - // The ID of the file to attach to the vector store. - FileID string `json:"file_id,required"` - // The key-value attributes stored with the file, which can be used for filtering. - Attributes map[string]VectorStoreFileNewParamsAttributeUnion `json:"attributes,omitzero"` - // The chunking strategy to use for the file. + FileID string `json:"file_id,required"` + Attributes map[string]any `json:"attributes,omitzero"` + // Automatic chunking strategy for vector store files. ChunkingStrategy VectorStoreFileNewParamsChunkingStrategyUnion `json:"chunking_strategy,omitzero"` paramObj } @@ -611,37 +477,6 @@ func (r *VectorStoreFileNewParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type VectorStoreFileNewParamsAttributeUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u VectorStoreFileNewParamsAttributeUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *VectorStoreFileNewParamsAttributeUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *VectorStoreFileNewParamsAttributeUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. @@ -693,19 +528,10 @@ func init() { ) } -func NewVectorStoreFileNewParamsChunkingStrategyAuto() VectorStoreFileNewParamsChunkingStrategyAuto { - return VectorStoreFileNewParamsChunkingStrategyAuto{ - Type: "auto", - } -} - // Automatic chunking strategy for vector store files. -// -// This struct has a constant value, construct it with -// [NewVectorStoreFileNewParamsChunkingStrategyAuto]. type VectorStoreFileNewParamsChunkingStrategyAuto struct { - // Strategy type, always "auto" for automatic chunking - Type constant.Auto `json:"type,required"` + // Any of "auto". + Type string `json:"type,omitzero"` paramObj } @@ -717,16 +543,20 @@ func (r *VectorStoreFileNewParamsChunkingStrategyAuto) UnmarshalJSON(data []byte return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[VectorStoreFileNewParamsChunkingStrategyAuto]( + "type", "auto", + ) +} + // Static chunking strategy with configurable parameters. // -// The properties Static, Type are required. +// The property Static is required. type VectorStoreFileNewParamsChunkingStrategyStatic struct { - // Configuration parameters for the static chunking strategy + // Configuration for static chunking strategy. Static VectorStoreFileNewParamsChunkingStrategyStaticStatic `json:"static,omitzero,required"` - // Strategy type, always "static" for static chunking - // - // This field can be elided, and will marshal its zero value as "static". - Type constant.Static `json:"type,required"` + // Any of "static". + Type string `json:"type,omitzero"` paramObj } @@ -738,14 +568,16 @@ func (r *VectorStoreFileNewParamsChunkingStrategyStatic) UnmarshalJSON(data []by return apijson.UnmarshalRoot(data, r) } -// Configuration parameters for the static chunking strategy -// -// The properties ChunkOverlapTokens, MaxChunkSizeTokens are required. +func init() { + apijson.RegisterFieldValidator[VectorStoreFileNewParamsChunkingStrategyStatic]( + "type", "static", + ) +} + +// Configuration for static chunking strategy. type VectorStoreFileNewParamsChunkingStrategyStaticStatic struct { - // Number of tokens to overlap between adjacent chunks - ChunkOverlapTokens int64 `json:"chunk_overlap_tokens,required"` - // Maximum number of tokens per chunk, must be between 100 and 4096 - MaxChunkSizeTokens int64 `json:"max_chunk_size_tokens,required"` + ChunkOverlapTokens param.Opt[int64] `json:"chunk_overlap_tokens,omitzero"` + MaxChunkSizeTokens param.Opt[int64] `json:"max_chunk_size_tokens,omitzero"` paramObj } @@ -763,9 +595,8 @@ type VectorStoreFileGetParams struct { } type VectorStoreFileUpdateParams struct { - VectorStoreID string `path:"vector_store_id,required" json:"-"` - // The updated key-value attributes to store with the file. - Attributes map[string]VectorStoreFileUpdateParamsAttributeUnion `json:"attributes,omitzero,required"` + VectorStoreID string `path:"vector_store_id,required" json:"-"` + Attributes map[string]any `json:"attributes,omitzero,required"` paramObj } @@ -777,52 +608,11 @@ func (r *VectorStoreFileUpdateParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type VectorStoreFileUpdateParamsAttributeUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u VectorStoreFileUpdateParamsAttributeUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *VectorStoreFileUpdateParamsAttributeUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *VectorStoreFileUpdateParamsAttributeUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - type VectorStoreFileListParams struct { - // (Optional) A cursor for use in pagination. `after` is an object ID that defines - // your place in the list. - After param.Opt[string] `query:"after,omitzero" json:"-"` - // (Optional) A cursor for use in pagination. `before` is an object ID that defines - // your place in the list. + After param.Opt[string] `query:"after,omitzero" json:"-"` Before param.Opt[string] `query:"before,omitzero" json:"-"` - // (Optional) A limit on the number of objects to be returned. Limit can range - // between 1 and 100, and the default is 20. - Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` - // (Optional) Sort order by the `created_at` timestamp of the objects. `asc` for - // ascending order and `desc` for descending order. - Order param.Opt[string] `query:"order,omitzero" json:"-"` - // (Optional) Filter by file status to only return files with the specified status. - // + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + Order param.Opt[string] `query:"order,omitzero" json:"-"` // Any of "completed", "in_progress", "cancelled", "failed". Filter VectorStoreFileListParamsFilter `query:"filter,omitzero" json:"-"` paramObj @@ -837,7 +627,6 @@ func (r VectorStoreFileListParams) URLQuery() (v url.Values, err error) { }) } -// (Optional) Filter by file status to only return files with the specified status. type VectorStoreFileListParamsFilter string const ( @@ -853,11 +642,9 @@ type VectorStoreFileDeleteParams struct { } type VectorStoreFileContentParams struct { - VectorStoreID string `path:"vector_store_id,required" json:"-"` - // Whether to include embedding vectors in the response. + VectorStoreID string `path:"vector_store_id,required" json:"-"` IncludeEmbeddings param.Opt[bool] `query:"include_embeddings,omitzero" json:"-"` - // Whether to include chunk metadata in the response. - IncludeMetadata param.Opt[bool] `query:"include_metadata,omitzero" json:"-"` + IncludeMetadata param.Opt[bool] `query:"include_metadata,omitzero" json:"-"` paramObj } diff --git a/vectorstorefile_test.go b/vectorstorefile_test.go index 7cc9a51..bb115fa 100644 --- a/vectorstorefile_test.go +++ b/vectorstorefile_test.go @@ -35,13 +35,13 @@ func TestVectorStoreFileNewWithOptionalParams(t *testing.T) { "vector_store_id", llamastackclient.VectorStoreFileNewParams{ FileID: "file_id", - Attributes: map[string]llamastackclient.VectorStoreFileNewParamsAttributeUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + Attributes: map[string]any{ + "foo": "bar", }, ChunkingStrategy: llamastackclient.VectorStoreFileNewParamsChunkingStrategyUnion{ - OfAuto: &llamastackclient.VectorStoreFileNewParamsChunkingStrategyAuto{}, + OfAuto: &llamastackclient.VectorStoreFileNewParamsChunkingStrategyAuto{ + Type: "auto", + }, }, }, ) @@ -97,10 +97,8 @@ func TestVectorStoreFileUpdate(t *testing.T) { "file_id", llamastackclient.VectorStoreFileUpdateParams{ VectorStoreID: "vector_store_id", - Attributes: map[string]llamastackclient.VectorStoreFileUpdateParamsAttributeUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + Attributes: map[string]any{ + "foo": "bar", }, }, ) diff --git a/vectorstorefilebatch.go b/vectorstorefilebatch.go index c736d48..a4bc04c 100644 --- a/vectorstorefilebatch.go +++ b/vectorstorefilebatch.go @@ -23,7 +23,6 @@ import ( "github.com/llamastack/llama-stack-client-go/packages/pagination" "github.com/llamastack/llama-stack-client-go/packages/param" "github.com/llamastack/llama-stack-client-go/packages/respjson" - "github.com/llamastack/llama-stack-client-go/shared/constant" ) // VectorStoreFileBatchService contains methods and other services that help with @@ -45,8 +44,10 @@ func NewVectorStoreFileBatchService(opts ...option.RequestOption) (r VectorStore return } -// Create a vector store file batch. Generate an OpenAI-compatible vector store -// file batch for the given vector store. +// Create a vector store file batch. +// +// Generate an OpenAI-compatible vector store file batch for the given vector +// store. func (r *VectorStoreFileBatchService) New(ctx context.Context, vectorStoreID string, body VectorStoreFileBatchNewParams, opts ...option.RequestOption) (res *VectorStoreFileBatches, err error) { opts = slices.Concat(r.Options, opts) if vectorStoreID == "" { @@ -123,23 +124,18 @@ func (r *VectorStoreFileBatchService) ListFilesAutoPaging(ctx context.Context, b // Response from listing files in a vector store file batch. type ListVectorStoreFilesInBatchResponse struct { - // List of vector store file objects in the batch - Data []VectorStoreFile `json:"data,required"` - // Whether there are more files available beyond this page - HasMore bool `json:"has_more,required"` - // Object type identifier, always "list" - Object string `json:"object,required"` - // (Optional) ID of the first file in the list for pagination - FirstID string `json:"first_id"` - // (Optional) ID of the last file in the list for pagination - LastID string `json:"last_id"` + Data []VectorStoreFile `json:"data,required"` + FirstID string `json:"first_id,nullable"` + HasMore bool `json:"has_more"` + LastID string `json:"last_id,nullable"` + Object string `json:"object"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Data respjson.Field - HasMore respjson.Field - Object respjson.Field FirstID respjson.Field + HasMore respjson.Field LastID respjson.Field + Object respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -153,28 +149,22 @@ func (r *ListVectorStoreFilesInBatchResponse) UnmarshalJSON(data []byte) error { // OpenAI Vector Store File Batch object. type VectorStoreFileBatches struct { - // Unique identifier for the file batch - ID string `json:"id,required"` - // Timestamp when the file batch was created - CreatedAt int64 `json:"created_at,required"` - // File processing status counts for the batch + ID string `json:"id,required"` + CreatedAt int64 `json:"created_at,required"` + // File processing status counts for a vector store. FileCounts VectorStoreFileBatchesFileCounts `json:"file_counts,required"` - // Object type identifier, always "vector_store.file_batch" - Object string `json:"object,required"` - // Current processing status of the file batch - // // Any of "completed", "in_progress", "cancelled", "failed". - Status VectorStoreFileBatchesStatus `json:"status,required"` - // ID of the vector store containing the file batch - VectorStoreID string `json:"vector_store_id,required"` + Status VectorStoreFileBatchesStatus `json:"status,required"` + VectorStoreID string `json:"vector_store_id,required"` + Object string `json:"object"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field CreatedAt respjson.Field FileCounts respjson.Field - Object respjson.Field Status respjson.Field VectorStoreID respjson.Field + Object respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -186,18 +176,13 @@ func (r *VectorStoreFileBatches) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// File processing status counts for the batch +// File processing status counts for a vector store. type VectorStoreFileBatchesFileCounts struct { - // Number of files that had their processing cancelled - Cancelled int64 `json:"cancelled,required"` - // Number of files that have been successfully processed - Completed int64 `json:"completed,required"` - // Number of files that failed to process - Failed int64 `json:"failed,required"` - // Number of files currently being processed + Cancelled int64 `json:"cancelled,required"` + Completed int64 `json:"completed,required"` + Failed int64 `json:"failed,required"` InProgress int64 `json:"in_progress,required"` - // Total number of files in the vector store - Total int64 `json:"total,required"` + Total int64 `json:"total,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Cancelled respjson.Field @@ -216,7 +201,6 @@ func (r *VectorStoreFileBatchesFileCounts) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Current processing status of the file batch type VectorStoreFileBatchesStatus string const ( @@ -227,11 +211,9 @@ const ( ) type VectorStoreFileBatchNewParams struct { - // A list of File IDs that the vector store should use - FileIDs []string `json:"file_ids,omitzero,required"` - // (Optional) Key-value attributes to store with the files - Attributes map[string]VectorStoreFileBatchNewParamsAttributeUnion `json:"attributes,omitzero"` - // (Optional) The chunking strategy used to chunk the file(s). Defaults to auto + FileIDs []string `json:"file_ids,omitzero,required"` + Attributes map[string]any `json:"attributes,omitzero"` + // Automatic chunking strategy for vector store files. ChunkingStrategy VectorStoreFileBatchNewParamsChunkingStrategyUnion `json:"chunking_strategy,omitzero"` paramObj } @@ -244,37 +226,6 @@ func (r *VectorStoreFileBatchNewParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type VectorStoreFileBatchNewParamsAttributeUnion struct { - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfString param.Opt[string] `json:",omitzero,inline"` - OfAnyArray []any `json:",omitzero,inline"` - paramUnion -} - -func (u VectorStoreFileBatchNewParamsAttributeUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *VectorStoreFileBatchNewParamsAttributeUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *VectorStoreFileBatchNewParamsAttributeUnion) asAny() any { - if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAnyArray) { - return &u.OfAnyArray - } - return nil -} - // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. @@ -326,19 +277,10 @@ func init() { ) } -func NewVectorStoreFileBatchNewParamsChunkingStrategyAuto() VectorStoreFileBatchNewParamsChunkingStrategyAuto { - return VectorStoreFileBatchNewParamsChunkingStrategyAuto{ - Type: "auto", - } -} - // Automatic chunking strategy for vector store files. -// -// This struct has a constant value, construct it with -// [NewVectorStoreFileBatchNewParamsChunkingStrategyAuto]. type VectorStoreFileBatchNewParamsChunkingStrategyAuto struct { - // Strategy type, always "auto" for automatic chunking - Type constant.Auto `json:"type,required"` + // Any of "auto". + Type string `json:"type,omitzero"` paramObj } @@ -350,16 +292,20 @@ func (r *VectorStoreFileBatchNewParamsChunkingStrategyAuto) UnmarshalJSON(data [ return apijson.UnmarshalRoot(data, r) } +func init() { + apijson.RegisterFieldValidator[VectorStoreFileBatchNewParamsChunkingStrategyAuto]( + "type", "auto", + ) +} + // Static chunking strategy with configurable parameters. // -// The properties Static, Type are required. +// The property Static is required. type VectorStoreFileBatchNewParamsChunkingStrategyStatic struct { - // Configuration parameters for the static chunking strategy + // Configuration for static chunking strategy. Static VectorStoreFileBatchNewParamsChunkingStrategyStaticStatic `json:"static,omitzero,required"` - // Strategy type, always "static" for static chunking - // - // This field can be elided, and will marshal its zero value as "static". - Type constant.Static `json:"type,required"` + // Any of "static". + Type string `json:"type,omitzero"` paramObj } @@ -371,14 +317,16 @@ func (r *VectorStoreFileBatchNewParamsChunkingStrategyStatic) UnmarshalJSON(data return apijson.UnmarshalRoot(data, r) } -// Configuration parameters for the static chunking strategy -// -// The properties ChunkOverlapTokens, MaxChunkSizeTokens are required. +func init() { + apijson.RegisterFieldValidator[VectorStoreFileBatchNewParamsChunkingStrategyStatic]( + "type", "static", + ) +} + +// Configuration for static chunking strategy. type VectorStoreFileBatchNewParamsChunkingStrategyStaticStatic struct { - // Number of tokens to overlap between adjacent chunks - ChunkOverlapTokens int64 `json:"chunk_overlap_tokens,required"` - // Maximum number of tokens per chunk, must be between 100 and 4096 - MaxChunkSizeTokens int64 `json:"max_chunk_size_tokens,required"` + ChunkOverlapTokens param.Opt[int64] `json:"chunk_overlap_tokens,omitzero"` + MaxChunkSizeTokens param.Opt[int64] `json:"max_chunk_size_tokens,omitzero"` paramObj } @@ -401,21 +349,12 @@ type VectorStoreFileBatchCancelParams struct { } type VectorStoreFileBatchListFilesParams struct { - VectorStoreID string `path:"vector_store_id,required" json:"-"` - // A cursor for use in pagination. `after` is an object ID that defines your place - // in the list. - After param.Opt[string] `query:"after,omitzero" json:"-"` - // A cursor for use in pagination. `before` is an object ID that defines your place - // in the list. - Before param.Opt[string] `query:"before,omitzero" json:"-"` - // Filter by file status. One of in_progress, completed, failed, cancelled. - Filter param.Opt[string] `query:"filter,omitzero" json:"-"` - // A limit on the number of objects to be returned. Limit can range between 1 and - // 100, and the default is 20. - Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` - // Sort order by the `created_at` timestamp of the objects. `asc` for ascending - // order and `desc` for descending order. - Order param.Opt[string] `query:"order,omitzero" json:"-"` + VectorStoreID string `path:"vector_store_id,required" json:"-"` + After param.Opt[string] `query:"after,omitzero" json:"-"` + Before param.Opt[string] `query:"before,omitzero" json:"-"` + Filter param.Opt[string] `query:"filter,omitzero" json:"-"` + Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` + Order param.Opt[string] `query:"order,omitzero" json:"-"` paramObj } diff --git a/vectorstorefilebatch_test.go b/vectorstorefilebatch_test.go index a35cfc3..674db24 100644 --- a/vectorstorefilebatch_test.go +++ b/vectorstorefilebatch_test.go @@ -35,13 +35,13 @@ func TestVectorStoreFileBatchNewWithOptionalParams(t *testing.T) { "vector_store_id", llamastackclient.VectorStoreFileBatchNewParams{ FileIDs: []string{"string"}, - Attributes: map[string]llamastackclient.VectorStoreFileBatchNewParamsAttributeUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + Attributes: map[string]any{ + "foo": "bar", }, ChunkingStrategy: llamastackclient.VectorStoreFileBatchNewParamsChunkingStrategyUnion{ - OfAuto: &llamastackclient.VectorStoreFileBatchNewParamsChunkingStrategyAuto{}, + OfAuto: &llamastackclient.VectorStoreFileBatchNewParamsChunkingStrategyAuto{ + Type: "auto", + }, }, }, ) From 7da5f07a1b07166105173d8263b95b59e06735fd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 17 Nov 2025 19:37:00 +0000 Subject: [PATCH 2/7] fix(openapi): restore embedded request wrappers --- .stats.yml | 4 +- alphaeval.go | 16 +-- betadataset.go | 120 ++++++++++++++++++++++- betadataset_test.go | 15 ++- scoringfunction.go | 212 ++++++++++++++++++++++++++++++++++++++-- scoringfunction_test.go | 22 +++-- 6 files changed, 359 insertions(+), 30 deletions(-) diff --git a/.stats.yml b/.stats.yml index 253e4ba..db94672 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 103 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-2b99a80543f8bc8fa164167693c214651ac8e710f4726fb5869183b4d6c71a03.yml -openapi_spec_hash: a5632057f5e4d956a71c20a79c0d879c +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-aab1b331382f758fc255f765e73b62fedf463cf0748bc11b2b08974de9ac816a.yml +openapi_spec_hash: f717a21f47419aa51e4d9298aa68cc45 config_hash: 0017f6c419cbbf7b949f9b2842917a79 diff --git a/alphaeval.go b/alphaeval.go index 0a40f86..b2b2141 100644 --- a/alphaeval.go +++ b/alphaeval.go @@ -10,14 +10,12 @@ package llamastackclient import ( "context" - "encoding/json" "errors" "fmt" "net/http" "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" - shimjson "github.com/llamastack/llama-stack-client-go/internal/encoding/json" "github.com/llamastack/llama-stack-client-go/internal/requestconfig" "github.com/llamastack/llama-stack-client-go/option" "github.com/llamastack/llama-stack-client-go/packages/param" @@ -407,26 +405,28 @@ func (r *AlphaEvalEvaluateRowsAlphaParams) UnmarshalJSON(data []byte) error { type AlphaEvalRunEvalParams struct { // A benchmark configuration for evaluation. - BenchmarkConfig BenchmarkConfigParam + BenchmarkConfig BenchmarkConfigParam `json:"benchmark_config,omitzero,required"` paramObj } func (r AlphaEvalRunEvalParams) MarshalJSON() (data []byte, err error) { - return shimjson.Marshal(r.BenchmarkConfig) + type shadow AlphaEvalRunEvalParams + return param.MarshalObject(r, (*shadow)(&r)) } func (r *AlphaEvalRunEvalParams) UnmarshalJSON(data []byte) error { - return json.Unmarshal(data, &r.BenchmarkConfig) + return apijson.UnmarshalRoot(data, r) } type AlphaEvalRunEvalAlphaParams struct { // A benchmark configuration for evaluation. - BenchmarkConfig BenchmarkConfigParam + BenchmarkConfig BenchmarkConfigParam `json:"benchmark_config,omitzero,required"` paramObj } func (r AlphaEvalRunEvalAlphaParams) MarshalJSON() (data []byte, err error) { - return shimjson.Marshal(r.BenchmarkConfig) + type shadow AlphaEvalRunEvalAlphaParams + return param.MarshalObject(r, (*shadow)(&r)) } func (r *AlphaEvalRunEvalAlphaParams) UnmarshalJSON(data []byte) error { - return json.Unmarshal(data, &r.BenchmarkConfig) + return apijson.UnmarshalRoot(data, r) } diff --git a/betadataset.go b/betadataset.go index 6c6a986..7343e48 100644 --- a/betadataset.go +++ b/betadataset.go @@ -662,10 +662,14 @@ func (r BetaDatasetIterrowsParams) URLQuery() (v url.Values, err error) { } type BetaDatasetRegisterParams struct { - Purpose any `json:"purpose,omitzero,required"` - Source any `json:"source,omitzero,required"` - DatasetID any `json:"dataset_id,omitzero"` - Metadata any `json:"metadata,omitzero"` + // Purpose of the dataset. Each purpose has a required input data schema. + // + // Any of "post-training/messages", "eval/question-answer", "eval/messages-answer". + Purpose BetaDatasetRegisterParamsPurpose `json:"purpose,omitzero,required"` + // A dataset that can be obtained from a URI. + Source BetaDatasetRegisterParamsSourceUnion `json:"source,omitzero,required"` + DatasetID param.Opt[string] `json:"dataset_id,omitzero"` + Metadata map[string]any `json:"metadata,omitzero"` paramObj } @@ -676,3 +680,111 @@ func (r BetaDatasetRegisterParams) MarshalJSON() (data []byte, err error) { func (r *BetaDatasetRegisterParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } + +// Purpose of the dataset. Each purpose has a required input data schema. +type BetaDatasetRegisterParamsPurpose string + +const ( + BetaDatasetRegisterParamsPurposePostTrainingMessages BetaDatasetRegisterParamsPurpose = "post-training/messages" + BetaDatasetRegisterParamsPurposeEvalQuestionAnswer BetaDatasetRegisterParamsPurpose = "eval/question-answer" + BetaDatasetRegisterParamsPurposeEvalMessagesAnswer BetaDatasetRegisterParamsPurpose = "eval/messages-answer" +) + +// Only one field can be non-zero. +// +// Use [param.IsOmitted] to confirm if a field is set. +type BetaDatasetRegisterParamsSourceUnion struct { + OfUriDataSource *BetaDatasetRegisterParamsSourceUriDataSource `json:",omitzero,inline"` + OfRowsDataSource *BetaDatasetRegisterParamsSourceRowsDataSource `json:",omitzero,inline"` + paramUnion +} + +func (u BetaDatasetRegisterParamsSourceUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfUriDataSource, u.OfRowsDataSource) +} +func (u *BetaDatasetRegisterParamsSourceUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *BetaDatasetRegisterParamsSourceUnion) asAny() any { + if !param.IsOmitted(u.OfUriDataSource) { + return u.OfUriDataSource + } else if !param.IsOmitted(u.OfRowsDataSource) { + return u.OfRowsDataSource + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u BetaDatasetRegisterParamsSourceUnion) GetUri() *string { + if vt := u.OfUriDataSource; vt != nil { + return &vt.Uri + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u BetaDatasetRegisterParamsSourceUnion) GetRows() []map[string]any { + if vt := u.OfRowsDataSource; vt != nil { + return vt.Rows + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u BetaDatasetRegisterParamsSourceUnion) GetType() *string { + if vt := u.OfUriDataSource; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfRowsDataSource; vt != nil { + return (*string)(&vt.Type) + } + return nil +} + +// A dataset that can be obtained from a URI. +// +// The property Uri is required. +type BetaDatasetRegisterParamsSourceUriDataSource struct { + Uri string `json:"uri,required"` + // Any of "uri". + Type string `json:"type,omitzero"` + paramObj +} + +func (r BetaDatasetRegisterParamsSourceUriDataSource) MarshalJSON() (data []byte, err error) { + type shadow BetaDatasetRegisterParamsSourceUriDataSource + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *BetaDatasetRegisterParamsSourceUriDataSource) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[BetaDatasetRegisterParamsSourceUriDataSource]( + "type", "uri", + ) +} + +// A dataset stored in rows. +// +// The property Rows is required. +type BetaDatasetRegisterParamsSourceRowsDataSource struct { + Rows []map[string]any `json:"rows,omitzero,required"` + // Any of "rows". + Type string `json:"type,omitzero"` + paramObj +} + +func (r BetaDatasetRegisterParamsSourceRowsDataSource) MarshalJSON() (data []byte, err error) { + type shadow BetaDatasetRegisterParamsSourceRowsDataSource + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *BetaDatasetRegisterParamsSourceRowsDataSource) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[BetaDatasetRegisterParamsSourceRowsDataSource]( + "type", "rows", + ) +} diff --git a/betadataset_test.go b/betadataset_test.go index 1b1d119..d2723d3 100644 --- a/betadataset_test.go +++ b/betadataset_test.go @@ -130,10 +130,17 @@ func TestBetaDatasetRegisterWithOptionalParams(t *testing.T) { option.WithBaseURL(baseURL), ) _, err := client.Beta.Datasets.Register(context.TODO(), llamastackclient.BetaDatasetRegisterParams{ - Purpose: map[string]interface{}{}, - Source: map[string]interface{}{}, - DatasetID: map[string]interface{}{}, - Metadata: map[string]interface{}{}, + Purpose: llamastackclient.BetaDatasetRegisterParamsPurposePostTrainingMessages, + Source: llamastackclient.BetaDatasetRegisterParamsSourceUnion{ + OfUriDataSource: &llamastackclient.BetaDatasetRegisterParamsSourceUriDataSource{ + Uri: "uri", + Type: "uri", + }, + }, + DatasetID: llamastackclient.String("dataset_id"), + Metadata: map[string]any{ + "foo": "bar", + }, }) if err != nil { var apierr *llamastackclient.Error diff --git a/scoringfunction.go b/scoringfunction.go index f2aac5b..66ddc12 100644 --- a/scoringfunction.go +++ b/scoringfunction.go @@ -334,12 +334,13 @@ const ( ) type ScoringFunctionRegisterParams struct { - Description any `json:"description,omitzero,required"` - ReturnType any `json:"return_type,omitzero,required"` - ScoringFnID any `json:"scoring_fn_id,omitzero,required"` - Params any `json:"params,omitzero"` - ProviderID any `json:"provider_id,omitzero"` - ProviderScoringFnID any `json:"provider_scoring_fn_id,omitzero"` + Description string `json:"description,required"` + ReturnType ScoringFunctionRegisterParamsReturnType `json:"return_type,omitzero,required"` + ScoringFnID string `json:"scoring_fn_id,required"` + ProviderID param.Opt[string] `json:"provider_id,omitzero"` + ProviderScoringFnID param.Opt[string] `json:"provider_scoring_fn_id,omitzero"` + // Parameters for LLM-as-judge scoring function configuration. + Params ScoringFunctionRegisterParamsParamsUnion `json:"params,omitzero"` paramObj } @@ -350,3 +351,202 @@ func (r ScoringFunctionRegisterParams) MarshalJSON() (data []byte, err error) { func (r *ScoringFunctionRegisterParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } + +// The property Type is required. +type ScoringFunctionRegisterParamsReturnType struct { + // Any of "string", "number", "boolean", "array", "object", "json", "union", + // "chat_completion_input", "completion_input", "agent_turn_input". + Type string `json:"type,omitzero,required"` + paramObj +} + +func (r ScoringFunctionRegisterParamsReturnType) MarshalJSON() (data []byte, err error) { + type shadow ScoringFunctionRegisterParamsReturnType + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ScoringFunctionRegisterParamsReturnType) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ScoringFunctionRegisterParamsReturnType]( + "type", "string", "number", "boolean", "array", "object", "json", "union", "chat_completion_input", "completion_input", "agent_turn_input", + ) +} + +// Only one field can be non-zero. +// +// Use [param.IsOmitted] to confirm if a field is set. +type ScoringFunctionRegisterParamsParamsUnion struct { + OfLlmAsJudge *ScoringFunctionRegisterParamsParamsLlmAsJudge `json:",omitzero,inline"` + OfRegexParser *ScoringFunctionRegisterParamsParamsRegexParser `json:",omitzero,inline"` + OfBasic *ScoringFunctionRegisterParamsParamsBasic `json:",omitzero,inline"` + paramUnion +} + +func (u ScoringFunctionRegisterParamsParamsUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfLlmAsJudge, u.OfRegexParser, u.OfBasic) +} +func (u *ScoringFunctionRegisterParamsParamsUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *ScoringFunctionRegisterParamsParamsUnion) asAny() any { + if !param.IsOmitted(u.OfLlmAsJudge) { + return u.OfLlmAsJudge + } else if !param.IsOmitted(u.OfRegexParser) { + return u.OfRegexParser + } else if !param.IsOmitted(u.OfBasic) { + return u.OfBasic + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ScoringFunctionRegisterParamsParamsUnion) GetJudgeModel() *string { + if vt := u.OfLlmAsJudge; vt != nil { + return &vt.JudgeModel + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ScoringFunctionRegisterParamsParamsUnion) GetJudgeScoreRegexes() []string { + if vt := u.OfLlmAsJudge; vt != nil { + return vt.JudgeScoreRegexes + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ScoringFunctionRegisterParamsParamsUnion) GetPromptTemplate() *string { + if vt := u.OfLlmAsJudge; vt != nil && vt.PromptTemplate.Valid() { + return &vt.PromptTemplate.Value + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ScoringFunctionRegisterParamsParamsUnion) GetParsingRegexes() []string { + if vt := u.OfRegexParser; vt != nil { + return vt.ParsingRegexes + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ScoringFunctionRegisterParamsParamsUnion) GetType() *string { + if vt := u.OfLlmAsJudge; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfRegexParser; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfBasic; vt != nil { + return (*string)(&vt.Type) + } + return nil +} + +// Returns a pointer to the underlying variant's AggregationFunctions property, if +// present. +func (u ScoringFunctionRegisterParamsParamsUnion) GetAggregationFunctions() []string { + if vt := u.OfLlmAsJudge; vt != nil { + return vt.AggregationFunctions + } else if vt := u.OfRegexParser; vt != nil { + return vt.AggregationFunctions + } else if vt := u.OfBasic; vt != nil { + return vt.AggregationFunctions + } + return nil +} + +func init() { + apijson.RegisterUnion[ScoringFunctionRegisterParamsParamsUnion]( + "type", + apijson.Discriminator[ScoringFunctionRegisterParamsParamsLlmAsJudge]("llm_as_judge"), + apijson.Discriminator[ScoringFunctionRegisterParamsParamsRegexParser]("regex_parser"), + apijson.Discriminator[ScoringFunctionRegisterParamsParamsBasic]("basic"), + ) +} + +// Parameters for LLM-as-judge scoring function configuration. +// +// The property JudgeModel is required. +type ScoringFunctionRegisterParamsParamsLlmAsJudge struct { + JudgeModel string `json:"judge_model,required"` + PromptTemplate param.Opt[string] `json:"prompt_template,omitzero"` + // Aggregation functions to apply to the scores of each row + // + // Any of "average", "weighted_average", "median", "categorical_count", "accuracy". + AggregationFunctions []string `json:"aggregation_functions,omitzero"` + // Regexes to extract the answer from generated response + JudgeScoreRegexes []string `json:"judge_score_regexes,omitzero"` + // Any of "llm_as_judge". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ScoringFunctionRegisterParamsParamsLlmAsJudge) MarshalJSON() (data []byte, err error) { + type shadow ScoringFunctionRegisterParamsParamsLlmAsJudge + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ScoringFunctionRegisterParamsParamsLlmAsJudge) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ScoringFunctionRegisterParamsParamsLlmAsJudge]( + "type", "llm_as_judge", + ) +} + +// Parameters for regex parser scoring function configuration. +type ScoringFunctionRegisterParamsParamsRegexParser struct { + // Aggregation functions to apply to the scores of each row + // + // Any of "average", "weighted_average", "median", "categorical_count", "accuracy". + AggregationFunctions []string `json:"aggregation_functions,omitzero"` + // Regex to extract the answer from generated response + ParsingRegexes []string `json:"parsing_regexes,omitzero"` + // Any of "regex_parser". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ScoringFunctionRegisterParamsParamsRegexParser) MarshalJSON() (data []byte, err error) { + type shadow ScoringFunctionRegisterParamsParamsRegexParser + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ScoringFunctionRegisterParamsParamsRegexParser) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ScoringFunctionRegisterParamsParamsRegexParser]( + "type", "regex_parser", + ) +} + +// Parameters for basic scoring function configuration. +type ScoringFunctionRegisterParamsParamsBasic struct { + // Aggregation functions to apply to the scores of each row + // + // Any of "average", "weighted_average", "median", "categorical_count", "accuracy". + AggregationFunctions []string `json:"aggregation_functions,omitzero"` + // Any of "basic". + Type string `json:"type,omitzero"` + paramObj +} + +func (r ScoringFunctionRegisterParamsParamsBasic) MarshalJSON() (data []byte, err error) { + type shadow ScoringFunctionRegisterParamsParamsBasic + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ScoringFunctionRegisterParamsParamsBasic) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +func init() { + apijson.RegisterFieldValidator[ScoringFunctionRegisterParamsParamsBasic]( + "type", "basic", + ) +} diff --git a/scoringfunction_test.go b/scoringfunction_test.go index cde50ce..2e95ff5 100644 --- a/scoringfunction_test.go +++ b/scoringfunction_test.go @@ -73,12 +73,22 @@ func TestScoringFunctionRegisterWithOptionalParams(t *testing.T) { option.WithBaseURL(baseURL), ) err := client.ScoringFunctions.Register(context.TODO(), llamastackclient.ScoringFunctionRegisterParams{ - Description: map[string]interface{}{}, - ReturnType: map[string]interface{}{}, - ScoringFnID: map[string]interface{}{}, - Params: map[string]interface{}{}, - ProviderID: map[string]interface{}{}, - ProviderScoringFnID: map[string]interface{}{}, + Description: "description", + ReturnType: llamastackclient.ScoringFunctionRegisterParamsReturnType{ + Type: "string", + }, + ScoringFnID: "scoring_fn_id", + Params: llamastackclient.ScoringFunctionRegisterParamsParamsUnion{ + OfLlmAsJudge: &llamastackclient.ScoringFunctionRegisterParamsParamsLlmAsJudge{ + JudgeModel: "judge_model", + AggregationFunctions: []string{"average"}, + JudgeScoreRegexes: []string{"string"}, + PromptTemplate: llamastackclient.String("prompt_template"), + Type: "llm_as_judge", + }, + }, + ProviderID: llamastackclient.String("provider_id"), + ProviderScoringFnID: llamastackclient.String("provider_scoring_fn_id"), }) if err != nil { var apierr *llamastackclient.Error From fe1904dcc8b62c1ca69b9510b499477ecca77ff7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 17 Nov 2025 20:48:44 +0000 Subject: [PATCH 3/7] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index db94672..6ebef99 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 103 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-aab1b331382f758fc255f765e73b62fedf463cf0748bc11b2b08974de9ac816a.yml openapi_spec_hash: f717a21f47419aa51e4d9298aa68cc45 -config_hash: 0017f6c419cbbf7b949f9b2842917a79 +config_hash: 39578cfdeb4a10121f2cb3fa3e4d5e20 From 1090be93ae142c74365868350c435380a63679ba Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 18 Nov 2025 19:25:42 +0000 Subject: [PATCH 4/7] feat: Wire through parallel_tool_calls to Responses API --- .stats.yml | 4 ++-- response.go | 5 +++-- response_test.go | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.stats.yml b/.stats.yml index 6ebef99..c9e7f12 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 103 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-aab1b331382f758fc255f765e73b62fedf463cf0748bc11b2b08974de9ac816a.yml -openapi_spec_hash: f717a21f47419aa51e4d9298aa68cc45 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-185ec058880381a5526ac91a488af1833f55656e36cd10b3795eb8fd4d75026f.yml +openapi_spec_hash: fa935c08e25d23cff624e5e150f8e6ca config_hash: 39578cfdeb4a10121f2cb3fa3e4d5e20 diff --git a/response.go b/response.go index 76530c9..6625daf 100644 --- a/response.go +++ b/response.go @@ -129,7 +129,7 @@ type ResponseObject struct { MaxToolCalls int64 `json:"max_tool_calls,nullable"` // Any of "response". Object ResponseObjectObject `json:"object"` - ParallelToolCalls bool `json:"parallel_tool_calls"` + ParallelToolCalls bool `json:"parallel_tool_calls,nullable"` PreviousResponseID string `json:"previous_response_id,nullable"` // OpenAI compatible Prompt object that is used in OpenAI responses. Prompt ResponseObjectPrompt `json:"prompt,nullable"` @@ -6275,7 +6275,7 @@ type ResponseListResponse struct { MaxToolCalls int64 `json:"max_tool_calls,nullable"` // Any of "response". Object ResponseListResponseObject `json:"object"` - ParallelToolCalls bool `json:"parallel_tool_calls"` + ParallelToolCalls bool `json:"parallel_tool_calls,nullable"` PreviousResponseID string `json:"previous_response_id,nullable"` // OpenAI compatible Prompt object that is used in OpenAI responses. Prompt ResponseListResponsePrompt `json:"prompt,nullable"` @@ -8894,6 +8894,7 @@ type ResponseNewParams struct { Instructions param.Opt[string] `json:"instructions,omitzero"` MaxInferIters param.Opt[int64] `json:"max_infer_iters,omitzero"` MaxToolCalls param.Opt[int64] `json:"max_tool_calls,omitzero"` + ParallelToolCalls param.Opt[bool] `json:"parallel_tool_calls,omitzero"` PreviousResponseID param.Opt[string] `json:"previous_response_id,omitzero"` Store param.Opt[bool] `json:"store,omitzero"` Temperature param.Opt[float64] `json:"temperature,omitzero"` diff --git a/response_test.go b/response_test.go index ceae9c2..af809db 100644 --- a/response_test.go +++ b/response_test.go @@ -40,6 +40,7 @@ func TestResponseNewWithOptionalParams(t *testing.T) { Instructions: llamastackclient.String("instructions"), MaxInferIters: llamastackclient.Int(0), MaxToolCalls: llamastackclient.Int(0), + ParallelToolCalls: llamastackclient.Bool(true), PreviousResponseID: llamastackclient.String("previous_response_id"), Prompt: llamastackclient.ResponseNewParamsPrompt{ ID: "id", From 303790079c138c442eb492fd9457b60dade84198 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 19 Nov 2025 05:06:00 +0000 Subject: [PATCH 5/7] fix(client): correctly specify Accept header with */* instead of empty --- alphabenchmark.go | 4 ++-- alphaevaljob.go | 2 +- alphaposttrainingjob.go | 2 +- betadataset.go | 4 ++-- model.go | 2 +- prompt.go | 2 +- scoringfunction.go | 4 ++-- shield.go | 2 +- toolgroup.go | 4 ++-- vectorio.go | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/alphabenchmark.go b/alphabenchmark.go index 33d0cfc..8463d63 100644 --- a/alphabenchmark.go +++ b/alphabenchmark.go @@ -71,7 +71,7 @@ func (r *AlphaBenchmarkService) List(ctx context.Context, opts ...option.Request // Deprecated: deprecated func (r *AlphaBenchmarkService) Register(ctx context.Context, body AlphaBenchmarkRegisterParams, opts ...option.RequestOption) (err error) { opts = slices.Concat(r.Options, opts) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...) path := "v1alpha/eval/benchmarks" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...) return @@ -82,7 +82,7 @@ func (r *AlphaBenchmarkService) Register(ctx context.Context, body AlphaBenchmar // Deprecated: deprecated func (r *AlphaBenchmarkService) Unregister(ctx context.Context, benchmarkID string, opts ...option.RequestOption) (err error) { opts = slices.Concat(r.Options, opts) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...) if benchmarkID == "" { err = errors.New("missing required benchmark_id parameter") return diff --git a/alphaevaljob.go b/alphaevaljob.go index 88dce1c..40692b0 100644 --- a/alphaevaljob.go +++ b/alphaevaljob.go @@ -57,7 +57,7 @@ func (r *AlphaEvalJobService) Get(ctx context.Context, jobID string, query Alpha // Cancel a job. func (r *AlphaEvalJobService) Cancel(ctx context.Context, jobID string, body AlphaEvalJobCancelParams, opts ...option.RequestOption) (err error) { opts = slices.Concat(r.Options, opts) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...) if body.BenchmarkID == "" { err = errors.New("missing required benchmark_id parameter") return diff --git a/alphaposttrainingjob.go b/alphaposttrainingjob.go index cb7b730..3ab0f7b 100644 --- a/alphaposttrainingjob.go +++ b/alphaposttrainingjob.go @@ -66,7 +66,7 @@ func (r *AlphaPostTrainingJobService) Artifacts(ctx context.Context, query Alpha // Cancel a training job. func (r *AlphaPostTrainingJobService) Cancel(ctx context.Context, body AlphaPostTrainingJobCancelParams, opts ...option.RequestOption) (err error) { opts = slices.Concat(r.Options, opts) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...) path := "v1alpha/post-training/job/cancel" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...) return diff --git a/betadataset.go b/betadataset.go index 7343e48..6ef0d08 100644 --- a/betadataset.go +++ b/betadataset.go @@ -72,7 +72,7 @@ func (r *BetaDatasetService) List(ctx context.Context, opts ...option.RequestOpt // Append rows to a dataset. func (r *BetaDatasetService) Appendrows(ctx context.Context, datasetID string, body BetaDatasetAppendrowsParams, opts ...option.RequestOption) (err error) { opts = slices.Concat(r.Options, opts) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...) if datasetID == "" { err = errors.New("missing required dataset_id parameter") return @@ -119,7 +119,7 @@ func (r *BetaDatasetService) Register(ctx context.Context, body BetaDatasetRegis // Deprecated: deprecated func (r *BetaDatasetService) Unregister(ctx context.Context, datasetID string, opts ...option.RequestOption) (err error) { opts = slices.Concat(r.Options, opts) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...) if datasetID == "" { err = errors.New("missing required dataset_id parameter") return diff --git a/model.go b/model.go index a1f3ed4..1de3c01 100644 --- a/model.go +++ b/model.go @@ -89,7 +89,7 @@ func (r *ModelService) Register(ctx context.Context, body ModelRegisterParams, o // Deprecated: deprecated func (r *ModelService) Unregister(ctx context.Context, modelID string, opts ...option.RequestOption) (err error) { opts = slices.Concat(r.Options, opts) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...) if modelID == "" { err = errors.New("missing required model_id parameter") return diff --git a/prompt.go b/prompt.go index 568297d..8918e98 100644 --- a/prompt.go +++ b/prompt.go @@ -101,7 +101,7 @@ func (r *PromptService) List(ctx context.Context, opts ...option.RequestOption) // Delete a prompt. func (r *PromptService) Delete(ctx context.Context, promptID string, opts ...option.RequestOption) (err error) { opts = slices.Concat(r.Options, opts) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...) if promptID == "" { err = errors.New("missing required prompt_id parameter") return diff --git a/scoringfunction.go b/scoringfunction.go index 66ddc12..4e005af 100644 --- a/scoringfunction.go +++ b/scoringfunction.go @@ -72,7 +72,7 @@ func (r *ScoringFunctionService) List(ctx context.Context, opts ...option.Reques // Deprecated: deprecated func (r *ScoringFunctionService) Register(ctx context.Context, body ScoringFunctionRegisterParams, opts ...option.RequestOption) (err error) { opts = slices.Concat(r.Options, opts) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...) path := "v1/scoring-functions" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...) return @@ -83,7 +83,7 @@ func (r *ScoringFunctionService) Register(ctx context.Context, body ScoringFunct // Deprecated: deprecated func (r *ScoringFunctionService) Unregister(ctx context.Context, scoringFnID string, opts ...option.RequestOption) (err error) { opts = slices.Concat(r.Options, opts) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...) if scoringFnID == "" { err = errors.New("missing required scoring_fn_id parameter") return diff --git a/shield.go b/shield.go index 64f592e..82708a9 100644 --- a/shield.go +++ b/shield.go @@ -71,7 +71,7 @@ func (r *ShieldService) List(ctx context.Context, opts ...option.RequestOption) // Deprecated: deprecated func (r *ShieldService) Delete(ctx context.Context, identifier string, opts ...option.RequestOption) (err error) { opts = slices.Concat(r.Options, opts) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...) if identifier == "" { err = errors.New("missing required identifier parameter") return diff --git a/toolgroup.go b/toolgroup.go index 6328263..4853e34 100644 --- a/toolgroup.go +++ b/toolgroup.go @@ -71,7 +71,7 @@ func (r *ToolgroupService) Get(ctx context.Context, toolgroupID string, opts ... // Deprecated: deprecated func (r *ToolgroupService) Register(ctx context.Context, body ToolgroupRegisterParams, opts ...option.RequestOption) (err error) { opts = slices.Concat(r.Options, opts) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...) path := "v1/toolgroups" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...) return @@ -82,7 +82,7 @@ func (r *ToolgroupService) Register(ctx context.Context, body ToolgroupRegisterP // Deprecated: deprecated func (r *ToolgroupService) Unregister(ctx context.Context, toolgroupID string, opts ...option.RequestOption) (err error) { opts = slices.Concat(r.Options, opts) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...) if toolgroupID == "" { err = errors.New("missing required toolgroup_id parameter") return diff --git a/vectorio.go b/vectorio.go index b61f961..0076bc2 100644 --- a/vectorio.go +++ b/vectorio.go @@ -43,7 +43,7 @@ func NewVectorIoService(opts ...option.RequestOption) (r VectorIoService) { // Insert chunks into a vector database. func (r *VectorIoService) Insert(ctx context.Context, body VectorIoInsertParams, opts ...option.RequestOption) (err error) { opts = slices.Concat(r.Options, opts) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...) path := "v1/vector-io/insert" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...) return From d0dd1c22471bbb6f9912c401921f1a708410574f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 19 Nov 2025 18:17:12 +0000 Subject: [PATCH 6/7] fix: Pydantic validation error with list-type metadata in vector search (#3797) --- .stats.yml | 4 ++-- vectorstorefile.go | 51 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index c9e7f12..4be566f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 103 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-185ec058880381a5526ac91a488af1833f55656e36cd10b3795eb8fd4d75026f.yml -openapi_spec_hash: fa935c08e25d23cff624e5e150f8e6ca +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-73fc7f59a69be032d1b18e2fff3ed7509e175703332723b27aac50e2514ca854.yml +openapi_spec_hash: a22051c017a4822ef689585896659675 config_hash: 39578cfdeb4a10121f2cb3fa3e4d5e20 diff --git a/vectorstorefile.go b/vectorstorefile.go index ce82d4b..6cb6987 100644 --- a/vectorstorefile.go +++ b/vectorstorefile.go @@ -158,7 +158,12 @@ type VectorStoreFile struct { // Any of "completed", "in_progress", "cancelled", "failed". Status VectorStoreFileStatus `json:"status,required"` VectorStoreID string `json:"vector_store_id,required"` - Attributes map[string]any `json:"attributes"` + // Set of 16 key-value pairs that can be attached to an object. This can be useful + // for storing additional information about the object in a structured format, and + // querying for objects via API or the dashboard. Keys are strings with a maximum + // length of 64 characters. Values are strings with a maximum length of 512 + // characters, booleans, or numbers. + Attributes map[string]VectorStoreFileAttributeUnion `json:"attributes"` // Error information for failed vector store file processing. LastError VectorStoreFileLastError `json:"last_error,nullable"` Object string `json:"object"` @@ -317,6 +322,50 @@ const ( VectorStoreFileStatusFailed VectorStoreFileStatus = "failed" ) +// VectorStoreFileAttributeUnion contains all possible properties and values from +// [string], [float64], [bool]. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +// +// If the underlying value is not a json object, one of the following properties +// will be valid: OfString OfFloat OfBool] +type VectorStoreFileAttributeUnion struct { + // This field will be present if the value is a [string] instead of an object. + OfString string `json:",inline"` + // This field will be present if the value is a [float64] instead of an object. + OfFloat float64 `json:",inline"` + // This field will be present if the value is a [bool] instead of an object. + OfBool bool `json:",inline"` + JSON struct { + OfString respjson.Field + OfFloat respjson.Field + OfBool respjson.Field + raw string + } `json:"-"` +} + +func (u VectorStoreFileAttributeUnion) AsString() (v string) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u VectorStoreFileAttributeUnion) AsFloat() (v float64) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u VectorStoreFileAttributeUnion) AsBool() (v bool) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u VectorStoreFileAttributeUnion) RawJSON() string { return u.JSON.raw } + +func (r *VectorStoreFileAttributeUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + // Error information for failed vector store file processing. type VectorStoreFileLastError struct { // Any of "server_error", "rate_limit_exceeded". From ac01a0183cec517d63d16aec9a84b1c3a6c7b01c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 19 Nov 2025 18:17:31 +0000 Subject: [PATCH 7/7] release: 0.4.0-alpha.2 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 20 ++++++++++++++++++++ README.md | 2 +- internal/version.go | 2 +- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index a9622d0..58a03f2 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.4.0-alpha.1" + ".": "0.4.0-alpha.2" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index dea4a8c..98d76f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,25 @@ # Changelog +## 0.4.0-alpha.2 (2025-11-19) + +Full Changelog: [v0.4.0-alpha.1...v0.4.0-alpha.2](https://github.com/llamastack/llama-stack-client-go/compare/v0.4.0-alpha.1...v0.4.0-alpha.2) + +### Features + +* Wire through parallel_tool_calls to Responses API ([1090be9](https://github.com/llamastack/llama-stack-client-go/commit/1090be93ae142c74365868350c435380a63679ba)) + + +### Bug Fixes + +* **client:** correctly specify Accept header with */* instead of empty ([3037900](https://github.com/llamastack/llama-stack-client-go/commit/303790079c138c442eb492fd9457b60dade84198)) +* **openapi:** restore embedded request wrappers ([7da5f07](https://github.com/llamastack/llama-stack-client-go/commit/7da5f07a1b07166105173d8263b95b59e06735fd)) +* Pydantic validation error with list-type metadata in vector search ([#3797](https://github.com/llamastack/llama-stack-client-go/issues/3797)) ([d0dd1c2](https://github.com/llamastack/llama-stack-client-go/commit/d0dd1c22471bbb6f9912c401921f1a708410574f)) + + +### Chores + +* use Pydantic to generate OpenAPI schema ([c7fafed](https://github.com/llamastack/llama-stack-client-go/commit/c7fafed933890ba05c37e6ab54cd5163d00801fc)) + ## 0.4.0-alpha.1 (2025-11-14) Full Changelog: [v0.1.0-alpha.1...v0.4.0-alpha.1](https://github.com/llamastack/llama-stack-client-go/compare/v0.1.0-alpha.1...v0.4.0-alpha.1) diff --git a/README.md b/README.md index 04f3789..378b2dc 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Or to pin the version: ```sh -go get -u 'github.com/llamastack/llama-stack-client-go@v0.4.0-alpha.1' +go get -u 'github.com/llamastack/llama-stack-client-go@v0.4.0-alpha.2' ``` diff --git a/internal/version.go b/internal/version.go index 051f665..ea14144 100644 --- a/internal/version.go +++ b/internal/version.go @@ -8,4 +8,4 @@ package internal -const PackageVersion = "0.4.0-alpha.1" // x-release-please-version +const PackageVersion = "0.4.0-alpha.2" // x-release-please-version