diff --git a/.release-please-manifest.json b/.release-please-manifest.json index ba6c348..a9622d0 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.1" + ".": "0.4.0-alpha.1" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index b90091b..c4e4ef9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 106 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-4f6633567c1a079df49d0cf58f37251a4bb0ee2f2a496ac83c9fee26eb325f9c.yml -openapi_spec_hash: af5b3d3bbecf48f15c90b982ccac852e -config_hash: ddcbd66d7ac80290da208232a746e30f +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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 80af85e..dea4a8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,87 @@ # Changelog +## 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) + +### ⚠ BREAKING CHANGES + +* **api:** /v1/inspect only lists v1 apis by default +* **api:** /v1/inspect only lists v1 apis by default +* **api:** use input_schema instead of parameters for tools +* **api:** fixes to remove deprecated inference resources + +### Features + +* add new API filter for all non-deprecated APIs ([d74e63b](https://github.com/llamastack/llama-stack-client-go/commit/d74e63bc707992772addee329a21676f3f4aaabc)) +* Adding option to return embeddings and metadata from `/vector_stores/*/files/*/content` and UI updates ([492a412](https://github.com/llamastack/llama-stack-client-go/commit/492a412c44448a6d76a2e8a04a5bd85c92deb5d0)) +* **api:** Adding prompts API to stainless config ([9d436bb](https://github.com/llamastack/llama-stack-client-go/commit/9d436bb1701c851bbedc124471c8caefddd38334)) +* **api:** expires_after changes for /files ([222bb4e](https://github.com/llamastack/llama-stack-client-go/commit/222bb4ed27e9a4afd247aacea50d1645326a6b54)) +* **api:** fix completion response breakage perhaps? ([3e9c39f](https://github.com/llamastack/llama-stack-client-go/commit/3e9c39f1bf837daf2487ec2c465a9522e6b5befe)) +* **api:** fix file batches SDK to list_files ([c9da417](https://github.com/llamastack/llama-stack-client-go/commit/c9da41734d782e758971ca2f5b9821669dbd7331)) +* **api:** fixes to remove deprecated inference resources ([9f926b2](https://github.com/llamastack/llama-stack-client-go/commit/9f926b25335010398c825844a60927709ccfc07f)) +* **api:** fixes to URLs ([6c9752f](https://github.com/llamastack/llama-stack-client-go/commit/6c9752f49b98e57c4ce06c6310f33d19207b3ae1)) +* **api:** manual updates ([114833d](https://github.com/llamastack/llama-stack-client-go/commit/114833d8ba92478231c41c85c11ac25b16a39c96)) +* **api:** manual updates ([1573312](https://github.com/llamastack/llama-stack-client-go/commit/15733129bb01716b4a1adcddc68f31c634e07f80)) +* **api:** manual updates ([5444c7c](https://github.com/llamastack/llama-stack-client-go/commit/5444c7cf065438ce85e0648a3a21b1642421b97f)) +* **api:** manual updates ([78a1b1a](https://github.com/llamastack/llama-stack-client-go/commit/78a1b1ad7d5c7c254b9c88f72316ba684077033a)) +* **api:** manual updates ([eb137af](https://github.com/llamastack/llama-stack-client-go/commit/eb137afa61bf5621159b871561e3a11ca3589b00)) +* **api:** manual updates ([9de5708](https://github.com/llamastack/llama-stack-client-go/commit/9de5708ab28e06c58731c3ac57c3e4c4fbc12aca)) +* **api:** manual updates??! ([9dd7521](https://github.com/llamastack/llama-stack-client-go/commit/9dd7521061ccd921680da4d179375ae19ece3591)) +* **api:** move datasets to beta, vector_db -> vector_store ([df1a9e5](https://github.com/llamastack/llama-stack-client-go/commit/df1a9e5dd98267cffab0d79cc9c3c4124c882040)) +* **api:** move post_training and eval under alpha namespace ([42bdca7](https://github.com/llamastack/llama-stack-client-go/commit/42bdca705b93c1c8c3330a4075bd8f5bde977f65)) +* **api:** moving { rerank, agents } to `client.alpha.` ([f12fecf](https://github.com/llamastack/llama-stack-client-go/commit/f12fecf6d892348ebee06652255f6ac66f38e0bb)) +* **api:** point models.list() to /v1/openai/v1/models ([010542c](https://github.com/llamastack/llama-stack-client-go/commit/010542c2ce776abdcb2ecbaa93cb4b754b10bfd8)) +* **api:** query_metrics, batches, changes ([06e03be](https://github.com/llamastack/llama-stack-client-go/commit/06e03be805d93736fcf4f848c5f9888e2871c911)) +* **api:** remove agents types ([56acfc3](https://github.com/llamastack/llama-stack-client-go/commit/56acfc3fe739820d08f74c109bda07e799c43724)) +* **api:** remove openai/v1 endpoints ([754e8a4](https://github.com/llamastack/llama-stack-client-go/commit/754e8a415667396f5f84e84ab014dbc7a42a1e8a)) +* **api:** removing openai/v1 ([b8635d7](https://github.com/llamastack/llama-stack-client-go/commit/b8635d7781c593fc1fb4bda7311189428f5bc128)) +* **api:** SDKs for vector store file batches ([2060878](https://github.com/llamastack/llama-stack-client-go/commit/2060878c2b6b81c76b65f56dab6d699df12fb7d0)) +* **api:** SDKs for vector store file batches apis ([e5f679f](https://github.com/llamastack/llama-stack-client-go/commit/e5f679f8f193fcdf76aba82288130854e9b86819)) +* **api:** several updates including Conversations, Responses changes, etc. ([978c65f](https://github.com/llamastack/llama-stack-client-go/commit/978c65fe02f0e044843b278ac27e0d9cc38f1739)) +* **api:** some updates to query metrics ([8243d43](https://github.com/llamastack/llama-stack-client-go/commit/8243d43dfa43bb9ec92d1edbed36f114240a265e)) +* **api:** sync ([d3f850b](https://github.com/llamastack/llama-stack-client-go/commit/d3f850bfd124b84d4d49e384961fd99c3d90be02)) +* **api:** tool api (input_schema, etc.) changes ([837277d](https://github.com/llamastack/llama-stack-client-go/commit/837277d4e6b4ffb57ce0136072b80400011da79a)) +* **api:** updates to vector_store, etc. ([837fd3a](https://github.com/llamastack/llama-stack-client-go/commit/837fd3a7e19b103f5ea122e02fe5005afa5e8f62)) +* **api:** updating post /v1/files to have correct multipart/form-data ([a3d6051](https://github.com/llamastack/llama-stack-client-go/commit/a3d6051547ce2b9cbd5af96b6b802515b737e7fb)) +* **api:** use input_schema instead of parameters for tools ([a16eaef](https://github.com/llamastack/llama-stack-client-go/commit/a16eaef870f6ec94ae6adf36eed0d65bfa9fd3b8)) +* **api:** vector_db_id -> vector_store_id ([6c8dbbd](https://github.com/llamastack/llama-stack-client-go/commit/6c8dbbd143f4fb8b7631a6597b40110612cee87b)) +* Implement the 'max_tool_calls' parameter for the Responses API ([ba81b90](https://github.com/llamastack/llama-stack-client-go/commit/ba81b90d0c4d49bdf100ce235353ba4c22212a40)) + + +### Bug Fixes + +* **api:** another fix to capture correct responses.create() params ([f3a9ee7](https://github.com/llamastack/llama-stack-client-go/commit/f3a9ee7303c890444802c76412d5d245a1420bdb)) +* **api:** ensure openapi spec has deprecated routes ([fd39305](https://github.com/llamastack/llama-stack-client-go/commit/fd393057fb65ee6303391debfa09ab7578f9e1c1)) +* **api:** fix the ToolDefParam updates ([65cef22](https://github.com/llamastack/llama-stack-client-go/commit/65cef2268480297f4233dd1c4c817aa03943f18e)) +* bugfix for setting JSON keys with special characters ([ceb15f3](https://github.com/llamastack/llama-stack-client-go/commit/ceb15f300fdf9b7e1b2615c14c352878bcfc082b)) +* **client:** fix circular dependencies and offset pagination ([0b95836](https://github.com/llamastack/llama-stack-client-go/commit/0b95836016ca0d089d3f7c07456ff5f55989011f)) +* close body before retrying ([66adbea](https://github.com/llamastack/llama-stack-client-go/commit/66adbea266032b1198c76c8f590808d61a3d145a)) +* fix stream event model reference ([d8b42f6](https://github.com/llamastack/llama-stack-client-go/commit/d8b42f67eefb216968989a10d68b2ff0e3e65a62)) +* **internal:** unmarshal correctly when there are multiple discriminators ([d76c69c](https://github.com/llamastack/llama-stack-client-go/commit/d76c69c30d1402e13178448691d8202e6f2b5d82)) +* MCP authorization parameter implementation ([e4d35c8](https://github.com/llamastack/llama-stack-client-go/commit/e4d35c89e989590b1df003d6b769b14d3d97b2b8)) +* use slices.Concat instead of sometimes modifying r.Options ([15dfa47](https://github.com/llamastack/llama-stack-client-go/commit/15dfa47636cc1cd0ccb6b089ae363a7e70a5f56c)) + + +### Chores + +* **api:** /v1/inspect only lists v1 apis by default ([7ce9eb3](https://github.com/llamastack/llama-stack-client-go/commit/7ce9eb3a6695e8f6f6fdf8675f6199730728a348)) +* **api:** /v1/inspect only lists v1 apis by default ([81ef91f](https://github.com/llamastack/llama-stack-client-go/commit/81ef91f4b156e5376f4857df41abd804d9a70f9f)) +* bump minimum go version to 1.22 ([7b5d227](https://github.com/llamastack/llama-stack-client-go/commit/7b5d227df87389479dc2f6954ba59147b5d1a0fc)) +* do not install brew dependencies in ./scripts/bootstrap by default ([062a46b](https://github.com/llamastack/llama-stack-client-go/commit/062a46b117baaf537ef9a0edef4222d7a1b3a839)) +* fix readme example ([d639e08](https://github.com/llamastack/llama-stack-client-go/commit/d639e08566eb3986bae58061db0eca193fe4c407)) +* fix readme examples ([7f95573](https://github.com/llamastack/llama-stack-client-go/commit/7f95573f7148f160c1054dd8656787f8c67ae603)) +* **internal:** clean up ([7ba4b62](https://github.com/llamastack/llama-stack-client-go/commit/7ba4b6268aff1e3e1ab45a811e39b4acbe738121)) +* **internal:** codegen related update ([30d522e](https://github.com/llamastack/llama-stack-client-go/commit/30d522ee9034d5ef35599aa5c6c6bcb2c512bfe3)) +* **internal:** codegen related update ([a3cccf1](https://github.com/llamastack/llama-stack-client-go/commit/a3cccf10d30121514bb6b07a6416c589a1881763)) +* **stainless:** add config for file header ([50d5a83](https://github.com/llamastack/llama-stack-client-go/commit/50d5a8365f3e0b68e313fd09566330c9a570c6db)) +* update more docs for 1.22 ([67c0b00](https://github.com/llamastack/llama-stack-client-go/commit/67c0b0067523c93560b6d6467b81e3e8c2ecb61e)) + + +### Documentation + +* update examples ([245c643](https://github.com/llamastack/llama-stack-client-go/commit/245c643bb01b573243c31bea5f66761ef7e3fba1)) + ## 0.1.0-alpha.1 (2025-08-21) Full Changelog: [v0.0.1-alpha.0...v0.1.0-alpha.1](https://github.com/llamastack/llama-stack-client-go/compare/v0.0.1-alpha.0...v0.1.0-alpha.1) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ab38e86..aa34efe 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,7 +9,7 @@ $ ./scripts/lint This will install all the required dependencies and build the SDK. -You can also [install go 1.18+ manually](https://go.dev/doc/install). +You can also [install go 1.22+ manually](https://go.dev/doc/install). ## Modifying/Adding code diff --git a/README.md b/README.md index 2fd267d..b5c682f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,11 @@ # Llama Stack Client Go API Library + + Go Reference + + The Llama Stack Client Go library provides convenient access to the [Llama Stack Client REST API](https://llama-stack.readthedocs.io/en/latest/) from applications written in Go. @@ -24,14 +28,14 @@ Or to pin the version: ```sh -go get -u 'github.com/llamastack/llama-stack-client-go@v0.1.0-alpha.1' +go get -u 'github.com/llamastack/llama-stack-client-go@v0.4.0-alpha.1' ``` ## Requirements -This library requires Go 1.18+. +This library requires Go 1.22+. ## Usage @@ -49,13 +53,13 @@ import ( func main() { client := llamastackclient.NewClient() - model, err := client.Models.Register(context.TODO(), llamastackclient.ModelRegisterParams{ + response, err := client.Models.Register(context.TODO(), llamastackclient.ModelRegisterParams{ ModelID: "model_id", }) if err != nil { panic(err.Error()) } - fmt.Printf("%+v\n", model.Identifier) + fmt.Printf("%+v\n", response.Identifier) } ``` @@ -120,7 +124,7 @@ custom := param.Override[llamastackclient.FooParams](12) ### Request unions -Unions are represented as a struct with fields prefixed by "Of" for each of it's variants, +Unions are represented as a struct with fields prefixed by "Of" for each of its variants, only one field can be non-zero. The non-zero field will be serialized. Sub-properties of the union can be accessed via methods on the union struct. @@ -261,7 +265,7 @@ client := llamastackclient.NewClient( option.WithHeader("X-Some-Header", "custom_header_info"), ) -client.Inference.ChatCompletion(context.TODO(), ..., +client.Chat.Completions.New(context.TODO(), ..., // Override the header option.WithHeader("X-Some-Header", "some_other_custom_header_info"), // Add an undocumented field to the request body, using sjson syntax @@ -292,15 +296,15 @@ When the API returns a non-success status code, we return an error with type To handle errors, we recommend that you use the `errors.As` pattern: ```go -_, err := client.Inference.ChatCompletion(context.TODO(), llamastackclient.InferenceChatCompletionParams{ - Messages: []shared.MessageUnionParam{{ - OfUser: &shared.UserMessageParam{ - Content: shared.InterleavedContentUnionParam{ +_, err := client.Chat.Completions.New(context.TODO(), llamastackclient.ChatCompletionNewParams{ + Messages: []llamastackclient.ChatCompletionNewParamsMessageUnion{{ + OfUser: &llamastackclient.ChatCompletionNewParamsMessageUser{ + Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, }, }}, - ModelID: "model_id", + Model: "model", }) if err != nil { var apierr *llamastackclient.Error @@ -308,7 +312,7 @@ if err != nil { println(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response } - panic(err.Error()) // GET "/v1/inference/chat-completion": 400 Bad Request { ... } + panic(err.Error()) // GET "/v1/chat/completions": 400 Bad Request { ... } } ``` @@ -326,17 +330,17 @@ To set a per-retry timeout, use `option.WithRequestTimeout()`. // This sets the timeout for the request, including all the retries. ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) defer cancel() -client.Inference.ChatCompletion( +client.Chat.Completions.New( ctx, - llamastackclient.InferenceChatCompletionParams{ - Messages: []shared.MessageUnionParam{{ - OfUser: &shared.UserMessageParam{ - Content: shared.InterleavedContentUnionParam{ + llamastackclient.ChatCompletionNewParams{ + Messages: []llamastackclient.ChatCompletionNewParamsMessageUnion{{ + OfUser: &llamastackclient.ChatCompletionNewParamsMessageUser{ + Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, }, }}, - ModelID: "model_id", + Model: "model", }, // This sets the per-retry timeout option.WithRequestTimeout(20*time.Second), @@ -392,17 +396,17 @@ client := llamastackclient.NewClient( ) // Override per-request: -client.Inference.ChatCompletion( +client.Chat.Completions.New( context.TODO(), - llamastackclient.InferenceChatCompletionParams{ - Messages: []shared.MessageUnionParam{{ - OfUser: &shared.UserMessageParam{ - Content: shared.InterleavedContentUnionParam{ + llamastackclient.ChatCompletionNewParams{ + Messages: []llamastackclient.ChatCompletionNewParamsMessageUnion{{ + OfUser: &llamastackclient.ChatCompletionNewParamsMessageUser{ + Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, }, }}, - ModelID: "model_id", + Model: "model", }, option.WithMaxRetries(5), ) @@ -416,24 +420,24 @@ you need to examine response headers, status codes, or other details. ```go // Create a variable to store the HTTP response var response *http.Response -chatCompletionResponse, err := client.Inference.ChatCompletion( +completion, err := client.Chat.Completions.New( context.TODO(), - llamastackclient.InferenceChatCompletionParams{ - Messages: []shared.MessageUnionParam{{ - OfUser: &shared.UserMessageParam{ - Content: shared.InterleavedContentUnionParam{ + llamastackclient.ChatCompletionNewParams{ + Messages: []llamastackclient.ChatCompletionNewParamsMessageUnion{{ + OfUser: &llamastackclient.ChatCompletionNewParamsMessageUser{ + Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, }, }}, - ModelID: "model_id", + Model: "model", }, option.WithResponseInto(&response), ) if err != nil { // handle error } -fmt.Printf("%+v\n", chatCompletionResponse) +fmt.Printf("%+v\n", completion) fmt.Printf("Status Code: %d\n", response.StatusCode) fmt.Printf("Headers: %+#v\n", response.Header) diff --git a/agent.go b/agent.go deleted file mode 100644 index d5d87ef..0000000 --- a/agent.go +++ /dev/null @@ -1,526 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package llamastackclient - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "net/http" - "net/url" - "time" - - "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/param" - "github.com/llamastack/llama-stack-client-go/packages/respjson" - "github.com/llamastack/llama-stack-client-go/shared" - "github.com/llamastack/llama-stack-client-go/shared/constant" -) - -// AgentService 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 [NewAgentService] method instead. -type AgentService struct { - Options []option.RequestOption - Session AgentSessionService - Steps AgentStepService - Turn AgentTurnService -} - -// NewAgentService 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 NewAgentService(opts ...option.RequestOption) (r AgentService) { - r = AgentService{} - r.Options = opts - r.Session = NewAgentSessionService(opts...) - r.Steps = NewAgentStepService(opts...) - r.Turn = NewAgentTurnService(opts...) - return -} - -// Create an agent with the given configuration. -func (r *AgentService) New(ctx context.Context, body AgentNewParams, opts ...option.RequestOption) (res *AgentNewResponse, err error) { - opts = append(r.Options[:], opts...) - path := "v1/agents" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) - return -} - -// Describe an agent by its ID. -func (r *AgentService) Get(ctx context.Context, agentID string, opts ...option.RequestOption) (res *AgentGetResponse, err error) { - opts = append(r.Options[:], opts...) - if agentID == "" { - err = errors.New("missing required agent_id parameter") - return - } - path := fmt.Sprintf("v1/agents/%s", agentID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) - return -} - -// List all agents. -func (r *AgentService) List(ctx context.Context, query AgentListParams, opts ...option.RequestOption) (res *AgentListResponse, err error) { - opts = append(r.Options[:], opts...) - path := "v1/agents" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) - return -} - -// Delete an agent by its ID and its associated sessions and turns. -func (r *AgentService) Delete(ctx context.Context, agentID string, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - if agentID == "" { - err = errors.New("missing required agent_id parameter") - return - } - path := fmt.Sprintf("v1/agents/%s", agentID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...) - return -} - -// An inference step in an agent turn. -type InferenceStep struct { - // The response from the LLM. - ModelResponse shared.CompletionMessage `json:"model_response,required"` - // The ID of the step. - StepID string `json:"step_id,required"` - // Type of the step in an agent turn. - StepType constant.Inference `json:"step_type,required"` - // The ID of the turn. - TurnID string `json:"turn_id,required"` - // The time the step completed. - CompletedAt time.Time `json:"completed_at" format:"date-time"` - // The time the step started. - StartedAt time.Time `json:"started_at" format:"date-time"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - ModelResponse respjson.Field - StepID respjson.Field - StepType respjson.Field - TurnID respjson.Field - CompletedAt respjson.Field - StartedAt respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r InferenceStep) RawJSON() string { return r.JSON.raw } -func (r *InferenceStep) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A memory retrieval step in an agent turn. -type MemoryRetrievalStep struct { - // The context retrieved from the vector databases. - InsertedContext shared.InterleavedContentUnion `json:"inserted_context,required"` - // The ID of the step. - StepID string `json:"step_id,required"` - // Type of the step in an agent turn. - StepType constant.MemoryRetrieval `json:"step_type,required"` - // The ID of the turn. - TurnID string `json:"turn_id,required"` - // The IDs of the vector databases to retrieve context from. - VectorDBIDs string `json:"vector_db_ids,required"` - // The time the step completed. - CompletedAt time.Time `json:"completed_at" format:"date-time"` - // The time the step started. - StartedAt time.Time `json:"started_at" format:"date-time"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - InsertedContext respjson.Field - StepID respjson.Field - StepType respjson.Field - TurnID respjson.Field - VectorDBIDs respjson.Field - CompletedAt respjson.Field - StartedAt respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r MemoryRetrievalStep) RawJSON() string { return r.JSON.raw } -func (r *MemoryRetrievalStep) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A shield call step in an agent turn. -type ShieldCallStep struct { - // The ID of the step. - StepID string `json:"step_id,required"` - // Type of the step in an agent turn. - StepType constant.ShieldCall `json:"step_type,required"` - // The ID of the turn. - TurnID string `json:"turn_id,required"` - // The time the step completed. - CompletedAt time.Time `json:"completed_at" format:"date-time"` - // The time the step started. - StartedAt time.Time `json:"started_at" format:"date-time"` - // The violation from the shield call. - Violation shared.SafetyViolation `json:"violation"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - StepID respjson.Field - StepType respjson.Field - TurnID respjson.Field - CompletedAt respjson.Field - StartedAt respjson.Field - Violation respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ShieldCallStep) RawJSON() string { return r.JSON.raw } -func (r *ShieldCallStep) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A tool execution step in an agent turn. -type ToolExecutionStep struct { - // The ID of the step. - StepID string `json:"step_id,required"` - // Type of the step in an agent turn. - StepType constant.ToolExecution `json:"step_type,required"` - // The tool calls to execute. - ToolCalls []shared.ToolCall `json:"tool_calls,required"` - // The tool responses from the tool calls. - ToolResponses []ToolResponse `json:"tool_responses,required"` - // The ID of the turn. - TurnID string `json:"turn_id,required"` - // The time the step completed. - CompletedAt time.Time `json:"completed_at" format:"date-time"` - // The time the step started. - StartedAt time.Time `json:"started_at" format:"date-time"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - StepID respjson.Field - StepType respjson.Field - ToolCalls respjson.Field - ToolResponses respjson.Field - TurnID respjson.Field - CompletedAt respjson.Field - StartedAt respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ToolExecutionStep) RawJSON() string { return r.JSON.raw } -func (r *ToolExecutionStep) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Response from a tool invocation. -type ToolResponse struct { - // Unique identifier for the tool call this response is for - CallID string `json:"call_id,required"` - // The response content from the tool - Content shared.InterleavedContentUnion `json:"content,required"` - // Name of the tool that was invoked - ToolName ToolResponseToolName `json:"tool_name,required"` - // (Optional) Additional metadata about the tool response - Metadata map[string]ToolResponseMetadataUnion `json:"metadata"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - CallID respjson.Field - Content respjson.Field - ToolName respjson.Field - Metadata respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ToolResponse) RawJSON() string { return r.JSON.raw } -func (r *ToolResponse) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ToParam converts this ToolResponse to a ToolResponseParam. -// -// 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 -// ToolResponseParam.Overrides() -func (r ToolResponse) ToParam() ToolResponseParam { - return param.Override[ToolResponseParam](json.RawMessage(r.RawJSON())) -} - -// Name of the tool that was invoked -type ToolResponseToolName string - -const ( - ToolResponseToolNameBraveSearch ToolResponseToolName = "brave_search" - ToolResponseToolNameWolframAlpha ToolResponseToolName = "wolfram_alpha" - ToolResponseToolNamePhotogen ToolResponseToolName = "photogen" - ToolResponseToolNameCodeInterpreter ToolResponseToolName = "code_interpreter" -) - -// ToolResponseMetadataUnion 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 ToolResponseMetadataUnion 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 ToolResponseMetadataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ToolResponseMetadataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ToolResponseMetadataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ToolResponseMetadataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ToolResponseMetadataUnion) RawJSON() string { return u.JSON.raw } - -func (r *ToolResponseMetadataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Response from a tool invocation. -// -// The properties CallID, Content, ToolName are required. -type ToolResponseParam struct { - // Unique identifier for the tool call this response is for - CallID string `json:"call_id,required"` - // The response content from the tool - Content shared.InterleavedContentUnionParam `json:"content,omitzero,required"` - // Name of the tool that was invoked - ToolName ToolResponseToolName `json:"tool_name,omitzero,required"` - // (Optional) Additional metadata about the tool response - Metadata map[string]ToolResponseMetadataUnionParam `json:"metadata,omitzero"` - paramObj -} - -func (r ToolResponseParam) MarshalJSON() (data []byte, err error) { - type shadow ToolResponseParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *ToolResponseParam) 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 ToolResponseMetadataUnionParam 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 ToolResponseMetadataUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *ToolResponseMetadataUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ToolResponseMetadataUnionParam) 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 -} - -// Response returned when creating a new agent. -type AgentNewResponse struct { - // Unique identifier for the created agent - AgentID string `json:"agent_id,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - AgentID respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r AgentNewResponse) RawJSON() string { return r.JSON.raw } -func (r *AgentNewResponse) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// An agent instance with configuration and metadata. -type AgentGetResponse struct { - // Configuration settings for the agent - AgentConfig shared.AgentConfig `json:"agent_config,required"` - // Unique identifier for the agent - AgentID string `json:"agent_id,required"` - // Timestamp when the agent was created - CreatedAt time.Time `json:"created_at,required" format:"date-time"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - AgentConfig respjson.Field - AgentID respjson.Field - CreatedAt respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r AgentGetResponse) RawJSON() string { return r.JSON.raw } -func (r *AgentGetResponse) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A generic paginated response that follows a simple format. -type AgentListResponse struct { - // The list of items for the current page - Data []map[string]AgentListResponseDataUnion `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"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Data respjson.Field - HasMore respjson.Field - URL respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r AgentListResponse) RawJSON() string { return r.JSON.raw } -func (r *AgentListResponse) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// AgentListResponseDataUnion 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 AgentListResponseDataUnion 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 AgentListResponseDataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u AgentListResponseDataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u AgentListResponseDataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u AgentListResponseDataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u AgentListResponseDataUnion) RawJSON() string { return u.JSON.raw } - -func (r *AgentListResponseDataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type AgentNewParams struct { - // The configuration for the agent. - AgentConfig shared.AgentConfigParam `json:"agent_config,omitzero,required"` - paramObj -} - -func (r AgentNewParams) MarshalJSON() (data []byte, err error) { - type shadow AgentNewParams - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *AgentNewParams) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type AgentListParams struct { - // The number of agents to return. - Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` - // The index to start the pagination from. - StartIndex param.Opt[int64] `query:"start_index,omitzero" json:"-"` - paramObj -} - -// URLQuery serializes [AgentListParams]'s query parameters as `url.Values`. -func (r AgentListParams) URLQuery() (v url.Values, err error) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} diff --git a/agent_test.go b/agent_test.go deleted file mode 100644 index 24d9e3c..0000000 --- a/agent_test.go +++ /dev/null @@ -1,157 +0,0 @@ -// 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" - "github.com/llamastack/llama-stack-client-go/shared" -) - -func TestAgentNewWithOptionalParams(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.Agents.New(context.TODO(), llamastackclient.AgentNewParams{ - AgentConfig: shared.AgentConfigParam{ - Instructions: "instructions", - Model: "model", - ClientTools: []shared.SharedToolDefParam{{ - Name: "name", - Description: llamastackclient.String("description"), - Metadata: map[string]shared.SharedToolDefMetadataUnionParam{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, - }, - Parameters: []shared.SharedToolDefParameterParam{{ - Description: "description", - Name: "name", - ParameterType: "parameter_type", - Required: true, - Default: shared.SharedToolDefParameterDefaultUnionParam{ - OfBool: llamastackclient.Bool(true), - }, - }}, - }}, - EnableSessionPersistence: llamastackclient.Bool(true), - InputShields: []string{"string"}, - MaxInferIters: llamastackclient.Int(0), - Name: llamastackclient.String("name"), - OutputShields: []string{"string"}, - ResponseFormat: shared.ResponseFormatUnionParam{ - OfJsonSchema: &shared.ResponseFormatJsonSchemaParam{ - JsonSchema: map[string]shared.ResponseFormatJsonSchemaJsonSchemaUnionParam{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, - }, - }, - }, - SamplingParams: shared.SamplingParams{ - Strategy: shared.SamplingParamsStrategyUnion{ - OfGreedy: &shared.SamplingParamsStrategyGreedy{}, - }, - MaxTokens: llamastackclient.Int(0), - RepetitionPenalty: llamastackclient.Float(0), - Stop: []string{"string"}, - }, - ToolChoice: shared.AgentConfigToolChoiceAuto, - ToolConfig: shared.AgentConfigToolConfigParam{ - SystemMessageBehavior: "append", - ToolChoice: "auto", - ToolPromptFormat: "json", - }, - ToolPromptFormat: shared.AgentConfigToolPromptFormatJson, - Toolgroups: []shared.AgentConfigToolgroupUnionParam{{ - OfString: llamastackclient.String("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 TestAgentGet(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.Agents.Get(context.TODO(), "agent_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 TestAgentListWithOptionalParams(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.Agents.List(context.TODO(), llamastackclient.AgentListParams{ - Limit: llamastackclient.Int(0), - StartIndex: 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 TestAgentDelete(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.Agents.Delete(context.TODO(), "agent_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/agentsession.go b/agentsession.go deleted file mode 100644 index 6685efb..0000000 --- a/agentsession.go +++ /dev/null @@ -1,267 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package llamastackclient - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "net/http" - "net/url" - "time" - - "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/param" - "github.com/llamastack/llama-stack-client-go/packages/respjson" -) - -// AgentSessionService 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 [NewAgentSessionService] method instead. -type AgentSessionService struct { - Options []option.RequestOption -} - -// NewAgentSessionService 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 NewAgentSessionService(opts ...option.RequestOption) (r AgentSessionService) { - r = AgentSessionService{} - r.Options = opts - return -} - -// Create a new session for an agent. -func (r *AgentSessionService) New(ctx context.Context, agentID string, body AgentSessionNewParams, opts ...option.RequestOption) (res *AgentSessionNewResponse, err error) { - opts = append(r.Options[:], opts...) - if agentID == "" { - err = errors.New("missing required agent_id parameter") - return - } - path := fmt.Sprintf("v1/agents/%s/session", agentID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) - return -} - -// Retrieve an agent session by its ID. -func (r *AgentSessionService) Get(ctx context.Context, sessionID string, params AgentSessionGetParams, opts ...option.RequestOption) (res *Session, err error) { - opts = append(r.Options[:], opts...) - if params.AgentID == "" { - err = errors.New("missing required agent_id parameter") - return - } - if sessionID == "" { - err = errors.New("missing required session_id parameter") - return - } - path := fmt.Sprintf("v1/agents/%s/session/%s", params.AgentID, sessionID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &res, opts...) - return -} - -// List all session(s) of a given agent. -func (r *AgentSessionService) List(ctx context.Context, agentID string, query AgentSessionListParams, opts ...option.RequestOption) (res *AgentSessionListResponse, err error) { - opts = append(r.Options[:], opts...) - if agentID == "" { - err = errors.New("missing required agent_id parameter") - return - } - path := fmt.Sprintf("v1/agents/%s/sessions", agentID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) - return -} - -// Delete an agent session by its ID and its associated turns. -func (r *AgentSessionService) Delete(ctx context.Context, sessionID string, body AgentSessionDeleteParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - if body.AgentID == "" { - err = errors.New("missing required agent_id parameter") - return - } - if sessionID == "" { - err = errors.New("missing required session_id parameter") - return - } - path := fmt.Sprintf("v1/agents/%s/session/%s", body.AgentID, sessionID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...) - return -} - -// A single session of an interaction with an Agentic System. -type Session struct { - // Unique identifier for the conversation session - SessionID string `json:"session_id,required"` - // Human-readable name for the session - SessionName string `json:"session_name,required"` - // Timestamp when the session was created - StartedAt time.Time `json:"started_at,required" format:"date-time"` - // List of all turns that have occurred in this session - Turns []Turn `json:"turns,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - SessionID respjson.Field - SessionName respjson.Field - StartedAt respjson.Field - Turns respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r Session) RawJSON() string { return r.JSON.raw } -func (r *Session) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Response returned when creating a new agent session. -type AgentSessionNewResponse struct { - // Unique identifier for the created session - SessionID string `json:"session_id,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - SessionID respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r AgentSessionNewResponse) RawJSON() string { return r.JSON.raw } -func (r *AgentSessionNewResponse) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A generic paginated response that follows a simple format. -type AgentSessionListResponse struct { - // The list of items for the current page - Data []map[string]AgentSessionListResponseDataUnion `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"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Data respjson.Field - HasMore respjson.Field - URL respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r AgentSessionListResponse) RawJSON() string { return r.JSON.raw } -func (r *AgentSessionListResponse) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// AgentSessionListResponseDataUnion 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 AgentSessionListResponseDataUnion 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 AgentSessionListResponseDataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u AgentSessionListResponseDataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u AgentSessionListResponseDataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u AgentSessionListResponseDataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u AgentSessionListResponseDataUnion) RawJSON() string { return u.JSON.raw } - -func (r *AgentSessionListResponseDataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type AgentSessionNewParams struct { - // The name of the session to create. - SessionName string `json:"session_name,required"` - paramObj -} - -func (r AgentSessionNewParams) MarshalJSON() (data []byte, err error) { - type shadow AgentSessionNewParams - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *AgentSessionNewParams) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type AgentSessionGetParams struct { - AgentID string `path:"agent_id,required" json:"-"` - // (Optional) List of turn IDs to filter the session by. - TurnIDs []string `query:"turn_ids,omitzero" json:"-"` - paramObj -} - -// URLQuery serializes [AgentSessionGetParams]'s query parameters as `url.Values`. -func (r AgentSessionGetParams) URLQuery() (v url.Values, err error) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type AgentSessionListParams struct { - // The number of sessions to return. - Limit param.Opt[int64] `query:"limit,omitzero" json:"-"` - // The index to start the pagination from. - StartIndex param.Opt[int64] `query:"start_index,omitzero" json:"-"` - paramObj -} - -// URLQuery serializes [AgentSessionListParams]'s query parameters as `url.Values`. -func (r AgentSessionListParams) URLQuery() (v url.Values, err error) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type AgentSessionDeleteParams struct { - AgentID string `path:"agent_id,required" json:"-"` - paramObj -} diff --git a/agentstep.go b/agentstep.go deleted file mode 100644 index 40ddfa3..0000000 --- a/agentstep.go +++ /dev/null @@ -1,190 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package llamastackclient - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "net/http" - "time" - - "github.com/llamastack/llama-stack-client-go/internal/apijson" - "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/respjson" - "github.com/llamastack/llama-stack-client-go/shared" -) - -// AgentStepService 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 [NewAgentStepService] method instead. -type AgentStepService struct { - Options []option.RequestOption -} - -// NewAgentStepService 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 NewAgentStepService(opts ...option.RequestOption) (r AgentStepService) { - r = AgentStepService{} - r.Options = opts - return -} - -// Retrieve an agent step by its ID. -func (r *AgentStepService) Get(ctx context.Context, stepID string, query AgentStepGetParams, opts ...option.RequestOption) (res *AgentStepGetResponse, err error) { - opts = append(r.Options[:], opts...) - if query.AgentID == "" { - err = errors.New("missing required agent_id parameter") - return - } - if query.SessionID == "" { - err = errors.New("missing required session_id parameter") - return - } - if query.TurnID == "" { - err = errors.New("missing required turn_id parameter") - return - } - if stepID == "" { - err = errors.New("missing required step_id parameter") - return - } - path := fmt.Sprintf("v1/agents/%s/session/%s/turn/%s/step/%s", query.AgentID, query.SessionID, query.TurnID, stepID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) - return -} - -// Response containing details of a specific agent step. -type AgentStepGetResponse struct { - // The complete step data and execution details - Step AgentStepGetResponseStepUnion `json:"step,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Step respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r AgentStepGetResponse) RawJSON() string { return r.JSON.raw } -func (r *AgentStepGetResponse) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// AgentStepGetResponseStepUnion contains all possible properties and values from -// [InferenceStep], [ToolExecutionStep], [ShieldCallStep], [MemoryRetrievalStep]. -// -// Use the [AgentStepGetResponseStepUnion.AsAny] method to switch on the variant. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -type AgentStepGetResponseStepUnion struct { - // This field is from variant [InferenceStep]. - ModelResponse shared.CompletionMessage `json:"model_response"` - StepID string `json:"step_id"` - // Any of "inference", "tool_execution", "shield_call", "memory_retrieval". - StepType string `json:"step_type"` - TurnID string `json:"turn_id"` - CompletedAt time.Time `json:"completed_at"` - StartedAt time.Time `json:"started_at"` - // This field is from variant [ToolExecutionStep]. - ToolCalls []shared.ToolCall `json:"tool_calls"` - // This field is from variant [ToolExecutionStep]. - ToolResponses []ToolResponse `json:"tool_responses"` - // This field is from variant [ShieldCallStep]. - Violation shared.SafetyViolation `json:"violation"` - // This field is from variant [MemoryRetrievalStep]. - InsertedContext shared.InterleavedContentUnion `json:"inserted_context"` - // This field is from variant [MemoryRetrievalStep]. - VectorDBIDs string `json:"vector_db_ids"` - JSON struct { - ModelResponse respjson.Field - StepID respjson.Field - StepType respjson.Field - TurnID respjson.Field - CompletedAt respjson.Field - StartedAt respjson.Field - ToolCalls respjson.Field - ToolResponses respjson.Field - Violation respjson.Field - InsertedContext respjson.Field - VectorDBIDs respjson.Field - raw string - } `json:"-"` -} - -// anyAgentStepGetResponseStep is implemented by each variant of -// [AgentStepGetResponseStepUnion] to add type safety for the return type of -// [AgentStepGetResponseStepUnion.AsAny] -type anyAgentStepGetResponseStep interface { - implAgentStepGetResponseStepUnion() -} - -func (InferenceStep) implAgentStepGetResponseStepUnion() {} -func (ToolExecutionStep) implAgentStepGetResponseStepUnion() {} -func (ShieldCallStep) implAgentStepGetResponseStepUnion() {} -func (MemoryRetrievalStep) implAgentStepGetResponseStepUnion() {} - -// Use the following switch statement to find the correct variant -// -// switch variant := AgentStepGetResponseStepUnion.AsAny().(type) { -// case llamastackclient.InferenceStep: -// case llamastackclient.ToolExecutionStep: -// case llamastackclient.ShieldCallStep: -// case llamastackclient.MemoryRetrievalStep: -// default: -// fmt.Errorf("no variant present") -// } -func (u AgentStepGetResponseStepUnion) AsAny() anyAgentStepGetResponseStep { - switch u.StepType { - case "inference": - return u.AsInference() - case "tool_execution": - return u.AsToolExecution() - case "shield_call": - return u.AsShieldCall() - case "memory_retrieval": - return u.AsMemoryRetrieval() - } - return nil -} - -func (u AgentStepGetResponseStepUnion) AsInference() (v InferenceStep) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u AgentStepGetResponseStepUnion) AsToolExecution() (v ToolExecutionStep) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u AgentStepGetResponseStepUnion) AsShieldCall() (v ShieldCallStep) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u AgentStepGetResponseStepUnion) AsMemoryRetrieval() (v MemoryRetrievalStep) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u AgentStepGetResponseStepUnion) RawJSON() string { return u.JSON.raw } - -func (r *AgentStepGetResponseStepUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type AgentStepGetParams struct { - AgentID string `path:"agent_id,required" json:"-"` - SessionID string `path:"session_id,required" json:"-"` - TurnID string `path:"turn_id,required" json:"-"` - paramObj -} diff --git a/agentturn.go b/agentturn.go deleted file mode 100644 index d3f14af..0000000 --- a/agentturn.go +++ /dev/null @@ -1,1386 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package llamastackclient - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "net/http" - "time" - - "github.com/llamastack/llama-stack-client-go/internal/apijson" - "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/packages/ssestream" - "github.com/llamastack/llama-stack-client-go/shared" - "github.com/llamastack/llama-stack-client-go/shared/constant" -) - -// AgentTurnService 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 [NewAgentTurnService] method instead. -type AgentTurnService struct { - Options []option.RequestOption -} - -// NewAgentTurnService 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 NewAgentTurnService(opts ...option.RequestOption) (r AgentTurnService) { - r = AgentTurnService{} - r.Options = opts - return -} - -// Create a new turn for an agent. -func (r *AgentTurnService) New(ctx context.Context, sessionID string, params AgentTurnNewParams, opts ...option.RequestOption) (res *Turn, err error) { - opts = append(r.Options[:], opts...) - if params.AgentID == "" { - err = errors.New("missing required agent_id parameter") - return - } - if sessionID == "" { - err = errors.New("missing required session_id parameter") - return - } - path := fmt.Sprintf("v1/agents/%s/session/%s/turn", params.AgentID, sessionID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...) - return -} - -// Create a new turn for an agent. -func (r *AgentTurnService) NewStreaming(ctx context.Context, sessionID string, params AgentTurnNewParams, opts ...option.RequestOption) (stream *ssestream.Stream[AgentTurnResponseStreamChunk]) { - var ( - raw *http.Response - err error - ) - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithJSONSet("stream", true)}, opts...) - if params.AgentID == "" { - err = errors.New("missing required agent_id parameter") - return - } - if sessionID == "" { - err = errors.New("missing required session_id parameter") - return - } - path := fmt.Sprintf("v1/agents/%s/session/%s/turn", params.AgentID, sessionID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &raw, opts...) - return ssestream.NewStream[AgentTurnResponseStreamChunk](ssestream.NewDecoder(raw), err) -} - -// Retrieve an agent turn by its ID. -func (r *AgentTurnService) Get(ctx context.Context, turnID string, query AgentTurnGetParams, opts ...option.RequestOption) (res *Turn, err error) { - opts = append(r.Options[:], opts...) - if query.AgentID == "" { - err = errors.New("missing required agent_id parameter") - return - } - if query.SessionID == "" { - err = errors.New("missing required session_id parameter") - return - } - if turnID == "" { - err = errors.New("missing required turn_id parameter") - return - } - path := fmt.Sprintf("v1/agents/%s/session/%s/turn/%s", query.AgentID, query.SessionID, turnID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) - return -} - -// Resume an agent turn with executed tool call responses. When a Turn has the -// status `awaiting_input` due to pending input from client side tool calls, this -// endpoint can be used to submit the outputs from the tool calls once they are -// ready. -func (r *AgentTurnService) Resume(ctx context.Context, turnID string, params AgentTurnResumeParams, opts ...option.RequestOption) (res *Turn, err error) { - opts = append(r.Options[:], opts...) - if params.AgentID == "" { - err = errors.New("missing required agent_id parameter") - return - } - if params.SessionID == "" { - err = errors.New("missing required session_id parameter") - return - } - if turnID == "" { - err = errors.New("missing required turn_id parameter") - return - } - path := fmt.Sprintf("v1/agents/%s/session/%s/turn/%s/resume", params.AgentID, params.SessionID, turnID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...) - return -} - -// Resume an agent turn with executed tool call responses. When a Turn has the -// status `awaiting_input` due to pending input from client side tool calls, this -// endpoint can be used to submit the outputs from the tool calls once they are -// ready. -func (r *AgentTurnService) ResumeStreaming(ctx context.Context, turnID string, params AgentTurnResumeParams, opts ...option.RequestOption) (stream *ssestream.Stream[AgentTurnResponseStreamChunk]) { - var ( - raw *http.Response - err error - ) - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithJSONSet("stream", true)}, opts...) - if params.AgentID == "" { - err = errors.New("missing required agent_id parameter") - return - } - if params.SessionID == "" { - err = errors.New("missing required session_id parameter") - return - } - if turnID == "" { - err = errors.New("missing required turn_id parameter") - return - } - path := fmt.Sprintf("v1/agents/%s/session/%s/turn/%s/resume", params.AgentID, params.SessionID, turnID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &raw, opts...) - return ssestream.NewStream[AgentTurnResponseStreamChunk](ssestream.NewDecoder(raw), err) -} - -// Streamed agent turn completion response. -type AgentTurnResponseStreamChunk struct { - // Individual event in the agent turn response stream - Event TurnResponseEvent `json:"event,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Event respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r AgentTurnResponseStreamChunk) RawJSON() string { return r.JSON.raw } -func (r *AgentTurnResponseStreamChunk) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A single turn in an interaction with an Agentic System. -type Turn struct { - // List of messages that initiated this turn - InputMessages []TurnInputMessageUnion `json:"input_messages,required"` - // The model's generated response containing content and metadata - OutputMessage shared.CompletionMessage `json:"output_message,required"` - // Unique identifier for the conversation session - SessionID string `json:"session_id,required"` - // Timestamp when the turn began - StartedAt time.Time `json:"started_at,required" format:"date-time"` - // Ordered list of processing steps executed during this turn - Steps []TurnStepUnion `json:"steps,required"` - // Unique identifier for the turn within a session - TurnID string `json:"turn_id,required"` - // (Optional) Timestamp when the turn finished, if completed - CompletedAt time.Time `json:"completed_at" format:"date-time"` - // (Optional) Files or media attached to the agent's response - OutputAttachments []TurnOutputAttachment `json:"output_attachments"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - InputMessages respjson.Field - OutputMessage respjson.Field - SessionID respjson.Field - StartedAt respjson.Field - Steps respjson.Field - TurnID respjson.Field - CompletedAt respjson.Field - OutputAttachments respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r Turn) RawJSON() string { return r.JSON.raw } -func (r *Turn) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// TurnInputMessageUnion contains all possible properties and values from -// [shared.UserMessage], [shared.ToolResponseMessage]. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -type TurnInputMessageUnion struct { - // This field is from variant [shared.UserMessage]. - Content shared.InterleavedContentUnion `json:"content"` - Role string `json:"role"` - // This field is from variant [shared.UserMessage]. - Context shared.InterleavedContentUnion `json:"context"` - // This field is from variant [shared.ToolResponseMessage]. - CallID string `json:"call_id"` - JSON struct { - Content respjson.Field - Role respjson.Field - Context respjson.Field - CallID respjson.Field - raw string - } `json:"-"` -} - -func (u TurnInputMessageUnion) AsUserMessage() (v shared.UserMessage) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u TurnInputMessageUnion) AsToolResponseMessage() (v shared.ToolResponseMessage) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u TurnInputMessageUnion) RawJSON() string { return u.JSON.raw } - -func (r *TurnInputMessageUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// TurnStepUnion contains all possible properties and values from [InferenceStep], -// [ToolExecutionStep], [ShieldCallStep], [MemoryRetrievalStep]. -// -// Use the [TurnStepUnion.AsAny] method to switch on the variant. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -type TurnStepUnion struct { - // This field is from variant [InferenceStep]. - ModelResponse shared.CompletionMessage `json:"model_response"` - StepID string `json:"step_id"` - // Any of "inference", "tool_execution", "shield_call", "memory_retrieval". - StepType string `json:"step_type"` - TurnID string `json:"turn_id"` - CompletedAt time.Time `json:"completed_at"` - StartedAt time.Time `json:"started_at"` - // This field is from variant [ToolExecutionStep]. - ToolCalls []shared.ToolCall `json:"tool_calls"` - // This field is from variant [ToolExecutionStep]. - ToolResponses []ToolResponse `json:"tool_responses"` - // This field is from variant [ShieldCallStep]. - Violation shared.SafetyViolation `json:"violation"` - // This field is from variant [MemoryRetrievalStep]. - InsertedContext shared.InterleavedContentUnion `json:"inserted_context"` - // This field is from variant [MemoryRetrievalStep]. - VectorDBIDs string `json:"vector_db_ids"` - JSON struct { - ModelResponse respjson.Field - StepID respjson.Field - StepType respjson.Field - TurnID respjson.Field - CompletedAt respjson.Field - StartedAt respjson.Field - ToolCalls respjson.Field - ToolResponses respjson.Field - Violation respjson.Field - InsertedContext respjson.Field - VectorDBIDs respjson.Field - raw string - } `json:"-"` -} - -// anyTurnStep is implemented by each variant of [TurnStepUnion] to add type safety -// for the return type of [TurnStepUnion.AsAny] -type anyTurnStep interface { - implTurnStepUnion() -} - -func (InferenceStep) implTurnStepUnion() {} -func (ToolExecutionStep) implTurnStepUnion() {} -func (ShieldCallStep) implTurnStepUnion() {} -func (MemoryRetrievalStep) implTurnStepUnion() {} - -// Use the following switch statement to find the correct variant -// -// switch variant := TurnStepUnion.AsAny().(type) { -// case llamastackclient.InferenceStep: -// case llamastackclient.ToolExecutionStep: -// case llamastackclient.ShieldCallStep: -// case llamastackclient.MemoryRetrievalStep: -// default: -// fmt.Errorf("no variant present") -// } -func (u TurnStepUnion) AsAny() anyTurnStep { - switch u.StepType { - case "inference": - return u.AsInference() - case "tool_execution": - return u.AsToolExecution() - case "shield_call": - return u.AsShieldCall() - case "memory_retrieval": - return u.AsMemoryRetrieval() - } - return nil -} - -func (u TurnStepUnion) AsInference() (v InferenceStep) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u TurnStepUnion) AsToolExecution() (v ToolExecutionStep) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u TurnStepUnion) AsShieldCall() (v ShieldCallStep) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u TurnStepUnion) AsMemoryRetrieval() (v MemoryRetrievalStep) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u TurnStepUnion) RawJSON() string { return u.JSON.raw } - -func (r *TurnStepUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// An attachment to an agent turn. -type TurnOutputAttachment struct { - // The content of the attachment. - Content TurnOutputAttachmentContentUnion `json:"content,required"` - // The MIME type of the attachment. - MimeType string `json:"mime_type,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Content respjson.Field - MimeType respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r TurnOutputAttachment) RawJSON() string { return r.JSON.raw } -func (r *TurnOutputAttachment) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// TurnOutputAttachmentContentUnion contains all possible properties and values -// from [string], [TurnOutputAttachmentContentImageContentItem], -// [TurnOutputAttachmentContentTextContentItem], -// [[]shared.InterleavedContentItemUnion], [TurnOutputAttachmentContentURL]. -// -// 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 TurnOutputAttachmentContentUnion 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 - // [[]shared.InterleavedContentItemUnion] instead of an object. - OfInterleavedContentItemArray []shared.InterleavedContentItemUnion `json:",inline"` - // This field is from variant [TurnOutputAttachmentContentImageContentItem]. - Image TurnOutputAttachmentContentImageContentItemImage `json:"image"` - Type string `json:"type"` - // This field is from variant [TurnOutputAttachmentContentTextContentItem]. - Text string `json:"text"` - // This field is from variant [TurnOutputAttachmentContentURL]. - Uri string `json:"uri"` - JSON struct { - OfString respjson.Field - OfInterleavedContentItemArray respjson.Field - Image respjson.Field - Type respjson.Field - Text respjson.Field - Uri respjson.Field - raw string - } `json:"-"` -} - -func (u TurnOutputAttachmentContentUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u TurnOutputAttachmentContentUnion) AsImageContentItem() (v TurnOutputAttachmentContentImageContentItem) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u TurnOutputAttachmentContentUnion) AsTextContentItem() (v TurnOutputAttachmentContentTextContentItem) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u TurnOutputAttachmentContentUnion) AsInterleavedContentItemArray() (v []shared.InterleavedContentItemUnion) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u TurnOutputAttachmentContentUnion) AsURL() (v TurnOutputAttachmentContentURL) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u TurnOutputAttachmentContentUnion) RawJSON() string { return u.JSON.raw } - -func (r *TurnOutputAttachmentContentUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A image content item -type TurnOutputAttachmentContentImageContentItem struct { - // Image as a base64 encoded string or an URL - Image TurnOutputAttachmentContentImageContentItemImage `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 TurnOutputAttachmentContentImageContentItem) RawJSON() string { return r.JSON.raw } -func (r *TurnOutputAttachmentContentImageContentItem) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Image as a base64 encoded string or an URL -type TurnOutputAttachmentContentImageContentItemImage 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 TurnOutputAttachmentContentImageContentItemImageURL `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 TurnOutputAttachmentContentImageContentItemImage) RawJSON() string { return r.JSON.raw } -func (r *TurnOutputAttachmentContentImageContentItemImage) 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 TurnOutputAttachmentContentImageContentItemImageURL 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 TurnOutputAttachmentContentImageContentItemImageURL) RawJSON() string { return r.JSON.raw } -func (r *TurnOutputAttachmentContentImageContentItemImageURL) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A text content item -type TurnOutputAttachmentContentTextContentItem 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:"-"` -} - -// Returns the unmodified JSON received from the API -func (r TurnOutputAttachmentContentTextContentItem) RawJSON() string { return r.JSON.raw } -func (r *TurnOutputAttachmentContentTextContentItem) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A URL reference to external content. -type TurnOutputAttachmentContentURL 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 TurnOutputAttachmentContentURL) RawJSON() string { return r.JSON.raw } -func (r *TurnOutputAttachmentContentURL) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// An event in an agent turn response stream. -type TurnResponseEvent struct { - // Event-specific payload containing event data - Payload TurnResponseEventPayloadUnion `json:"payload,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Payload respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r TurnResponseEvent) RawJSON() string { return r.JSON.raw } -func (r *TurnResponseEvent) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// TurnResponseEventPayloadUnion contains all possible properties and values from -// [TurnResponseEventPayloadStepStart], [TurnResponseEventPayloadStepProgress], -// [TurnResponseEventPayloadStepComplete], [TurnResponseEventPayloadTurnStart], -// [TurnResponseEventPayloadTurnComplete], -// [TurnResponseEventPayloadTurnAwaitingInput]. -// -// Use the [TurnResponseEventPayloadUnion.AsAny] method to switch on the variant. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -type TurnResponseEventPayloadUnion struct { - // Any of "step_start", "step_progress", "step_complete", "turn_start", - // "turn_complete", "turn_awaiting_input". - EventType string `json:"event_type"` - StepID string `json:"step_id"` - StepType string `json:"step_type"` - // This field is from variant [TurnResponseEventPayloadStepStart]. - Metadata map[string]TurnResponseEventPayloadStepStartMetadataUnion `json:"metadata"` - // This field is from variant [TurnResponseEventPayloadStepProgress]. - Delta shared.ContentDeltaUnion `json:"delta"` - // This field is from variant [TurnResponseEventPayloadStepComplete]. - StepDetails TurnResponseEventPayloadStepCompleteStepDetailsUnion `json:"step_details"` - // This field is from variant [TurnResponseEventPayloadTurnStart]. - TurnID string `json:"turn_id"` - // This field is from variant [TurnResponseEventPayloadTurnComplete]. - Turn Turn `json:"turn"` - JSON struct { - EventType respjson.Field - StepID respjson.Field - StepType respjson.Field - Metadata respjson.Field - Delta respjson.Field - StepDetails respjson.Field - TurnID respjson.Field - Turn respjson.Field - raw string - } `json:"-"` -} - -// anyTurnResponseEventPayload is implemented by each variant of -// [TurnResponseEventPayloadUnion] to add type safety for the return type of -// [TurnResponseEventPayloadUnion.AsAny] -type anyTurnResponseEventPayload interface { - implTurnResponseEventPayloadUnion() -} - -func (TurnResponseEventPayloadStepStart) implTurnResponseEventPayloadUnion() {} -func (TurnResponseEventPayloadStepProgress) implTurnResponseEventPayloadUnion() {} -func (TurnResponseEventPayloadStepComplete) implTurnResponseEventPayloadUnion() {} -func (TurnResponseEventPayloadTurnStart) implTurnResponseEventPayloadUnion() {} -func (TurnResponseEventPayloadTurnComplete) implTurnResponseEventPayloadUnion() {} -func (TurnResponseEventPayloadTurnAwaitingInput) implTurnResponseEventPayloadUnion() {} - -// Use the following switch statement to find the correct variant -// -// switch variant := TurnResponseEventPayloadUnion.AsAny().(type) { -// case llamastackclient.TurnResponseEventPayloadStepStart: -// case llamastackclient.TurnResponseEventPayloadStepProgress: -// case llamastackclient.TurnResponseEventPayloadStepComplete: -// case llamastackclient.TurnResponseEventPayloadTurnStart: -// case llamastackclient.TurnResponseEventPayloadTurnComplete: -// case llamastackclient.TurnResponseEventPayloadTurnAwaitingInput: -// default: -// fmt.Errorf("no variant present") -// } -func (u TurnResponseEventPayloadUnion) AsAny() anyTurnResponseEventPayload { - switch u.EventType { - case "step_start": - return u.AsStepStart() - case "step_progress": - return u.AsStepProgress() - case "step_complete": - return u.AsStepComplete() - case "turn_start": - return u.AsTurnStart() - case "turn_complete": - return u.AsTurnComplete() - case "turn_awaiting_input": - return u.AsTurnAwaitingInput() - } - return nil -} - -func (u TurnResponseEventPayloadUnion) AsStepStart() (v TurnResponseEventPayloadStepStart) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u TurnResponseEventPayloadUnion) AsStepProgress() (v TurnResponseEventPayloadStepProgress) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u TurnResponseEventPayloadUnion) AsStepComplete() (v TurnResponseEventPayloadStepComplete) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u TurnResponseEventPayloadUnion) AsTurnStart() (v TurnResponseEventPayloadTurnStart) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u TurnResponseEventPayloadUnion) AsTurnComplete() (v TurnResponseEventPayloadTurnComplete) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u TurnResponseEventPayloadUnion) AsTurnAwaitingInput() (v TurnResponseEventPayloadTurnAwaitingInput) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u TurnResponseEventPayloadUnion) RawJSON() string { return u.JSON.raw } - -func (r *TurnResponseEventPayloadUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Payload for step start events in agent turn responses. -type TurnResponseEventPayloadStepStart struct { - // Type of event being reported - EventType constant.StepStart `json:"event_type,required"` - // Unique identifier for the step within a turn - StepID string `json:"step_id,required"` - // Type of step being executed - // - // Any of "inference", "tool_execution", "shield_call", "memory_retrieval". - StepType string `json:"step_type,required"` - // (Optional) Additional metadata for the step - Metadata map[string]TurnResponseEventPayloadStepStartMetadataUnion `json:"metadata"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - EventType respjson.Field - StepID respjson.Field - StepType respjson.Field - Metadata respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r TurnResponseEventPayloadStepStart) RawJSON() string { return r.JSON.raw } -func (r *TurnResponseEventPayloadStepStart) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// TurnResponseEventPayloadStepStartMetadataUnion 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 TurnResponseEventPayloadStepStartMetadataUnion 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 TurnResponseEventPayloadStepStartMetadataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u TurnResponseEventPayloadStepStartMetadataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u TurnResponseEventPayloadStepStartMetadataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u TurnResponseEventPayloadStepStartMetadataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u TurnResponseEventPayloadStepStartMetadataUnion) RawJSON() string { return u.JSON.raw } - -func (r *TurnResponseEventPayloadStepStartMetadataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Payload for step progress events in agent turn responses. -type TurnResponseEventPayloadStepProgress struct { - // Incremental content changes during step execution - Delta shared.ContentDeltaUnion `json:"delta,required"` - // Type of event being reported - EventType constant.StepProgress `json:"event_type,required"` - // Unique identifier for the step within a turn - StepID string `json:"step_id,required"` - // Type of step being executed - // - // Any of "inference", "tool_execution", "shield_call", "memory_retrieval". - StepType string `json:"step_type,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Delta respjson.Field - EventType respjson.Field - StepID respjson.Field - StepType respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r TurnResponseEventPayloadStepProgress) RawJSON() string { return r.JSON.raw } -func (r *TurnResponseEventPayloadStepProgress) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Payload for step completion events in agent turn responses. -type TurnResponseEventPayloadStepComplete struct { - // Type of event being reported - EventType constant.StepComplete `json:"event_type,required"` - // Complete details of the executed step - StepDetails TurnResponseEventPayloadStepCompleteStepDetailsUnion `json:"step_details,required"` - // Unique identifier for the step within a turn - StepID string `json:"step_id,required"` - // Type of step being executed - // - // Any of "inference", "tool_execution", "shield_call", "memory_retrieval". - StepType string `json:"step_type,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - EventType respjson.Field - StepDetails respjson.Field - StepID respjson.Field - StepType respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r TurnResponseEventPayloadStepComplete) RawJSON() string { return r.JSON.raw } -func (r *TurnResponseEventPayloadStepComplete) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// TurnResponseEventPayloadStepCompleteStepDetailsUnion contains all possible -// properties and values from [InferenceStep], [ToolExecutionStep], -// [ShieldCallStep], [MemoryRetrievalStep]. -// -// Use the [TurnResponseEventPayloadStepCompleteStepDetailsUnion.AsAny] method to -// switch on the variant. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -type TurnResponseEventPayloadStepCompleteStepDetailsUnion struct { - // This field is from variant [InferenceStep]. - ModelResponse shared.CompletionMessage `json:"model_response"` - StepID string `json:"step_id"` - // Any of "inference", "tool_execution", "shield_call", "memory_retrieval". - StepType string `json:"step_type"` - TurnID string `json:"turn_id"` - CompletedAt time.Time `json:"completed_at"` - StartedAt time.Time `json:"started_at"` - // This field is from variant [ToolExecutionStep]. - ToolCalls []shared.ToolCall `json:"tool_calls"` - // This field is from variant [ToolExecutionStep]. - ToolResponses []ToolResponse `json:"tool_responses"` - // This field is from variant [ShieldCallStep]. - Violation shared.SafetyViolation `json:"violation"` - // This field is from variant [MemoryRetrievalStep]. - InsertedContext shared.InterleavedContentUnion `json:"inserted_context"` - // This field is from variant [MemoryRetrievalStep]. - VectorDBIDs string `json:"vector_db_ids"` - JSON struct { - ModelResponse respjson.Field - StepID respjson.Field - StepType respjson.Field - TurnID respjson.Field - CompletedAt respjson.Field - StartedAt respjson.Field - ToolCalls respjson.Field - ToolResponses respjson.Field - Violation respjson.Field - InsertedContext respjson.Field - VectorDBIDs respjson.Field - raw string - } `json:"-"` -} - -// anyTurnResponseEventPayloadStepCompleteStepDetails is implemented by each -// variant of [TurnResponseEventPayloadStepCompleteStepDetailsUnion] to add type -// safety for the return type of -// [TurnResponseEventPayloadStepCompleteStepDetailsUnion.AsAny] -type anyTurnResponseEventPayloadStepCompleteStepDetails interface { - implTurnResponseEventPayloadStepCompleteStepDetailsUnion() -} - -func (InferenceStep) implTurnResponseEventPayloadStepCompleteStepDetailsUnion() {} -func (ToolExecutionStep) implTurnResponseEventPayloadStepCompleteStepDetailsUnion() {} -func (ShieldCallStep) implTurnResponseEventPayloadStepCompleteStepDetailsUnion() {} -func (MemoryRetrievalStep) implTurnResponseEventPayloadStepCompleteStepDetailsUnion() {} - -// Use the following switch statement to find the correct variant -// -// switch variant := TurnResponseEventPayloadStepCompleteStepDetailsUnion.AsAny().(type) { -// case llamastackclient.InferenceStep: -// case llamastackclient.ToolExecutionStep: -// case llamastackclient.ShieldCallStep: -// case llamastackclient.MemoryRetrievalStep: -// default: -// fmt.Errorf("no variant present") -// } -func (u TurnResponseEventPayloadStepCompleteStepDetailsUnion) AsAny() anyTurnResponseEventPayloadStepCompleteStepDetails { - switch u.StepType { - case "inference": - return u.AsInference() - case "tool_execution": - return u.AsToolExecution() - case "shield_call": - return u.AsShieldCall() - case "memory_retrieval": - return u.AsMemoryRetrieval() - } - return nil -} - -func (u TurnResponseEventPayloadStepCompleteStepDetailsUnion) AsInference() (v InferenceStep) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u TurnResponseEventPayloadStepCompleteStepDetailsUnion) AsToolExecution() (v ToolExecutionStep) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u TurnResponseEventPayloadStepCompleteStepDetailsUnion) AsShieldCall() (v ShieldCallStep) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u TurnResponseEventPayloadStepCompleteStepDetailsUnion) AsMemoryRetrieval() (v MemoryRetrievalStep) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u TurnResponseEventPayloadStepCompleteStepDetailsUnion) RawJSON() string { return u.JSON.raw } - -func (r *TurnResponseEventPayloadStepCompleteStepDetailsUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Payload for turn start events in agent turn responses. -type TurnResponseEventPayloadTurnStart struct { - // Type of event being reported - EventType constant.TurnStart `json:"event_type,required"` - // Unique identifier for the turn within a session - TurnID string `json:"turn_id,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - EventType respjson.Field - TurnID respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r TurnResponseEventPayloadTurnStart) RawJSON() string { return r.JSON.raw } -func (r *TurnResponseEventPayloadTurnStart) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Payload for turn completion events in agent turn responses. -type TurnResponseEventPayloadTurnComplete struct { - // Type of event being reported - EventType constant.TurnComplete `json:"event_type,required"` - // Complete turn data including all steps and results - Turn Turn `json:"turn,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - EventType respjson.Field - Turn respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r TurnResponseEventPayloadTurnComplete) RawJSON() string { return r.JSON.raw } -func (r *TurnResponseEventPayloadTurnComplete) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Payload for turn awaiting input events in agent turn responses. -type TurnResponseEventPayloadTurnAwaitingInput struct { - // Type of event being reported - EventType constant.TurnAwaitingInput `json:"event_type,required"` - // Turn data when waiting for external tool responses - Turn Turn `json:"turn,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - EventType respjson.Field - Turn respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r TurnResponseEventPayloadTurnAwaitingInput) RawJSON() string { return r.JSON.raw } -func (r *TurnResponseEventPayloadTurnAwaitingInput) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type AgentTurnNewParams struct { - AgentID string `path:"agent_id,required" json:"-"` - // List of messages to start the turn with. - Messages []AgentTurnNewParamsMessageUnion `json:"messages,omitzero,required"` - // (Optional) List of documents to create the turn with. - Documents []AgentTurnNewParamsDocument `json:"documents,omitzero"` - // (Optional) The tool configuration to create the turn with, will be used to - // override the agent's tool_config. - ToolConfig AgentTurnNewParamsToolConfig `json:"tool_config,omitzero"` - // (Optional) List of toolgroups to create the turn with, will be used in addition - // to the agent's config toolgroups for the request. - Toolgroups []AgentTurnNewParamsToolgroupUnion `json:"toolgroups,omitzero"` - paramObj -} - -func (r AgentTurnNewParams) MarshalJSON() (data []byte, err error) { - type shadow AgentTurnNewParams - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *AgentTurnNewParams) 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 AgentTurnNewParamsMessageUnion struct { - OfUserMessage *shared.UserMessageParam `json:",omitzero,inline"` - OfToolResponseMessage *shared.ToolResponseMessageParam `json:",omitzero,inline"` - paramUnion -} - -func (u AgentTurnNewParamsMessageUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfUserMessage, u.OfToolResponseMessage) -} -func (u *AgentTurnNewParamsMessageUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *AgentTurnNewParamsMessageUnion) asAny() any { - if !param.IsOmitted(u.OfUserMessage) { - return u.OfUserMessage - } else if !param.IsOmitted(u.OfToolResponseMessage) { - return u.OfToolResponseMessage - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u AgentTurnNewParamsMessageUnion) GetContext() *shared.InterleavedContentUnionParam { - if vt := u.OfUserMessage; vt != nil { - return &vt.Context - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u AgentTurnNewParamsMessageUnion) GetCallID() *string { - if vt := u.OfToolResponseMessage; vt != nil { - return &vt.CallID - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u AgentTurnNewParamsMessageUnion) GetRole() *string { - if vt := u.OfUserMessage; vt != nil { - return (*string)(&vt.Role) - } else if vt := u.OfToolResponseMessage; vt != nil { - return (*string)(&vt.Role) - } - return nil -} - -// Returns a pointer to the underlying variant's Content property, if present. -func (u AgentTurnNewParamsMessageUnion) GetContent() *shared.InterleavedContentUnionParam { - if vt := u.OfUserMessage; vt != nil { - return &vt.Content - } else if vt := u.OfToolResponseMessage; vt != nil { - return &vt.Content - } - return nil -} - -// A document to be used by an agent. -// -// The properties Content, MimeType are required. -type AgentTurnNewParamsDocument struct { - // The content of the document. - Content AgentTurnNewParamsDocumentContentUnion `json:"content,omitzero,required"` - // The MIME type of the document. - MimeType string `json:"mime_type,required"` - paramObj -} - -func (r AgentTurnNewParamsDocument) MarshalJSON() (data []byte, err error) { - type shadow AgentTurnNewParamsDocument - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *AgentTurnNewParamsDocument) 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 AgentTurnNewParamsDocumentContentUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfImageContentItem *AgentTurnNewParamsDocumentContentImageContentItem `json:",omitzero,inline"` - OfTextContentItem *AgentTurnNewParamsDocumentContentTextContentItem `json:",omitzero,inline"` - OfInterleavedContentItemArray []shared.InterleavedContentItemUnionParam `json:",omitzero,inline"` - OfURL *AgentTurnNewParamsDocumentContentURL `json:",omitzero,inline"` - paramUnion -} - -func (u AgentTurnNewParamsDocumentContentUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, - u.OfImageContentItem, - u.OfTextContentItem, - u.OfInterleavedContentItemArray, - u.OfURL) -} -func (u *AgentTurnNewParamsDocumentContentUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *AgentTurnNewParamsDocumentContentUnion) 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 - } else if !param.IsOmitted(u.OfURL) { - return u.OfURL - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u AgentTurnNewParamsDocumentContentUnion) GetImage() *AgentTurnNewParamsDocumentContentImageContentItemImage { - if vt := u.OfImageContentItem; vt != nil { - return &vt.Image - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u AgentTurnNewParamsDocumentContentUnion) 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 AgentTurnNewParamsDocumentContentUnion) GetUri() *string { - if vt := u.OfURL; vt != nil { - return &vt.Uri - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u AgentTurnNewParamsDocumentContentUnion) GetType() *string { - if vt := u.OfImageContentItem; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfTextContentItem; vt != nil { - return (*string)(&vt.Type) - } - return nil -} - -// A image content item -// -// The properties Image, Type are required. -type AgentTurnNewParamsDocumentContentImageContentItem struct { - // Image as a base64 encoded string or an URL - Image AgentTurnNewParamsDocumentContentImageContentItemImage `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 -} - -func (r AgentTurnNewParamsDocumentContentImageContentItem) MarshalJSON() (data []byte, err error) { - type shadow AgentTurnNewParamsDocumentContentImageContentItem - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *AgentTurnNewParamsDocumentContentImageContentItem) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Image as a base64 encoded string or an URL -type AgentTurnNewParamsDocumentContentImageContentItemImage 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 AgentTurnNewParamsDocumentContentImageContentItemImageURL `json:"url,omitzero"` - paramObj -} - -func (r AgentTurnNewParamsDocumentContentImageContentItemImage) MarshalJSON() (data []byte, err error) { - type shadow AgentTurnNewParamsDocumentContentImageContentItemImage - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *AgentTurnNewParamsDocumentContentImageContentItemImage) 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 AgentTurnNewParamsDocumentContentImageContentItemImageURL struct { - // The URL string pointing to the resource - Uri string `json:"uri,required"` - paramObj -} - -func (r AgentTurnNewParamsDocumentContentImageContentItemImageURL) MarshalJSON() (data []byte, err error) { - type shadow AgentTurnNewParamsDocumentContentImageContentItemImageURL - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *AgentTurnNewParamsDocumentContentImageContentItemImageURL) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A text content item -// -// The properties Text, Type are required. -type AgentTurnNewParamsDocumentContentTextContentItem 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"` - paramObj -} - -func (r AgentTurnNewParamsDocumentContentTextContentItem) MarshalJSON() (data []byte, err error) { - type shadow AgentTurnNewParamsDocumentContentTextContentItem - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *AgentTurnNewParamsDocumentContentTextContentItem) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A URL reference to external content. -// -// The property Uri is required. -type AgentTurnNewParamsDocumentContentURL struct { - // The URL string pointing to the resource - Uri string `json:"uri,required"` - paramObj -} - -func (r AgentTurnNewParamsDocumentContentURL) MarshalJSON() (data []byte, err error) { - type shadow AgentTurnNewParamsDocumentContentURL - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *AgentTurnNewParamsDocumentContentURL) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// (Optional) The tool configuration to create the turn with, will be used to -// override the agent's tool_config. -type AgentTurnNewParamsToolConfig struct { - // (Optional) Config for how to override the default system prompt. - - // `SystemMessageBehavior.append`: Appends the provided system message to the - // default system prompt. - `SystemMessageBehavior.replace`: Replaces the default - // system prompt with the provided system message. The system message can include - // the string '{{function_definitions}}' to indicate where the function definitions - // should be inserted. - // - // Any of "append", "replace". - SystemMessageBehavior string `json:"system_message_behavior,omitzero"` - // (Optional) Whether tool use is automatic, required, or none. Can also specify a - // tool name to use a specific tool. Defaults to ToolChoice.auto. - ToolChoice string `json:"tool_choice,omitzero"` - // (Optional) Instructs the model how to format tool calls. By default, Llama Stack - // will attempt to use a format that is best adapted to the model. - - // `ToolPromptFormat.json`: The tool calls are formatted as a JSON object. - - // `ToolPromptFormat.function_tag`: The tool calls are enclosed in a - // tag. - `ToolPromptFormat.python_list`: The tool calls - // are output as Python syntax -- a list of function calls. - // - // Any of "json", "function_tag", "python_list". - ToolPromptFormat string `json:"tool_prompt_format,omitzero"` - paramObj -} - -func (r AgentTurnNewParamsToolConfig) MarshalJSON() (data []byte, err error) { - type shadow AgentTurnNewParamsToolConfig - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *AgentTurnNewParamsToolConfig) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -func init() { - apijson.RegisterFieldValidator[AgentTurnNewParamsToolConfig]( - "system_message_behavior", "append", "replace", - ) - apijson.RegisterFieldValidator[AgentTurnNewParamsToolConfig]( - "tool_prompt_format", "json", "function_tag", "python_list", - ) -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type AgentTurnNewParamsToolgroupUnion struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfAgentToolGroupWithArgs *AgentTurnNewParamsToolgroupAgentToolGroupWithArgs `json:",omitzero,inline"` - paramUnion -} - -func (u AgentTurnNewParamsToolgroupUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfAgentToolGroupWithArgs) -} -func (u *AgentTurnNewParamsToolgroupUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *AgentTurnNewParamsToolgroupUnion) asAny() any { - if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAgentToolGroupWithArgs) { - return u.OfAgentToolGroupWithArgs - } - return nil -} - -// The properties Args, Name are required. -type AgentTurnNewParamsToolgroupAgentToolGroupWithArgs struct { - Args map[string]AgentTurnNewParamsToolgroupAgentToolGroupWithArgsArgUnion `json:"args,omitzero,required"` - Name string `json:"name,required"` - paramObj -} - -func (r AgentTurnNewParamsToolgroupAgentToolGroupWithArgs) MarshalJSON() (data []byte, err error) { - type shadow AgentTurnNewParamsToolgroupAgentToolGroupWithArgs - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *AgentTurnNewParamsToolgroupAgentToolGroupWithArgs) 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 AgentTurnNewParamsToolgroupAgentToolGroupWithArgsArgUnion 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 AgentTurnNewParamsToolgroupAgentToolGroupWithArgsArgUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *AgentTurnNewParamsToolgroupAgentToolGroupWithArgsArgUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *AgentTurnNewParamsToolgroupAgentToolGroupWithArgsArgUnion) 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 AgentTurnGetParams struct { - AgentID string `path:"agent_id,required" json:"-"` - SessionID string `path:"session_id,required" json:"-"` - paramObj -} - -type AgentTurnResumeParams struct { - AgentID string `path:"agent_id,required" json:"-"` - SessionID string `path:"session_id,required" json:"-"` - // The tool call responses to resume the turn with. - ToolResponses []ToolResponseParam `json:"tool_responses,omitzero,required"` - paramObj -} - -func (r AgentTurnResumeParams) MarshalJSON() (data []byte, err error) { - type shadow AgentTurnResumeParams - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *AgentTurnResumeParams) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} diff --git a/agentturn_test.go b/agentturn_test.go deleted file mode 100644 index 72ef6ce..0000000 --- a/agentturn_test.go +++ /dev/null @@ -1,134 +0,0 @@ -// 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" - "github.com/llamastack/llama-stack-client-go/shared" -) - -func TestAgentTurnNewWithOptionalParams(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.Agents.Turn.New( - context.TODO(), - "session_id", - llamastackclient.AgentTurnNewParams{ - AgentID: "agent_id", - Messages: []llamastackclient.AgentTurnNewParamsMessageUnion{{ - OfUserMessage: &shared.UserMessageParam{ - Content: shared.InterleavedContentUnionParam{ - OfString: llamastackclient.String("string"), - }, - Context: shared.InterleavedContentUnionParam{ - OfString: llamastackclient.String("string"), - }, - }, - }}, - Documents: []llamastackclient.AgentTurnNewParamsDocument{{ - Content: llamastackclient.AgentTurnNewParamsDocumentContentUnion{ - OfString: llamastackclient.String("string"), - }, - MimeType: "mime_type", - }}, - ToolConfig: llamastackclient.AgentTurnNewParamsToolConfig{ - SystemMessageBehavior: "append", - ToolChoice: "auto", - ToolPromptFormat: "json", - }, - Toolgroups: []llamastackclient.AgentTurnNewParamsToolgroupUnion{{ - OfString: llamastackclient.String("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 TestAgentTurnGet(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.Agents.Turn.Get( - context.TODO(), - "turn_id", - llamastackclient.AgentTurnGetParams{ - AgentID: "agent_id", - SessionID: "session_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 TestAgentTurnResumeWithOptionalParams(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.Agents.Turn.Resume( - context.TODO(), - "turn_id", - llamastackclient.AgentTurnResumeParams{ - AgentID: "agent_id", - SessionID: "session_id", - ToolResponses: []llamastackclient.ToolResponseParam{{ - CallID: "call_id", - Content: shared.InterleavedContentUnionParam{ - OfString: llamastackclient.String("string"), - }, - ToolName: llamastackclient.ToolResponseToolNameBraveSearch, - Metadata: map[string]llamastackclient.ToolResponseMetadataUnionParam{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, - }, - }}, - }, - ) - 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/aliases.go b/aliases.go index 72179d3..058a3d1 100644 --- a/aliases.go +++ b/aliases.go @@ -1,3 +1,9 @@ +// 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 @@ -5,7 +11,6 @@ package llamastackclient import ( "github.com/llamastack/llama-stack-client-go/internal/apierror" "github.com/llamastack/llama-stack-client-go/packages/param" - "github.com/llamastack/llama-stack-client-go/shared" ) // aliased to make [param.APIUnion] private when embedding @@ -15,660 +20,3 @@ type paramUnion = param.APIUnion type paramObj = param.APIObject type Error = apierror.Error - -// Configuration for an agent. -// -// This is an alias to an internal type. -type AgentConfig = shared.AgentConfig - -// Whether tool use is required or automatic. This is a hint to the model which may -// not be followed. It depends on the Instruction Following capabilities of the -// model. -// -// This is an alias to an internal type. -type AgentConfigToolChoice = shared.AgentConfigToolChoice - -// Equals "auto" -const AgentConfigToolChoiceAuto = shared.AgentConfigToolChoiceAuto - -// Equals "required" -const AgentConfigToolChoiceRequired = shared.AgentConfigToolChoiceRequired - -// Equals "none" -const AgentConfigToolChoiceNone = shared.AgentConfigToolChoiceNone - -// Configuration for tool use. -// -// This is an alias to an internal type. -type AgentConfigToolConfig = shared.AgentConfigToolConfig - -// Prompt format for calling custom / zero shot tools. -// -// This is an alias to an internal type. -type AgentConfigToolPromptFormat = shared.AgentConfigToolPromptFormat - -// Equals "json" -const AgentConfigToolPromptFormatJson = shared.AgentConfigToolPromptFormatJson - -// Equals "function_tag" -const AgentConfigToolPromptFormatFunctionTag = shared.AgentConfigToolPromptFormatFunctionTag - -// Equals "python_list" -const AgentConfigToolPromptFormatPythonList = shared.AgentConfigToolPromptFormatPythonList - -// This is an alias to an internal type. -type AgentConfigToolgroupUnion = shared.AgentConfigToolgroupUnion - -// This is an alias to an internal type. -type AgentConfigToolgroupAgentToolGroupWithArgs = shared.AgentConfigToolgroupAgentToolGroupWithArgs - -// This is an alias to an internal type. -type AgentConfigToolgroupAgentToolGroupWithArgsArgUnion = shared.AgentConfigToolgroupAgentToolGroupWithArgsArgUnion - -// Configuration for an agent. -// -// This is an alias to an internal type. -type AgentConfigParam = shared.AgentConfigParam - -// Configuration for tool use. -// -// This is an alias to an internal type. -type AgentConfigToolConfigParam = shared.AgentConfigToolConfigParam - -// This is an alias to an internal type. -type AgentConfigToolgroupUnionParam = shared.AgentConfigToolgroupUnionParam - -// This is an alias to an internal type. -type AgentConfigToolgroupAgentToolGroupWithArgsParam = shared.AgentConfigToolgroupAgentToolGroupWithArgsParam - -// This is an alias to an internal type. -type AgentConfigToolgroupAgentToolGroupWithArgsArgUnionParam = shared.AgentConfigToolgroupAgentToolGroupWithArgsArgUnionParam - -// Response from a batch completion request. -// -// This is an alias to an internal type. -type BatchCompletion = shared.BatchCompletion - -// Response from a chat completion request. -// -// This is an alias to an internal type. -type ChatCompletionResponse = shared.ChatCompletionResponse - -// Log probabilities for generated tokens. -// -// This is an alias to an internal type. -type ChatCompletionResponseLogprob = shared.ChatCompletionResponseLogprob - -// A metric value included in API responses. -// -// This is an alias to an internal type. -type ChatCompletionResponseMetric = shared.ChatCompletionResponseMetric - -// A message containing the model's (assistant) response in a chat conversation. -// -// This is an alias to an internal type. -type CompletionMessage = shared.CompletionMessage - -// Reason why the model stopped generating. Options are: - -// `StopReason.end_of_turn`: The model finished generating the entire response. - -// `StopReason.end_of_message`: The model finished generating but generated a -// partial response -- usually, a tool call. The user may call the tool and -// continue the conversation with the tool's response. - -// `StopReason.out_of_tokens`: The model ran out of token budget. -// -// This is an alias to an internal type. -type CompletionMessageStopReason = shared.CompletionMessageStopReason - -// Equals "end_of_turn" -const CompletionMessageStopReasonEndOfTurn = shared.CompletionMessageStopReasonEndOfTurn - -// Equals "end_of_message" -const CompletionMessageStopReasonEndOfMessage = shared.CompletionMessageStopReasonEndOfMessage - -// Equals "out_of_tokens" -const CompletionMessageStopReasonOutOfTokens = shared.CompletionMessageStopReasonOutOfTokens - -// A message containing the model's (assistant) response in a chat conversation. -// -// This is an alias to an internal type. -type CompletionMessageParam = shared.CompletionMessageParam - -// A text content delta for streaming responses. -// -// This is an alias to an internal type. -type ContentDeltaUnion = shared.ContentDeltaUnion - -// A text content delta for streaming responses. -// -// This is an alias to an internal type. -type ContentDeltaText = shared.ContentDeltaText - -// An image content delta for streaming responses. -// -// This is an alias to an internal type. -type ContentDeltaImage = shared.ContentDeltaImage - -// A tool call content delta for streaming responses. -// -// This is an alias to an internal type. -type ContentDeltaToolCall = shared.ContentDeltaToolCall - -// A document to be used for document ingestion in the RAG Tool. -// -// This is an alias to an internal type. -type DocumentParam = shared.DocumentParam - -// The content of the document. -// -// This is an alias to an internal type. -type DocumentContentUnionParam = shared.DocumentContentUnionParam - -// A image content item -// -// This is an alias to an internal type. -type DocumentContentImageContentItemParam = shared.DocumentContentImageContentItemParam - -// Image as a base64 encoded string or an URL -// -// This is an alias to an internal type. -type DocumentContentImageContentItemImageParam = shared.DocumentContentImageContentItemImageParam - -// A URL of the image or data URL in the format of data:image/{type};base64,{data}. -// Note that URL could have length limits. -// -// This is an alias to an internal type. -type DocumentContentImageContentItemImageURLParam = shared.DocumentContentImageContentItemImageURLParam - -// A text content item -// -// This is an alias to an internal type. -type DocumentContentTextContentItemParam = shared.DocumentContentTextContentItemParam - -// A URL reference to external content. -// -// This is an alias to an internal type. -type DocumentContentURLParam = shared.DocumentContentURLParam - -// This is an alias to an internal type. -type DocumentMetadataUnionParam = shared.DocumentMetadataUnionParam - -// A image content item -// -// This is an alias to an internal type. -type InterleavedContentUnion = shared.InterleavedContentUnion - -// A image content item -// -// This is an alias to an internal type. -type InterleavedContentImageContentItem = shared.InterleavedContentImageContentItem - -// Image as a base64 encoded string or an URL -// -// This is an alias to an internal type. -type InterleavedContentImageContentItemImage = shared.InterleavedContentImageContentItemImage - -// A URL of the image or data URL in the format of data:image/{type};base64,{data}. -// Note that URL could have length limits. -// -// This is an alias to an internal type. -type InterleavedContentImageContentItemImageURL = shared.InterleavedContentImageContentItemImageURL - -// A text content item -// -// This is an alias to an internal type. -type InterleavedContentTextContentItem = shared.InterleavedContentTextContentItem - -// A image content item -// -// This is an alias to an internal type. -type InterleavedContentUnionParam = shared.InterleavedContentUnionParam - -// A image content item -// -// This is an alias to an internal type. -type InterleavedContentImageContentItemParam = shared.InterleavedContentImageContentItemParam - -// Image as a base64 encoded string or an URL -// -// This is an alias to an internal type. -type InterleavedContentImageContentItemImageParam = shared.InterleavedContentImageContentItemImageParam - -// A URL of the image or data URL in the format of data:image/{type};base64,{data}. -// Note that URL could have length limits. -// -// This is an alias to an internal type. -type InterleavedContentImageContentItemImageURLParam = shared.InterleavedContentImageContentItemImageURLParam - -// A text content item -// -// This is an alias to an internal type. -type InterleavedContentTextContentItemParam = shared.InterleavedContentTextContentItemParam - -// A image content item -// -// This is an alias to an internal type. -type InterleavedContentItemUnion = shared.InterleavedContentItemUnion - -// A image content item -// -// This is an alias to an internal type. -type InterleavedContentItemImage = shared.InterleavedContentItemImage - -// Image as a base64 encoded string or an URL -// -// This is an alias to an internal type. -type InterleavedContentItemImageImage = shared.InterleavedContentItemImageImage - -// A URL of the image or data URL in the format of data:image/{type};base64,{data}. -// Note that URL could have length limits. -// -// This is an alias to an internal type. -type InterleavedContentItemImageImageURL = shared.InterleavedContentItemImageImageURL - -// A text content item -// -// This is an alias to an internal type. -type InterleavedContentItemText = shared.InterleavedContentItemText - -// A image content item -// -// This is an alias to an internal type. -type InterleavedContentItemUnionParam = shared.InterleavedContentItemUnionParam - -// A image content item -// -// This is an alias to an internal type. -type InterleavedContentItemImageParam = shared.InterleavedContentItemImageParam - -// Image as a base64 encoded string or an URL -// -// This is an alias to an internal type. -type InterleavedContentItemImageImageParam = shared.InterleavedContentItemImageImageParam - -// A URL of the image or data URL in the format of data:image/{type};base64,{data}. -// Note that URL could have length limits. -// -// This is an alias to an internal type. -type InterleavedContentItemImageImageURLParam = shared.InterleavedContentItemImageImageURLParam - -// A text content item -// -// This is an alias to an internal type. -type InterleavedContentItemTextParam = shared.InterleavedContentItemTextParam - -// A message from the user in a chat conversation. -// -// This is an alias to an internal type. -type MessageUnionParam = shared.MessageUnionParam - -// Configuration for the RAG query generation. -// -// This is an alias to an internal type. -type QueryConfigParam = shared.QueryConfigParam - -// Search mode for retrieval—either "vector", "keyword", or "hybrid". Default -// "vector". -// -// This is an alias to an internal type. -type QueryConfigMode = shared.QueryConfigMode - -// Equals "vector" -const QueryConfigModeVector = shared.QueryConfigModeVector - -// Equals "keyword" -const QueryConfigModeKeyword = shared.QueryConfigModeKeyword - -// Equals "hybrid" -const QueryConfigModeHybrid = shared.QueryConfigModeHybrid - -// Configuration for the ranker to use in hybrid search. Defaults to RRF ranker. -// -// This is an alias to an internal type. -type QueryConfigRankerUnionParam = shared.QueryConfigRankerUnionParam - -// Reciprocal Rank Fusion (RRF) ranker configuration. -// -// This is an alias to an internal type. -type QueryConfigRankerRrfParam = shared.QueryConfigRankerRrfParam - -// Weighted ranker configuration that combines vector and keyword scores. -// -// This is an alias to an internal type. -type QueryConfigRankerWeightedParam = shared.QueryConfigRankerWeightedParam - -// Configuration for the default RAG query generator. -// -// This is an alias to an internal type. -type QueryGeneratorConfigUnionParam = shared.QueryGeneratorConfigUnionParam - -// Configuration for the default RAG query generator. -// -// This is an alias to an internal type. -type QueryGeneratorConfigDefaultParam = shared.QueryGeneratorConfigDefaultParam - -// Configuration for the LLM-based RAG query generator. -// -// This is an alias to an internal type. -type QueryGeneratorConfigLlmParam = shared.QueryGeneratorConfigLlmParam - -// Result of a RAG query containing retrieved content and metadata. -// -// This is an alias to an internal type. -type QueryResult = shared.QueryResult - -// This is an alias to an internal type. -type QueryResultMetadataUnion = shared.QueryResultMetadataUnion - -// Configuration for JSON schema-guided response generation. -// -// This is an alias to an internal type. -type ResponseFormatUnion = shared.ResponseFormatUnion - -// Configuration for JSON schema-guided response generation. -// -// This is an alias to an internal type. -type ResponseFormatJsonSchema = shared.ResponseFormatJsonSchema - -// This is an alias to an internal type. -type ResponseFormatJsonSchemaJsonSchemaUnion = shared.ResponseFormatJsonSchemaJsonSchemaUnion - -// Configuration for grammar-guided response generation. -// -// This is an alias to an internal type. -type ResponseFormatGrammar = shared.ResponseFormatGrammar - -// This is an alias to an internal type. -type ResponseFormatGrammarBnfUnion = shared.ResponseFormatGrammarBnfUnion - -// Configuration for JSON schema-guided response generation. -// -// This is an alias to an internal type. -type ResponseFormatUnionParam = shared.ResponseFormatUnionParam - -// Configuration for JSON schema-guided response generation. -// -// This is an alias to an internal type. -type ResponseFormatJsonSchemaParam = shared.ResponseFormatJsonSchemaParam - -// This is an alias to an internal type. -type ResponseFormatJsonSchemaJsonSchemaUnionParam = shared.ResponseFormatJsonSchemaJsonSchemaUnionParam - -// Configuration for grammar-guided response generation. -// -// This is an alias to an internal type. -type ResponseFormatGrammarParam = shared.ResponseFormatGrammarParam - -// This is an alias to an internal type. -type ResponseFormatGrammarBnfUnionParam = shared.ResponseFormatGrammarBnfUnionParam - -// This is an alias to an internal type. -type ReturnType = shared.ReturnType - -// This is an alias to an internal type. -type ReturnTypeType = shared.ReturnTypeType - -// Equals "string" -const ReturnTypeTypeString = shared.ReturnTypeTypeString - -// Equals "number" -const ReturnTypeTypeNumber = shared.ReturnTypeTypeNumber - -// Equals "boolean" -const ReturnTypeTypeBoolean = shared.ReturnTypeTypeBoolean - -// Equals "array" -const ReturnTypeTypeArray = shared.ReturnTypeTypeArray - -// Equals "object" -const ReturnTypeTypeObject = shared.ReturnTypeTypeObject - -// Equals "json" -const ReturnTypeTypeJson = shared.ReturnTypeTypeJson - -// Equals "union" -const ReturnTypeTypeUnion = shared.ReturnTypeTypeUnion - -// Equals "chat_completion_input" -const ReturnTypeTypeChatCompletionInput = shared.ReturnTypeTypeChatCompletionInput - -// Equals "completion_input" -const ReturnTypeTypeCompletionInput = shared.ReturnTypeTypeCompletionInput - -// Equals "agent_turn_input" -const ReturnTypeTypeAgentTurnInput = shared.ReturnTypeTypeAgentTurnInput - -// This is an alias to an internal type. -type ReturnTypeParam = shared.ReturnTypeParam - -// Details of a safety violation detected by content moderation. -// -// This is an alias to an internal type. -type SafetyViolation = shared.SafetyViolation - -// This is an alias to an internal type. -type SafetyViolationMetadataUnion = shared.SafetyViolationMetadataUnion - -// Severity level of the violation -// -// This is an alias to an internal type. -type SafetyViolationViolationLevel = shared.SafetyViolationViolationLevel - -// Equals "info" -const SafetyViolationViolationLevelInfo = shared.SafetyViolationViolationLevelInfo - -// Equals "warn" -const SafetyViolationViolationLevelWarn = shared.SafetyViolationViolationLevelWarn - -// Equals "error" -const SafetyViolationViolationLevelError = shared.SafetyViolationViolationLevelError - -// Sampling parameters. -// -// This is an alias to an internal type. -type SamplingParamsResp = shared.SamplingParamsResp - -// The sampling strategy. -// -// This is an alias to an internal type. -type SamplingParamsStrategyUnionResp = shared.SamplingParamsStrategyUnionResp - -// Greedy sampling strategy that selects the highest probability token at each -// step. -// -// This is an alias to an internal type. -type SamplingParamsStrategyGreedyResp = shared.SamplingParamsStrategyGreedyResp - -// Top-p (nucleus) sampling strategy that samples from the smallest set of tokens -// with cumulative probability >= p. -// -// This is an alias to an internal type. -type SamplingParamsStrategyTopPResp = shared.SamplingParamsStrategyTopPResp - -// Top-k sampling strategy that restricts sampling to the k most likely tokens. -// -// This is an alias to an internal type. -type SamplingParamsStrategyTopKResp = shared.SamplingParamsStrategyTopKResp - -// Sampling parameters. -// -// This is an alias to an internal type. -type SamplingParams = shared.SamplingParams - -// The sampling strategy. -// -// This is an alias to an internal type. -type SamplingParamsStrategyUnion = shared.SamplingParamsStrategyUnion - -// Greedy sampling strategy that selects the highest probability token at each -// step. -// -// This is an alias to an internal type. -type SamplingParamsStrategyGreedy = shared.SamplingParamsStrategyGreedy - -// Top-p (nucleus) sampling strategy that samples from the smallest set of tokens -// with cumulative probability >= p. -// -// This is an alias to an internal type. -type SamplingParamsStrategyTopP = shared.SamplingParamsStrategyTopP - -// Top-k sampling strategy that restricts sampling to the k most likely tokens. -// -// This is an alias to an internal type. -type SamplingParamsStrategyTopK = shared.SamplingParamsStrategyTopK - -// A scoring result for a single row. -// -// This is an alias to an internal type. -type ScoringResult = shared.ScoringResult - -// This is an alias to an internal type. -type ScoringResultAggregatedResultUnion = shared.ScoringResultAggregatedResultUnion - -// This is an alias to an internal type. -type ScoringResultScoreRowUnion = shared.ScoringResultScoreRowUnion - -// Response from a completion request. -// -// This is an alias to an internal type. -type SharedCompletionResponse = shared.SharedCompletionResponse - -// Reason why generation stopped -// -// This is an alias to an internal type. -type SharedCompletionResponseStopReason = shared.SharedCompletionResponseStopReason - -// Equals "end_of_turn" -const SharedCompletionResponseStopReasonEndOfTurn = shared.SharedCompletionResponseStopReasonEndOfTurn - -// Equals "end_of_message" -const SharedCompletionResponseStopReasonEndOfMessage = shared.SharedCompletionResponseStopReasonEndOfMessage - -// Equals "out_of_tokens" -const SharedCompletionResponseStopReasonOutOfTokens = shared.SharedCompletionResponseStopReasonOutOfTokens - -// Log probabilities for generated tokens. -// -// This is an alias to an internal type. -type SharedCompletionResponseLogprob = shared.SharedCompletionResponseLogprob - -// A metric value included in API responses. -// -// This is an alias to an internal type. -type SharedCompletionResponseMetric = shared.SharedCompletionResponseMetric - -// Tool definition used in runtime contexts. -// -// This is an alias to an internal type. -type SharedToolDef = shared.SharedToolDef - -// This is an alias to an internal type. -type SharedToolDefMetadataUnion = shared.SharedToolDefMetadataUnion - -// Parameter definition for a tool. -// -// This is an alias to an internal type. -type SharedToolDefParameter = shared.SharedToolDefParameter - -// (Optional) Default value for the parameter if not provided -// -// This is an alias to an internal type. -type SharedToolDefParameterDefaultUnion = shared.SharedToolDefParameterDefaultUnion - -// Tool definition used in runtime contexts. -// -// This is an alias to an internal type. -type SharedToolDefParam = shared.SharedToolDefParam - -// This is an alias to an internal type. -type SharedToolDefMetadataUnionParam = shared.SharedToolDefMetadataUnionParam - -// Parameter definition for a tool. -// -// This is an alias to an internal type. -type SharedToolDefParameterParam = shared.SharedToolDefParameterParam - -// (Optional) Default value for the parameter if not provided -// -// This is an alias to an internal type. -type SharedToolDefParameterDefaultUnionParam = shared.SharedToolDefParameterDefaultUnionParam - -// A system message providing instructions or context to the model. -// -// This is an alias to an internal type. -type SystemMessageParam = shared.SystemMessageParam - -// This is an alias to an internal type. -type ToolCall = shared.ToolCall - -// This is an alias to an internal type. -type ToolCallArgumentsUnion = shared.ToolCallArgumentsUnion - -// This is an alias to an internal type. -type ToolCallArgumentsMapItemUnion = shared.ToolCallArgumentsMapItemUnion - -// This is an alias to an internal type. -type ToolCallArgumentsMapItemArrayItemUnion = shared.ToolCallArgumentsMapItemArrayItemUnion - -// This is an alias to an internal type. -type ToolCallArgumentsMapItemMapItemUnion = shared.ToolCallArgumentsMapItemMapItemUnion - -// This is an alias to an internal type. -type ToolCallToolName = shared.ToolCallToolName - -// Equals "brave_search" -const ToolCallToolNameBraveSearch = shared.ToolCallToolNameBraveSearch - -// Equals "wolfram_alpha" -const ToolCallToolNameWolframAlpha = shared.ToolCallToolNameWolframAlpha - -// Equals "photogen" -const ToolCallToolNamePhotogen = shared.ToolCallToolNamePhotogen - -// Equals "code_interpreter" -const ToolCallToolNameCodeInterpreter = shared.ToolCallToolNameCodeInterpreter - -// This is an alias to an internal type. -type ToolCallParam = shared.ToolCallParam - -// This is an alias to an internal type. -type ToolCallArgumentsUnionParam = shared.ToolCallArgumentsUnionParam - -// This is an alias to an internal type. -type ToolCallArgumentsMapItemUnionParam = shared.ToolCallArgumentsMapItemUnionParam - -// This is an alias to an internal type. -type ToolCallArgumentsMapItemArrayItemUnionParam = shared.ToolCallArgumentsMapItemArrayItemUnionParam - -// This is an alias to an internal type. -type ToolCallArgumentsMapItemMapItemUnionParam = shared.ToolCallArgumentsMapItemMapItemUnionParam - -// Either an in-progress tool call string or the final parsed tool call -// -// This is an alias to an internal type. -type ToolCallOrStringUnion = shared.ToolCallOrStringUnion - -// This is an alias to an internal type. -type ToolParamDefinition = shared.ToolParamDefinition - -// This is an alias to an internal type. -type ToolParamDefinitionDefaultUnion = shared.ToolParamDefinitionDefaultUnion - -// A message representing the result of a tool invocation. -// -// This is an alias to an internal type. -type ToolResponseMessage = shared.ToolResponseMessage - -// A message representing the result of a tool invocation. -// -// This is an alias to an internal type. -type ToolResponseMessageParam = shared.ToolResponseMessageParam - -// A message from the user in a chat conversation. -// -// This is an alias to an internal type. -type UserMessage = shared.UserMessage - -// A message from the user in a chat conversation. -// -// This is an alias to an internal type. -type UserMessageParam = shared.UserMessageParam diff --git a/alpha.go b/alpha.go new file mode 100644 index 0000000..42f3020 --- /dev/null +++ b/alpha.go @@ -0,0 +1,40 @@ +// 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" +) + +// AlphaService 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 [NewAlphaService] method instead. +type AlphaService struct { + Options []option.RequestOption + Inference AlphaInferenceService + PostTraining AlphaPostTrainingService + Benchmarks AlphaBenchmarkService + Eval AlphaEvalService +} + +// NewAlphaService 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 NewAlphaService(opts ...option.RequestOption) (r AlphaService) { + r = AlphaService{} + r.Options = opts + r.Inference = NewAlphaInferenceService(opts...) + r.PostTraining = NewAlphaPostTrainingService(opts...) + r.Benchmarks = NewAlphaBenchmarkService(opts...) + r.Eval = NewAlphaEvalService(opts...) + return +} diff --git a/benchmark.go b/alphabenchmark.go similarity index 76% rename from benchmark.go rename to alphabenchmark.go index b11a273..6f433bd 100644 --- a/benchmark.go +++ b/alphabenchmark.go @@ -1,3 +1,9 @@ +// 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 @@ -8,6 +14,7 @@ import ( "errors" "fmt" "net/http" + "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" "github.com/llamastack/llama-stack-client-go/internal/requestconfig" @@ -17,42 +24,42 @@ import ( "github.com/llamastack/llama-stack-client-go/shared/constant" ) -// BenchmarkService contains methods and other services that help with interacting -// with the llama-stack-client API. +// AlphaBenchmarkService 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 [NewBenchmarkService] method instead. -type BenchmarkService struct { +// the [NewAlphaBenchmarkService] method instead. +type AlphaBenchmarkService struct { Options []option.RequestOption } -// NewBenchmarkService generates a new service that applies the given options to -// each request. These options are applied after the parent client's options (if +// NewAlphaBenchmarkService 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 NewBenchmarkService(opts ...option.RequestOption) (r BenchmarkService) { - r = BenchmarkService{} +func NewAlphaBenchmarkService(opts ...option.RequestOption) (r AlphaBenchmarkService) { + r = AlphaBenchmarkService{} r.Options = opts return } // Get a benchmark by its ID. -func (r *BenchmarkService) Get(ctx context.Context, benchmarkID string, opts ...option.RequestOption) (res *Benchmark, err error) { - opts = append(r.Options[:], opts...) +func (r *AlphaBenchmarkService) Get(ctx context.Context, benchmarkID string, opts ...option.RequestOption) (res *Benchmark, err error) { + opts = slices.Concat(r.Options, opts) if benchmarkID == "" { err = errors.New("missing required benchmark_id parameter") return } - path := fmt.Sprintf("v1/eval/benchmarks/%s", benchmarkID) + path := fmt.Sprintf("v1alpha/eval/benchmarks/%s", benchmarkID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return } // List all benchmarks. -func (r *BenchmarkService) List(ctx context.Context, opts ...option.RequestOption) (res *[]Benchmark, err error) { +func (r *AlphaBenchmarkService) List(ctx context.Context, opts ...option.RequestOption) (res *[]Benchmark, err error) { var env ListBenchmarksResponse - opts = append(r.Options[:], opts...) - path := "v1/eval/benchmarks" + opts = slices.Concat(r.Options, opts) + path := "v1alpha/eval/benchmarks" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) if err != nil { return @@ -62,10 +69,12 @@ func (r *BenchmarkService) List(ctx context.Context, opts ...option.RequestOptio } // Register a benchmark. -func (r *BenchmarkService) Register(ctx context.Context, body BenchmarkRegisterParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) +// +// 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...) - path := "v1/eval/benchmarks" + path := "v1alpha/eval/benchmarks" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...) return } @@ -171,7 +180,7 @@ func (r *ListBenchmarksResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type BenchmarkRegisterParams struct { +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. @@ -183,22 +192,22 @@ type BenchmarkRegisterParams struct { // 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]BenchmarkRegisterParamsMetadataUnion `json:"metadata,omitzero"` + Metadata map[string]AlphaBenchmarkRegisterParamsMetadataUnion `json:"metadata,omitzero"` paramObj } -func (r BenchmarkRegisterParams) MarshalJSON() (data []byte, err error) { - type shadow BenchmarkRegisterParams +func (r AlphaBenchmarkRegisterParams) MarshalJSON() (data []byte, err error) { + type shadow AlphaBenchmarkRegisterParams return param.MarshalObject(r, (*shadow)(&r)) } -func (r *BenchmarkRegisterParams) UnmarshalJSON(data []byte) 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 BenchmarkRegisterParamsMetadataUnion struct { +type AlphaBenchmarkRegisterParamsMetadataUnion struct { OfBool param.Opt[bool] `json:",omitzero,inline"` OfFloat param.Opt[float64] `json:",omitzero,inline"` OfString param.Opt[string] `json:",omitzero,inline"` @@ -206,14 +215,14 @@ type BenchmarkRegisterParamsMetadataUnion struct { paramUnion } -func (u BenchmarkRegisterParamsMetadataUnion) MarshalJSON() ([]byte, error) { +func (u AlphaBenchmarkRegisterParamsMetadataUnion) MarshalJSON() ([]byte, error) { return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) } -func (u *BenchmarkRegisterParamsMetadataUnion) UnmarshalJSON(data []byte) error { +func (u *AlphaBenchmarkRegisterParamsMetadataUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *BenchmarkRegisterParamsMetadataUnion) asAny() any { +func (u *AlphaBenchmarkRegisterParamsMetadataUnion) asAny() any { if !param.IsOmitted(u.OfBool) { return &u.OfBool.Value } else if !param.IsOmitted(u.OfFloat) { diff --git a/benchmark_test.go b/alphabenchmark_test.go similarity index 74% rename from benchmark_test.go rename to alphabenchmark_test.go index 368eeb7..4602eae 100644 --- a/benchmark_test.go +++ b/alphabenchmark_test.go @@ -1,3 +1,9 @@ +// 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 @@ -13,7 +19,7 @@ import ( "github.com/llamastack/llama-stack-client-go/option" ) -func TestBenchmarkGet(t *testing.T) { +func TestAlphaBenchmarkGet(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -24,7 +30,7 @@ func TestBenchmarkGet(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.Benchmarks.Get(context.TODO(), "benchmark_id") + _, err := client.Alpha.Benchmarks.Get(context.TODO(), "benchmark_id") if err != nil { var apierr *llamastackclient.Error if errors.As(err, &apierr) { @@ -34,7 +40,7 @@ func TestBenchmarkGet(t *testing.T) { } } -func TestBenchmarkList(t *testing.T) { +func TestAlphaBenchmarkList(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -45,7 +51,7 @@ func TestBenchmarkList(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.Benchmarks.List(context.TODO()) + _, err := client.Alpha.Benchmarks.List(context.TODO()) if err != nil { var apierr *llamastackclient.Error if errors.As(err, &apierr) { @@ -55,7 +61,7 @@ func TestBenchmarkList(t *testing.T) { } } -func TestBenchmarkRegisterWithOptionalParams(t *testing.T) { +func TestAlphaBenchmarkRegisterWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -66,11 +72,11 @@ func TestBenchmarkRegisterWithOptionalParams(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - err := client.Benchmarks.Register(context.TODO(), llamastackclient.BenchmarkRegisterParams{ + err := client.Alpha.Benchmarks.Register(context.TODO(), llamastackclient.AlphaBenchmarkRegisterParams{ BenchmarkID: "benchmark_id", DatasetID: "dataset_id", ScoringFunctions: []string{"string"}, - Metadata: map[string]llamastackclient.BenchmarkRegisterParamsMetadataUnion{ + Metadata: map[string]llamastackclient.AlphaBenchmarkRegisterParamsMetadataUnion{ "foo": { OfBool: llamastackclient.Bool(true), }, diff --git a/eval.go b/alphaeval.go similarity index 58% rename from eval.go rename to alphaeval.go index 779d51d..ba5de6c 100644 --- a/eval.go +++ b/alphaeval.go @@ -1,3 +1,9 @@ +// 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 @@ -8,81 +14,81 @@ import ( "errors" "fmt" "net/http" + "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" "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" "github.com/llamastack/llama-stack-client-go/shared/constant" ) -// EvalService contains methods and other services that help with interacting with -// the llama-stack-client API. +// AlphaEvalService 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 [NewEvalService] method instead. -type EvalService struct { +// the [NewAlphaEvalService] method instead. +type AlphaEvalService struct { Options []option.RequestOption - Jobs EvalJobService + Jobs AlphaEvalJobService } -// NewEvalService 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 NewEvalService(opts ...option.RequestOption) (r EvalService) { - r = EvalService{} +// NewAlphaEvalService 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 NewAlphaEvalService(opts ...option.RequestOption) (r AlphaEvalService) { + r = AlphaEvalService{} r.Options = opts - r.Jobs = NewEvalJobService(opts...) + r.Jobs = NewAlphaEvalJobService(opts...) return } // Evaluate a list of rows on a benchmark. -func (r *EvalService) EvaluateRows(ctx context.Context, benchmarkID string, body EvalEvaluateRowsParams, opts ...option.RequestOption) (res *EvaluateResponse, err error) { - opts = append(r.Options[:], opts...) +func (r *AlphaEvalService) EvaluateRows(ctx context.Context, benchmarkID string, body AlphaEvalEvaluateRowsParams, opts ...option.RequestOption) (res *EvaluateResponse, err error) { + opts = slices.Concat(r.Options, opts) if benchmarkID == "" { err = errors.New("missing required benchmark_id parameter") return } - path := fmt.Sprintf("v1/eval/benchmarks/%s/evaluations", benchmarkID) + path := fmt.Sprintf("v1alpha/eval/benchmarks/%s/evaluations", benchmarkID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return } // Evaluate a list of rows on a benchmark. -func (r *EvalService) EvaluateRowsAlpha(ctx context.Context, benchmarkID string, body EvalEvaluateRowsAlphaParams, opts ...option.RequestOption) (res *EvaluateResponse, err error) { - opts = append(r.Options[:], opts...) +func (r *AlphaEvalService) EvaluateRowsAlpha(ctx context.Context, benchmarkID string, body AlphaEvalEvaluateRowsAlphaParams, opts ...option.RequestOption) (res *EvaluateResponse, err error) { + opts = slices.Concat(r.Options, opts) if benchmarkID == "" { err = errors.New("missing required benchmark_id parameter") return } - path := fmt.Sprintf("v1/eval/benchmarks/%s/evaluations", benchmarkID) + path := fmt.Sprintf("v1alpha/eval/benchmarks/%s/evaluations", benchmarkID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return } // Run an evaluation on a benchmark. -func (r *EvalService) RunEval(ctx context.Context, benchmarkID string, body EvalRunEvalParams, opts ...option.RequestOption) (res *Job, err error) { - opts = append(r.Options[:], opts...) +func (r *AlphaEvalService) RunEval(ctx context.Context, benchmarkID string, body AlphaEvalRunEvalParams, opts ...option.RequestOption) (res *Job, err error) { + opts = slices.Concat(r.Options, opts) if benchmarkID == "" { err = errors.New("missing required benchmark_id parameter") return } - path := fmt.Sprintf("v1/eval/benchmarks/%s/jobs", benchmarkID) + path := fmt.Sprintf("v1alpha/eval/benchmarks/%s/jobs", benchmarkID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return } // Run an evaluation on a benchmark. -func (r *EvalService) RunEvalAlpha(ctx context.Context, benchmarkID string, body EvalRunEvalAlphaParams, opts ...option.RequestOption) (res *Job, err error) { - opts = append(r.Options[:], opts...) +func (r *AlphaEvalService) RunEvalAlpha(ctx context.Context, benchmarkID string, body AlphaEvalRunEvalAlphaParams, opts ...option.RequestOption) (res *Job, err error) { + opts = slices.Concat(r.Options, opts) if benchmarkID == "" { err = errors.New("missing required benchmark_id parameter") return } - path := fmt.Sprintf("v1/eval/benchmarks/%s/jobs", benchmarkID) + path := fmt.Sprintf("v1alpha/eval/benchmarks/%s/jobs", benchmarkID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return } @@ -92,7 +98,7 @@ func (r *EvalService) RunEvalAlpha(ctx context.Context, benchmarkID string, body // The properties EvalCandidate, ScoringParams are required. type BenchmarkConfigParam struct { // The candidate to evaluate. - EvalCandidate EvalCandidateUnionParam `json:"eval_candidate,omitzero,required"` + EvalCandidate BenchmarkConfigEvalCandidateParam `json:"eval_candidate,omitzero,required"` // Map between scoring function id and parameters for each scoring function you // want to run ScoringParams map[string]ScoringFnParamsUnion `json:"scoring_params,omitzero,required"` @@ -110,133 +116,26 @@ func (r *BenchmarkConfigParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -func EvalCandidateParamOfModel(model string, samplingParams shared.SamplingParams) EvalCandidateUnionParam { - var variant EvalCandidateModelParam - variant.Model = model - variant.SamplingParams = samplingParams - return EvalCandidateUnionParam{OfModel: &variant} -} - -func EvalCandidateParamOfAgent(config shared.AgentConfigParam) EvalCandidateUnionParam { - var agent EvalCandidateAgentParam - agent.Config = config - return EvalCandidateUnionParam{OfAgent: &agent} -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type EvalCandidateUnionParam struct { - OfModel *EvalCandidateModelParam `json:",omitzero,inline"` - OfAgent *EvalCandidateAgentParam `json:",omitzero,inline"` - paramUnion -} - -func (u EvalCandidateUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfModel, u.OfAgent) -} -func (u *EvalCandidateUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *EvalCandidateUnionParam) asAny() any { - if !param.IsOmitted(u.OfModel) { - return u.OfModel - } else if !param.IsOmitted(u.OfAgent) { - return u.OfAgent - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u EvalCandidateUnionParam) GetModel() *string { - if vt := u.OfModel; vt != nil { - return &vt.Model - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u EvalCandidateUnionParam) GetSamplingParams() *shared.SamplingParams { - if vt := u.OfModel; vt != nil { - return &vt.SamplingParams - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u EvalCandidateUnionParam) GetSystemMessage() *shared.SystemMessageParam { - if vt := u.OfModel; vt != nil { - return &vt.SystemMessage - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u EvalCandidateUnionParam) GetConfig() *shared.AgentConfigParam { - if vt := u.OfAgent; vt != nil { - return &vt.Config - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u EvalCandidateUnionParam) GetType() *string { - if vt := u.OfModel; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfAgent; vt != nil { - return (*string)(&vt.Type) - } - return nil -} - -func init() { - apijson.RegisterUnion[EvalCandidateUnionParam]( - "type", - apijson.Discriminator[EvalCandidateModelParam]("model"), - apijson.Discriminator[EvalCandidateAgentParam]("agent"), - ) -} - -// A model candidate for evaluation. +// The candidate to evaluate. // // The properties Model, SamplingParams, Type are required. -type EvalCandidateModelParam struct { +type BenchmarkConfigEvalCandidateParam struct { // The model ID to evaluate. Model string `json:"model,required"` // The sampling parameters for the model. - SamplingParams shared.SamplingParams `json:"sampling_params,omitzero,required"` + SamplingParams SamplingParams `json:"sampling_params,omitzero,required"` // (Optional) The system message providing instructions or context to the model. - SystemMessage shared.SystemMessageParam `json:"system_message,omitzero"` + 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"` paramObj } -func (r EvalCandidateModelParam) MarshalJSON() (data []byte, err error) { - type shadow EvalCandidateModelParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *EvalCandidateModelParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// An agent candidate for evaluation. -// -// The properties Config, Type are required. -type EvalCandidateAgentParam struct { - // The configuration for the agent candidate. - Config shared.AgentConfigParam `json:"config,omitzero,required"` - // This field can be elided, and will marshal its zero value as "agent". - Type constant.Agent `json:"type,required"` - paramObj -} - -func (r EvalCandidateAgentParam) MarshalJSON() (data []byte, err error) { - type shadow EvalCandidateAgentParam +func (r BenchmarkConfigEvalCandidateParam) MarshalJSON() (data []byte, err error) { + type shadow BenchmarkConfigEvalCandidateParam return param.MarshalObject(r, (*shadow)(&r)) } -func (r *EvalCandidateAgentParam) UnmarshalJSON(data []byte) error { +func (r *BenchmarkConfigEvalCandidateParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } @@ -245,7 +144,7 @@ type EvaluateResponse struct { // The generations from the evaluation. Generations []map[string]EvaluateResponseGenerationUnion `json:"generations,required"` // The scores from the evaluation. - Scores map[string]shared.ScoringResult `json:"scores,required"` + Scores map[string]ScoringResult `json:"scores,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Generations respjson.Field @@ -347,28 +246,28 @@ const ( JobStatusCancelled JobStatus = "cancelled" ) -type EvalEvaluateRowsParams struct { +type AlphaEvalEvaluateRowsParams struct { // The configuration for the benchmark. BenchmarkConfig BenchmarkConfigParam `json:"benchmark_config,omitzero,required"` // The rows to evaluate. - InputRows []map[string]EvalEvaluateRowsParamsInputRowUnion `json:"input_rows,omitzero,required"` + InputRows []map[string]AlphaEvalEvaluateRowsParamsInputRowUnion `json:"input_rows,omitzero,required"` // The scoring functions to use for the evaluation. ScoringFunctions []string `json:"scoring_functions,omitzero,required"` paramObj } -func (r EvalEvaluateRowsParams) MarshalJSON() (data []byte, err error) { - type shadow EvalEvaluateRowsParams +func (r AlphaEvalEvaluateRowsParams) MarshalJSON() (data []byte, err error) { + type shadow AlphaEvalEvaluateRowsParams return param.MarshalObject(r, (*shadow)(&r)) } -func (r *EvalEvaluateRowsParams) UnmarshalJSON(data []byte) error { +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 EvalEvaluateRowsParamsInputRowUnion struct { +type AlphaEvalEvaluateRowsParamsInputRowUnion struct { OfBool param.Opt[bool] `json:",omitzero,inline"` OfFloat param.Opt[float64] `json:",omitzero,inline"` OfString param.Opt[string] `json:",omitzero,inline"` @@ -376,14 +275,14 @@ type EvalEvaluateRowsParamsInputRowUnion struct { paramUnion } -func (u EvalEvaluateRowsParamsInputRowUnion) MarshalJSON() ([]byte, error) { +func (u AlphaEvalEvaluateRowsParamsInputRowUnion) MarshalJSON() ([]byte, error) { return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) } -func (u *EvalEvaluateRowsParamsInputRowUnion) UnmarshalJSON(data []byte) error { +func (u *AlphaEvalEvaluateRowsParamsInputRowUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *EvalEvaluateRowsParamsInputRowUnion) asAny() any { +func (u *AlphaEvalEvaluateRowsParamsInputRowUnion) asAny() any { if !param.IsOmitted(u.OfBool) { return &u.OfBool.Value } else if !param.IsOmitted(u.OfFloat) { @@ -396,28 +295,28 @@ func (u *EvalEvaluateRowsParamsInputRowUnion) asAny() any { return nil } -type EvalEvaluateRowsAlphaParams struct { +type AlphaEvalEvaluateRowsAlphaParams struct { // The configuration for the benchmark. BenchmarkConfig BenchmarkConfigParam `json:"benchmark_config,omitzero,required"` // The rows to evaluate. - InputRows []map[string]EvalEvaluateRowsAlphaParamsInputRowUnion `json:"input_rows,omitzero,required"` + InputRows []map[string]AlphaEvalEvaluateRowsAlphaParamsInputRowUnion `json:"input_rows,omitzero,required"` // The scoring functions to use for the evaluation. ScoringFunctions []string `json:"scoring_functions,omitzero,required"` paramObj } -func (r EvalEvaluateRowsAlphaParams) MarshalJSON() (data []byte, err error) { - type shadow EvalEvaluateRowsAlphaParams +func (r AlphaEvalEvaluateRowsAlphaParams) MarshalJSON() (data []byte, err error) { + type shadow AlphaEvalEvaluateRowsAlphaParams return param.MarshalObject(r, (*shadow)(&r)) } -func (r *EvalEvaluateRowsAlphaParams) UnmarshalJSON(data []byte) error { +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 EvalEvaluateRowsAlphaParamsInputRowUnion struct { +type AlphaEvalEvaluateRowsAlphaParamsInputRowUnion struct { OfBool param.Opt[bool] `json:",omitzero,inline"` OfFloat param.Opt[float64] `json:",omitzero,inline"` OfString param.Opt[string] `json:",omitzero,inline"` @@ -425,14 +324,14 @@ type EvalEvaluateRowsAlphaParamsInputRowUnion struct { paramUnion } -func (u EvalEvaluateRowsAlphaParamsInputRowUnion) MarshalJSON() ([]byte, error) { +func (u AlphaEvalEvaluateRowsAlphaParamsInputRowUnion) MarshalJSON() ([]byte, error) { return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) } -func (u *EvalEvaluateRowsAlphaParamsInputRowUnion) UnmarshalJSON(data []byte) error { +func (u *AlphaEvalEvaluateRowsAlphaParamsInputRowUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *EvalEvaluateRowsAlphaParamsInputRowUnion) asAny() any { +func (u *AlphaEvalEvaluateRowsAlphaParamsInputRowUnion) asAny() any { if !param.IsOmitted(u.OfBool) { return &u.OfBool.Value } else if !param.IsOmitted(u.OfFloat) { @@ -445,30 +344,30 @@ func (u *EvalEvaluateRowsAlphaParamsInputRowUnion) asAny() any { return nil } -type EvalRunEvalParams struct { +type AlphaEvalRunEvalParams struct { // The configuration for the benchmark. BenchmarkConfig BenchmarkConfigParam `json:"benchmark_config,omitzero,required"` paramObj } -func (r EvalRunEvalParams) MarshalJSON() (data []byte, err error) { - type shadow EvalRunEvalParams +func (r AlphaEvalRunEvalParams) MarshalJSON() (data []byte, err error) { + type shadow AlphaEvalRunEvalParams return param.MarshalObject(r, (*shadow)(&r)) } -func (r *EvalRunEvalParams) UnmarshalJSON(data []byte) error { +func (r *AlphaEvalRunEvalParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type EvalRunEvalAlphaParams struct { +type AlphaEvalRunEvalAlphaParams struct { // The configuration for the benchmark. BenchmarkConfig BenchmarkConfigParam `json:"benchmark_config,omitzero,required"` paramObj } -func (r EvalRunEvalAlphaParams) MarshalJSON() (data []byte, err error) { - type shadow EvalRunEvalAlphaParams +func (r AlphaEvalRunEvalAlphaParams) MarshalJSON() (data []byte, err error) { + type shadow AlphaEvalRunEvalAlphaParams return param.MarshalObject(r, (*shadow)(&r)) } -func (r *EvalRunEvalAlphaParams) UnmarshalJSON(data []byte) error { +func (r *AlphaEvalRunEvalAlphaParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } diff --git a/eval_test.go b/alphaeval_test.go similarity index 57% rename from eval_test.go rename to alphaeval_test.go index 7ae74bc..ccb533b 100644 --- a/eval_test.go +++ b/alphaeval_test.go @@ -1,3 +1,9 @@ +// 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 @@ -11,10 +17,9 @@ import ( "github.com/llamastack/llama-stack-client-go" "github.com/llamastack/llama-stack-client-go/internal/testutil" "github.com/llamastack/llama-stack-client-go/option" - "github.com/llamastack/llama-stack-client-go/shared" ) -func TestEvalEvaluateRowsWithOptionalParams(t *testing.T) { +func TestAlphaEvalEvaluateRowsWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -25,26 +30,24 @@ func TestEvalEvaluateRowsWithOptionalParams(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.Eval.EvaluateRows( + _, err := client.Alpha.Eval.EvaluateRows( context.TODO(), "benchmark_id", - llamastackclient.EvalEvaluateRowsParams{ + llamastackclient.AlphaEvalEvaluateRowsParams{ BenchmarkConfig: llamastackclient.BenchmarkConfigParam{ - EvalCandidate: llamastackclient.EvalCandidateUnionParam{ - OfModel: &llamastackclient.EvalCandidateModelParam{ - Model: "model", - SamplingParams: shared.SamplingParams{ - Strategy: shared.SamplingParamsStrategyUnion{ - OfGreedy: &shared.SamplingParamsStrategyGreedy{}, - }, - MaxTokens: llamastackclient.Int(0), - RepetitionPenalty: llamastackclient.Float(0), - Stop: []string{"string"}, + EvalCandidate: llamastackclient.BenchmarkConfigEvalCandidateParam{ + Model: "model", + SamplingParams: llamastackclient.SamplingParams{ + Strategy: llamastackclient.SamplingParamsStrategyUnion{ + OfGreedy: &llamastackclient.SamplingParamsStrategyGreedy{}, }, - SystemMessage: shared.SystemMessageParam{ - Content: shared.InterleavedContentUnionParam{ - OfString: llamastackclient.String("string"), - }, + MaxTokens: llamastackclient.Int(0), + RepetitionPenalty: llamastackclient.Float(0), + Stop: []string{"string"}, + }, + SystemMessage: llamastackclient.SystemMessageParam{ + Content: llamastackclient.InterleavedContentUnionParam{ + OfString: llamastackclient.String("string"), }, }, }, @@ -60,7 +63,7 @@ func TestEvalEvaluateRowsWithOptionalParams(t *testing.T) { }, NumExamples: llamastackclient.Int(0), }, - InputRows: []map[string]llamastackclient.EvalEvaluateRowsParamsInputRowUnion{{ + InputRows: []map[string]llamastackclient.AlphaEvalEvaluateRowsParamsInputRowUnion{{ "foo": { OfBool: llamastackclient.Bool(true), }, @@ -77,7 +80,7 @@ func TestEvalEvaluateRowsWithOptionalParams(t *testing.T) { } } -func TestEvalEvaluateRowsAlphaWithOptionalParams(t *testing.T) { +func TestAlphaEvalEvaluateRowsAlphaWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -88,26 +91,24 @@ func TestEvalEvaluateRowsAlphaWithOptionalParams(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.Eval.EvaluateRowsAlpha( + _, err := client.Alpha.Eval.EvaluateRowsAlpha( context.TODO(), "benchmark_id", - llamastackclient.EvalEvaluateRowsAlphaParams{ + llamastackclient.AlphaEvalEvaluateRowsAlphaParams{ BenchmarkConfig: llamastackclient.BenchmarkConfigParam{ - EvalCandidate: llamastackclient.EvalCandidateUnionParam{ - OfModel: &llamastackclient.EvalCandidateModelParam{ - Model: "model", - SamplingParams: shared.SamplingParams{ - Strategy: shared.SamplingParamsStrategyUnion{ - OfGreedy: &shared.SamplingParamsStrategyGreedy{}, - }, - MaxTokens: llamastackclient.Int(0), - RepetitionPenalty: llamastackclient.Float(0), - Stop: []string{"string"}, + EvalCandidate: llamastackclient.BenchmarkConfigEvalCandidateParam{ + Model: "model", + SamplingParams: llamastackclient.SamplingParams{ + Strategy: llamastackclient.SamplingParamsStrategyUnion{ + OfGreedy: &llamastackclient.SamplingParamsStrategyGreedy{}, }, - SystemMessage: shared.SystemMessageParam{ - Content: shared.InterleavedContentUnionParam{ - OfString: llamastackclient.String("string"), - }, + MaxTokens: llamastackclient.Int(0), + RepetitionPenalty: llamastackclient.Float(0), + Stop: []string{"string"}, + }, + SystemMessage: llamastackclient.SystemMessageParam{ + Content: llamastackclient.InterleavedContentUnionParam{ + OfString: llamastackclient.String("string"), }, }, }, @@ -123,7 +124,7 @@ func TestEvalEvaluateRowsAlphaWithOptionalParams(t *testing.T) { }, NumExamples: llamastackclient.Int(0), }, - InputRows: []map[string]llamastackclient.EvalEvaluateRowsAlphaParamsInputRowUnion{{ + InputRows: []map[string]llamastackclient.AlphaEvalEvaluateRowsAlphaParamsInputRowUnion{{ "foo": { OfBool: llamastackclient.Bool(true), }, @@ -140,7 +141,7 @@ func TestEvalEvaluateRowsAlphaWithOptionalParams(t *testing.T) { } } -func TestEvalRunEvalWithOptionalParams(t *testing.T) { +func TestAlphaEvalRunEvalWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -151,26 +152,24 @@ func TestEvalRunEvalWithOptionalParams(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.Eval.RunEval( + _, err := client.Alpha.Eval.RunEval( context.TODO(), "benchmark_id", - llamastackclient.EvalRunEvalParams{ + llamastackclient.AlphaEvalRunEvalParams{ BenchmarkConfig: llamastackclient.BenchmarkConfigParam{ - EvalCandidate: llamastackclient.EvalCandidateUnionParam{ - OfModel: &llamastackclient.EvalCandidateModelParam{ - Model: "model", - SamplingParams: shared.SamplingParams{ - Strategy: shared.SamplingParamsStrategyUnion{ - OfGreedy: &shared.SamplingParamsStrategyGreedy{}, - }, - MaxTokens: llamastackclient.Int(0), - RepetitionPenalty: llamastackclient.Float(0), - Stop: []string{"string"}, + EvalCandidate: llamastackclient.BenchmarkConfigEvalCandidateParam{ + Model: "model", + SamplingParams: llamastackclient.SamplingParams{ + Strategy: llamastackclient.SamplingParamsStrategyUnion{ + OfGreedy: &llamastackclient.SamplingParamsStrategyGreedy{}, }, - SystemMessage: shared.SystemMessageParam{ - Content: shared.InterleavedContentUnionParam{ - OfString: llamastackclient.String("string"), - }, + MaxTokens: llamastackclient.Int(0), + RepetitionPenalty: llamastackclient.Float(0), + Stop: []string{"string"}, + }, + SystemMessage: llamastackclient.SystemMessageParam{ + Content: llamastackclient.InterleavedContentUnionParam{ + OfString: llamastackclient.String("string"), }, }, }, @@ -197,7 +196,7 @@ func TestEvalRunEvalWithOptionalParams(t *testing.T) { } } -func TestEvalRunEvalAlphaWithOptionalParams(t *testing.T) { +func TestAlphaEvalRunEvalAlphaWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -208,26 +207,24 @@ func TestEvalRunEvalAlphaWithOptionalParams(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.Eval.RunEvalAlpha( + _, err := client.Alpha.Eval.RunEvalAlpha( context.TODO(), "benchmark_id", - llamastackclient.EvalRunEvalAlphaParams{ + llamastackclient.AlphaEvalRunEvalAlphaParams{ BenchmarkConfig: llamastackclient.BenchmarkConfigParam{ - EvalCandidate: llamastackclient.EvalCandidateUnionParam{ - OfModel: &llamastackclient.EvalCandidateModelParam{ - Model: "model", - SamplingParams: shared.SamplingParams{ - Strategy: shared.SamplingParamsStrategyUnion{ - OfGreedy: &shared.SamplingParamsStrategyGreedy{}, - }, - MaxTokens: llamastackclient.Int(0), - RepetitionPenalty: llamastackclient.Float(0), - Stop: []string{"string"}, + EvalCandidate: llamastackclient.BenchmarkConfigEvalCandidateParam{ + Model: "model", + SamplingParams: llamastackclient.SamplingParams{ + Strategy: llamastackclient.SamplingParamsStrategyUnion{ + OfGreedy: &llamastackclient.SamplingParamsStrategyGreedy{}, }, - SystemMessage: shared.SystemMessageParam{ - Content: shared.InterleavedContentUnionParam{ - OfString: llamastackclient.String("string"), - }, + MaxTokens: llamastackclient.Int(0), + RepetitionPenalty: llamastackclient.Float(0), + Stop: []string{"string"}, + }, + SystemMessage: llamastackclient.SystemMessageParam{ + Content: llamastackclient.InterleavedContentUnionParam{ + OfString: llamastackclient.String("string"), }, }, }, diff --git a/evaljob.go b/alphaevaljob.go similarity index 50% rename from evaljob.go rename to alphaevaljob.go index f7e700b..88dce1c 100644 --- a/evaljob.go +++ b/alphaevaljob.go @@ -1,3 +1,9 @@ +// 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 @@ -7,33 +13,34 @@ import ( "errors" "fmt" "net/http" + "slices" "github.com/llamastack/llama-stack-client-go/internal/requestconfig" "github.com/llamastack/llama-stack-client-go/option" ) -// EvalJobService contains methods and other services that help with interacting -// with the llama-stack-client API. +// AlphaEvalJobService 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 [NewEvalJobService] method instead. -type EvalJobService struct { +// the [NewAlphaEvalJobService] method instead. +type AlphaEvalJobService struct { Options []option.RequestOption } -// NewEvalJobService 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 NewEvalJobService(opts ...option.RequestOption) (r EvalJobService) { - r = EvalJobService{} +// NewAlphaEvalJobService 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 NewAlphaEvalJobService(opts ...option.RequestOption) (r AlphaEvalJobService) { + r = AlphaEvalJobService{} r.Options = opts return } // Get the result of a job. -func (r *EvalJobService) Get(ctx context.Context, jobID string, query EvalJobGetParams, opts ...option.RequestOption) (res *EvaluateResponse, err error) { - opts = append(r.Options[:], opts...) +func (r *AlphaEvalJobService) Get(ctx context.Context, jobID string, query AlphaEvalJobGetParams, opts ...option.RequestOption) (res *EvaluateResponse, err error) { + opts = slices.Concat(r.Options, opts) if query.BenchmarkID == "" { err = errors.New("missing required benchmark_id parameter") return @@ -42,14 +49,14 @@ func (r *EvalJobService) Get(ctx context.Context, jobID string, query EvalJobGet err = errors.New("missing required job_id parameter") return } - path := fmt.Sprintf("v1/eval/benchmarks/%s/jobs/%s/result", query.BenchmarkID, jobID) + path := fmt.Sprintf("v1alpha/eval/benchmarks/%s/jobs/%s/result", query.BenchmarkID, jobID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return } // Cancel a job. -func (r *EvalJobService) Cancel(ctx context.Context, jobID string, body EvalJobCancelParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) +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...) if body.BenchmarkID == "" { err = errors.New("missing required benchmark_id parameter") @@ -59,14 +66,14 @@ func (r *EvalJobService) Cancel(ctx context.Context, jobID string, body EvalJobC err = errors.New("missing required job_id parameter") return } - path := fmt.Sprintf("v1/eval/benchmarks/%s/jobs/%s", body.BenchmarkID, jobID) + path := fmt.Sprintf("v1alpha/eval/benchmarks/%s/jobs/%s", body.BenchmarkID, jobID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...) return } // Get the status of a job. -func (r *EvalJobService) Status(ctx context.Context, jobID string, query EvalJobStatusParams, opts ...option.RequestOption) (res *Job, err error) { - opts = append(r.Options[:], opts...) +func (r *AlphaEvalJobService) Status(ctx context.Context, jobID string, query AlphaEvalJobStatusParams, opts ...option.RequestOption) (res *Job, err error) { + opts = slices.Concat(r.Options, opts) if query.BenchmarkID == "" { err = errors.New("missing required benchmark_id parameter") return @@ -75,22 +82,22 @@ func (r *EvalJobService) Status(ctx context.Context, jobID string, query EvalJob err = errors.New("missing required job_id parameter") return } - path := fmt.Sprintf("v1/eval/benchmarks/%s/jobs/%s", query.BenchmarkID, jobID) + path := fmt.Sprintf("v1alpha/eval/benchmarks/%s/jobs/%s", query.BenchmarkID, jobID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return } -type EvalJobGetParams struct { +type AlphaEvalJobGetParams struct { BenchmarkID string `path:"benchmark_id,required" json:"-"` paramObj } -type EvalJobCancelParams struct { +type AlphaEvalJobCancelParams struct { BenchmarkID string `path:"benchmark_id,required" json:"-"` paramObj } -type EvalJobStatusParams struct { +type AlphaEvalJobStatusParams struct { BenchmarkID string `path:"benchmark_id,required" json:"-"` paramObj } diff --git a/evaljob_test.go b/alphaevaljob_test.go similarity index 75% rename from evaljob_test.go rename to alphaevaljob_test.go index 4af20d9..14f9c25 100644 --- a/evaljob_test.go +++ b/alphaevaljob_test.go @@ -1,3 +1,9 @@ +// 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 @@ -13,7 +19,7 @@ import ( "github.com/llamastack/llama-stack-client-go/option" ) -func TestEvalJobGet(t *testing.T) { +func TestAlphaEvalJobGet(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -24,10 +30,10 @@ func TestEvalJobGet(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.Eval.Jobs.Get( + _, err := client.Alpha.Eval.Jobs.Get( context.TODO(), "job_id", - llamastackclient.EvalJobGetParams{ + llamastackclient.AlphaEvalJobGetParams{ BenchmarkID: "benchmark_id", }, ) @@ -40,7 +46,7 @@ func TestEvalJobGet(t *testing.T) { } } -func TestEvalJobCancel(t *testing.T) { +func TestAlphaEvalJobCancel(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -51,10 +57,10 @@ func TestEvalJobCancel(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - err := client.Eval.Jobs.Cancel( + err := client.Alpha.Eval.Jobs.Cancel( context.TODO(), "job_id", - llamastackclient.EvalJobCancelParams{ + llamastackclient.AlphaEvalJobCancelParams{ BenchmarkID: "benchmark_id", }, ) @@ -67,7 +73,7 @@ func TestEvalJobCancel(t *testing.T) { } } -func TestEvalJobStatus(t *testing.T) { +func TestAlphaEvalJobStatus(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -78,10 +84,10 @@ func TestEvalJobStatus(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.Eval.Jobs.Status( + _, err := client.Alpha.Eval.Jobs.Status( context.TODO(), "job_id", - llamastackclient.EvalJobStatusParams{ + llamastackclient.AlphaEvalJobStatusParams{ BenchmarkID: "benchmark_id", }, ) diff --git a/alphainference.go b/alphainference.go new file mode 100644 index 0000000..d7d0918 --- /dev/null +++ b/alphainference.go @@ -0,0 +1,347 @@ +// 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" + "net/http" + "slices" + + "github.com/llamastack/llama-stack-client-go/internal/apijson" + "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" +) + +// AlphaInferenceService 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 [NewAlphaInferenceService] method instead. +type AlphaInferenceService struct { + Options []option.RequestOption +} + +// NewAlphaInferenceService 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 NewAlphaInferenceService(opts ...option.RequestOption) (r AlphaInferenceService) { + r = AlphaInferenceService{} + r.Options = opts + return +} + +// Rerank a list of documents based on their relevance to a query. +func (r *AlphaInferenceService) Rerank(ctx context.Context, body AlphaInferenceRerankParams, opts ...option.RequestOption) (res *[]AlphaInferenceRerankResponse, err error) { + var env AlphaInferenceRerankResponseEnvelope + opts = slices.Concat(r.Options, opts) + path := "v1alpha/inference/rerank" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Data + return +} + +// 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. + RelevanceScore float64 `json:"relevance_score,required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Index respjson.Field + RelevanceScore respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AlphaInferenceRerankResponse) RawJSON() string { return r.JSON.raw } +func (r *AlphaInferenceRerankResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +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"` + paramObj +} + +func (r AlphaInferenceRerankParams) MarshalJSON() (data []byte, err error) { + type shadow AlphaInferenceRerankParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AlphaInferenceRerankParams) 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 AlphaInferenceRerankParamsItemUnion struct { + OfString param.Opt[string] `json:",omitzero,inline"` + OfOpenAIChatCompletionContentPartText *AlphaInferenceRerankParamsItemOpenAIChatCompletionContentPartTextParam `json:",omitzero,inline"` + OfOpenAIChatCompletionContentPartImage *AlphaInferenceRerankParamsItemOpenAIChatCompletionContentPartImageParam `json:",omitzero,inline"` + paramUnion +} + +func (u AlphaInferenceRerankParamsItemUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfString, u.OfOpenAIChatCompletionContentPartText, u.OfOpenAIChatCompletionContentPartImage) +} +func (u *AlphaInferenceRerankParamsItemUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *AlphaInferenceRerankParamsItemUnion) asAny() any { + if !param.IsOmitted(u.OfString) { + return &u.OfString.Value + } else if !param.IsOmitted(u.OfOpenAIChatCompletionContentPartText) { + return u.OfOpenAIChatCompletionContentPartText + } else if !param.IsOmitted(u.OfOpenAIChatCompletionContentPartImage) { + return u.OfOpenAIChatCompletionContentPartImage + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u AlphaInferenceRerankParamsItemUnion) GetText() *string { + if vt := u.OfOpenAIChatCompletionContentPartText; vt != nil { + return &vt.Text + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u AlphaInferenceRerankParamsItemUnion) GetImageURL() *AlphaInferenceRerankParamsItemOpenAIChatCompletionContentPartImageParamImageURL { + if vt := u.OfOpenAIChatCompletionContentPartImage; vt != nil { + return &vt.ImageURL + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u AlphaInferenceRerankParamsItemUnion) GetType() *string { + if vt := u.OfOpenAIChatCompletionContentPartText; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfOpenAIChatCompletionContentPartImage; vt != nil { + return (*string)(&vt.Type) + } + return nil +} + +// Text content part for OpenAI-compatible chat completion messages. +// +// The properties Text, Type are 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"` + paramObj +} + +func (r AlphaInferenceRerankParamsItemOpenAIChatCompletionContentPartTextParam) MarshalJSON() (data []byte, err error) { + type shadow AlphaInferenceRerankParamsItemOpenAIChatCompletionContentPartTextParam + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AlphaInferenceRerankParamsItemOpenAIChatCompletionContentPartTextParam) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Image content part for OpenAI-compatible chat completion messages. +// +// The properties ImageURL, Type are required. +type AlphaInferenceRerankParamsItemOpenAIChatCompletionContentPartImageParam struct { + // Image URL specification and processing details + 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"` + paramObj +} + +func (r AlphaInferenceRerankParamsItemOpenAIChatCompletionContentPartImageParam) MarshalJSON() (data []byte, err error) { + type shadow AlphaInferenceRerankParamsItemOpenAIChatCompletionContentPartImageParam + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AlphaInferenceRerankParamsItemOpenAIChatCompletionContentPartImageParam) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Image URL specification and processing details +// +// 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" + Detail param.Opt[string] `json:"detail,omitzero"` + paramObj +} + +func (r AlphaInferenceRerankParamsItemOpenAIChatCompletionContentPartImageParamImageURL) MarshalJSON() (data []byte, err error) { + type shadow AlphaInferenceRerankParamsItemOpenAIChatCompletionContentPartImageParamImageURL + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AlphaInferenceRerankParamsItemOpenAIChatCompletionContentPartImageParamImageURL) 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 AlphaInferenceRerankParamsQueryUnion struct { + OfString param.Opt[string] `json:",omitzero,inline"` + OfOpenAIChatCompletionContentPartText *AlphaInferenceRerankParamsQueryOpenAIChatCompletionContentPartTextParam `json:",omitzero,inline"` + OfOpenAIChatCompletionContentPartImage *AlphaInferenceRerankParamsQueryOpenAIChatCompletionContentPartImageParam `json:",omitzero,inline"` + paramUnion +} + +func (u AlphaInferenceRerankParamsQueryUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfString, u.OfOpenAIChatCompletionContentPartText, u.OfOpenAIChatCompletionContentPartImage) +} +func (u *AlphaInferenceRerankParamsQueryUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *AlphaInferenceRerankParamsQueryUnion) asAny() any { + if !param.IsOmitted(u.OfString) { + return &u.OfString.Value + } else if !param.IsOmitted(u.OfOpenAIChatCompletionContentPartText) { + return u.OfOpenAIChatCompletionContentPartText + } else if !param.IsOmitted(u.OfOpenAIChatCompletionContentPartImage) { + return u.OfOpenAIChatCompletionContentPartImage + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u AlphaInferenceRerankParamsQueryUnion) GetText() *string { + if vt := u.OfOpenAIChatCompletionContentPartText; vt != nil { + return &vt.Text + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u AlphaInferenceRerankParamsQueryUnion) GetImageURL() *AlphaInferenceRerankParamsQueryOpenAIChatCompletionContentPartImageParamImageURL { + if vt := u.OfOpenAIChatCompletionContentPartImage; vt != nil { + return &vt.ImageURL + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u AlphaInferenceRerankParamsQueryUnion) GetType() *string { + if vt := u.OfOpenAIChatCompletionContentPartText; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfOpenAIChatCompletionContentPartImage; vt != nil { + return (*string)(&vt.Type) + } + return nil +} + +// Text content part for OpenAI-compatible chat completion messages. +// +// The properties Text, Type are 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"` + paramObj +} + +func (r AlphaInferenceRerankParamsQueryOpenAIChatCompletionContentPartTextParam) MarshalJSON() (data []byte, err error) { + type shadow AlphaInferenceRerankParamsQueryOpenAIChatCompletionContentPartTextParam + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AlphaInferenceRerankParamsQueryOpenAIChatCompletionContentPartTextParam) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Image content part for OpenAI-compatible chat completion messages. +// +// The properties ImageURL, Type are required. +type AlphaInferenceRerankParamsQueryOpenAIChatCompletionContentPartImageParam struct { + // Image URL specification and processing details + 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"` + paramObj +} + +func (r AlphaInferenceRerankParamsQueryOpenAIChatCompletionContentPartImageParam) MarshalJSON() (data []byte, err error) { + type shadow AlphaInferenceRerankParamsQueryOpenAIChatCompletionContentPartImageParam + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AlphaInferenceRerankParamsQueryOpenAIChatCompletionContentPartImageParam) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Image URL specification and processing details +// +// 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" + Detail param.Opt[string] `json:"detail,omitzero"` + paramObj +} + +func (r AlphaInferenceRerankParamsQueryOpenAIChatCompletionContentPartImageParamImageURL) MarshalJSON() (data []byte, err error) { + type shadow AlphaInferenceRerankParamsQueryOpenAIChatCompletionContentPartImageParamImageURL + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *AlphaInferenceRerankParamsQueryOpenAIChatCompletionContentPartImageParamImageURL) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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 { + Data respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r AlphaInferenceRerankResponseEnvelope) RawJSON() string { return r.JSON.raw } +func (r *AlphaInferenceRerankResponseEnvelope) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} diff --git a/syntheticdatageneration_test.go b/alphainference_test.go similarity index 52% rename from syntheticdatageneration_test.go rename to alphainference_test.go index 02c3a1b..395f69d 100644 --- a/syntheticdatageneration_test.go +++ b/alphainference_test.go @@ -1,3 +1,9 @@ +// 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 @@ -11,10 +17,9 @@ import ( "github.com/llamastack/llama-stack-client-go" "github.com/llamastack/llama-stack-client-go/internal/testutil" "github.com/llamastack/llama-stack-client-go/option" - "github.com/llamastack/llama-stack-client-go/shared" ) -func TestSyntheticDataGenerationGenerateWithOptionalParams(t *testing.T) { +func TestAlphaInferenceRerankWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -25,19 +30,15 @@ func TestSyntheticDataGenerationGenerateWithOptionalParams(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.SyntheticDataGeneration.Generate(context.TODO(), llamastackclient.SyntheticDataGenerationGenerateParams{ - Dialogs: []shared.MessageUnionParam{{ - OfUser: &shared.UserMessageParam{ - Content: shared.InterleavedContentUnionParam{ - OfString: llamastackclient.String("string"), - }, - Context: shared.InterleavedContentUnionParam{ - OfString: llamastackclient.String("string"), - }, - }, + _, err := client.Alpha.Inference.Rerank(context.TODO(), llamastackclient.AlphaInferenceRerankParams{ + Items: []llamastackclient.AlphaInferenceRerankParamsItemUnion{{ + OfString: llamastackclient.String("string"), }}, - FilteringFunction: llamastackclient.SyntheticDataGenerationGenerateParamsFilteringFunctionNone, - Model: llamastackclient.String("model"), + Model: "model", + Query: llamastackclient.AlphaInferenceRerankParamsQueryUnion{ + OfString: llamastackclient.String("string"), + }, + MaxNumResults: llamastackclient.Int(0), }) if err != nil { var apierr *llamastackclient.Error diff --git a/posttraining.go b/alphaposttraining.go similarity index 65% rename from posttraining.go rename to alphaposttraining.go index b919dfd..d3c655b 100644 --- a/posttraining.go +++ b/alphaposttraining.go @@ -1,3 +1,9 @@ +// 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 @@ -5,6 +11,7 @@ package llamastackclient import ( "context" "net/http" + "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" "github.com/llamastack/llama-stack-client-go/internal/requestconfig" @@ -14,39 +21,39 @@ import ( "github.com/llamastack/llama-stack-client-go/shared/constant" ) -// PostTrainingService contains methods and other services that help with +// AlphaPostTrainingService 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 [NewPostTrainingService] method instead. -type PostTrainingService struct { +// the [NewAlphaPostTrainingService] method instead. +type AlphaPostTrainingService struct { Options []option.RequestOption - Job PostTrainingJobService + Job AlphaPostTrainingJobService } -// NewPostTrainingService 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 NewPostTrainingService(opts ...option.RequestOption) (r PostTrainingService) { - r = PostTrainingService{} +// NewAlphaPostTrainingService 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 NewAlphaPostTrainingService(opts ...option.RequestOption) (r AlphaPostTrainingService) { + r = AlphaPostTrainingService{} r.Options = opts - r.Job = NewPostTrainingJobService(opts...) + r.Job = NewAlphaPostTrainingJobService(opts...) return } // Run preference optimization of a model. -func (r *PostTrainingService) PreferenceOptimize(ctx context.Context, body PostTrainingPreferenceOptimizeParams, opts ...option.RequestOption) (res *PostTrainingJob, err error) { - opts = append(r.Options[:], opts...) - path := "v1/post-training/preference-optimize" +func (r *AlphaPostTrainingService) PreferenceOptimize(ctx context.Context, body AlphaPostTrainingPreferenceOptimizeParams, opts ...option.RequestOption) (res *PostTrainingJob, err error) { + opts = slices.Concat(r.Options, opts) + path := "v1alpha/post-training/preference-optimize" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return } // Run supervised fine-tuning of a model. -func (r *PostTrainingService) SupervisedFineTune(ctx context.Context, body PostTrainingSupervisedFineTuneParams, opts ...option.RequestOption) (res *PostTrainingJob, err error) { - opts = append(r.Options[:], opts...) - path := "v1/post-training/supervised-fine-tune" +func (r *AlphaPostTrainingService) SupervisedFineTune(ctx context.Context, body AlphaPostTrainingSupervisedFineTuneParams, opts ...option.RequestOption) (res *PostTrainingJob, err error) { + opts = slices.Concat(r.Options, opts) + path := "v1alpha/post-training/supervised-fine-tune" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return } @@ -230,6 +237,38 @@ func (r *AlgorithmConfigQatParam) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +type ListPostTrainingJobsResponse struct { + Data []ListPostTrainingJobsResponseData `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:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ListPostTrainingJobsResponse) RawJSON() string { return r.JSON.raw } +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]. @@ -246,34 +285,34 @@ func (r *PostTrainingJob) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type PostTrainingPreferenceOptimizeParams struct { +type AlphaPostTrainingPreferenceOptimizeParams struct { // The algorithm configuration. - AlgorithmConfig PostTrainingPreferenceOptimizeParamsAlgorithmConfig `json:"algorithm_config,omitzero,required"` + 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]PostTrainingPreferenceOptimizeParamsHyperparamSearchConfigUnion `json:"hyperparam_search_config,omitzero,required"` + 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]PostTrainingPreferenceOptimizeParamsLoggerConfigUnion `json:"logger_config,omitzero,required"` + LoggerConfig map[string]AlphaPostTrainingPreferenceOptimizeParamsLoggerConfigUnion `json:"logger_config,omitzero,required"` // The training configuration. - TrainingConfig PostTrainingPreferenceOptimizeParamsTrainingConfig `json:"training_config,omitzero,required"` + TrainingConfig AlphaPostTrainingPreferenceOptimizeParamsTrainingConfig `json:"training_config,omitzero,required"` paramObj } -func (r PostTrainingPreferenceOptimizeParams) MarshalJSON() (data []byte, err error) { - type shadow PostTrainingPreferenceOptimizeParams +func (r AlphaPostTrainingPreferenceOptimizeParams) MarshalJSON() (data []byte, err error) { + type shadow AlphaPostTrainingPreferenceOptimizeParams return param.MarshalObject(r, (*shadow)(&r)) } -func (r *PostTrainingPreferenceOptimizeParams) UnmarshalJSON(data []byte) error { +func (r *AlphaPostTrainingPreferenceOptimizeParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // The algorithm configuration. // // The properties Beta, LossType are required. -type PostTrainingPreferenceOptimizeParamsAlgorithmConfig struct { +type AlphaPostTrainingPreferenceOptimizeParamsAlgorithmConfig struct { // Temperature parameter for the DPO loss Beta float64 `json:"beta,required"` // The type of loss function to use for DPO @@ -283,16 +322,16 @@ type PostTrainingPreferenceOptimizeParamsAlgorithmConfig struct { paramObj } -func (r PostTrainingPreferenceOptimizeParamsAlgorithmConfig) MarshalJSON() (data []byte, err error) { - type shadow PostTrainingPreferenceOptimizeParamsAlgorithmConfig +func (r AlphaPostTrainingPreferenceOptimizeParamsAlgorithmConfig) MarshalJSON() (data []byte, err error) { + type shadow AlphaPostTrainingPreferenceOptimizeParamsAlgorithmConfig return param.MarshalObject(r, (*shadow)(&r)) } -func (r *PostTrainingPreferenceOptimizeParamsAlgorithmConfig) UnmarshalJSON(data []byte) error { +func (r *AlphaPostTrainingPreferenceOptimizeParamsAlgorithmConfig) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } func init() { - apijson.RegisterFieldValidator[PostTrainingPreferenceOptimizeParamsAlgorithmConfig]( + apijson.RegisterFieldValidator[AlphaPostTrainingPreferenceOptimizeParamsAlgorithmConfig]( "loss_type", "sigmoid", "hinge", "ipo", "kto_pair", ) } @@ -300,7 +339,7 @@ func init() { // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. -type PostTrainingPreferenceOptimizeParamsHyperparamSearchConfigUnion struct { +type AlphaPostTrainingPreferenceOptimizeParamsHyperparamSearchConfigUnion struct { OfBool param.Opt[bool] `json:",omitzero,inline"` OfFloat param.Opt[float64] `json:",omitzero,inline"` OfString param.Opt[string] `json:",omitzero,inline"` @@ -308,14 +347,14 @@ type PostTrainingPreferenceOptimizeParamsHyperparamSearchConfigUnion struct { paramUnion } -func (u PostTrainingPreferenceOptimizeParamsHyperparamSearchConfigUnion) MarshalJSON() ([]byte, error) { +func (u AlphaPostTrainingPreferenceOptimizeParamsHyperparamSearchConfigUnion) MarshalJSON() ([]byte, error) { return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) } -func (u *PostTrainingPreferenceOptimizeParamsHyperparamSearchConfigUnion) UnmarshalJSON(data []byte) error { +func (u *AlphaPostTrainingPreferenceOptimizeParamsHyperparamSearchConfigUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *PostTrainingPreferenceOptimizeParamsHyperparamSearchConfigUnion) asAny() any { +func (u *AlphaPostTrainingPreferenceOptimizeParamsHyperparamSearchConfigUnion) asAny() any { if !param.IsOmitted(u.OfBool) { return &u.OfBool.Value } else if !param.IsOmitted(u.OfFloat) { @@ -331,7 +370,7 @@ func (u *PostTrainingPreferenceOptimizeParamsHyperparamSearchConfigUnion) asAny( // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. -type PostTrainingPreferenceOptimizeParamsLoggerConfigUnion struct { +type AlphaPostTrainingPreferenceOptimizeParamsLoggerConfigUnion struct { OfBool param.Opt[bool] `json:",omitzero,inline"` OfFloat param.Opt[float64] `json:",omitzero,inline"` OfString param.Opt[string] `json:",omitzero,inline"` @@ -339,14 +378,14 @@ type PostTrainingPreferenceOptimizeParamsLoggerConfigUnion struct { paramUnion } -func (u PostTrainingPreferenceOptimizeParamsLoggerConfigUnion) MarshalJSON() ([]byte, error) { +func (u AlphaPostTrainingPreferenceOptimizeParamsLoggerConfigUnion) MarshalJSON() ([]byte, error) { return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) } -func (u *PostTrainingPreferenceOptimizeParamsLoggerConfigUnion) UnmarshalJSON(data []byte) error { +func (u *AlphaPostTrainingPreferenceOptimizeParamsLoggerConfigUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *PostTrainingPreferenceOptimizeParamsLoggerConfigUnion) asAny() any { +func (u *AlphaPostTrainingPreferenceOptimizeParamsLoggerConfigUnion) asAny() any { if !param.IsOmitted(u.OfBool) { return &u.OfBool.Value } else if !param.IsOmitted(u.OfFloat) { @@ -363,7 +402,7 @@ func (u *PostTrainingPreferenceOptimizeParamsLoggerConfigUnion) asAny() any { // // The properties GradientAccumulationSteps, MaxStepsPerEpoch, NEpochs are // required. -type PostTrainingPreferenceOptimizeParamsTrainingConfig struct { +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 @@ -375,26 +414,26 @@ type PostTrainingPreferenceOptimizeParamsTrainingConfig struct { // (Optional) Maximum number of validation steps per epoch MaxValidationSteps param.Opt[int64] `json:"max_validation_steps,omitzero"` // (Optional) Configuration for data loading and formatting - DataConfig PostTrainingPreferenceOptimizeParamsTrainingConfigDataConfig `json:"data_config,omitzero"` + DataConfig AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigDataConfig `json:"data_config,omitzero"` // (Optional) Configuration for memory and compute optimizations - EfficiencyConfig PostTrainingPreferenceOptimizeParamsTrainingConfigEfficiencyConfig `json:"efficiency_config,omitzero"` + EfficiencyConfig AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigEfficiencyConfig `json:"efficiency_config,omitzero"` // (Optional) Configuration for the optimization algorithm - OptimizerConfig PostTrainingPreferenceOptimizeParamsTrainingConfigOptimizerConfig `json:"optimizer_config,omitzero"` + OptimizerConfig AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigOptimizerConfig `json:"optimizer_config,omitzero"` paramObj } -func (r PostTrainingPreferenceOptimizeParamsTrainingConfig) MarshalJSON() (data []byte, err error) { - type shadow PostTrainingPreferenceOptimizeParamsTrainingConfig +func (r AlphaPostTrainingPreferenceOptimizeParamsTrainingConfig) MarshalJSON() (data []byte, err error) { + type shadow AlphaPostTrainingPreferenceOptimizeParamsTrainingConfig return param.MarshalObject(r, (*shadow)(&r)) } -func (r *PostTrainingPreferenceOptimizeParamsTrainingConfig) UnmarshalJSON(data []byte) error { +func (r *AlphaPostTrainingPreferenceOptimizeParamsTrainingConfig) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // (Optional) Configuration for data loading and formatting // // The properties BatchSize, DataFormat, DatasetID, Shuffle are required. -type PostTrainingPreferenceOptimizeParamsTrainingConfigDataConfig struct { +type AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigDataConfig struct { // Number of samples per training batch BatchSize int64 `json:"batch_size,required"` // Format of the dataset (instruct or dialog) @@ -415,22 +454,22 @@ type PostTrainingPreferenceOptimizeParamsTrainingConfigDataConfig struct { paramObj } -func (r PostTrainingPreferenceOptimizeParamsTrainingConfigDataConfig) MarshalJSON() (data []byte, err error) { - type shadow PostTrainingPreferenceOptimizeParamsTrainingConfigDataConfig +func (r AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigDataConfig) MarshalJSON() (data []byte, err error) { + type shadow AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigDataConfig return param.MarshalObject(r, (*shadow)(&r)) } -func (r *PostTrainingPreferenceOptimizeParamsTrainingConfigDataConfig) UnmarshalJSON(data []byte) error { +func (r *AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigDataConfig) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } func init() { - apijson.RegisterFieldValidator[PostTrainingPreferenceOptimizeParamsTrainingConfigDataConfig]( + apijson.RegisterFieldValidator[AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigDataConfig]( "data_format", "instruct", "dialog", ) } // (Optional) Configuration for memory and compute optimizations -type PostTrainingPreferenceOptimizeParamsTrainingConfigEfficiencyConfig struct { +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 @@ -442,18 +481,18 @@ type PostTrainingPreferenceOptimizeParamsTrainingConfigEfficiencyConfig struct { paramObj } -func (r PostTrainingPreferenceOptimizeParamsTrainingConfigEfficiencyConfig) MarshalJSON() (data []byte, err error) { - type shadow PostTrainingPreferenceOptimizeParamsTrainingConfigEfficiencyConfig +func (r AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigEfficiencyConfig) MarshalJSON() (data []byte, err error) { + type shadow AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigEfficiencyConfig return param.MarshalObject(r, (*shadow)(&r)) } -func (r *PostTrainingPreferenceOptimizeParamsTrainingConfigEfficiencyConfig) UnmarshalJSON(data []byte) error { +func (r *AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigEfficiencyConfig) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // (Optional) Configuration for the optimization algorithm // // The properties Lr, NumWarmupSteps, OptimizerType, WeightDecay are required. -type PostTrainingPreferenceOptimizeParamsTrainingConfigOptimizerConfig struct { +type AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigOptimizerConfig struct { // Learning rate for the optimizer Lr float64 `json:"lr,required"` // Number of steps for learning rate warmup @@ -467,29 +506,29 @@ type PostTrainingPreferenceOptimizeParamsTrainingConfigOptimizerConfig struct { paramObj } -func (r PostTrainingPreferenceOptimizeParamsTrainingConfigOptimizerConfig) MarshalJSON() (data []byte, err error) { - type shadow PostTrainingPreferenceOptimizeParamsTrainingConfigOptimizerConfig +func (r AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigOptimizerConfig) MarshalJSON() (data []byte, err error) { + type shadow AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigOptimizerConfig return param.MarshalObject(r, (*shadow)(&r)) } -func (r *PostTrainingPreferenceOptimizeParamsTrainingConfigOptimizerConfig) UnmarshalJSON(data []byte) error { +func (r *AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigOptimizerConfig) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } func init() { - apijson.RegisterFieldValidator[PostTrainingPreferenceOptimizeParamsTrainingConfigOptimizerConfig]( + apijson.RegisterFieldValidator[AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigOptimizerConfig]( "optimizer_type", "adam", "adamw", "sgd", ) } -type PostTrainingSupervisedFineTuneParams struct { +type AlphaPostTrainingSupervisedFineTuneParams struct { // The hyperparam search configuration. - HyperparamSearchConfig map[string]PostTrainingSupervisedFineTuneParamsHyperparamSearchConfigUnion `json:"hyperparam_search_config,omitzero,required"` + 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]PostTrainingSupervisedFineTuneParamsLoggerConfigUnion `json:"logger_config,omitzero,required"` + LoggerConfig map[string]AlphaPostTrainingSupervisedFineTuneParamsLoggerConfigUnion `json:"logger_config,omitzero,required"` // The training configuration. - TrainingConfig PostTrainingSupervisedFineTuneParamsTrainingConfig `json:"training_config,omitzero,required"` + 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. @@ -499,18 +538,18 @@ type PostTrainingSupervisedFineTuneParams struct { paramObj } -func (r PostTrainingSupervisedFineTuneParams) MarshalJSON() (data []byte, err error) { - type shadow PostTrainingSupervisedFineTuneParams +func (r AlphaPostTrainingSupervisedFineTuneParams) MarshalJSON() (data []byte, err error) { + type shadow AlphaPostTrainingSupervisedFineTuneParams return param.MarshalObject(r, (*shadow)(&r)) } -func (r *PostTrainingSupervisedFineTuneParams) UnmarshalJSON(data []byte) error { +func (r *AlphaPostTrainingSupervisedFineTuneParams) 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 PostTrainingSupervisedFineTuneParamsHyperparamSearchConfigUnion struct { +type AlphaPostTrainingSupervisedFineTuneParamsHyperparamSearchConfigUnion struct { OfBool param.Opt[bool] `json:",omitzero,inline"` OfFloat param.Opt[float64] `json:",omitzero,inline"` OfString param.Opt[string] `json:",omitzero,inline"` @@ -518,14 +557,14 @@ type PostTrainingSupervisedFineTuneParamsHyperparamSearchConfigUnion struct { paramUnion } -func (u PostTrainingSupervisedFineTuneParamsHyperparamSearchConfigUnion) MarshalJSON() ([]byte, error) { +func (u AlphaPostTrainingSupervisedFineTuneParamsHyperparamSearchConfigUnion) MarshalJSON() ([]byte, error) { return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) } -func (u *PostTrainingSupervisedFineTuneParamsHyperparamSearchConfigUnion) UnmarshalJSON(data []byte) error { +func (u *AlphaPostTrainingSupervisedFineTuneParamsHyperparamSearchConfigUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *PostTrainingSupervisedFineTuneParamsHyperparamSearchConfigUnion) asAny() any { +func (u *AlphaPostTrainingSupervisedFineTuneParamsHyperparamSearchConfigUnion) asAny() any { if !param.IsOmitted(u.OfBool) { return &u.OfBool.Value } else if !param.IsOmitted(u.OfFloat) { @@ -541,7 +580,7 @@ func (u *PostTrainingSupervisedFineTuneParamsHyperparamSearchConfigUnion) asAny( // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. -type PostTrainingSupervisedFineTuneParamsLoggerConfigUnion struct { +type AlphaPostTrainingSupervisedFineTuneParamsLoggerConfigUnion struct { OfBool param.Opt[bool] `json:",omitzero,inline"` OfFloat param.Opt[float64] `json:",omitzero,inline"` OfString param.Opt[string] `json:",omitzero,inline"` @@ -549,14 +588,14 @@ type PostTrainingSupervisedFineTuneParamsLoggerConfigUnion struct { paramUnion } -func (u PostTrainingSupervisedFineTuneParamsLoggerConfigUnion) MarshalJSON() ([]byte, error) { +func (u AlphaPostTrainingSupervisedFineTuneParamsLoggerConfigUnion) MarshalJSON() ([]byte, error) { return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) } -func (u *PostTrainingSupervisedFineTuneParamsLoggerConfigUnion) UnmarshalJSON(data []byte) error { +func (u *AlphaPostTrainingSupervisedFineTuneParamsLoggerConfigUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *PostTrainingSupervisedFineTuneParamsLoggerConfigUnion) asAny() any { +func (u *AlphaPostTrainingSupervisedFineTuneParamsLoggerConfigUnion) asAny() any { if !param.IsOmitted(u.OfBool) { return &u.OfBool.Value } else if !param.IsOmitted(u.OfFloat) { @@ -573,7 +612,7 @@ func (u *PostTrainingSupervisedFineTuneParamsLoggerConfigUnion) asAny() any { // // The properties GradientAccumulationSteps, MaxStepsPerEpoch, NEpochs are // required. -type PostTrainingSupervisedFineTuneParamsTrainingConfig struct { +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 @@ -585,26 +624,26 @@ type PostTrainingSupervisedFineTuneParamsTrainingConfig struct { // (Optional) Maximum number of validation steps per epoch MaxValidationSteps param.Opt[int64] `json:"max_validation_steps,omitzero"` // (Optional) Configuration for data loading and formatting - DataConfig PostTrainingSupervisedFineTuneParamsTrainingConfigDataConfig `json:"data_config,omitzero"` + DataConfig AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigDataConfig `json:"data_config,omitzero"` // (Optional) Configuration for memory and compute optimizations - EfficiencyConfig PostTrainingSupervisedFineTuneParamsTrainingConfigEfficiencyConfig `json:"efficiency_config,omitzero"` + EfficiencyConfig AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigEfficiencyConfig `json:"efficiency_config,omitzero"` // (Optional) Configuration for the optimization algorithm - OptimizerConfig PostTrainingSupervisedFineTuneParamsTrainingConfigOptimizerConfig `json:"optimizer_config,omitzero"` + OptimizerConfig AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigOptimizerConfig `json:"optimizer_config,omitzero"` paramObj } -func (r PostTrainingSupervisedFineTuneParamsTrainingConfig) MarshalJSON() (data []byte, err error) { - type shadow PostTrainingSupervisedFineTuneParamsTrainingConfig +func (r AlphaPostTrainingSupervisedFineTuneParamsTrainingConfig) MarshalJSON() (data []byte, err error) { + type shadow AlphaPostTrainingSupervisedFineTuneParamsTrainingConfig return param.MarshalObject(r, (*shadow)(&r)) } -func (r *PostTrainingSupervisedFineTuneParamsTrainingConfig) UnmarshalJSON(data []byte) error { +func (r *AlphaPostTrainingSupervisedFineTuneParamsTrainingConfig) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // (Optional) Configuration for data loading and formatting // // The properties BatchSize, DataFormat, DatasetID, Shuffle are required. -type PostTrainingSupervisedFineTuneParamsTrainingConfigDataConfig struct { +type AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigDataConfig struct { // Number of samples per training batch BatchSize int64 `json:"batch_size,required"` // Format of the dataset (instruct or dialog) @@ -625,22 +664,22 @@ type PostTrainingSupervisedFineTuneParamsTrainingConfigDataConfig struct { paramObj } -func (r PostTrainingSupervisedFineTuneParamsTrainingConfigDataConfig) MarshalJSON() (data []byte, err error) { - type shadow PostTrainingSupervisedFineTuneParamsTrainingConfigDataConfig +func (r AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigDataConfig) MarshalJSON() (data []byte, err error) { + type shadow AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigDataConfig return param.MarshalObject(r, (*shadow)(&r)) } -func (r *PostTrainingSupervisedFineTuneParamsTrainingConfigDataConfig) UnmarshalJSON(data []byte) error { +func (r *AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigDataConfig) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } func init() { - apijson.RegisterFieldValidator[PostTrainingSupervisedFineTuneParamsTrainingConfigDataConfig]( + apijson.RegisterFieldValidator[AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigDataConfig]( "data_format", "instruct", "dialog", ) } // (Optional) Configuration for memory and compute optimizations -type PostTrainingSupervisedFineTuneParamsTrainingConfigEfficiencyConfig struct { +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 @@ -652,18 +691,18 @@ type PostTrainingSupervisedFineTuneParamsTrainingConfigEfficiencyConfig struct { paramObj } -func (r PostTrainingSupervisedFineTuneParamsTrainingConfigEfficiencyConfig) MarshalJSON() (data []byte, err error) { - type shadow PostTrainingSupervisedFineTuneParamsTrainingConfigEfficiencyConfig +func (r AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigEfficiencyConfig) MarshalJSON() (data []byte, err error) { + type shadow AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigEfficiencyConfig return param.MarshalObject(r, (*shadow)(&r)) } -func (r *PostTrainingSupervisedFineTuneParamsTrainingConfigEfficiencyConfig) UnmarshalJSON(data []byte) error { +func (r *AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigEfficiencyConfig) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // (Optional) Configuration for the optimization algorithm // // The properties Lr, NumWarmupSteps, OptimizerType, WeightDecay are required. -type PostTrainingSupervisedFineTuneParamsTrainingConfigOptimizerConfig struct { +type AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigOptimizerConfig struct { // Learning rate for the optimizer Lr float64 `json:"lr,required"` // Number of steps for learning rate warmup @@ -677,16 +716,16 @@ type PostTrainingSupervisedFineTuneParamsTrainingConfigOptimizerConfig struct { paramObj } -func (r PostTrainingSupervisedFineTuneParamsTrainingConfigOptimizerConfig) MarshalJSON() (data []byte, err error) { - type shadow PostTrainingSupervisedFineTuneParamsTrainingConfigOptimizerConfig +func (r AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigOptimizerConfig) MarshalJSON() (data []byte, err error) { + type shadow AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigOptimizerConfig return param.MarshalObject(r, (*shadow)(&r)) } -func (r *PostTrainingSupervisedFineTuneParamsTrainingConfigOptimizerConfig) UnmarshalJSON(data []byte) error { +func (r *AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigOptimizerConfig) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } func init() { - apijson.RegisterFieldValidator[PostTrainingSupervisedFineTuneParamsTrainingConfigOptimizerConfig]( + apijson.RegisterFieldValidator[AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigOptimizerConfig]( "optimizer_type", "adam", "adamw", "sgd", ) } diff --git a/posttraining_test.go b/alphaposttraining_test.go similarity index 65% rename from posttraining_test.go rename to alphaposttraining_test.go index f43920e..c297d87 100644 --- a/posttraining_test.go +++ b/alphaposttraining_test.go @@ -1,3 +1,9 @@ +// 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 @@ -13,7 +19,7 @@ import ( "github.com/llamastack/llama-stack-client-go/option" ) -func TestPostTrainingPreferenceOptimizeWithOptionalParams(t *testing.T) { +func TestAlphaPostTrainingPreferenceOptimizeWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -24,28 +30,28 @@ func TestPostTrainingPreferenceOptimizeWithOptionalParams(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.PostTraining.PreferenceOptimize(context.TODO(), llamastackclient.PostTrainingPreferenceOptimizeParams{ - AlgorithmConfig: llamastackclient.PostTrainingPreferenceOptimizeParamsAlgorithmConfig{ + _, err := client.Alpha.PostTraining.PreferenceOptimize(context.TODO(), llamastackclient.AlphaPostTrainingPreferenceOptimizeParams{ + AlgorithmConfig: llamastackclient.AlphaPostTrainingPreferenceOptimizeParamsAlgorithmConfig{ Beta: 0, LossType: "sigmoid", }, FinetunedModel: "finetuned_model", - HyperparamSearchConfig: map[string]llamastackclient.PostTrainingPreferenceOptimizeParamsHyperparamSearchConfigUnion{ + HyperparamSearchConfig: map[string]llamastackclient.AlphaPostTrainingPreferenceOptimizeParamsHyperparamSearchConfigUnion{ "foo": { OfBool: llamastackclient.Bool(true), }, }, JobUuid: "job_uuid", - LoggerConfig: map[string]llamastackclient.PostTrainingPreferenceOptimizeParamsLoggerConfigUnion{ + LoggerConfig: map[string]llamastackclient.AlphaPostTrainingPreferenceOptimizeParamsLoggerConfigUnion{ "foo": { OfBool: llamastackclient.Bool(true), }, }, - TrainingConfig: llamastackclient.PostTrainingPreferenceOptimizeParamsTrainingConfig{ + TrainingConfig: llamastackclient.AlphaPostTrainingPreferenceOptimizeParamsTrainingConfig{ GradientAccumulationSteps: 0, MaxStepsPerEpoch: 0, NEpochs: 0, - DataConfig: llamastackclient.PostTrainingPreferenceOptimizeParamsTrainingConfigDataConfig{ + DataConfig: llamastackclient.AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigDataConfig{ BatchSize: 0, DataFormat: "instruct", DatasetID: "dataset_id", @@ -55,14 +61,14 @@ func TestPostTrainingPreferenceOptimizeWithOptionalParams(t *testing.T) { ValidationDatasetID: llamastackclient.String("validation_dataset_id"), }, Dtype: llamastackclient.String("dtype"), - EfficiencyConfig: llamastackclient.PostTrainingPreferenceOptimizeParamsTrainingConfigEfficiencyConfig{ + EfficiencyConfig: llamastackclient.AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigEfficiencyConfig{ EnableActivationCheckpointing: llamastackclient.Bool(true), EnableActivationOffloading: llamastackclient.Bool(true), FsdpCPUOffload: llamastackclient.Bool(true), MemoryEfficientFsdpWrap: llamastackclient.Bool(true), }, MaxValidationSteps: llamastackclient.Int(0), - OptimizerConfig: llamastackclient.PostTrainingPreferenceOptimizeParamsTrainingConfigOptimizerConfig{ + OptimizerConfig: llamastackclient.AlphaPostTrainingPreferenceOptimizeParamsTrainingConfigOptimizerConfig{ Lr: 0, NumWarmupSteps: 0, OptimizerType: "adam", @@ -79,7 +85,7 @@ func TestPostTrainingPreferenceOptimizeWithOptionalParams(t *testing.T) { } } -func TestPostTrainingSupervisedFineTuneWithOptionalParams(t *testing.T) { +func TestAlphaPostTrainingSupervisedFineTuneWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -90,23 +96,23 @@ func TestPostTrainingSupervisedFineTuneWithOptionalParams(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.PostTraining.SupervisedFineTune(context.TODO(), llamastackclient.PostTrainingSupervisedFineTuneParams{ - HyperparamSearchConfig: map[string]llamastackclient.PostTrainingSupervisedFineTuneParamsHyperparamSearchConfigUnion{ + _, err := client.Alpha.PostTraining.SupervisedFineTune(context.TODO(), llamastackclient.AlphaPostTrainingSupervisedFineTuneParams{ + HyperparamSearchConfig: map[string]llamastackclient.AlphaPostTrainingSupervisedFineTuneParamsHyperparamSearchConfigUnion{ "foo": { OfBool: llamastackclient.Bool(true), }, }, JobUuid: "job_uuid", - LoggerConfig: map[string]llamastackclient.PostTrainingSupervisedFineTuneParamsLoggerConfigUnion{ + LoggerConfig: map[string]llamastackclient.AlphaPostTrainingSupervisedFineTuneParamsLoggerConfigUnion{ "foo": { OfBool: llamastackclient.Bool(true), }, }, - TrainingConfig: llamastackclient.PostTrainingSupervisedFineTuneParamsTrainingConfig{ + TrainingConfig: llamastackclient.AlphaPostTrainingSupervisedFineTuneParamsTrainingConfig{ GradientAccumulationSteps: 0, MaxStepsPerEpoch: 0, NEpochs: 0, - DataConfig: llamastackclient.PostTrainingSupervisedFineTuneParamsTrainingConfigDataConfig{ + DataConfig: llamastackclient.AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigDataConfig{ BatchSize: 0, DataFormat: "instruct", DatasetID: "dataset_id", @@ -116,14 +122,14 @@ func TestPostTrainingSupervisedFineTuneWithOptionalParams(t *testing.T) { ValidationDatasetID: llamastackclient.String("validation_dataset_id"), }, Dtype: llamastackclient.String("dtype"), - EfficiencyConfig: llamastackclient.PostTrainingSupervisedFineTuneParamsTrainingConfigEfficiencyConfig{ + EfficiencyConfig: llamastackclient.AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigEfficiencyConfig{ EnableActivationCheckpointing: llamastackclient.Bool(true), EnableActivationOffloading: llamastackclient.Bool(true), FsdpCPUOffload: llamastackclient.Bool(true), MemoryEfficientFsdpWrap: llamastackclient.Bool(true), }, MaxValidationSteps: llamastackclient.Int(0), - OptimizerConfig: llamastackclient.PostTrainingSupervisedFineTuneParamsTrainingConfigOptimizerConfig{ + OptimizerConfig: llamastackclient.AlphaPostTrainingSupervisedFineTuneParamsTrainingConfigOptimizerConfig{ Lr: 0, NumWarmupSteps: 0, OptimizerType: "adam", diff --git a/posttrainingjob.go b/alphaposttrainingjob.go similarity index 59% rename from posttrainingjob.go rename to alphaposttrainingjob.go index 45109d8..7c85e31 100644 --- a/posttrainingjob.go +++ b/alphaposttrainingjob.go @@ -1,3 +1,9 @@ +// 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 @@ -7,6 +13,7 @@ import ( "encoding/json" "net/http" "net/url" + "slices" "time" "github.com/llamastack/llama-stack-client-go/internal/apijson" @@ -17,30 +24,30 @@ import ( "github.com/llamastack/llama-stack-client-go/packages/respjson" ) -// PostTrainingJobService contains methods and other services that help with +// AlphaPostTrainingJobService 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 [NewPostTrainingJobService] method instead. -type PostTrainingJobService struct { +// the [NewAlphaPostTrainingJobService] method instead. +type AlphaPostTrainingJobService struct { Options []option.RequestOption } -// NewPostTrainingJobService 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 NewPostTrainingJobService(opts ...option.RequestOption) (r PostTrainingJobService) { - r = PostTrainingJobService{} +// NewAlphaPostTrainingJobService 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 NewAlphaPostTrainingJobService(opts ...option.RequestOption) (r AlphaPostTrainingJobService) { + r = AlphaPostTrainingJobService{} r.Options = opts return } // Get all training jobs. -func (r *PostTrainingJobService) List(ctx context.Context, opts ...option.RequestOption) (res *[]ListPostTrainingJobsResponseData, err error) { +func (r *AlphaPostTrainingJobService) List(ctx context.Context, opts ...option.RequestOption) (res *[]ListPostTrainingJobsResponseData, err error) { var env ListPostTrainingJobsResponse - opts = append(r.Options[:], opts...) - path := "v1/post-training/jobs" + opts = slices.Concat(r.Options, opts) + path := "v1alpha/post-training/jobs" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) if err != nil { return @@ -50,34 +57,34 @@ func (r *PostTrainingJobService) List(ctx context.Context, opts ...option.Reques } // Get the artifacts of a training job. -func (r *PostTrainingJobService) Artifacts(ctx context.Context, query PostTrainingJobArtifactsParams, opts ...option.RequestOption) (res *PostTrainingJobArtifactsResponse, err error) { - opts = append(r.Options[:], opts...) - path := "v1/post-training/job/artifacts" +func (r *AlphaPostTrainingJobService) Artifacts(ctx context.Context, query AlphaPostTrainingJobArtifactsParams, opts ...option.RequestOption) (res *AlphaPostTrainingJobArtifactsResponse, err error) { + opts = slices.Concat(r.Options, opts) + path := "v1alpha/post-training/job/artifacts" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) return } // Cancel a training job. -func (r *PostTrainingJobService) Cancel(ctx context.Context, body PostTrainingJobCancelParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) +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...) - path := "v1/post-training/job/cancel" + path := "v1alpha/post-training/job/cancel" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...) return } // Get the status of a training job. -func (r *PostTrainingJobService) Status(ctx context.Context, query PostTrainingJobStatusParams, opts ...option.RequestOption) (res *PostTrainingJobStatusResponse, err error) { - opts = append(r.Options[:], opts...) - path := "v1/post-training/job/status" +func (r *AlphaPostTrainingJobService) Status(ctx context.Context, query AlphaPostTrainingJobStatusParams, opts ...option.RequestOption) (res *AlphaPostTrainingJobStatusResponse, err error) { + opts = slices.Concat(r.Options, opts) + path := "v1alpha/post-training/job/status" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) return } // Artifacts of a finetuning job. -type PostTrainingJobArtifactsResponse struct { +type AlphaPostTrainingJobArtifactsResponse struct { // List of model checkpoints created during training - Checkpoints []PostTrainingJobArtifactsResponseCheckpoint `json:"checkpoints,required"` + Checkpoints []AlphaPostTrainingJobArtifactsResponseCheckpoint `json:"checkpoints,required"` // Unique identifier for the training job JobUuid string `json:"job_uuid,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. @@ -90,13 +97,13 @@ type PostTrainingJobArtifactsResponse struct { } // Returns the unmodified JSON received from the API -func (r PostTrainingJobArtifactsResponse) RawJSON() string { return r.JSON.raw } -func (r *PostTrainingJobArtifactsResponse) UnmarshalJSON(data []byte) error { +func (r AlphaPostTrainingJobArtifactsResponse) RawJSON() string { return r.JSON.raw } +func (r *AlphaPostTrainingJobArtifactsResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Checkpoint created during training runs. -type PostTrainingJobArtifactsResponseCheckpoint struct { +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 @@ -108,7 +115,7 @@ type PostTrainingJobArtifactsResponseCheckpoint struct { // 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 PostTrainingJobArtifactsResponseCheckpointTrainingMetrics `json:"training_metrics"` + TrainingMetrics AlphaPostTrainingJobArtifactsResponseCheckpointTrainingMetrics `json:"training_metrics"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { CreatedAt respjson.Field @@ -123,13 +130,13 @@ type PostTrainingJobArtifactsResponseCheckpoint struct { } // Returns the unmodified JSON received from the API -func (r PostTrainingJobArtifactsResponseCheckpoint) RawJSON() string { return r.JSON.raw } -func (r *PostTrainingJobArtifactsResponseCheckpoint) UnmarshalJSON(data []byte) error { +func (r AlphaPostTrainingJobArtifactsResponseCheckpoint) RawJSON() string { return r.JSON.raw } +func (r *AlphaPostTrainingJobArtifactsResponseCheckpoint) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // (Optional) Training metrics associated with this checkpoint -type PostTrainingJobArtifactsResponseCheckpointTrainingMetrics struct { +type AlphaPostTrainingJobArtifactsResponseCheckpointTrainingMetrics struct { // Training epoch number Epoch int64 `json:"epoch,required"` // Perplexity metric indicating model confidence @@ -150,27 +157,27 @@ type PostTrainingJobArtifactsResponseCheckpointTrainingMetrics struct { } // Returns the unmodified JSON received from the API -func (r PostTrainingJobArtifactsResponseCheckpointTrainingMetrics) RawJSON() string { +func (r AlphaPostTrainingJobArtifactsResponseCheckpointTrainingMetrics) RawJSON() string { return r.JSON.raw } -func (r *PostTrainingJobArtifactsResponseCheckpointTrainingMetrics) UnmarshalJSON(data []byte) error { +func (r *AlphaPostTrainingJobArtifactsResponseCheckpointTrainingMetrics) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Status of a finetuning job. -type PostTrainingJobStatusResponse struct { +type AlphaPostTrainingJobStatusResponse struct { // List of model checkpoints created during training - Checkpoints []PostTrainingJobStatusResponseCheckpoint `json:"checkpoints,required"` + Checkpoints []AlphaPostTrainingJobStatusResponseCheckpoint `json:"checkpoints,required"` // Unique identifier for the training job JobUuid string `json:"job_uuid,required"` // Current status of the training job // // Any of "completed", "in_progress", "failed", "scheduled", "cancelled". - Status PostTrainingJobStatusResponseStatus `json:"status,required"` + 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]PostTrainingJobStatusResponseResourcesAllocatedUnion `json:"resources_allocated"` + 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 @@ -190,13 +197,13 @@ type PostTrainingJobStatusResponse struct { } // Returns the unmodified JSON received from the API -func (r PostTrainingJobStatusResponse) RawJSON() string { return r.JSON.raw } -func (r *PostTrainingJobStatusResponse) UnmarshalJSON(data []byte) error { +func (r AlphaPostTrainingJobStatusResponse) RawJSON() string { return r.JSON.raw } +func (r *AlphaPostTrainingJobStatusResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Checkpoint created during training runs. -type PostTrainingJobStatusResponseCheckpoint struct { +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 @@ -208,7 +215,7 @@ type PostTrainingJobStatusResponseCheckpoint struct { // 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 PostTrainingJobStatusResponseCheckpointTrainingMetrics `json:"training_metrics"` + TrainingMetrics AlphaPostTrainingJobStatusResponseCheckpointTrainingMetrics `json:"training_metrics"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { CreatedAt respjson.Field @@ -223,13 +230,13 @@ type PostTrainingJobStatusResponseCheckpoint struct { } // Returns the unmodified JSON received from the API -func (r PostTrainingJobStatusResponseCheckpoint) RawJSON() string { return r.JSON.raw } -func (r *PostTrainingJobStatusResponseCheckpoint) UnmarshalJSON(data []byte) error { +func (r AlphaPostTrainingJobStatusResponseCheckpoint) RawJSON() string { return r.JSON.raw } +func (r *AlphaPostTrainingJobStatusResponseCheckpoint) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // (Optional) Training metrics associated with this checkpoint -type PostTrainingJobStatusResponseCheckpointTrainingMetrics struct { +type AlphaPostTrainingJobStatusResponseCheckpointTrainingMetrics struct { // Training epoch number Epoch int64 `json:"epoch,required"` // Perplexity metric indicating model confidence @@ -250,30 +257,32 @@ type PostTrainingJobStatusResponseCheckpointTrainingMetrics struct { } // Returns the unmodified JSON received from the API -func (r PostTrainingJobStatusResponseCheckpointTrainingMetrics) RawJSON() string { return r.JSON.raw } -func (r *PostTrainingJobStatusResponseCheckpointTrainingMetrics) UnmarshalJSON(data []byte) error { +func (r AlphaPostTrainingJobStatusResponseCheckpointTrainingMetrics) RawJSON() string { + return r.JSON.raw +} +func (r *AlphaPostTrainingJobStatusResponseCheckpointTrainingMetrics) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Current status of the training job -type PostTrainingJobStatusResponseStatus string +type AlphaPostTrainingJobStatusResponseStatus string const ( - PostTrainingJobStatusResponseStatusCompleted PostTrainingJobStatusResponseStatus = "completed" - PostTrainingJobStatusResponseStatusInProgress PostTrainingJobStatusResponseStatus = "in_progress" - PostTrainingJobStatusResponseStatusFailed PostTrainingJobStatusResponseStatus = "failed" - PostTrainingJobStatusResponseStatusScheduled PostTrainingJobStatusResponseStatus = "scheduled" - PostTrainingJobStatusResponseStatusCancelled PostTrainingJobStatusResponseStatus = "cancelled" + AlphaPostTrainingJobStatusResponseStatusCompleted AlphaPostTrainingJobStatusResponseStatus = "completed" + AlphaPostTrainingJobStatusResponseStatusInProgress AlphaPostTrainingJobStatusResponseStatus = "in_progress" + AlphaPostTrainingJobStatusResponseStatusFailed AlphaPostTrainingJobStatusResponseStatus = "failed" + AlphaPostTrainingJobStatusResponseStatusScheduled AlphaPostTrainingJobStatusResponseStatus = "scheduled" + AlphaPostTrainingJobStatusResponseStatusCancelled AlphaPostTrainingJobStatusResponseStatus = "cancelled" ) -// PostTrainingJobStatusResponseResourcesAllocatedUnion contains all possible +// 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 PostTrainingJobStatusResponseResourcesAllocatedUnion struct { +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. @@ -291,103 +300,73 @@ type PostTrainingJobStatusResponseResourcesAllocatedUnion struct { } `json:"-"` } -func (u PostTrainingJobStatusResponseResourcesAllocatedUnion) AsBool() (v bool) { +func (u AlphaPostTrainingJobStatusResponseResourcesAllocatedUnion) AsBool() (v bool) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u PostTrainingJobStatusResponseResourcesAllocatedUnion) AsFloat() (v float64) { +func (u AlphaPostTrainingJobStatusResponseResourcesAllocatedUnion) AsFloat() (v float64) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u PostTrainingJobStatusResponseResourcesAllocatedUnion) AsString() (v string) { +func (u AlphaPostTrainingJobStatusResponseResourcesAllocatedUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u PostTrainingJobStatusResponseResourcesAllocatedUnion) AsAnyArray() (v []any) { +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 PostTrainingJobStatusResponseResourcesAllocatedUnion) RawJSON() string { return u.JSON.raw } - -func (r *PostTrainingJobStatusResponseResourcesAllocatedUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type ListPostTrainingJobsResponse struct { - Data []ListPostTrainingJobsResponseData `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) RawJSON() string { + return u.JSON.raw } -// Returns the unmodified JSON received from the API -func (r ListPostTrainingJobsResponse) RawJSON() string { return r.JSON.raw } -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 { +func (r *AlphaPostTrainingJobStatusResponseResourcesAllocatedUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type PostTrainingJobArtifactsParams struct { +type AlphaPostTrainingJobArtifactsParams struct { // The UUID of the job to get the artifacts of. JobUuid string `query:"job_uuid,required" json:"-"` paramObj } -// URLQuery serializes [PostTrainingJobArtifactsParams]'s query parameters as +// URLQuery serializes [AlphaPostTrainingJobArtifactsParams]'s query parameters as // `url.Values`. -func (r PostTrainingJobArtifactsParams) URLQuery() (v url.Values, err error) { +func (r AlphaPostTrainingJobArtifactsParams) URLQuery() (v url.Values, err error) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ ArrayFormat: apiquery.ArrayQueryFormatComma, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } -type PostTrainingJobCancelParams struct { +type AlphaPostTrainingJobCancelParams struct { // The UUID of the job to cancel. JobUuid string `json:"job_uuid,required"` paramObj } -func (r PostTrainingJobCancelParams) MarshalJSON() (data []byte, err error) { - type shadow PostTrainingJobCancelParams +func (r AlphaPostTrainingJobCancelParams) MarshalJSON() (data []byte, err error) { + type shadow AlphaPostTrainingJobCancelParams return param.MarshalObject(r, (*shadow)(&r)) } -func (r *PostTrainingJobCancelParams) UnmarshalJSON(data []byte) error { +func (r *AlphaPostTrainingJobCancelParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type PostTrainingJobStatusParams struct { +type AlphaPostTrainingJobStatusParams struct { // The UUID of the job to get the status of. JobUuid string `query:"job_uuid,required" json:"-"` paramObj } -// URLQuery serializes [PostTrainingJobStatusParams]'s query parameters as +// URLQuery serializes [AlphaPostTrainingJobStatusParams]'s query parameters as // `url.Values`. -func (r PostTrainingJobStatusParams) URLQuery() (v url.Values, err error) { +func (r AlphaPostTrainingJobStatusParams) URLQuery() (v url.Values, err error) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ ArrayFormat: apiquery.ArrayQueryFormatComma, NestedFormat: apiquery.NestedQueryFormatBrackets, diff --git a/posttrainingjob_test.go b/alphaposttrainingjob_test.go similarity index 72% rename from posttrainingjob_test.go rename to alphaposttrainingjob_test.go index 0771c91..df4e36b 100644 --- a/posttrainingjob_test.go +++ b/alphaposttrainingjob_test.go @@ -1,3 +1,9 @@ +// 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 @@ -13,7 +19,7 @@ import ( "github.com/llamastack/llama-stack-client-go/option" ) -func TestPostTrainingJobList(t *testing.T) { +func TestAlphaPostTrainingJobList(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -24,7 +30,7 @@ func TestPostTrainingJobList(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.PostTraining.Job.List(context.TODO()) + _, err := client.Alpha.PostTraining.Job.List(context.TODO()) if err != nil { var apierr *llamastackclient.Error if errors.As(err, &apierr) { @@ -34,7 +40,7 @@ func TestPostTrainingJobList(t *testing.T) { } } -func TestPostTrainingJobArtifacts(t *testing.T) { +func TestAlphaPostTrainingJobArtifacts(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -45,7 +51,7 @@ func TestPostTrainingJobArtifacts(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.PostTraining.Job.Artifacts(context.TODO(), llamastackclient.PostTrainingJobArtifactsParams{ + _, err := client.Alpha.PostTraining.Job.Artifacts(context.TODO(), llamastackclient.AlphaPostTrainingJobArtifactsParams{ JobUuid: "job_uuid", }) if err != nil { @@ -57,7 +63,7 @@ func TestPostTrainingJobArtifacts(t *testing.T) { } } -func TestPostTrainingJobCancel(t *testing.T) { +func TestAlphaPostTrainingJobCancel(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -68,7 +74,7 @@ func TestPostTrainingJobCancel(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - err := client.PostTraining.Job.Cancel(context.TODO(), llamastackclient.PostTrainingJobCancelParams{ + err := client.Alpha.PostTraining.Job.Cancel(context.TODO(), llamastackclient.AlphaPostTrainingJobCancelParams{ JobUuid: "job_uuid", }) if err != nil { @@ -80,7 +86,7 @@ func TestPostTrainingJobCancel(t *testing.T) { } } -func TestPostTrainingJobStatus(t *testing.T) { +func TestAlphaPostTrainingJobStatus(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -91,7 +97,7 @@ func TestPostTrainingJobStatus(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.PostTraining.Job.Status(context.TODO(), llamastackclient.PostTrainingJobStatusParams{ + _, err := client.Alpha.PostTraining.Job.Status(context.TODO(), llamastackclient.AlphaPostTrainingJobStatusParams{ JobUuid: "job_uuid", }) if err != nil { diff --git a/api.md b/api.md index cdc8ff2..dcfb0cb 100644 --- a/api.md +++ b/api.md @@ -1,44 +1,16 @@ # Shared Params Types -- shared.AgentConfigParam -- shared.CompletionMessageParam -- shared.DocumentParam -- shared.InterleavedContentUnionParam -- shared.InterleavedContentItemUnionParam -- shared.MessageUnionParam -- shared.QueryConfigParam -- shared.QueryGeneratorConfigUnionParam -- shared.ResponseFormatUnionParam -- shared.ReturnTypeParam -- shared.SamplingParams -- shared.SharedToolDefParam -- shared.SystemMessageParam -- shared.ToolCallParam -- shared.ToolParamDefinition -- shared.ToolResponseMessageParam -- shared.UserMessageParam +- llamastackclient.InterleavedContentUnionParam +- llamastackclient.InterleavedContentItemUnionParam +- llamastackclient.SamplingParams +- llamastackclient.SystemMessageParam # Shared Response Types -- shared.AgentConfig -- shared.BatchCompletion -- shared.ChatCompletionResponse -- shared.CompletionMessage -- shared.ContentDeltaUnion -- shared.InterleavedContentUnion -- shared.InterleavedContentItemUnion -- shared.QueryResult -- shared.ResponseFormatUnion -- shared.ReturnType -- shared.SafetyViolation -- shared.SamplingParamsResp -- shared.ScoringResult -- shared.SharedCompletionResponse -- shared.SharedToolDef -- shared.ToolCall -- shared.ToolCallOrStringUnion -- shared.ToolResponseMessage -- shared.UserMessage +- llamastackclient.InterleavedContentUnion +- llamastackclient.InterleavedContentItemUnion +- llamastackclient.SafetyViolation +- llamastackclient.ScoringResult # Toolgroups @@ -56,34 +28,25 @@ Methods: # Tools -Response Types: - -- llamastackclient.ListToolsResponse -- llamastackclient.Tool - Methods: -- client.Tools.List(ctx context.Context, query llamastackclient.ToolListParams) ([]llamastackclient.Tool, error) -- client.Tools.Get(ctx context.Context, toolName string) (llamastackclient.Tool, error) +- client.Tools.List(ctx context.Context, query llamastackclient.ToolListParams) ([]llamastackclient.ToolDef, error) +- client.Tools.Get(ctx context.Context, toolName string) (llamastackclient.ToolDef, error) # ToolRuntime Response Types: +- llamastackclient.ToolDef - llamastackclient.ToolInvocationResult Methods: - client.ToolRuntime.InvokeTool(ctx context.Context, body llamastackclient.ToolRuntimeInvokeToolParams) (llamastackclient.ToolInvocationResult, error) -- client.ToolRuntime.ListTools(ctx context.Context, query llamastackclient.ToolRuntimeListToolsParams) ([]shared.SharedToolDef, error) +- client.ToolRuntime.ListTools(ctx context.Context, query llamastackclient.ToolRuntimeListToolsParams) ([]llamastackclient.ToolDef, error) ## RagTool -Methods: - -- client.ToolRuntime.RagTool.Insert(ctx context.Context, body llamastackclient.ToolRuntimeRagToolInsertParams) error -- client.ToolRuntime.RagTool.Query(ctx context.Context, body llamastackclient.ToolRuntimeRagToolQueryParams) (shared.QueryResult, error) - # Responses Response Types: @@ -91,12 +54,14 @@ Response Types: - llamastackclient.ResponseObject - llamastackclient.ResponseObjectStreamUnion - llamastackclient.ResponseListResponse +- llamastackclient.ResponseDeleteResponse Methods: -- client.Responses.New(ctx context.Context, body llamastackclient.ResponseNewParams) (llamastackclient.ResponseObject, error) -- client.Responses.Get(ctx context.Context, responseID string) (llamastackclient.ResponseObject, error) -- client.Responses.List(ctx context.Context, query llamastackclient.ResponseListParams) (pagination.OpenAICursorPage[llamastackclient.ResponseListResponse], error) +- client.Responses.New(ctx context.Context, body llamastackclient.ResponseNewParams) (llamastackclient.ResponseObject, error) +- client.Responses.Get(ctx context.Context, responseID string) (llamastackclient.ResponseObject, error) +- client.Responses.List(ctx context.Context, query llamastackclient.ResponseListParams) (pagination.OpenAICursorPage[llamastackclient.ResponseListResponse], error) +- client.Responses.Delete(ctx context.Context, responseID string) (llamastackclient.ResponseDeleteResponse, error) ## InputItems @@ -106,116 +71,57 @@ Response Types: Methods: -- client.Responses.InputItems.List(ctx context.Context, responseID string, query llamastackclient.ResponseInputItemListParams) (llamastackclient.ResponseInputItemListResponse, error) - -# Agents - -Params Types: - -- llamastackclient.ToolResponseParam - -Response Types: - -- llamastackclient.InferenceStep -- llamastackclient.MemoryRetrievalStep -- llamastackclient.ShieldCallStep -- llamastackclient.ToolExecutionStep -- llamastackclient.ToolResponse -- llamastackclient.AgentNewResponse -- llamastackclient.AgentGetResponse -- llamastackclient.AgentListResponse - -Methods: - -- client.Agents.New(ctx context.Context, body llamastackclient.AgentNewParams) (llamastackclient.AgentNewResponse, error) -- client.Agents.Get(ctx context.Context, agentID string) (llamastackclient.AgentGetResponse, error) -- client.Agents.List(ctx context.Context, query llamastackclient.AgentListParams) (llamastackclient.AgentListResponse, error) -- client.Agents.Delete(ctx context.Context, agentID string) error - -## Session - -Response Types: - -- llamastackclient.Session -- llamastackclient.AgentSessionNewResponse -- llamastackclient.AgentSessionListResponse - -Methods: - -- client.Agents.Session.New(ctx context.Context, agentID string, body llamastackclient.AgentSessionNewParams) (llamastackclient.AgentSessionNewResponse, error) -- client.Agents.Session.Get(ctx context.Context, sessionID string, params llamastackclient.AgentSessionGetParams) (llamastackclient.Session, error) -- client.Agents.Session.List(ctx context.Context, agentID string, query llamastackclient.AgentSessionListParams) (llamastackclient.AgentSessionListResponse, error) -- client.Agents.Session.Delete(ctx context.Context, sessionID string, body llamastackclient.AgentSessionDeleteParams) error +- client.Responses.InputItems.List(ctx context.Context, responseID string, query llamastackclient.ResponseInputItemListParams) (llamastackclient.ResponseInputItemListResponse, error) -## Steps +# Prompts Response Types: -- llamastackclient.AgentStepGetResponse +- llamastackclient.ListPromptsResponse +- llamastackclient.Prompt Methods: -- client.Agents.Steps.Get(ctx context.Context, stepID string, query llamastackclient.AgentStepGetParams) (llamastackclient.AgentStepGetResponse, error) +- client.Prompts.New(ctx context.Context, body llamastackclient.PromptNewParams) (llamastackclient.Prompt, error) +- client.Prompts.Get(ctx context.Context, promptID string, query llamastackclient.PromptGetParams) (llamastackclient.Prompt, error) +- client.Prompts.Update(ctx context.Context, promptID string, body llamastackclient.PromptUpdateParams) (llamastackclient.Prompt, error) +- client.Prompts.List(ctx context.Context) ([]llamastackclient.Prompt, error) +- client.Prompts.Delete(ctx context.Context, promptID string) error +- client.Prompts.SetDefaultVersion(ctx context.Context, promptID string, body llamastackclient.PromptSetDefaultVersionParams) (llamastackclient.Prompt, error) -## Turn - -Response Types: - -- llamastackclient.AgentTurnResponseStreamChunk -- llamastackclient.Turn -- llamastackclient.TurnResponseEvent -- llamastackclient.TurnResponseEventPayloadUnion +## Versions Methods: -- client.Agents.Turn.New(ctx context.Context, sessionID string, params llamastackclient.AgentTurnNewParams) (llamastackclient.Turn, error) -- client.Agents.Turn.Get(ctx context.Context, turnID string, query llamastackclient.AgentTurnGetParams) (llamastackclient.Turn, error) -- client.Agents.Turn.Resume(ctx context.Context, turnID string, params llamastackclient.AgentTurnResumeParams) (llamastackclient.Turn, error) +- client.Prompts.Versions.List(ctx context.Context, promptID string) ([]llamastackclient.Prompt, error) -# Datasets +# Conversations Response Types: -- llamastackclient.ListDatasetsResponse -- llamastackclient.DatasetGetResponse -- llamastackclient.DatasetIterrowsResponse -- llamastackclient.DatasetRegisterResponse +- llamastackclient.ConversationObject +- llamastackclient.ConversationDeleteResponse Methods: -- client.Datasets.Get(ctx context.Context, datasetID string) (llamastackclient.DatasetGetResponse, error) -- client.Datasets.List(ctx context.Context) ([]llamastackclient.ListDatasetsResponseData, error) -- client.Datasets.Appendrows(ctx context.Context, datasetID string, body llamastackclient.DatasetAppendrowsParams) error -- client.Datasets.Iterrows(ctx context.Context, datasetID string, query llamastackclient.DatasetIterrowsParams) (llamastackclient.DatasetIterrowsResponse, error) -- client.Datasets.Register(ctx context.Context, body llamastackclient.DatasetRegisterParams) (llamastackclient.DatasetRegisterResponse, error) -- client.Datasets.Unregister(ctx context.Context, datasetID string) error +- client.Conversations.New(ctx context.Context, body llamastackclient.ConversationNewParams) (llamastackclient.ConversationObject, error) +- client.Conversations.Get(ctx context.Context, conversationID string) (llamastackclient.ConversationObject, error) +- client.Conversations.Update(ctx context.Context, conversationID string, body llamastackclient.ConversationUpdateParams) (llamastackclient.ConversationObject, error) +- client.Conversations.Delete(ctx context.Context, conversationID string) (llamastackclient.ConversationDeleteResponse, error) -# Eval - -Params Types: - -- llamastackclient.BenchmarkConfigParam -- llamastackclient.EvalCandidateUnionParam +## Items Response Types: -- llamastackclient.EvaluateResponse -- llamastackclient.Job - -Methods: - -- client.Eval.EvaluateRows(ctx context.Context, benchmarkID string, body llamastackclient.EvalEvaluateRowsParams) (llamastackclient.EvaluateResponse, error) -- client.Eval.EvaluateRowsAlpha(ctx context.Context, benchmarkID string, body llamastackclient.EvalEvaluateRowsAlphaParams) (llamastackclient.EvaluateResponse, error) -- client.Eval.RunEval(ctx context.Context, benchmarkID string, body llamastackclient.EvalRunEvalParams) (llamastackclient.Job, error) -- client.Eval.RunEvalAlpha(ctx context.Context, benchmarkID string, body llamastackclient.EvalRunEvalAlphaParams) (llamastackclient.Job, error) - -## Jobs +- llamastackclient.ConversationItemNewResponse +- llamastackclient.ConversationItemListResponseUnion +- llamastackclient.ConversationItemGetResponseUnion Methods: -- client.Eval.Jobs.Get(ctx context.Context, jobID string, query llamastackclient.EvalJobGetParams) (llamastackclient.EvaluateResponse, error) -- client.Eval.Jobs.Cancel(ctx context.Context, jobID string, body llamastackclient.EvalJobCancelParams) error -- client.Eval.Jobs.Status(ctx context.Context, jobID string, query llamastackclient.EvalJobStatusParams) (llamastackclient.Job, error) +- 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) # Inspect @@ -231,22 +137,6 @@ Methods: - client.Inspect.Health(ctx context.Context) (llamastackclient.HealthInfo, error) - client.Inspect.Version(ctx context.Context) (llamastackclient.VersionInfo, error) -# Inference - -Response Types: - -- llamastackclient.ChatCompletionResponseStreamChunk -- llamastackclient.EmbeddingsResponse -- llamastackclient.InferenceBatchChatCompletionResponse - -Methods: - -- client.Inference.BatchChatCompletion(ctx context.Context, body llamastackclient.InferenceBatchChatCompletionParams) (llamastackclient.InferenceBatchChatCompletionResponse, error) -- client.Inference.BatchCompletion(ctx context.Context, body llamastackclient.InferenceBatchCompletionParams) (shared.BatchCompletion, error) -- client.Inference.ChatCompletion(ctx context.Context, body llamastackclient.InferenceChatCompletionParams) (shared.ChatCompletionResponse, error) -- client.Inference.Completion(ctx context.Context, body llamastackclient.InferenceCompletionParams) (shared.SharedCompletionResponse, error) -- client.Inference.Embeddings(ctx context.Context, body llamastackclient.InferenceEmbeddingsParams) (llamastackclient.EmbeddingsResponse, error) - # Embeddings Response Types: @@ -255,7 +145,7 @@ Response Types: Methods: -- client.Embeddings.New(ctx context.Context, body llamastackclient.EmbeddingNewParams) (llamastackclient.CreateEmbeddingsResponse, error) +- client.Embeddings.New(ctx context.Context, body llamastackclient.EmbeddingNewParams) (llamastackclient.CreateEmbeddingsResponse, error) # Chat @@ -273,9 +163,9 @@ Response Types: Methods: -- client.Chat.Completions.New(ctx context.Context, body llamastackclient.ChatCompletionNewParams) (llamastackclient.ChatCompletionNewResponseUnion, 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.New(ctx context.Context, body llamastackclient.ChatCompletionNewParams) (llamastackclient.ChatCompletionNewResponseUnion, 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) # Completions @@ -285,7 +175,7 @@ Response Types: Methods: -- client.Completions.New(ctx context.Context, body llamastackclient.CompletionNewParams) (llamastackclient.CompletionNewResponse, error) +- client.Completions.New(ctx context.Context, body llamastackclient.CompletionNewParams) (llamastackclient.CompletionNewResponse, error) # VectorIo @@ -298,21 +188,6 @@ Methods: - client.VectorIo.Insert(ctx context.Context, body llamastackclient.VectorIoInsertParams) error - client.VectorIo.Query(ctx context.Context, body llamastackclient.VectorIoQueryParams) (llamastackclient.QueryChunksResponse, error) -# VectorDBs - -Response Types: - -- llamastackclient.ListVectorDBsResponse -- llamastackclient.VectorDBGetResponse -- llamastackclient.VectorDBRegisterResponse - -Methods: - -- client.VectorDBs.Get(ctx context.Context, vectorDBID string) (llamastackclient.VectorDBGetResponse, error) -- client.VectorDBs.List(ctx context.Context) ([]llamastackclient.ListVectorDBsResponseData, error) -- client.VectorDBs.Register(ctx context.Context, body llamastackclient.VectorDBRegisterParams) (llamastackclient.VectorDBRegisterResponse, error) -- client.VectorDBs.Unregister(ctx context.Context, vectorDBID string) error - # VectorStores Response Types: @@ -324,12 +199,12 @@ Response Types: Methods: -- client.VectorStores.New(ctx context.Context, body llamastackclient.VectorStoreNewParams) (llamastackclient.VectorStore, error) -- client.VectorStores.Get(ctx context.Context, vectorStoreID string) (llamastackclient.VectorStore, error) -- client.VectorStores.Update(ctx context.Context, vectorStoreID string, body llamastackclient.VectorStoreUpdateParams) (llamastackclient.VectorStore, error) -- client.VectorStores.List(ctx context.Context, query llamastackclient.VectorStoreListParams) (pagination.OpenAICursorPage[llamastackclient.VectorStore], error) -- client.VectorStores.Delete(ctx context.Context, vectorStoreID string) (llamastackclient.VectorStoreDeleteResponse, error) -- client.VectorStores.Search(ctx context.Context, vectorStoreID string, body llamastackclient.VectorStoreSearchParams) (llamastackclient.VectorStoreSearchResponse, error) +- client.VectorStores.New(ctx context.Context, body llamastackclient.VectorStoreNewParams) (llamastackclient.VectorStore, error) +- client.VectorStores.Get(ctx context.Context, vectorStoreID string) (llamastackclient.VectorStore, error) +- client.VectorStores.Update(ctx context.Context, vectorStoreID string, body llamastackclient.VectorStoreUpdateParams) (llamastackclient.VectorStore, error) +- client.VectorStores.List(ctx context.Context, query llamastackclient.VectorStoreListParams) (pagination.OpenAICursorPage[llamastackclient.VectorStore], error) +- client.VectorStores.Delete(ctx context.Context, vectorStoreID string) (llamastackclient.VectorStoreDeleteResponse, error) +- client.VectorStores.Search(ctx context.Context, vectorStoreID string, body llamastackclient.VectorStoreSearchParams) (llamastackclient.VectorStoreSearchResponse, error) ## Files @@ -341,56 +216,48 @@ Response Types: Methods: -- client.VectorStores.Files.New(ctx context.Context, vectorStoreID string, body llamastackclient.VectorStoreFileNewParams) (llamastackclient.VectorStoreFile, error) -- client.VectorStores.Files.Get(ctx context.Context, fileID string, query llamastackclient.VectorStoreFileGetParams) (llamastackclient.VectorStoreFile, error) -- client.VectorStores.Files.Update(ctx context.Context, fileID string, params llamastackclient.VectorStoreFileUpdateParams) (llamastackclient.VectorStoreFile, error) -- client.VectorStores.Files.List(ctx context.Context, vectorStoreID string, query llamastackclient.VectorStoreFileListParams) (pagination.OpenAICursorPage[llamastackclient.VectorStoreFile], error) -- client.VectorStores.Files.Delete(ctx context.Context, fileID string, body llamastackclient.VectorStoreFileDeleteParams) (llamastackclient.VectorStoreFileDeleteResponse, error) -- client.VectorStores.Files.Content(ctx context.Context, fileID string, query llamastackclient.VectorStoreFileContentParams) (llamastackclient.VectorStoreFileContentResponse, error) +- client.VectorStores.Files.New(ctx context.Context, vectorStoreID string, body llamastackclient.VectorStoreFileNewParams) (llamastackclient.VectorStoreFile, error) +- client.VectorStores.Files.Get(ctx context.Context, fileID string, query llamastackclient.VectorStoreFileGetParams) (llamastackclient.VectorStoreFile, error) +- client.VectorStores.Files.Update(ctx context.Context, fileID string, params llamastackclient.VectorStoreFileUpdateParams) (llamastackclient.VectorStoreFile, error) +- client.VectorStores.Files.List(ctx context.Context, vectorStoreID string, query llamastackclient.VectorStoreFileListParams) (pagination.OpenAICursorPage[llamastackclient.VectorStoreFile], error) +- client.VectorStores.Files.Delete(ctx context.Context, fileID string, body llamastackclient.VectorStoreFileDeleteParams) (llamastackclient.VectorStoreFileDeleteResponse, error) +- client.VectorStores.Files.Content(ctx context.Context, fileID string, params llamastackclient.VectorStoreFileContentParams) (llamastackclient.VectorStoreFileContentResponse, error) -# Models +## FileBatches Response Types: -- llamastackclient.ListModelsResponse -- llamastackclient.Model +- llamastackclient.ListVectorStoreFilesInBatchResponse +- llamastackclient.VectorStoreFileBatches Methods: -- client.Models.Get(ctx context.Context, modelID string) (llamastackclient.Model, error) -- client.Models.List(ctx context.Context) ([]llamastackclient.Model, error) -- client.Models.Register(ctx context.Context, body llamastackclient.ModelRegisterParams) (llamastackclient.Model, error) -- client.Models.Unregister(ctx context.Context, modelID string) error - -# PostTraining - -Params Types: +- client.VectorStores.FileBatches.New(ctx context.Context, vectorStoreID string, body llamastackclient.VectorStoreFileBatchNewParams) (llamastackclient.VectorStoreFileBatches, error) +- client.VectorStores.FileBatches.Get(ctx context.Context, batchID string, query llamastackclient.VectorStoreFileBatchGetParams) (llamastackclient.VectorStoreFileBatches, error) +- client.VectorStores.FileBatches.Cancel(ctx context.Context, batchID string, body llamastackclient.VectorStoreFileBatchCancelParams) (llamastackclient.VectorStoreFileBatches, error) +- client.VectorStores.FileBatches.ListFiles(ctx context.Context, batchID string, params llamastackclient.VectorStoreFileBatchListFilesParams) (pagination.OpenAICursorPage[llamastackclient.VectorStoreFile], error) -- llamastackclient.AlgorithmConfigUnionParam +# Models Response Types: -- llamastackclient.ListPostTrainingJobsResponse -- llamastackclient.PostTrainingJob +- llamastackclient.ListModelsResponse +- llamastackclient.Model +- llamastackclient.ModelGetResponse +- llamastackclient.ModelRegisterResponse Methods: -- client.PostTraining.PreferenceOptimize(ctx context.Context, body llamastackclient.PostTrainingPreferenceOptimizeParams) (llamastackclient.PostTrainingJob, error) -- client.PostTraining.SupervisedFineTune(ctx context.Context, body llamastackclient.PostTrainingSupervisedFineTuneParams) (llamastackclient.PostTrainingJob, error) - -## Job - -Response Types: +- client.Models.Get(ctx context.Context, modelID string) (llamastackclient.ModelGetResponse, error) +- client.Models.List(ctx context.Context) ([]llamastackclient.Model, error) +- client.Models.Register(ctx context.Context, body llamastackclient.ModelRegisterParams) (llamastackclient.ModelRegisterResponse, error) +- client.Models.Unregister(ctx context.Context, modelID string) error -- llamastackclient.PostTrainingJobArtifactsResponse -- llamastackclient.PostTrainingJobStatusResponse +## OpenAI Methods: -- client.PostTraining.Job.List(ctx context.Context) ([]llamastackclient.ListPostTrainingJobsResponseData, error) -- client.PostTraining.Job.Artifacts(ctx context.Context, query llamastackclient.PostTrainingJobArtifactsParams) (llamastackclient.PostTrainingJobArtifactsResponse, error) -- client.PostTraining.Job.Cancel(ctx context.Context, body llamastackclient.PostTrainingJobCancelParams) error -- client.PostTraining.Job.Status(ctx context.Context, query llamastackclient.PostTrainingJobStatusParams) (llamastackclient.PostTrainingJobStatusResponse, error) +- client.Models.OpenAI.List(ctx context.Context) ([]llamastackclient.Model, error) # Providers @@ -411,7 +278,7 @@ Response Types: Methods: -- client.Routes.List(ctx context.Context) ([]llamastackclient.RouteInfo, error) +- client.Routes.List(ctx context.Context, query llamastackclient.RouteListParams) ([]llamastackclient.RouteInfo, error) # Moderations @@ -421,7 +288,7 @@ Response Types: Methods: -- client.Moderations.New(ctx context.Context, body llamastackclient.ModerationNewParams) (llamastackclient.CreateResponse, error) +- client.Moderations.New(ctx context.Context, body llamastackclient.ModerationNewParams) (llamastackclient.CreateResponse, error) # Safety @@ -444,74 +311,99 @@ Methods: - client.Shields.Get(ctx context.Context, identifier string) (llamastackclient.Shield, error) - client.Shields.List(ctx context.Context) ([]llamastackclient.Shield, error) +- client.Shields.Delete(ctx context.Context, identifier string) error - client.Shields.Register(ctx context.Context, body llamastackclient.ShieldRegisterParams) (llamastackclient.Shield, error) -# SyntheticDataGeneration +# Scoring Response Types: -- llamastackclient.SyntheticDataGenerationResponse +- llamastackclient.ScoringScoreResponse +- llamastackclient.ScoringScoreBatchResponse Methods: -- client.SyntheticDataGeneration.Generate(ctx context.Context, body llamastackclient.SyntheticDataGenerationGenerateParams) (llamastackclient.SyntheticDataGenerationResponse, error) +- client.Scoring.Score(ctx context.Context, body llamastackclient.ScoringScoreParams) (llamastackclient.ScoringScoreResponse, error) +- client.Scoring.ScoreBatch(ctx context.Context, body llamastackclient.ScoringScoreBatchParams) (llamastackclient.ScoringScoreBatchResponse, error) -# Telemetry +# ScoringFunctions Params Types: -- llamastackclient.EventUnionParam -- llamastackclient.QueryConditionParam +- llamastackclient.ScoringFnParamsUnion Response Types: -- llamastackclient.QuerySpansResponse -- llamastackclient.SpanWithStatus -- llamastackclient.Trace -- llamastackclient.TelemetryGetSpanResponse -- llamastackclient.TelemetryGetSpanTreeResponse +- llamastackclient.ListScoringFunctionsResponse +- llamastackclient.ScoringFn +- llamastackclient.ScoringFnParamsUnionResp Methods: -- client.Telemetry.GetSpan(ctx context.Context, spanID string, query llamastackclient.TelemetryGetSpanParams) (llamastackclient.TelemetryGetSpanResponse, error) -- client.Telemetry.GetSpanTree(ctx context.Context, spanID string, body llamastackclient.TelemetryGetSpanTreeParams) (llamastackclient.TelemetryGetSpanTreeResponse, error) -- client.Telemetry.GetTrace(ctx context.Context, traceID string) (llamastackclient.Trace, error) -- client.Telemetry.LogEvent(ctx context.Context, body llamastackclient.TelemetryLogEventParams) error -- client.Telemetry.QuerySpans(ctx context.Context, body llamastackclient.TelemetryQuerySpansParams) ([]llamastackclient.QuerySpansResponseData, error) -- client.Telemetry.QueryTraces(ctx context.Context, body llamastackclient.TelemetryQueryTracesParams) ([]llamastackclient.Trace, error) -- client.Telemetry.SaveSpansToDataset(ctx context.Context, body llamastackclient.TelemetrySaveSpansToDatasetParams) error +- 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 -# Scoring +# Files Response Types: -- llamastackclient.ScoringScoreResponse -- llamastackclient.ScoringScoreBatchResponse +- llamastackclient.DeleteFileResponse +- llamastackclient.File +- llamastackclient.ListFilesResponse +- llamastackclient.FileContentResponse Methods: -- client.Scoring.Score(ctx context.Context, body llamastackclient.ScoringScoreParams) (llamastackclient.ScoringScoreResponse, error) -- client.Scoring.ScoreBatch(ctx context.Context, body llamastackclient.ScoringScoreBatchParams) (llamastackclient.ScoringScoreBatchResponse, error) +- client.Files.New(ctx context.Context, body llamastackclient.FileNewParams) (llamastackclient.File, error) +- client.Files.Get(ctx context.Context, fileID string) (llamastackclient.File, error) +- client.Files.List(ctx context.Context, query llamastackclient.FileListParams) (pagination.OpenAICursorPage[llamastackclient.File], error) +- client.Files.Delete(ctx context.Context, fileID string) (llamastackclient.DeleteFileResponse, error) +- client.Files.Content(ctx context.Context, fileID string) (llamastackclient.FileContentResponse, error) -# ScoringFunctions +# Alpha + +## Inference + +Response Types: + +- llamastackclient.AlphaInferenceRerankResponse + +Methods: + +- client.Alpha.Inference.Rerank(ctx context.Context, body llamastackclient.AlphaInferenceRerankParams) ([]llamastackclient.AlphaInferenceRerankResponse, error) + +## PostTraining Params Types: -- llamastackclient.ScoringFnParamsUnion +- llamastackclient.AlgorithmConfigUnionParam Response Types: -- llamastackclient.ListScoringFunctionsResponse -- llamastackclient.ScoringFn -- llamastackclient.ScoringFnParamsUnionResp +- llamastackclient.ListPostTrainingJobsResponse +- llamastackclient.PostTrainingJob 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.Alpha.PostTraining.PreferenceOptimize(ctx context.Context, body llamastackclient.AlphaPostTrainingPreferenceOptimizeParams) (llamastackclient.PostTrainingJob, error) +- client.Alpha.PostTraining.SupervisedFineTune(ctx context.Context, body llamastackclient.AlphaPostTrainingSupervisedFineTuneParams) (llamastackclient.PostTrainingJob, error) + +### Job + +Response Types: + +- llamastackclient.AlphaPostTrainingJobArtifactsResponse +- llamastackclient.AlphaPostTrainingJobStatusResponse + +Methods: + +- client.Alpha.PostTraining.Job.List(ctx context.Context) ([]llamastackclient.ListPostTrainingJobsResponseData, 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) -# Benchmarks +## Benchmarks Response Types: @@ -520,23 +412,52 @@ Response Types: Methods: -- client.Benchmarks.Get(ctx context.Context, benchmarkID string) (llamastackclient.Benchmark, error) -- client.Benchmarks.List(ctx context.Context) ([]llamastackclient.Benchmark, error) -- client.Benchmarks.Register(ctx context.Context, body llamastackclient.BenchmarkRegisterParams) error +- 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 -# Files +## Eval + +Params Types: + +- llamastackclient.BenchmarkConfigParam Response Types: -- llamastackclient.DeleteFileResponse -- llamastackclient.File -- llamastackclient.ListFilesResponse -- llamastackclient.FileContentResponse +- llamastackclient.EvaluateResponse +- llamastackclient.Job + +Methods: + +- client.Alpha.Eval.EvaluateRows(ctx context.Context, benchmarkID string, body llamastackclient.AlphaEvalEvaluateRowsParams) (llamastackclient.EvaluateResponse, error) +- client.Alpha.Eval.EvaluateRowsAlpha(ctx context.Context, benchmarkID string, body llamastackclient.AlphaEvalEvaluateRowsAlphaParams) (llamastackclient.EvaluateResponse, error) +- client.Alpha.Eval.RunEval(ctx context.Context, benchmarkID string, body llamastackclient.AlphaEvalRunEvalParams) (llamastackclient.Job, error) +- client.Alpha.Eval.RunEvalAlpha(ctx context.Context, benchmarkID string, body llamastackclient.AlphaEvalRunEvalAlphaParams) (llamastackclient.Job, error) + +### Jobs + +Methods: + +- client.Alpha.Eval.Jobs.Get(ctx context.Context, jobID string, query llamastackclient.AlphaEvalJobGetParams) (llamastackclient.EvaluateResponse, error) +- client.Alpha.Eval.Jobs.Cancel(ctx context.Context, jobID string, body llamastackclient.AlphaEvalJobCancelParams) error +- client.Alpha.Eval.Jobs.Status(ctx context.Context, jobID string, query llamastackclient.AlphaEvalJobStatusParams) (llamastackclient.Job, error) + +# Beta + +## Datasets + +Response Types: + +- llamastackclient.ListDatasetsResponse +- llamastackclient.BetaDatasetGetResponse +- llamastackclient.BetaDatasetIterrowsResponse +- llamastackclient.BetaDatasetRegisterResponse Methods: -- client.Files.New(ctx context.Context, body llamastackclient.FileNewParams) (llamastackclient.File, error) -- client.Files.Get(ctx context.Context, fileID string) (llamastackclient.File, error) -- client.Files.List(ctx context.Context, query llamastackclient.FileListParams) (pagination.OpenAICursorPage[llamastackclient.File], error) -- client.Files.Delete(ctx context.Context, fileID string) (llamastackclient.DeleteFileResponse, error) -- client.Files.Content(ctx context.Context, fileID string) (llamastackclient.FileContentResponse, error) +- client.Beta.Datasets.Get(ctx context.Context, datasetID string) (llamastackclient.BetaDatasetGetResponse, error) +- client.Beta.Datasets.List(ctx context.Context) ([]llamastackclient.ListDatasetsResponseData, error) +- client.Beta.Datasets.Appendrows(ctx context.Context, datasetID string, body llamastackclient.BetaDatasetAppendrowsParams) error +- client.Beta.Datasets.Iterrows(ctx context.Context, datasetID string, query llamastackclient.BetaDatasetIterrowsParams) (llamastackclient.BetaDatasetIterrowsResponse, error) +- client.Beta.Datasets.Register(ctx context.Context, body llamastackclient.BetaDatasetRegisterParams) (llamastackclient.BetaDatasetRegisterResponse, error) +- client.Beta.Datasets.Unregister(ctx context.Context, datasetID string) error diff --git a/beta.go b/beta.go new file mode 100644 index 0000000..de86f7d --- /dev/null +++ b/beta.go @@ -0,0 +1,34 @@ +// 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" +) + +// BetaService 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 [NewBetaService] method instead. +type BetaService struct { + Options []option.RequestOption + Datasets BetaDatasetService +} + +// NewBetaService 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 NewBetaService(opts ...option.RequestOption) (r BetaService) { + r = BetaService{} + r.Options = opts + r.Datasets = NewBetaDatasetService(opts...) + return +} diff --git a/dataset.go b/betadataset.go similarity index 68% rename from dataset.go rename to betadataset.go index f31e6b3..8568bf0 100644 --- a/dataset.go +++ b/betadataset.go @@ -1,3 +1,9 @@ +// 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 @@ -9,6 +15,7 @@ import ( "fmt" "net/http" "net/url" + "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" "github.com/llamastack/llama-stack-client-go/internal/apiquery" @@ -19,42 +26,42 @@ import ( "github.com/llamastack/llama-stack-client-go/shared/constant" ) -// DatasetService contains methods and other services that help with interacting -// with the llama-stack-client API. +// BetaDatasetService 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 [NewDatasetService] method instead. -type DatasetService struct { +// the [NewBetaDatasetService] method instead. +type BetaDatasetService struct { Options []option.RequestOption } -// NewDatasetService 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 NewDatasetService(opts ...option.RequestOption) (r DatasetService) { - r = DatasetService{} +// NewBetaDatasetService 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 NewBetaDatasetService(opts ...option.RequestOption) (r BetaDatasetService) { + r = BetaDatasetService{} r.Options = opts return } // Get a dataset by its ID. -func (r *DatasetService) Get(ctx context.Context, datasetID string, opts ...option.RequestOption) (res *DatasetGetResponse, err error) { - opts = append(r.Options[:], opts...) +func (r *BetaDatasetService) Get(ctx context.Context, datasetID string, opts ...option.RequestOption) (res *BetaDatasetGetResponse, err error) { + opts = slices.Concat(r.Options, opts) if datasetID == "" { err = errors.New("missing required dataset_id parameter") return } - path := fmt.Sprintf("v1/datasets/%s", datasetID) + path := fmt.Sprintf("v1beta/datasets/%s", datasetID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return } // List all datasets. -func (r *DatasetService) List(ctx context.Context, opts ...option.RequestOption) (res *[]ListDatasetsResponseData, err error) { +func (r *BetaDatasetService) List(ctx context.Context, opts ...option.RequestOption) (res *[]ListDatasetsResponseData, err error) { var env ListDatasetsResponse - opts = append(r.Options[:], opts...) - path := "v1/datasets" + opts = slices.Concat(r.Options, opts) + path := "v1beta/datasets" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) if err != nil { return @@ -64,14 +71,14 @@ func (r *DatasetService) List(ctx context.Context, opts ...option.RequestOption) } // Append rows to a dataset. -func (r *DatasetService) Appendrows(ctx context.Context, datasetID string, body DatasetAppendrowsParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) +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...) if datasetID == "" { err = errors.New("missing required dataset_id parameter") return } - path := fmt.Sprintf("v1/datasetio/append-rows/%s", datasetID) + path := fmt.Sprintf("v1beta/datasetio/append-rows/%s", datasetID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...) return } @@ -85,34 +92,38 @@ func (r *DatasetService) Appendrows(ctx context.Context, datasetID string, body // // - data: List of items for the current page. // - has_more: Whether there are more items available after this set. -func (r *DatasetService) Iterrows(ctx context.Context, datasetID string, query DatasetIterrowsParams, opts ...option.RequestOption) (res *DatasetIterrowsResponse, err error) { - opts = append(r.Options[:], opts...) +func (r *BetaDatasetService) Iterrows(ctx context.Context, datasetID string, query BetaDatasetIterrowsParams, opts ...option.RequestOption) (res *BetaDatasetIterrowsResponse, err error) { + opts = slices.Concat(r.Options, opts) if datasetID == "" { err = errors.New("missing required dataset_id parameter") return } - path := fmt.Sprintf("v1/datasetio/iterrows/%s", datasetID) + path := fmt.Sprintf("v1beta/datasetio/iterrows/%s", datasetID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) return } // Register a new dataset. -func (r *DatasetService) Register(ctx context.Context, body DatasetRegisterParams, opts ...option.RequestOption) (res *DatasetRegisterResponse, err error) { - opts = append(r.Options[:], opts...) - path := "v1/datasets" +// +// Deprecated: deprecated +func (r *BetaDatasetService) Register(ctx context.Context, body BetaDatasetRegisterParams, opts ...option.RequestOption) (res *BetaDatasetRegisterResponse, err error) { + opts = slices.Concat(r.Options, opts) + path := "v1beta/datasets" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return } // Unregister a dataset by its ID. -func (r *DatasetService) Unregister(ctx context.Context, datasetID string, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) +// +// 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...) if datasetID == "" { err = errors.New("missing required dataset_id parameter") return } - path := fmt.Sprintf("v1/datasets/%s", datasetID) + path := fmt.Sprintf("v1beta/datasets/%s", datasetID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...) return } @@ -386,17 +397,17 @@ func (r *ListDatasetsResponseDataSourceRowsRowUnion) UnmarshalJSON(data []byte) } // Dataset resource for storing and accessing training or evaluation data. -type DatasetGetResponse struct { +type BetaDatasetGetResponse struct { Identifier string `json:"identifier,required"` // Additional metadata for the dataset - Metadata map[string]DatasetGetResponseMetadataUnion `json:"metadata,required"` - ProviderID string `json:"provider_id,required"` + Metadata map[string]BetaDatasetGetResponseMetadataUnion `json:"metadata,required"` + ProviderID string `json:"provider_id,required"` // Purpose of the dataset indicating its intended use // // Any of "post-training/messages", "eval/question-answer", "eval/messages-answer". - Purpose DatasetGetResponsePurpose `json:"purpose,required"` + Purpose BetaDatasetGetResponsePurpose `json:"purpose,required"` // Data source configuration for the dataset - Source DatasetGetResponseSourceUnion `json:"source,required"` + Source BetaDatasetGetResponseSourceUnion `json:"source,required"` // Type of resource, always 'dataset' for datasets Type constant.Dataset `json:"type,required"` ProviderResourceID string `json:"provider_resource_id"` @@ -415,19 +426,19 @@ type DatasetGetResponse struct { } // Returns the unmodified JSON received from the API -func (r DatasetGetResponse) RawJSON() string { return r.JSON.raw } -func (r *DatasetGetResponse) UnmarshalJSON(data []byte) error { +func (r BetaDatasetGetResponse) RawJSON() string { return r.JSON.raw } +func (r *BetaDatasetGetResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// DatasetGetResponseMetadataUnion contains all possible properties and values from -// [bool], [float64], [string], [[]any]. +// 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 DatasetGetResponseMetadataUnion struct { +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. @@ -445,55 +456,56 @@ type DatasetGetResponseMetadataUnion struct { } `json:"-"` } -func (u DatasetGetResponseMetadataUnion) AsBool() (v bool) { +func (u BetaDatasetGetResponseMetadataUnion) AsBool() (v bool) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u DatasetGetResponseMetadataUnion) AsFloat() (v float64) { +func (u BetaDatasetGetResponseMetadataUnion) AsFloat() (v float64) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u DatasetGetResponseMetadataUnion) AsString() (v string) { +func (u BetaDatasetGetResponseMetadataUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u DatasetGetResponseMetadataUnion) AsAnyArray() (v []any) { +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 DatasetGetResponseMetadataUnion) RawJSON() string { return u.JSON.raw } +func (u BetaDatasetGetResponseMetadataUnion) RawJSON() string { return u.JSON.raw } -func (r *DatasetGetResponseMetadataUnion) UnmarshalJSON(data []byte) error { +func (r *BetaDatasetGetResponseMetadataUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Purpose of the dataset indicating its intended use -type DatasetGetResponsePurpose string +type BetaDatasetGetResponsePurpose string const ( - DatasetGetResponsePurposePostTrainingMessages DatasetGetResponsePurpose = "post-training/messages" - DatasetGetResponsePurposeEvalQuestionAnswer DatasetGetResponsePurpose = "eval/question-answer" - DatasetGetResponsePurposeEvalMessagesAnswer DatasetGetResponsePurpose = "eval/messages-answer" + BetaDatasetGetResponsePurposePostTrainingMessages BetaDatasetGetResponsePurpose = "post-training/messages" + BetaDatasetGetResponsePurposeEvalQuestionAnswer BetaDatasetGetResponsePurpose = "eval/question-answer" + BetaDatasetGetResponsePurposeEvalMessagesAnswer BetaDatasetGetResponsePurpose = "eval/messages-answer" ) -// DatasetGetResponseSourceUnion contains all possible properties and values from -// [DatasetGetResponseSourceUri], [DatasetGetResponseSourceRows]. +// BetaDatasetGetResponseSourceUnion contains all possible properties and values +// from [BetaDatasetGetResponseSourceUri], [BetaDatasetGetResponseSourceRows]. // -// Use the [DatasetGetResponseSourceUnion.AsAny] method to switch on the variant. +// Use the [BetaDatasetGetResponseSourceUnion.AsAny] method to switch on the +// variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type DatasetGetResponseSourceUnion struct { +type BetaDatasetGetResponseSourceUnion struct { // Any of "uri", "rows". Type string `json:"type"` - // This field is from variant [DatasetGetResponseSourceUri]. + // This field is from variant [BetaDatasetGetResponseSourceUri]. Uri string `json:"uri"` - // This field is from variant [DatasetGetResponseSourceRows]. - Rows []map[string]DatasetGetResponseSourceRowsRowUnion `json:"rows"` + // This field is from variant [BetaDatasetGetResponseSourceRows]. + Rows []map[string]BetaDatasetGetResponseSourceRowsRowUnion `json:"rows"` JSON struct { Type respjson.Field Uri respjson.Field @@ -502,25 +514,25 @@ type DatasetGetResponseSourceUnion struct { } `json:"-"` } -// anyDatasetGetResponseSource is implemented by each variant of -// [DatasetGetResponseSourceUnion] to add type safety for the return type of -// [DatasetGetResponseSourceUnion.AsAny] -type anyDatasetGetResponseSource interface { - implDatasetGetResponseSourceUnion() +// anyBetaDatasetGetResponseSource is implemented by each variant of +// [BetaDatasetGetResponseSourceUnion] to add type safety for the return type of +// [BetaDatasetGetResponseSourceUnion.AsAny] +type anyBetaDatasetGetResponseSource interface { + implBetaDatasetGetResponseSourceUnion() } -func (DatasetGetResponseSourceUri) implDatasetGetResponseSourceUnion() {} -func (DatasetGetResponseSourceRows) implDatasetGetResponseSourceUnion() {} +func (BetaDatasetGetResponseSourceUri) implBetaDatasetGetResponseSourceUnion() {} +func (BetaDatasetGetResponseSourceRows) implBetaDatasetGetResponseSourceUnion() {} // Use the following switch statement to find the correct variant // -// switch variant := DatasetGetResponseSourceUnion.AsAny().(type) { -// case llamastackclient.DatasetGetResponseSourceUri: -// case llamastackclient.DatasetGetResponseSourceRows: +// switch variant := BetaDatasetGetResponseSourceUnion.AsAny().(type) { +// case llamastackclient.BetaDatasetGetResponseSourceUri: +// case llamastackclient.BetaDatasetGetResponseSourceRows: // default: // fmt.Errorf("no variant present") // } -func (u DatasetGetResponseSourceUnion) AsAny() anyDatasetGetResponseSource { +func (u BetaDatasetGetResponseSourceUnion) AsAny() anyBetaDatasetGetResponseSource { switch u.Type { case "uri": return u.AsUri() @@ -530,25 +542,25 @@ func (u DatasetGetResponseSourceUnion) AsAny() anyDatasetGetResponseSource { return nil } -func (u DatasetGetResponseSourceUnion) AsUri() (v DatasetGetResponseSourceUri) { +func (u BetaDatasetGetResponseSourceUnion) AsUri() (v BetaDatasetGetResponseSourceUri) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u DatasetGetResponseSourceUnion) AsRows() (v DatasetGetResponseSourceRows) { +func (u BetaDatasetGetResponseSourceUnion) AsRows() (v BetaDatasetGetResponseSourceRows) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u DatasetGetResponseSourceUnion) RawJSON() string { return u.JSON.raw } +func (u BetaDatasetGetResponseSourceUnion) RawJSON() string { return u.JSON.raw } -func (r *DatasetGetResponseSourceUnion) UnmarshalJSON(data []byte) error { +func (r *BetaDatasetGetResponseSourceUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A dataset that can be obtained from a URI. -type DatasetGetResponseSourceUri struct { +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" - @@ -564,18 +576,18 @@ type DatasetGetResponseSourceUri struct { } // Returns the unmodified JSON received from the API -func (r DatasetGetResponseSourceUri) RawJSON() string { return r.JSON.raw } -func (r *DatasetGetResponseSourceUri) UnmarshalJSON(data []byte) error { +func (r BetaDatasetGetResponseSourceUri) RawJSON() string { return r.JSON.raw } +func (r *BetaDatasetGetResponseSourceUri) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A dataset stored in rows. -type DatasetGetResponseSourceRows struct { +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]DatasetGetResponseSourceRowsRowUnion `json:"rows,required"` - Type constant.Rows `json:"type,required"` + Rows []map[string]BetaDatasetGetResponseSourceRowsRowUnion `json:"rows,required"` + Type constant.Rows `json:"type,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Rows respjson.Field @@ -586,19 +598,19 @@ type DatasetGetResponseSourceRows struct { } // Returns the unmodified JSON received from the API -func (r DatasetGetResponseSourceRows) RawJSON() string { return r.JSON.raw } -func (r *DatasetGetResponseSourceRows) UnmarshalJSON(data []byte) error { +func (r BetaDatasetGetResponseSourceRows) RawJSON() string { return r.JSON.raw } +func (r *BetaDatasetGetResponseSourceRows) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// DatasetGetResponseSourceRowsRowUnion contains all possible properties and values -// from [bool], [float64], [string], [[]any]. +// 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 DatasetGetResponseSourceRowsRowUnion struct { +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. @@ -616,37 +628,37 @@ type DatasetGetResponseSourceRowsRowUnion struct { } `json:"-"` } -func (u DatasetGetResponseSourceRowsRowUnion) AsBool() (v bool) { +func (u BetaDatasetGetResponseSourceRowsRowUnion) AsBool() (v bool) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u DatasetGetResponseSourceRowsRowUnion) AsFloat() (v float64) { +func (u BetaDatasetGetResponseSourceRowsRowUnion) AsFloat() (v float64) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u DatasetGetResponseSourceRowsRowUnion) AsString() (v string) { +func (u BetaDatasetGetResponseSourceRowsRowUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u DatasetGetResponseSourceRowsRowUnion) AsAnyArray() (v []any) { +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 DatasetGetResponseSourceRowsRowUnion) RawJSON() string { return u.JSON.raw } +func (u BetaDatasetGetResponseSourceRowsRowUnion) RawJSON() string { return u.JSON.raw } -func (r *DatasetGetResponseSourceRowsRowUnion) UnmarshalJSON(data []byte) error { +func (r *BetaDatasetGetResponseSourceRowsRowUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A generic paginated response that follows a simple format. -type DatasetIterrowsResponse struct { +type BetaDatasetIterrowsResponse struct { // The list of items for the current page - Data []map[string]DatasetIterrowsResponseDataUnion `json:"data,required"` + 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 @@ -662,19 +674,19 @@ type DatasetIterrowsResponse struct { } // Returns the unmodified JSON received from the API -func (r DatasetIterrowsResponse) RawJSON() string { return r.JSON.raw } -func (r *DatasetIterrowsResponse) UnmarshalJSON(data []byte) error { +func (r BetaDatasetIterrowsResponse) RawJSON() string { return r.JSON.raw } +func (r *BetaDatasetIterrowsResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// DatasetIterrowsResponseDataUnion contains all possible properties and values +// 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 DatasetIterrowsResponseDataUnion struct { +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. @@ -692,45 +704,45 @@ type DatasetIterrowsResponseDataUnion struct { } `json:"-"` } -func (u DatasetIterrowsResponseDataUnion) AsBool() (v bool) { +func (u BetaDatasetIterrowsResponseDataUnion) AsBool() (v bool) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u DatasetIterrowsResponseDataUnion) AsFloat() (v float64) { +func (u BetaDatasetIterrowsResponseDataUnion) AsFloat() (v float64) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u DatasetIterrowsResponseDataUnion) AsString() (v string) { +func (u BetaDatasetIterrowsResponseDataUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u DatasetIterrowsResponseDataUnion) AsAnyArray() (v []any) { +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 DatasetIterrowsResponseDataUnion) RawJSON() string { return u.JSON.raw } +func (u BetaDatasetIterrowsResponseDataUnion) RawJSON() string { return u.JSON.raw } -func (r *DatasetIterrowsResponseDataUnion) UnmarshalJSON(data []byte) error { +func (r *BetaDatasetIterrowsResponseDataUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Dataset resource for storing and accessing training or evaluation data. -type DatasetRegisterResponse struct { +type BetaDatasetRegisterResponse struct { Identifier string `json:"identifier,required"` // Additional metadata for the dataset - Metadata map[string]DatasetRegisterResponseMetadataUnion `json:"metadata,required"` - ProviderID string `json:"provider_id,required"` + Metadata map[string]BetaDatasetRegisterResponseMetadataUnion `json:"metadata,required"` + ProviderID string `json:"provider_id,required"` // Purpose of the dataset indicating its intended use // // Any of "post-training/messages", "eval/question-answer", "eval/messages-answer". - Purpose DatasetRegisterResponsePurpose `json:"purpose,required"` + Purpose BetaDatasetRegisterResponsePurpose `json:"purpose,required"` // Data source configuration for the dataset - Source DatasetRegisterResponseSourceUnion `json:"source,required"` + Source BetaDatasetRegisterResponseSourceUnion `json:"source,required"` // Type of resource, always 'dataset' for datasets Type constant.Dataset `json:"type,required"` ProviderResourceID string `json:"provider_resource_id"` @@ -749,19 +761,19 @@ type DatasetRegisterResponse struct { } // Returns the unmodified JSON received from the API -func (r DatasetRegisterResponse) RawJSON() string { return r.JSON.raw } -func (r *DatasetRegisterResponse) UnmarshalJSON(data []byte) error { +func (r BetaDatasetRegisterResponse) RawJSON() string { return r.JSON.raw } +func (r *BetaDatasetRegisterResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// DatasetRegisterResponseMetadataUnion contains all possible properties and values -// from [bool], [float64], [string], [[]any]. +// 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 DatasetRegisterResponseMetadataUnion struct { +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. @@ -779,56 +791,57 @@ type DatasetRegisterResponseMetadataUnion struct { } `json:"-"` } -func (u DatasetRegisterResponseMetadataUnion) AsBool() (v bool) { +func (u BetaDatasetRegisterResponseMetadataUnion) AsBool() (v bool) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u DatasetRegisterResponseMetadataUnion) AsFloat() (v float64) { +func (u BetaDatasetRegisterResponseMetadataUnion) AsFloat() (v float64) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u DatasetRegisterResponseMetadataUnion) AsString() (v string) { +func (u BetaDatasetRegisterResponseMetadataUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u DatasetRegisterResponseMetadataUnion) AsAnyArray() (v []any) { +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 DatasetRegisterResponseMetadataUnion) RawJSON() string { return u.JSON.raw } +func (u BetaDatasetRegisterResponseMetadataUnion) RawJSON() string { return u.JSON.raw } -func (r *DatasetRegisterResponseMetadataUnion) UnmarshalJSON(data []byte) error { +func (r *BetaDatasetRegisterResponseMetadataUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Purpose of the dataset indicating its intended use -type DatasetRegisterResponsePurpose string +type BetaDatasetRegisterResponsePurpose string const ( - DatasetRegisterResponsePurposePostTrainingMessages DatasetRegisterResponsePurpose = "post-training/messages" - DatasetRegisterResponsePurposeEvalQuestionAnswer DatasetRegisterResponsePurpose = "eval/question-answer" - DatasetRegisterResponsePurposeEvalMessagesAnswer DatasetRegisterResponsePurpose = "eval/messages-answer" + BetaDatasetRegisterResponsePurposePostTrainingMessages BetaDatasetRegisterResponsePurpose = "post-training/messages" + BetaDatasetRegisterResponsePurposeEvalQuestionAnswer BetaDatasetRegisterResponsePurpose = "eval/question-answer" + BetaDatasetRegisterResponsePurposeEvalMessagesAnswer BetaDatasetRegisterResponsePurpose = "eval/messages-answer" ) -// DatasetRegisterResponseSourceUnion contains all possible properties and values -// from [DatasetRegisterResponseSourceUri], [DatasetRegisterResponseSourceRows]. +// BetaDatasetRegisterResponseSourceUnion contains all possible properties and +// values from [BetaDatasetRegisterResponseSourceUri], +// [BetaDatasetRegisterResponseSourceRows]. // -// Use the [DatasetRegisterResponseSourceUnion.AsAny] method to switch on the +// Use the [BetaDatasetRegisterResponseSourceUnion.AsAny] method to switch on the // variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type DatasetRegisterResponseSourceUnion struct { +type BetaDatasetRegisterResponseSourceUnion struct { // Any of "uri", "rows". Type string `json:"type"` - // This field is from variant [DatasetRegisterResponseSourceUri]. + // This field is from variant [BetaDatasetRegisterResponseSourceUri]. Uri string `json:"uri"` - // This field is from variant [DatasetRegisterResponseSourceRows]. - Rows []map[string]DatasetRegisterResponseSourceRowsRowUnion `json:"rows"` + // This field is from variant [BetaDatasetRegisterResponseSourceRows]. + Rows []map[string]BetaDatasetRegisterResponseSourceRowsRowUnion `json:"rows"` JSON struct { Type respjson.Field Uri respjson.Field @@ -837,25 +850,25 @@ type DatasetRegisterResponseSourceUnion struct { } `json:"-"` } -// anyDatasetRegisterResponseSource is implemented by each variant of -// [DatasetRegisterResponseSourceUnion] to add type safety for the return type of -// [DatasetRegisterResponseSourceUnion.AsAny] -type anyDatasetRegisterResponseSource interface { - implDatasetRegisterResponseSourceUnion() +// anyBetaDatasetRegisterResponseSource is implemented by each variant of +// [BetaDatasetRegisterResponseSourceUnion] to add type safety for the return type +// of [BetaDatasetRegisterResponseSourceUnion.AsAny] +type anyBetaDatasetRegisterResponseSource interface { + implBetaDatasetRegisterResponseSourceUnion() } -func (DatasetRegisterResponseSourceUri) implDatasetRegisterResponseSourceUnion() {} -func (DatasetRegisterResponseSourceRows) implDatasetRegisterResponseSourceUnion() {} +func (BetaDatasetRegisterResponseSourceUri) implBetaDatasetRegisterResponseSourceUnion() {} +func (BetaDatasetRegisterResponseSourceRows) implBetaDatasetRegisterResponseSourceUnion() {} // Use the following switch statement to find the correct variant // -// switch variant := DatasetRegisterResponseSourceUnion.AsAny().(type) { -// case llamastackclient.DatasetRegisterResponseSourceUri: -// case llamastackclient.DatasetRegisterResponseSourceRows: +// switch variant := BetaDatasetRegisterResponseSourceUnion.AsAny().(type) { +// case llamastackclient.BetaDatasetRegisterResponseSourceUri: +// case llamastackclient.BetaDatasetRegisterResponseSourceRows: // default: // fmt.Errorf("no variant present") // } -func (u DatasetRegisterResponseSourceUnion) AsAny() anyDatasetRegisterResponseSource { +func (u BetaDatasetRegisterResponseSourceUnion) AsAny() anyBetaDatasetRegisterResponseSource { switch u.Type { case "uri": return u.AsUri() @@ -865,25 +878,25 @@ func (u DatasetRegisterResponseSourceUnion) AsAny() anyDatasetRegisterResponseSo return nil } -func (u DatasetRegisterResponseSourceUnion) AsUri() (v DatasetRegisterResponseSourceUri) { +func (u BetaDatasetRegisterResponseSourceUnion) AsUri() (v BetaDatasetRegisterResponseSourceUri) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u DatasetRegisterResponseSourceUnion) AsRows() (v DatasetRegisterResponseSourceRows) { +func (u BetaDatasetRegisterResponseSourceUnion) AsRows() (v BetaDatasetRegisterResponseSourceRows) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u DatasetRegisterResponseSourceUnion) RawJSON() string { return u.JSON.raw } +func (u BetaDatasetRegisterResponseSourceUnion) RawJSON() string { return u.JSON.raw } -func (r *DatasetRegisterResponseSourceUnion) UnmarshalJSON(data []byte) error { +func (r *BetaDatasetRegisterResponseSourceUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A dataset that can be obtained from a URI. -type DatasetRegisterResponseSourceUri struct { +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" - @@ -899,18 +912,18 @@ type DatasetRegisterResponseSourceUri struct { } // Returns the unmodified JSON received from the API -func (r DatasetRegisterResponseSourceUri) RawJSON() string { return r.JSON.raw } -func (r *DatasetRegisterResponseSourceUri) UnmarshalJSON(data []byte) error { +func (r BetaDatasetRegisterResponseSourceUri) RawJSON() string { return r.JSON.raw } +func (r *BetaDatasetRegisterResponseSourceUri) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A dataset stored in rows. -type DatasetRegisterResponseSourceRows struct { +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]DatasetRegisterResponseSourceRowsRowUnion `json:"rows,required"` - Type constant.Rows `json:"type,required"` + Rows []map[string]BetaDatasetRegisterResponseSourceRowsRowUnion `json:"rows,required"` + Type constant.Rows `json:"type,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Rows respjson.Field @@ -921,19 +934,19 @@ type DatasetRegisterResponseSourceRows struct { } // Returns the unmodified JSON received from the API -func (r DatasetRegisterResponseSourceRows) RawJSON() string { return r.JSON.raw } -func (r *DatasetRegisterResponseSourceRows) UnmarshalJSON(data []byte) error { +func (r BetaDatasetRegisterResponseSourceRows) RawJSON() string { return r.JSON.raw } +func (r *BetaDatasetRegisterResponseSourceRows) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// DatasetRegisterResponseSourceRowsRowUnion contains all possible properties and -// values from [bool], [float64], [string], [[]any]. +// 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 DatasetRegisterResponseSourceRowsRowUnion struct { +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. @@ -951,51 +964,51 @@ type DatasetRegisterResponseSourceRowsRowUnion struct { } `json:"-"` } -func (u DatasetRegisterResponseSourceRowsRowUnion) AsBool() (v bool) { +func (u BetaDatasetRegisterResponseSourceRowsRowUnion) AsBool() (v bool) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u DatasetRegisterResponseSourceRowsRowUnion) AsFloat() (v float64) { +func (u BetaDatasetRegisterResponseSourceRowsRowUnion) AsFloat() (v float64) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u DatasetRegisterResponseSourceRowsRowUnion) AsString() (v string) { +func (u BetaDatasetRegisterResponseSourceRowsRowUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u DatasetRegisterResponseSourceRowsRowUnion) AsAnyArray() (v []any) { +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 DatasetRegisterResponseSourceRowsRowUnion) RawJSON() string { return u.JSON.raw } +func (u BetaDatasetRegisterResponseSourceRowsRowUnion) RawJSON() string { return u.JSON.raw } -func (r *DatasetRegisterResponseSourceRowsRowUnion) UnmarshalJSON(data []byte) error { +func (r *BetaDatasetRegisterResponseSourceRowsRowUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type DatasetAppendrowsParams struct { +type BetaDatasetAppendrowsParams struct { // The rows to append to the dataset. - Rows []map[string]DatasetAppendrowsParamsRowUnion `json:"rows,omitzero,required"` + Rows []map[string]BetaDatasetAppendrowsParamsRowUnion `json:"rows,omitzero,required"` paramObj } -func (r DatasetAppendrowsParams) MarshalJSON() (data []byte, err error) { - type shadow DatasetAppendrowsParams +func (r BetaDatasetAppendrowsParams) MarshalJSON() (data []byte, err error) { + type shadow BetaDatasetAppendrowsParams return param.MarshalObject(r, (*shadow)(&r)) } -func (r *DatasetAppendrowsParams) UnmarshalJSON(data []byte) error { +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 DatasetAppendrowsParamsRowUnion struct { +type BetaDatasetAppendrowsParamsRowUnion struct { OfBool param.Opt[bool] `json:",omitzero,inline"` OfFloat param.Opt[float64] `json:",omitzero,inline"` OfString param.Opt[string] `json:",omitzero,inline"` @@ -1003,14 +1016,14 @@ type DatasetAppendrowsParamsRowUnion struct { paramUnion } -func (u DatasetAppendrowsParamsRowUnion) MarshalJSON() ([]byte, error) { +func (u BetaDatasetAppendrowsParamsRowUnion) MarshalJSON() ([]byte, error) { return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) } -func (u *DatasetAppendrowsParamsRowUnion) UnmarshalJSON(data []byte) error { +func (u *BetaDatasetAppendrowsParamsRowUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *DatasetAppendrowsParamsRowUnion) asAny() any { +func (u *BetaDatasetAppendrowsParamsRowUnion) asAny() any { if !param.IsOmitted(u.OfBool) { return &u.OfBool.Value } else if !param.IsOmitted(u.OfFloat) { @@ -1023,7 +1036,7 @@ func (u *DatasetAppendrowsParamsRowUnion) asAny() any { return nil } -type DatasetIterrowsParams struct { +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. @@ -1031,15 +1044,16 @@ type DatasetIterrowsParams struct { paramObj } -// URLQuery serializes [DatasetIterrowsParams]'s query parameters as `url.Values`. -func (r DatasetIterrowsParams) URLQuery() (v url.Values, err error) { +// URLQuery serializes [BetaDatasetIterrowsParams]'s query parameters as +// `url.Values`. +func (r BetaDatasetIterrowsParams) URLQuery() (v url.Values, err error) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ ArrayFormat: apiquery.ArrayQueryFormatComma, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } -type DatasetRegisterParams struct { +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": @@ -1053,7 +1067,7 @@ type DatasetRegisterParams struct { // "What's my name?"}, ], "answer": "John Doe" } // // Any of "post-training/messages", "eval/question-answer", "eval/messages-answer". - Purpose DatasetRegisterParamsPurpose `json:"purpose,omitzero,required"` + 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": @@ -1062,19 +1076,19 @@ type DatasetRegisterParams struct { // "huggingface://llamastack/simpleqa?split=train" } - { "type": "rows", "rows": [ // { "messages": [ {"role": "user", "content": "Hello, world!"}, {"role": // "assistant", "content": "Hello, world!"}, ] } ] } - Source DatasetRegisterParamsSourceUnion `json:"source,omitzero,required"` + 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]DatasetRegisterParamsMetadataUnion `json:"metadata,omitzero"` + Metadata map[string]BetaDatasetRegisterParamsMetadataUnion `json:"metadata,omitzero"` paramObj } -func (r DatasetRegisterParams) MarshalJSON() (data []byte, err error) { - type shadow DatasetRegisterParams +func (r BetaDatasetRegisterParams) MarshalJSON() (data []byte, err error) { + type shadow BetaDatasetRegisterParams return param.MarshalObject(r, (*shadow)(&r)) } -func (r *DatasetRegisterParams) UnmarshalJSON(data []byte) error { +func (r *BetaDatasetRegisterParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } @@ -1089,31 +1103,31 @@ func (r *DatasetRegisterParams) UnmarshalJSON(data []byte) error { // "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 DatasetRegisterParamsPurpose string +type BetaDatasetRegisterParamsPurpose string const ( - DatasetRegisterParamsPurposePostTrainingMessages DatasetRegisterParamsPurpose = "post-training/messages" - DatasetRegisterParamsPurposeEvalQuestionAnswer DatasetRegisterParamsPurpose = "eval/question-answer" - DatasetRegisterParamsPurposeEvalMessagesAnswer DatasetRegisterParamsPurpose = "eval/messages-answer" + 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 DatasetRegisterParamsSourceUnion struct { - OfUri *DatasetRegisterParamsSourceUri `json:",omitzero,inline"` - OfRows *DatasetRegisterParamsSourceRows `json:",omitzero,inline"` +type BetaDatasetRegisterParamsSourceUnion struct { + OfUri *BetaDatasetRegisterParamsSourceUri `json:",omitzero,inline"` + OfRows *BetaDatasetRegisterParamsSourceRows `json:",omitzero,inline"` paramUnion } -func (u DatasetRegisterParamsSourceUnion) MarshalJSON() ([]byte, error) { +func (u BetaDatasetRegisterParamsSourceUnion) MarshalJSON() ([]byte, error) { return param.MarshalUnion(u, u.OfUri, u.OfRows) } -func (u *DatasetRegisterParamsSourceUnion) UnmarshalJSON(data []byte) error { +func (u *BetaDatasetRegisterParamsSourceUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *DatasetRegisterParamsSourceUnion) asAny() any { +func (u *BetaDatasetRegisterParamsSourceUnion) asAny() any { if !param.IsOmitted(u.OfUri) { return u.OfUri } else if !param.IsOmitted(u.OfRows) { @@ -1123,7 +1137,7 @@ func (u *DatasetRegisterParamsSourceUnion) asAny() any { } // Returns a pointer to the underlying variant's property, if present. -func (u DatasetRegisterParamsSourceUnion) GetUri() *string { +func (u BetaDatasetRegisterParamsSourceUnion) GetUri() *string { if vt := u.OfUri; vt != nil { return &vt.Uri } @@ -1131,7 +1145,7 @@ func (u DatasetRegisterParamsSourceUnion) GetUri() *string { } // Returns a pointer to the underlying variant's property, if present. -func (u DatasetRegisterParamsSourceUnion) GetRows() []map[string]DatasetRegisterParamsSourceRowsRowUnion { +func (u BetaDatasetRegisterParamsSourceUnion) GetRows() []map[string]BetaDatasetRegisterParamsSourceRowsRowUnion { if vt := u.OfRows; vt != nil { return vt.Rows } @@ -1139,7 +1153,7 @@ func (u DatasetRegisterParamsSourceUnion) GetRows() []map[string]DatasetRegister } // Returns a pointer to the underlying variant's property, if present. -func (u DatasetRegisterParamsSourceUnion) GetType() *string { +func (u BetaDatasetRegisterParamsSourceUnion) GetType() *string { if vt := u.OfUri; vt != nil { return (*string)(&vt.Type) } else if vt := u.OfRows; vt != nil { @@ -1149,17 +1163,17 @@ func (u DatasetRegisterParamsSourceUnion) GetType() *string { } func init() { - apijson.RegisterUnion[DatasetRegisterParamsSourceUnion]( + apijson.RegisterUnion[BetaDatasetRegisterParamsSourceUnion]( "type", - apijson.Discriminator[DatasetRegisterParamsSourceUri]("uri"), - apijson.Discriminator[DatasetRegisterParamsSourceRows]("rows"), + apijson.Discriminator[BetaDatasetRegisterParamsSourceUri]("uri"), + apijson.Discriminator[BetaDatasetRegisterParamsSourceRows]("rows"), ) } // A dataset that can be obtained from a URI. // // The properties Type, Uri are required. -type DatasetRegisterParamsSourceUri struct { +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}" @@ -1169,39 +1183,39 @@ type DatasetRegisterParamsSourceUri struct { paramObj } -func (r DatasetRegisterParamsSourceUri) MarshalJSON() (data []byte, err error) { - type shadow DatasetRegisterParamsSourceUri +func (r BetaDatasetRegisterParamsSourceUri) MarshalJSON() (data []byte, err error) { + type shadow BetaDatasetRegisterParamsSourceUri return param.MarshalObject(r, (*shadow)(&r)) } -func (r *DatasetRegisterParamsSourceUri) UnmarshalJSON(data []byte) error { +func (r *BetaDatasetRegisterParamsSourceUri) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // A dataset stored in rows. // // The properties Rows, Type are required. -type DatasetRegisterParamsSourceRows struct { +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]DatasetRegisterParamsSourceRowsRowUnion `json:"rows,omitzero,required"` + 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 DatasetRegisterParamsSourceRows) MarshalJSON() (data []byte, err error) { - type shadow DatasetRegisterParamsSourceRows +func (r BetaDatasetRegisterParamsSourceRows) MarshalJSON() (data []byte, err error) { + type shadow BetaDatasetRegisterParamsSourceRows return param.MarshalObject(r, (*shadow)(&r)) } -func (r *DatasetRegisterParamsSourceRows) UnmarshalJSON(data []byte) error { +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 DatasetRegisterParamsSourceRowsRowUnion struct { +type BetaDatasetRegisterParamsSourceRowsRowUnion struct { OfBool param.Opt[bool] `json:",omitzero,inline"` OfFloat param.Opt[float64] `json:",omitzero,inline"` OfString param.Opt[string] `json:",omitzero,inline"` @@ -1209,14 +1223,14 @@ type DatasetRegisterParamsSourceRowsRowUnion struct { paramUnion } -func (u DatasetRegisterParamsSourceRowsRowUnion) MarshalJSON() ([]byte, error) { +func (u BetaDatasetRegisterParamsSourceRowsRowUnion) MarshalJSON() ([]byte, error) { return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) } -func (u *DatasetRegisterParamsSourceRowsRowUnion) UnmarshalJSON(data []byte) error { +func (u *BetaDatasetRegisterParamsSourceRowsRowUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *DatasetRegisterParamsSourceRowsRowUnion) asAny() any { +func (u *BetaDatasetRegisterParamsSourceRowsRowUnion) asAny() any { if !param.IsOmitted(u.OfBool) { return &u.OfBool.Value } else if !param.IsOmitted(u.OfFloat) { @@ -1232,7 +1246,7 @@ func (u *DatasetRegisterParamsSourceRowsRowUnion) asAny() any { // Only one field can be non-zero. // // Use [param.IsOmitted] to confirm if a field is set. -type DatasetRegisterParamsMetadataUnion struct { +type BetaDatasetRegisterParamsMetadataUnion struct { OfBool param.Opt[bool] `json:",omitzero,inline"` OfFloat param.Opt[float64] `json:",omitzero,inline"` OfString param.Opt[string] `json:",omitzero,inline"` @@ -1240,14 +1254,14 @@ type DatasetRegisterParamsMetadataUnion struct { paramUnion } -func (u DatasetRegisterParamsMetadataUnion) MarshalJSON() ([]byte, error) { +func (u BetaDatasetRegisterParamsMetadataUnion) MarshalJSON() ([]byte, error) { return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) } -func (u *DatasetRegisterParamsMetadataUnion) UnmarshalJSON(data []byte) error { +func (u *BetaDatasetRegisterParamsMetadataUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *DatasetRegisterParamsMetadataUnion) asAny() any { +func (u *BetaDatasetRegisterParamsMetadataUnion) asAny() any { if !param.IsOmitted(u.OfBool) { return &u.OfBool.Value } else if !param.IsOmitted(u.OfFloat) { diff --git a/dataset_test.go b/betadataset_test.go similarity index 71% rename from dataset_test.go rename to betadataset_test.go index dc5ab37..4143ec6 100644 --- a/dataset_test.go +++ b/betadataset_test.go @@ -1,3 +1,9 @@ +// 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 @@ -13,7 +19,7 @@ import ( "github.com/llamastack/llama-stack-client-go/option" ) -func TestDatasetGet(t *testing.T) { +func TestBetaDatasetGet(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -24,7 +30,7 @@ func TestDatasetGet(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.Datasets.Get(context.TODO(), "dataset_id") + _, err := client.Beta.Datasets.Get(context.TODO(), "dataset_id") if err != nil { var apierr *llamastackclient.Error if errors.As(err, &apierr) { @@ -34,7 +40,7 @@ func TestDatasetGet(t *testing.T) { } } -func TestDatasetList(t *testing.T) { +func TestBetaDatasetList(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -45,7 +51,7 @@ func TestDatasetList(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.Datasets.List(context.TODO()) + _, err := client.Beta.Datasets.List(context.TODO()) if err != nil { var apierr *llamastackclient.Error if errors.As(err, &apierr) { @@ -55,7 +61,7 @@ func TestDatasetList(t *testing.T) { } } -func TestDatasetAppendrows(t *testing.T) { +func TestBetaDatasetAppendrows(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -66,11 +72,11 @@ func TestDatasetAppendrows(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - err := client.Datasets.Appendrows( + err := client.Beta.Datasets.Appendrows( context.TODO(), "dataset_id", - llamastackclient.DatasetAppendrowsParams{ - Rows: []map[string]llamastackclient.DatasetAppendrowsParamsRowUnion{{ + llamastackclient.BetaDatasetAppendrowsParams{ + Rows: []map[string]llamastackclient.BetaDatasetAppendrowsParamsRowUnion{{ "foo": { OfBool: llamastackclient.Bool(true), }, @@ -86,7 +92,7 @@ func TestDatasetAppendrows(t *testing.T) { } } -func TestDatasetIterrowsWithOptionalParams(t *testing.T) { +func TestBetaDatasetIterrowsWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -97,10 +103,10 @@ func TestDatasetIterrowsWithOptionalParams(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.Datasets.Iterrows( + _, err := client.Beta.Datasets.Iterrows( context.TODO(), "dataset_id", - llamastackclient.DatasetIterrowsParams{ + llamastackclient.BetaDatasetIterrowsParams{ Limit: llamastackclient.Int(0), StartIndex: llamastackclient.Int(0), }, @@ -114,7 +120,7 @@ func TestDatasetIterrowsWithOptionalParams(t *testing.T) { } } -func TestDatasetRegisterWithOptionalParams(t *testing.T) { +func TestBetaDatasetRegisterWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -125,15 +131,15 @@ func TestDatasetRegisterWithOptionalParams(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.Datasets.Register(context.TODO(), llamastackclient.DatasetRegisterParams{ - Purpose: llamastackclient.DatasetRegisterParamsPurposePostTrainingMessages, - Source: llamastackclient.DatasetRegisterParamsSourceUnion{ - OfUri: &llamastackclient.DatasetRegisterParamsSourceUri{ + _, 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.DatasetRegisterParamsMetadataUnion{ + Metadata: map[string]llamastackclient.BetaDatasetRegisterParamsMetadataUnion{ "foo": { OfBool: llamastackclient.Bool(true), }, @@ -148,7 +154,7 @@ func TestDatasetRegisterWithOptionalParams(t *testing.T) { } } -func TestDatasetUnregister(t *testing.T) { +func TestBetaDatasetUnregister(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -159,7 +165,7 @@ func TestDatasetUnregister(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - err := client.Datasets.Unregister(context.TODO(), "dataset_id") + err := client.Beta.Datasets.Unregister(context.TODO(), "dataset_id") if err != nil { var apierr *llamastackclient.Error if errors.As(err, &apierr) { diff --git a/chat.go b/chat.go index 84d46ca..519c9ac 100644 --- a/chat.go +++ b/chat.go @@ -1,3 +1,9 @@ +// 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 @@ -42,6 +48,8 @@ type ChatCompletionChunk struct { 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -49,6 +57,7 @@ type ChatCompletionChunk struct { Created respjson.Field Model respjson.Field Object respjson.Field + Usage respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -91,6 +100,8 @@ func (r *ChatCompletionChunkChoice) UnmarshalJSON(data []byte) error { 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 @@ -99,12 +110,13 @@ type ChatCompletionChunkChoiceDelta struct { ToolCalls []ChatCompletionChunkChoiceDeltaToolCall `json:"tool_calls"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Content respjson.Field - Refusal respjson.Field - Role respjson.Field - ToolCalls respjson.Field - ExtraFields map[string]respjson.Field - raw string + Content respjson.Field + ReasoningContent respjson.Field + Refusal respjson.Field + Role respjson.Field + ToolCalls respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } @@ -274,3 +286,69 @@ func (r ChatCompletionChunkChoiceLogprobsRefusalTopLogprob) RawJSON() string { r func (r *ChatCompletionChunkChoiceLogprobsRefusalTopLogprob) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } + +// Token usage information (typically included in final chunk with stream_options) +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"` + // Token details for output tokens in OpenAI chat completion usage. + CompletionTokensDetails ChatCompletionChunkUsageCompletionTokensDetails `json:"completion_tokens_details"` + // Token details for prompt tokens in OpenAI chat completion usage. + PromptTokensDetails ChatCompletionChunkUsagePromptTokensDetails `json:"prompt_tokens_details"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + CompletionTokens respjson.Field + PromptTokens respjson.Field + TotalTokens respjson.Field + CompletionTokensDetails respjson.Field + PromptTokensDetails respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ChatCompletionChunkUsage) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionChunkUsage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` + // 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 ChatCompletionChunkUsageCompletionTokensDetails) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionChunkUsageCompletionTokensDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Token details for prompt tokens in OpenAI chat completion usage. +type ChatCompletionChunkUsagePromptTokensDetails struct { + // Number of tokens retrieved from cache + CachedTokens int64 `json:"cached_tokens"` + // 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 ChatCompletionChunkUsagePromptTokensDetails) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionChunkUsagePromptTokensDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} diff --git a/chatcompletion.go b/chatcompletion.go index 89356fc..add4bd1 100644 --- a/chatcompletion.go +++ b/chatcompletion.go @@ -1,3 +1,9 @@ +// 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 @@ -9,6 +15,7 @@ import ( "fmt" "net/http" "net/url" + "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" "github.com/llamastack/llama-stack-client-go/internal/apiquery" @@ -40,47 +47,47 @@ func NewChatCompletionService(opts ...option.RequestOption) (r ChatCompletionSer return } -// 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) New(ctx context.Context, body ChatCompletionNewParams, opts ...option.RequestOption) (res *ChatCompletionNewResponseUnion, err error) { - opts = append(r.Options[:], opts...) - path := "v1/openai/v1/chat/completions" + opts = slices.Concat(r.Options, opts) + path := "v1/chat/completions" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return } -// 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 err error ) - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithJSONSet("stream", true)}, opts...) - path := "v1/openai/v1/chat/completions" + path := "v1/chat/completions" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &raw, opts...) return ssestream.NewStream[ChatCompletionChunk](ssestream.NewDecoder(raw), err) } -// 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 = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if completionID == "" { err = errors.New("missing required completion_id parameter") return } - path := fmt.Sprintf("v1/openai/v1/chat/completions/%s", completionID) + path := fmt.Sprintf("v1/chat/completions/%s", completionID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return } -// List all chat completions. +// 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 - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := "v1/openai/v1/chat/completions" + path := "v1/chat/completions" cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) if err != nil { return nil, err @@ -93,7 +100,7 @@ func (r *ChatCompletionService) List(ctx context.Context, query ChatCompletionLi return res, nil } -// List all chat completions. +// 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...)) } @@ -111,12 +118,16 @@ type ChatCompletionNewResponseUnion struct { Created int64 `json:"created"` Model string `json:"model"` Object string `json:"object"` - JSON struct { + // 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:"-"` } @@ -166,6 +177,76 @@ 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 @@ -178,6 +259,8 @@ type ChatCompletionNewResponseOpenAIChatCompletion struct { 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -185,6 +268,7 @@ type ChatCompletionNewResponseOpenAIChatCompletion struct { Created respjson.Field Model respjson.Field Object respjson.Field + Usage respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -1215,6 +1299,76 @@ func (r *ChatCompletionNewResponseOpenAIChatCompletionChoiceLogprobsRefusalTopLo return apijson.UnmarshalRoot(data, r) } +// Token usage information for the completion +type ChatCompletionNewResponseOpenAIChatCompletionUsage 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"` + // Token details for output tokens in OpenAI chat completion usage. + CompletionTokensDetails ChatCompletionNewResponseOpenAIChatCompletionUsageCompletionTokensDetails `json:"completion_tokens_details"` + // Token details for prompt tokens in OpenAI chat completion usage. + PromptTokensDetails ChatCompletionNewResponseOpenAIChatCompletionUsagePromptTokensDetails `json:"prompt_tokens_details"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + CompletionTokens respjson.Field + PromptTokens respjson.Field + TotalTokens respjson.Field + CompletionTokensDetails respjson.Field + PromptTokensDetails respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ChatCompletionNewResponseOpenAIChatCompletionUsage) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionNewResponseOpenAIChatCompletionUsage) 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"` + // 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 ChatCompletionNewResponseOpenAIChatCompletionUsageCompletionTokensDetails) RawJSON() string { + return r.JSON.raw +} +func (r *ChatCompletionNewResponseOpenAIChatCompletionUsageCompletionTokensDetails) 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"` + // 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 ChatCompletionNewResponseOpenAIChatCompletionUsagePromptTokensDetails) RawJSON() string { + return r.JSON.raw +} +func (r *ChatCompletionNewResponseOpenAIChatCompletionUsagePromptTokensDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + type ChatCompletionGetResponse struct { // The ID of the chat completion ID string `json:"id,required"` @@ -1227,6 +1381,8 @@ type ChatCompletionGetResponse struct { 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -1235,6 +1391,7 @@ type ChatCompletionGetResponse struct { InputMessages respjson.Field Model respjson.Field Object respjson.Field + Usage respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -3060,6 +3217,72 @@ func (r *ChatCompletionGetResponseInputMessageDeveloperContentArrayItem) Unmarsh return apijson.UnmarshalRoot(data, r) } +// Token usage information for the 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"` + // Token details for output tokens in OpenAI chat completion usage. + CompletionTokensDetails ChatCompletionGetResponseUsageCompletionTokensDetails `json:"completion_tokens_details"` + // Token details for prompt tokens in OpenAI chat completion usage. + PromptTokensDetails ChatCompletionGetResponseUsagePromptTokensDetails `json:"prompt_tokens_details"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + CompletionTokens respjson.Field + PromptTokens respjson.Field + TotalTokens respjson.Field + CompletionTokensDetails respjson.Field + PromptTokensDetails respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ChatCompletionGetResponseUsage) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionGetResponseUsage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` + // 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 ChatCompletionGetResponseUsageCompletionTokensDetails) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionGetResponseUsageCompletionTokensDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Token details for prompt tokens in OpenAI chat completion usage. +type ChatCompletionGetResponseUsagePromptTokensDetails struct { + // Number of tokens retrieved from cache + CachedTokens int64 `json:"cached_tokens"` + // 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 ChatCompletionGetResponseUsagePromptTokensDetails) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionGetResponseUsagePromptTokensDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + type ChatCompletionListResponse struct { // The ID of the chat completion ID string `json:"id,required"` @@ -3072,6 +3295,8 @@ type ChatCompletionListResponse struct { 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -3080,6 +3305,7 @@ type ChatCompletionListResponse struct { InputMessages respjson.Field Model respjson.Field Object respjson.Field + Usage respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -4918,6 +5144,72 @@ func (r *ChatCompletionListResponseInputMessageDeveloperContentArrayItem) Unmars return apijson.UnmarshalRoot(data, r) } +// Token usage information for the completion +type ChatCompletionListResponseUsage 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"` + // Token details for output tokens in OpenAI chat completion usage. + CompletionTokensDetails ChatCompletionListResponseUsageCompletionTokensDetails `json:"completion_tokens_details"` + // Token details for prompt tokens in OpenAI chat completion usage. + PromptTokensDetails ChatCompletionListResponseUsagePromptTokensDetails `json:"prompt_tokens_details"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + CompletionTokens respjson.Field + PromptTokens respjson.Field + TotalTokens respjson.Field + CompletionTokensDetails respjson.Field + PromptTokensDetails respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ChatCompletionListResponseUsage) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionListResponseUsage) 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"` + // 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 ChatCompletionListResponseUsageCompletionTokensDetails) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionListResponseUsageCompletionTokensDetails) 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"` + // 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 ChatCompletionListResponseUsagePromptTokensDetails) RawJSON() string { return r.JSON.raw } +func (r *ChatCompletionListResponseUsagePromptTokensDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + type ChatCompletionNewParams struct { // List of messages in the conversation. Messages []ChatCompletionNewParamsMessageUnion `json:"messages,omitzero,required"` diff --git a/chatcompletion_test.go b/chatcompletion_test.go index bf9e75a..34c5f93 100644 --- a/chatcompletion_test.go +++ b/chatcompletion_test.go @@ -1,3 +1,9 @@ +// 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 diff --git a/client.go b/client.go index 871db20..0e744ef 100644 --- a/client.go +++ b/client.go @@ -1,3 +1,9 @@ +// 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 @@ -6,6 +12,7 @@ import ( "context" "net/http" "os" + "slices" "github.com/llamastack/llama-stack-client-go/internal/requestconfig" "github.com/llamastack/llama-stack-client-go/option" @@ -15,35 +22,30 @@ import ( // interacting with the llama-stack-client API. You should not instantiate this // client directly, and instead use the [NewClient] method instead. type Client struct { - Options []option.RequestOption - Toolgroups ToolgroupService - Tools ToolService - ToolRuntime ToolRuntimeService - Responses ResponseService - Agents AgentService - Datasets DatasetService - Eval EvalService - Inspect InspectService - Inference InferenceService - Embeddings EmbeddingService - Chat ChatService - Completions CompletionService - VectorIo VectorIoService - VectorDBs VectorDBService - VectorStores VectorStoreService - Models ModelService - PostTraining PostTrainingService - Providers ProviderService - Routes RouteService - Moderations ModerationService - Safety SafetyService - Shields ShieldService - SyntheticDataGeneration SyntheticDataGenerationService - Telemetry TelemetryService - Scoring ScoringService - ScoringFunctions ScoringFunctionService - Benchmarks BenchmarkService - Files FileService + Options []option.RequestOption + Toolgroups ToolgroupService + Tools ToolService + ToolRuntime ToolRuntimeService + Responses ResponseService + Prompts PromptService + Conversations ConversationService + Inspect InspectService + Embeddings EmbeddingService + Chat ChatService + Completions CompletionService + VectorIo VectorIoService + VectorStores VectorStoreService + Models ModelService + Providers ProviderService + Routes RouteService + Moderations ModerationService + Safety SafetyService + Shields ShieldService + Scoring ScoringService + ScoringFunctions ScoringFunctionService + Files FileService + Alpha AlphaService + Beta BetaService } // DefaultClientOptions read from the environment (LLAMA_STACK_CLIENT_API_KEY, @@ -72,30 +74,25 @@ func NewClient(opts ...option.RequestOption) (r Client) { r.Tools = NewToolService(opts...) r.ToolRuntime = NewToolRuntimeService(opts...) r.Responses = NewResponseService(opts...) - r.Agents = NewAgentService(opts...) - r.Datasets = NewDatasetService(opts...) - r.Eval = NewEvalService(opts...) + r.Prompts = NewPromptService(opts...) + r.Conversations = NewConversationService(opts...) r.Inspect = NewInspectService(opts...) - r.Inference = NewInferenceService(opts...) r.Embeddings = NewEmbeddingService(opts...) r.Chat = NewChatService(opts...) r.Completions = NewCompletionService(opts...) r.VectorIo = NewVectorIoService(opts...) - r.VectorDBs = NewVectorDBService(opts...) r.VectorStores = NewVectorStoreService(opts...) r.Models = NewModelService(opts...) - r.PostTraining = NewPostTrainingService(opts...) r.Providers = NewProviderService(opts...) r.Routes = NewRouteService(opts...) r.Moderations = NewModerationService(opts...) r.Safety = NewSafetyService(opts...) r.Shields = NewShieldService(opts...) - r.SyntheticDataGeneration = NewSyntheticDataGenerationService(opts...) - r.Telemetry = NewTelemetryService(opts...) r.Scoring = NewScoringService(opts...) r.ScoringFunctions = NewScoringFunctionService(opts...) - r.Benchmarks = NewBenchmarkService(opts...) r.Files = NewFileService(opts...) + r.Alpha = NewAlphaService(opts...) + r.Beta = NewBetaService(opts...) return } @@ -132,7 +129,7 @@ func NewClient(opts ...option.RequestOption) (r Client) { // For even greater flexibility, see [option.WithResponseInto] and // [option.WithResponseBodyInto]. func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, opts ...option.RequestOption) error { - opts = append(r.Options, opts...) + opts = slices.Concat(r.Options, opts) return requestconfig.ExecuteNewRequest(ctx, method, path, params, res, opts...) } diff --git a/client_test.go b/client_test.go index f297c94..b8d8be8 100644 --- a/client_test.go +++ b/client_test.go @@ -1,3 +1,9 @@ +// 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 @@ -14,7 +20,6 @@ import ( "github.com/llamastack/llama-stack-client-go" "github.com/llamastack/llama-stack-client-go/internal" "github.com/llamastack/llama-stack-client-go/option" - "github.com/llamastack/llama-stack-client-go/shared" ) type closureTransport struct { @@ -39,15 +44,15 @@ func TestUserAgentHeader(t *testing.T) { }, }), ) - client.Inference.ChatCompletion(context.Background(), llamastackclient.InferenceChatCompletionParams{ - Messages: []shared.MessageUnionParam{{ - OfUser: &shared.UserMessageParam{ - Content: shared.InterleavedContentUnionParam{ + client.Chat.Completions.New(context.Background(), llamastackclient.ChatCompletionNewParams{ + Messages: []llamastackclient.ChatCompletionNewParamsMessageUnion{{ + OfUser: &llamastackclient.ChatCompletionNewParamsMessageUser{ + Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, }, }}, - ModelID: "model_id", + Model: "model", }) if userAgent != fmt.Sprintf("LlamaStackClient/Go %s", internal.PackageVersion) { t.Errorf("Expected User-Agent to be correct, but got: %#v", userAgent) @@ -71,15 +76,15 @@ func TestRetryAfter(t *testing.T) { }, }), ) - _, err := client.Inference.ChatCompletion(context.Background(), llamastackclient.InferenceChatCompletionParams{ - Messages: []shared.MessageUnionParam{{ - OfUser: &shared.UserMessageParam{ - Content: shared.InterleavedContentUnionParam{ + _, err := client.Chat.Completions.New(context.Background(), llamastackclient.ChatCompletionNewParams{ + Messages: []llamastackclient.ChatCompletionNewParamsMessageUnion{{ + OfUser: &llamastackclient.ChatCompletionNewParamsMessageUser{ + Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, }, }}, - ModelID: "model_id", + Model: "model", }) if err == nil { t.Error("Expected there to be a cancel error") @@ -114,15 +119,15 @@ func TestDeleteRetryCountHeader(t *testing.T) { }), option.WithHeaderDel("X-Stainless-Retry-Count"), ) - _, err := client.Inference.ChatCompletion(context.Background(), llamastackclient.InferenceChatCompletionParams{ - Messages: []shared.MessageUnionParam{{ - OfUser: &shared.UserMessageParam{ - Content: shared.InterleavedContentUnionParam{ + _, err := client.Chat.Completions.New(context.Background(), llamastackclient.ChatCompletionNewParams{ + Messages: []llamastackclient.ChatCompletionNewParamsMessageUnion{{ + OfUser: &llamastackclient.ChatCompletionNewParamsMessageUser{ + Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, }, }}, - ModelID: "model_id", + Model: "model", }) if err == nil { t.Error("Expected there to be a cancel error") @@ -152,15 +157,15 @@ func TestOverwriteRetryCountHeader(t *testing.T) { }), option.WithHeader("X-Stainless-Retry-Count", "42"), ) - _, err := client.Inference.ChatCompletion(context.Background(), llamastackclient.InferenceChatCompletionParams{ - Messages: []shared.MessageUnionParam{{ - OfUser: &shared.UserMessageParam{ - Content: shared.InterleavedContentUnionParam{ + _, err := client.Chat.Completions.New(context.Background(), llamastackclient.ChatCompletionNewParams{ + Messages: []llamastackclient.ChatCompletionNewParamsMessageUnion{{ + OfUser: &llamastackclient.ChatCompletionNewParamsMessageUser{ + Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, }, }}, - ModelID: "model_id", + Model: "model", }) if err == nil { t.Error("Expected there to be a cancel error") @@ -189,15 +194,15 @@ func TestRetryAfterMs(t *testing.T) { }, }), ) - _, err := client.Inference.ChatCompletion(context.Background(), llamastackclient.InferenceChatCompletionParams{ - Messages: []shared.MessageUnionParam{{ - OfUser: &shared.UserMessageParam{ - Content: shared.InterleavedContentUnionParam{ + _, err := client.Chat.Completions.New(context.Background(), llamastackclient.ChatCompletionNewParams{ + Messages: []llamastackclient.ChatCompletionNewParamsMessageUnion{{ + OfUser: &llamastackclient.ChatCompletionNewParamsMessageUser{ + Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, }, }}, - ModelID: "model_id", + Model: "model", }) if err == nil { t.Error("Expected there to be a cancel error") @@ -220,15 +225,15 @@ func TestContextCancel(t *testing.T) { ) cancelCtx, cancel := context.WithCancel(context.Background()) cancel() - _, err := client.Inference.ChatCompletion(cancelCtx, llamastackclient.InferenceChatCompletionParams{ - Messages: []shared.MessageUnionParam{{ - OfUser: &shared.UserMessageParam{ - Content: shared.InterleavedContentUnionParam{ + _, err := client.Chat.Completions.New(cancelCtx, llamastackclient.ChatCompletionNewParams{ + Messages: []llamastackclient.ChatCompletionNewParamsMessageUnion{{ + OfUser: &llamastackclient.ChatCompletionNewParamsMessageUser{ + Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, }, }}, - ModelID: "model_id", + Model: "model", }) if err == nil { t.Error("Expected there to be a cancel error") @@ -248,15 +253,15 @@ func TestContextCancelDelay(t *testing.T) { ) cancelCtx, cancel := context.WithTimeout(context.Background(), 2*time.Millisecond) defer cancel() - _, err := client.Inference.ChatCompletion(cancelCtx, llamastackclient.InferenceChatCompletionParams{ - Messages: []shared.MessageUnionParam{{ - OfUser: &shared.UserMessageParam{ - Content: shared.InterleavedContentUnionParam{ + _, err := client.Chat.Completions.New(cancelCtx, llamastackclient.ChatCompletionNewParams{ + Messages: []llamastackclient.ChatCompletionNewParamsMessageUnion{{ + OfUser: &llamastackclient.ChatCompletionNewParamsMessageUser{ + Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, }, }}, - ModelID: "model_id", + Model: "model", }) if err == nil { t.Error("expected there to be a cancel error") @@ -282,15 +287,15 @@ func TestContextDeadline(t *testing.T) { }, }), ) - _, err := client.Inference.ChatCompletion(deadlineCtx, llamastackclient.InferenceChatCompletionParams{ - Messages: []shared.MessageUnionParam{{ - OfUser: &shared.UserMessageParam{ - Content: shared.InterleavedContentUnionParam{ + _, err := client.Chat.Completions.New(deadlineCtx, llamastackclient.ChatCompletionNewParams{ + Messages: []llamastackclient.ChatCompletionNewParamsMessageUnion{{ + OfUser: &llamastackclient.ChatCompletionNewParamsMessageUser{ + Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, }, }}, - ModelID: "model_id", + Model: "model", }) if err == nil { t.Error("expected there to be a deadline error") @@ -335,15 +340,15 @@ func TestContextDeadlineStreaming(t *testing.T) { }, }), ) - stream := client.Inference.ChatCompletionStreaming(deadlineCtx, llamastackclient.InferenceChatCompletionParams{ - Messages: []shared.MessageUnionParam{{ - OfUser: &shared.UserMessageParam{ - Content: shared.InterleavedContentUnionParam{ + stream := client.Chat.Completions.NewStreaming(deadlineCtx, llamastackclient.ChatCompletionNewParams{ + Messages: []llamastackclient.ChatCompletionNewParamsMessageUnion{{ + OfUser: &llamastackclient.ChatCompletionNewParamsMessageUser{ + Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, }, }}, - ModelID: "model_id", + Model: "model", }) for stream.Next() { _ = stream.Current() @@ -388,17 +393,17 @@ func TestContextDeadlineStreamingWithRequestTimeout(t *testing.T) { }, }), ) - stream := client.Inference.ChatCompletionStreaming( + stream := client.Chat.Completions.NewStreaming( context.Background(), - llamastackclient.InferenceChatCompletionParams{ - Messages: []shared.MessageUnionParam{{ - OfUser: &shared.UserMessageParam{ - Content: shared.InterleavedContentUnionParam{ + llamastackclient.ChatCompletionNewParams{ + Messages: []llamastackclient.ChatCompletionNewParamsMessageUnion{{ + OfUser: &llamastackclient.ChatCompletionNewParamsMessageUser{ + Content: llamastackclient.ChatCompletionNewParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, }, }}, - ModelID: "model_id", + Model: "model", }, option.WithRequestTimeout((100 * time.Millisecond)), ) diff --git a/completion.go b/completion.go index 799b51d..e95e849 100644 --- a/completion.go +++ b/completion.go @@ -1,3 +1,9 @@ +// 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 @@ -5,6 +11,7 @@ package llamastackclient import ( "context" "net/http" + "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" "github.com/llamastack/llama-stack-client-go/internal/requestconfig" @@ -34,25 +41,25 @@ func NewCompletionService(opts ...option.RequestOption) (r CompletionService) { return } -// 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 = append(r.Options[:], opts...) - path := "v1/openai/v1/completions" + opts = slices.Concat(r.Options, opts) + path := "v1/completions" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return } -// 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 err error ) - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithJSONSet("stream", true)}, opts...) - path := "v1/openai/v1/completions" + path := "v1/completions" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &raw, opts...) return ssestream.NewStream[CompletionNewResponse](ssestream.NewDecoder(raw), err) } @@ -241,7 +248,6 @@ type CompletionNewParams struct { N param.Opt[int64] `json:"n,omitzero"` // (Optional) The penalty for repeated tokens. PresencePenalty param.Opt[float64] `json:"presence_penalty,omitzero"` - PromptLogprobs param.Opt[int64] `json:"prompt_logprobs,omitzero"` // (Optional) The seed to use. Seed param.Opt[int64] `json:"seed,omitzero"` // (Optional) The suffix that should be appended to the completion. @@ -251,8 +257,7 @@ type CompletionNewParams struct { // (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"` - GuidedChoice []string `json:"guided_choice,omitzero"` + 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. diff --git a/completion_test.go b/completion_test.go index d35fcf1..9f15245 100644 --- a/completion_test.go +++ b/completion_test.go @@ -1,3 +1,9 @@ +// 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 @@ -32,7 +38,6 @@ func TestCompletionNewWithOptionalParams(t *testing.T) { BestOf: llamastackclient.Int(0), Echo: llamastackclient.Bool(true), FrequencyPenalty: llamastackclient.Float(0), - GuidedChoice: []string{"string"}, LogitBias: map[string]float64{ "foo": 0, }, @@ -40,7 +45,6 @@ func TestCompletionNewWithOptionalParams(t *testing.T) { MaxTokens: llamastackclient.Int(0), N: llamastackclient.Int(0), PresencePenalty: llamastackclient.Float(0), - PromptLogprobs: llamastackclient.Int(0), Seed: llamastackclient.Int(0), Stop: llamastackclient.CompletionNewParamsStopUnion{ OfString: llamastackclient.String("string"), diff --git a/conversation.go b/conversation.go new file mode 100644 index 0000000..ba75c12 --- /dev/null +++ b/conversation.go @@ -0,0 +1,988 @@ +// 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" + "slices" + + "github.com/llamastack/llama-stack-client-go/internal/apijson" + "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" +) + +// ConversationService 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 [NewConversationService] method instead. +type ConversationService struct { + Options []option.RequestOption + Items ConversationItemService +} + +// NewConversationService 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 NewConversationService(opts ...option.RequestOption) (r ConversationService) { + r = ConversationService{} + r.Options = opts + r.Items = NewConversationItemService(opts...) + return +} + +// 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" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return +} + +// 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 == "" { + err = errors.New("missing required conversation_id parameter") + return + } + path := fmt.Sprintf("v1/conversations/%s", conversationID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return +} + +// 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 == "" { + err = errors.New("missing required conversation_id parameter") + return + } + path := fmt.Sprintf("v1/conversations/%s", conversationID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return +} + +// 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 == "" { + err = errors.New("missing required conversation_id parameter") + return + } + path := fmt.Sprintf("v1/conversations/%s", conversationID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return +} + +// 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"` + // 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 + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationObject) RawJSON() string { return r.JSON.raw } +func (r *ConversationObject) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Response for deleted conversation. +type ConversationDeleteResponse struct { + ID string `json:"id,required"` + Deleted bool `json:"deleted,required"` + Object string `json:"object,required"` + // 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:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationDeleteResponse) RawJSON() string { return r.JSON.raw } +func (r *ConversationDeleteResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +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"` + paramObj +} + +func (r ConversationNewParams) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationNewParams) 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 ConversationNewParamsItemUnion struct { + OfMessage *ConversationNewParamsItemMessage `json:",omitzero,inline"` + OfWebSearchCall *ConversationNewParamsItemWebSearchCall `json:",omitzero,inline"` + OfFileSearchCall *ConversationNewParamsItemFileSearchCall `json:",omitzero,inline"` + OfFunctionCall *ConversationNewParamsItemFunctionCall `json:",omitzero,inline"` + OfFunctionCallOutput *ConversationNewParamsItemFunctionCallOutput `json:",omitzero,inline"` + OfMcpApprovalRequest *ConversationNewParamsItemMcpApprovalRequest `json:",omitzero,inline"` + OfMcpApprovalResponse *ConversationNewParamsItemMcpApprovalResponse `json:",omitzero,inline"` + OfMcpCall *ConversationNewParamsItemMcpCall `json:",omitzero,inline"` + OfMcpListTools *ConversationNewParamsItemMcpListTools `json:",omitzero,inline"` + paramUnion +} + +func (u ConversationNewParamsItemUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfMessage, + u.OfWebSearchCall, + u.OfFileSearchCall, + u.OfFunctionCall, + u.OfFunctionCallOutput, + u.OfMcpApprovalRequest, + u.OfMcpApprovalResponse, + u.OfMcpCall, + u.OfMcpListTools) +} +func (u *ConversationNewParamsItemUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *ConversationNewParamsItemUnion) asAny() any { + if !param.IsOmitted(u.OfMessage) { + return u.OfMessage + } else if !param.IsOmitted(u.OfWebSearchCall) { + return u.OfWebSearchCall + } else if !param.IsOmitted(u.OfFileSearchCall) { + return u.OfFileSearchCall + } else if !param.IsOmitted(u.OfFunctionCall) { + return u.OfFunctionCall + } else if !param.IsOmitted(u.OfFunctionCallOutput) { + return u.OfFunctionCallOutput + } else if !param.IsOmitted(u.OfMcpApprovalRequest) { + return u.OfMcpApprovalRequest + } else if !param.IsOmitted(u.OfMcpApprovalResponse) { + return u.OfMcpApprovalResponse + } else if !param.IsOmitted(u.OfMcpCall) { + return u.OfMcpCall + } else if !param.IsOmitted(u.OfMcpListTools) { + return u.OfMcpListTools + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemUnion) GetContent() *ConversationNewParamsItemMessageContentUnion { + if vt := u.OfMessage; vt != nil { + return &vt.Content + } + return nil +} + +// 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 nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemUnion) GetQueries() []string { + if vt := u.OfFileSearchCall; vt != nil { + return vt.Queries + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemUnion) GetResults() []ConversationNewParamsItemFileSearchCallResult { + if vt := u.OfFileSearchCall; vt != nil { + return vt.Results + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemUnion) GetApprovalRequestID() *string { + if vt := u.OfMcpApprovalResponse; vt != nil { + return &vt.ApprovalRequestID + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemUnion) GetApprove() *bool { + if vt := u.OfMcpApprovalResponse; vt != nil { + return &vt.Approve + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemUnion) GetReason() *string { + if vt := u.OfMcpApprovalResponse; vt != nil && vt.Reason.Valid() { + return &vt.Reason.Value + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemUnion) GetError() *string { + if vt := u.OfMcpCall; vt != nil && vt.Error.Valid() { + return &vt.Error.Value + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemUnion) GetTools() []ConversationNewParamsItemMcpListToolsTool { + if vt := u.OfMcpListTools; vt != nil { + return vt.Tools + } + 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() { + 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 ConversationNewParamsItemUnion) 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 ConversationNewParamsItemUnion) 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) + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemUnion) 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 ConversationNewParamsItemUnion) 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 ConversationNewParamsItemUnion) 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 ConversationNewParamsItemUnion) 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) + } + return nil +} + +func init() { + apijson.RegisterUnion[ConversationNewParamsItemUnion]( + "type", + apijson.Discriminator[ConversationNewParamsItemMessage]("message"), + apijson.Discriminator[ConversationNewParamsItemWebSearchCall]("web_search_call"), + apijson.Discriminator[ConversationNewParamsItemFileSearchCall]("file_search_call"), + apijson.Discriminator[ConversationNewParamsItemFunctionCall]("function_call"), + apijson.Discriminator[ConversationNewParamsItemFunctionCallOutput]("function_call_output"), + apijson.Discriminator[ConversationNewParamsItemMcpApprovalRequest]("mcp_approval_request"), + apijson.Discriminator[ConversationNewParamsItemMcpApprovalResponse]("mcp_approval_response"), + apijson.Discriminator[ConversationNewParamsItemMcpCall]("mcp_call"), + apijson.Discriminator[ConversationNewParamsItemMcpListTools]("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, Type 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"` + paramObj +} + +func (r ConversationNewParamsItemMessage) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParamsItemMessage + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationNewParamsItemMessage) 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 ConversationNewParamsItemMessageContentUnion struct { + OfString param.Opt[string] `json:",omitzero,inline"` + OfConversationNewsItemMessageContentArray []ConversationNewParamsItemMessageContentArrayItemUnion `json:",omitzero,inline"` + OfVariant2 []ConversationNewParamsItemMessageContentArrayItemUnion `json:",omitzero,inline"` + paramUnion +} + +func (u ConversationNewParamsItemMessageContentUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfString, u.OfConversationNewsItemMessageContentArray, u.OfVariant2) +} +func (u *ConversationNewParamsItemMessageContentUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +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 + } + return nil +} + +// 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"` + paramUnion +} + +func (u ConversationNewParamsItemMessageContentArrayItemUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfInputText, u.OfInputImage, u.OfInputFile) +} +func (u *ConversationNewParamsItemMessageContentArrayItemUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *ConversationNewParamsItemMessageContentArrayItemUnion) 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 ConversationNewParamsItemMessageContentArrayItemUnion) 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 ConversationNewParamsItemMessageContentArrayItemUnion) GetDetail() *string { + if vt := u.OfInputImage; vt != nil { + return (*string)(&vt.Detail) + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationNewParamsItemMessageContentArrayItemUnion) 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 ConversationNewParamsItemMessageContentArrayItemUnion) 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 ConversationNewParamsItemMessageContentArrayItemUnion) 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 ConversationNewParamsItemMessageContentArrayItemUnion) 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 ConversationNewParamsItemMessageContentArrayItemUnion) 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 ConversationNewParamsItemMessageContentArrayItemUnion) 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[ConversationNewParamsItemMessageContentArrayItemUnion]( + "type", + apijson.Discriminator[ConversationNewParamsItemMessageContentArrayItemInputText]("input_text"), + apijson.Discriminator[ConversationNewParamsItemMessageContentArrayItemInputImage]("input_image"), + apijson.Discriminator[ConversationNewParamsItemMessageContentArrayItemInputFile]("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 + 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"` + paramObj +} + +func (r ConversationNewParamsItemMessageContentArrayItemInputText) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParamsItemMessageContentArrayItemInputText + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationNewParamsItemMessageContentArrayItemInputText) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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 + 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"` + paramObj +} + +func (r ConversationNewParamsItemMessageContentArrayItemInputImage) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParamsItemMessageContentArrayItemInputImage + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationNewParamsItemMessageContentArrayItemInputImage) 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" +) + +// 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. + 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"` + paramObj +} + +func (r ConversationNewParamsItemMessageContentArrayItemInputFile) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParamsItemMessageContentArrayItemInputFile + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationNewParamsItemMessageContentArrayItemInputFile) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type ConversationNewParamsItemMessageRole string + +const ( + ConversationNewParamsItemMessageRoleSystem ConversationNewParamsItemMessageRole = "system" + ConversationNewParamsItemMessageRoleDeveloper ConversationNewParamsItemMessageRole = "developer" + ConversationNewParamsItemMessageRoleUser ConversationNewParamsItemMessageRole = "user" + ConversationNewParamsItemMessageRoleAssistant ConversationNewParamsItemMessageRole = "assistant" +) + +// Web search tool call output message for OpenAI responses. +// +// The properties ID, Status, Type are required. +type ConversationNewParamsItemWebSearchCall 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"` + paramObj +} + +func (r ConversationNewParamsItemWebSearchCall) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParamsItemWebSearchCall + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationNewParamsItemWebSearchCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// File search tool call output message for OpenAI responses. +// +// The properties ID, Queries, Status, Type 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 + 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"` + paramObj +} + +func (r ConversationNewParamsItemFileSearchCall) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParamsItemFileSearchCall + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationNewParamsItemFileSearchCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` + paramObj +} + +func (r ConversationNewParamsItemFileSearchCallResult) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParamsItemFileSearchCallResult + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationNewParamsItemFileSearchCallResult) 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 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. +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"` + paramObj +} + +func (r ConversationNewParamsItemFunctionCall) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParamsItemFunctionCall + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationNewParamsItemFunctionCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// This represents the output of a function call that gets passed back to the +// model. +// +// The properties CallID, Output, Type 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"` + paramObj +} + +func (r ConversationNewParamsItemFunctionCallOutput) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParamsItemFunctionCallOutput + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationNewParamsItemFunctionCallOutput) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// A request for human approval of a tool invocation. +// +// The properties ID, Arguments, Name, ServerLabel, Type 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"` + paramObj +} + +func (r ConversationNewParamsItemMcpApprovalRequest) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParamsItemMcpApprovalRequest + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationNewParamsItemMcpApprovalRequest) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// A response to an MCP approval request. +// +// The properties ApprovalRequestID, Approve, Type 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"` + paramObj +} + +func (r ConversationNewParamsItemMcpApprovalResponse) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParamsItemMcpApprovalResponse + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationNewParamsItemMcpApprovalResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Model Context Protocol (MCP) call output message for OpenAI responses. +// +// The properties ID, Arguments, Name, ServerLabel, Type 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"` + paramObj +} + +func (r ConversationNewParamsItemMcpCall) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParamsItemMcpCall + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationNewParamsItemMcpCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// MCP list tools output message containing available tools from an MCP server. +// +// The properties ID, ServerLabel, Tools, Type 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"` + paramObj +} + +func (r ConversationNewParamsItemMcpListTools) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParamsItemMcpListTools + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationNewParamsItemMcpListTools) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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 + Description param.Opt[string] `json:"description,omitzero"` + paramObj +} + +func (r ConversationNewParamsItemMcpListToolsTool) MarshalJSON() (data []byte, err error) { + type shadow ConversationNewParamsItemMcpListToolsTool + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationNewParamsItemMcpListToolsTool) 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 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 +} + +func (r ConversationUpdateParams) MarshalJSON() (data []byte, err error) { + type shadow ConversationUpdateParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationUpdateParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} diff --git a/agentsession_test.go b/conversation_test.go similarity index 61% rename from agentsession_test.go rename to conversation_test.go index 1960a8f..791bbb9 100644 --- a/agentsession_test.go +++ b/conversation_test.go @@ -1,3 +1,9 @@ +// 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 @@ -13,7 +19,7 @@ import ( "github.com/llamastack/llama-stack-client-go/option" ) -func TestAgentSessionNew(t *testing.T) { +func TestConversationNewWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -24,13 +30,21 @@ func TestAgentSessionNew(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.Agents.Session.New( - context.TODO(), - "agent_id", - llamastackclient.AgentSessionNewParams{ - SessionName: "session_name", + _, err := client.Conversations.New(context.TODO(), llamastackclient.ConversationNewParams{ + Items: []llamastackclient.ConversationNewParamsItemUnion{{ + OfMessage: &llamastackclient.ConversationNewParamsItemMessage{ + Content: llamastackclient.ConversationNewParamsItemMessageContentUnion{ + OfString: llamastackclient.String("string"), + }, + Role: llamastackclient.ConversationNewParamsItemMessageRoleSystem, + ID: llamastackclient.String("id"), + Status: llamastackclient.String("status"), + }, + }}, + Metadata: map[string]string{ + "foo": "string", }, - ) + }) if err != nil { var apierr *llamastackclient.Error if errors.As(err, &apierr) { @@ -40,7 +54,7 @@ func TestAgentSessionNew(t *testing.T) { } } -func TestAgentSessionGetWithOptionalParams(t *testing.T) { +func TestConversationGet(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -51,14 +65,7 @@ func TestAgentSessionGetWithOptionalParams(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.Agents.Session.Get( - context.TODO(), - "session_id", - llamastackclient.AgentSessionGetParams{ - AgentID: "agent_id", - TurnIDs: []string{"string"}, - }, - ) + _, err := client.Conversations.Get(context.TODO(), "conversation_id") if err != nil { var apierr *llamastackclient.Error if errors.As(err, &apierr) { @@ -68,7 +75,7 @@ func TestAgentSessionGetWithOptionalParams(t *testing.T) { } } -func TestAgentSessionListWithOptionalParams(t *testing.T) { +func TestConversationUpdate(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -79,12 +86,13 @@ func TestAgentSessionListWithOptionalParams(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.Agents.Session.List( + _, err := client.Conversations.Update( context.TODO(), - "agent_id", - llamastackclient.AgentSessionListParams{ - Limit: llamastackclient.Int(0), - StartIndex: llamastackclient.Int(0), + "conversation_id", + llamastackclient.ConversationUpdateParams{ + Metadata: map[string]string{ + "foo": "string", + }, }, ) if err != nil { @@ -96,7 +104,7 @@ func TestAgentSessionListWithOptionalParams(t *testing.T) { } } -func TestAgentSessionDelete(t *testing.T) { +func TestConversationDelete(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -107,13 +115,7 @@ func TestAgentSessionDelete(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - err := client.Agents.Session.Delete( - context.TODO(), - "session_id", - llamastackclient.AgentSessionDeleteParams{ - AgentID: "agent_id", - }, - ) + _, err := client.Conversations.Delete(context.TODO(), "conversation_id") if err != nil { var apierr *llamastackclient.Error if errors.As(err, &apierr) { diff --git a/conversationitem.go b/conversationitem.go new file mode 100644 index 0000000..2c2ea7e --- /dev/null +++ b/conversationitem.go @@ -0,0 +1,3590 @@ +// 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" + "encoding/json" + "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" +) + +// ConversationItemService 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 [NewConversationItemService] method instead. +type ConversationItemService struct { + Options []option.RequestOption +} + +// NewConversationItemService 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 NewConversationItemService(opts ...option.RequestOption) (r ConversationItemService) { + r = ConversationItemService{} + r.Options = opts + return +} + +// 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 == "" { + err = errors.New("missing required conversation_id parameter") + return + } + path := fmt.Sprintf("v1/conversations/%s/items", conversationID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return +} + +// 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) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + if conversationID == "" { + err = errors.New("missing required conversation_id parameter") + return + } + path := fmt.Sprintf("v1/conversations/%s/items", conversationID) + 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 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) { + opts = slices.Concat(r.Options, opts) + if query.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", query.ConversationID, itemID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return +} + +// 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"` + // 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 + LastID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemNewResponse) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemNewResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ConversationItemNewResponseDataUnion contains all possible properties and values +// from [ConversationItemNewResponseDataMessage], +// [ConversationItemNewResponseDataWebSearchCall], +// [ConversationItemNewResponseDataFileSearchCall], +// [ConversationItemNewResponseDataFunctionCall], +// [ConversationItemNewResponseDataFunctionCallOutput], +// [ConversationItemNewResponseDataMcpApprovalRequest], +// [ConversationItemNewResponseDataMcpApprovalResponse], +// [ConversationItemNewResponseDataMcpCall], +// [ConversationItemNewResponseDataMcpListTools]. +// +// Use the [ConversationItemNewResponseDataUnion.AsAny] method to switch on the +// variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ConversationItemNewResponseDataUnion struct { + // This field is from variant [ConversationItemNewResponseDataMessage]. + Content ConversationItemNewResponseDataMessageContentUnion `json:"content"` + // This field is from variant [ConversationItemNewResponseDataMessage]. + Role ConversationItemNewResponseDataMessageRole `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 [ConversationItemNewResponseDataFileSearchCall]. + Queries []string `json:"queries"` + // This field is from variant [ConversationItemNewResponseDataFileSearchCall]. + Results []ConversationItemNewResponseDataFileSearchCallResult `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 [ConversationItemNewResponseDataMcpApprovalResponse]. + ApprovalRequestID string `json:"approval_request_id"` + // This field is from variant [ConversationItemNewResponseDataMcpApprovalResponse]. + Approve bool `json:"approve"` + // This field is from variant [ConversationItemNewResponseDataMcpApprovalResponse]. + Reason string `json:"reason"` + // This field is from variant [ConversationItemNewResponseDataMcpCall]. + Error string `json:"error"` + // This field is from variant [ConversationItemNewResponseDataMcpListTools]. + Tools []ConversationItemNewResponseDataMcpListToolsTool `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 + } `json:"-"` +} + +// anyConversationItemNewResponseData is implemented by each variant of +// [ConversationItemNewResponseDataUnion] to add type safety for the return type of +// [ConversationItemNewResponseDataUnion.AsAny] +type anyConversationItemNewResponseData interface { + implConversationItemNewResponseDataUnion() +} + +func (ConversationItemNewResponseDataMessage) implConversationItemNewResponseDataUnion() {} +func (ConversationItemNewResponseDataWebSearchCall) implConversationItemNewResponseDataUnion() {} +func (ConversationItemNewResponseDataFileSearchCall) implConversationItemNewResponseDataUnion() {} +func (ConversationItemNewResponseDataFunctionCall) implConversationItemNewResponseDataUnion() {} +func (ConversationItemNewResponseDataFunctionCallOutput) implConversationItemNewResponseDataUnion() {} +func (ConversationItemNewResponseDataMcpApprovalRequest) implConversationItemNewResponseDataUnion() {} +func (ConversationItemNewResponseDataMcpApprovalResponse) implConversationItemNewResponseDataUnion() { +} +func (ConversationItemNewResponseDataMcpCall) implConversationItemNewResponseDataUnion() {} +func (ConversationItemNewResponseDataMcpListTools) implConversationItemNewResponseDataUnion() {} + +// Use the following switch statement to find the correct variant +// +// switch variant := ConversationItemNewResponseDataUnion.AsAny().(type) { +// case llamastackclient.ConversationItemNewResponseDataMessage: +// case llamastackclient.ConversationItemNewResponseDataWebSearchCall: +// case llamastackclient.ConversationItemNewResponseDataFileSearchCall: +// case llamastackclient.ConversationItemNewResponseDataFunctionCall: +// case llamastackclient.ConversationItemNewResponseDataFunctionCallOutput: +// case llamastackclient.ConversationItemNewResponseDataMcpApprovalRequest: +// case llamastackclient.ConversationItemNewResponseDataMcpApprovalResponse: +// case llamastackclient.ConversationItemNewResponseDataMcpCall: +// case llamastackclient.ConversationItemNewResponseDataMcpListTools: +// default: +// fmt.Errorf("no variant present") +// } +func (u ConversationItemNewResponseDataUnion) AsAny() anyConversationItemNewResponseData { + 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 ConversationItemNewResponseDataUnion) AsMessage() (v ConversationItemNewResponseDataMessage) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemNewResponseDataUnion) AsWebSearchCall() (v ConversationItemNewResponseDataWebSearchCall) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemNewResponseDataUnion) AsFileSearchCall() (v ConversationItemNewResponseDataFileSearchCall) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemNewResponseDataUnion) AsFunctionCall() (v ConversationItemNewResponseDataFunctionCall) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemNewResponseDataUnion) AsFunctionCallOutput() (v ConversationItemNewResponseDataFunctionCallOutput) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemNewResponseDataUnion) AsMcpApprovalRequest() (v ConversationItemNewResponseDataMcpApprovalRequest) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemNewResponseDataUnion) AsMcpApprovalResponse() (v ConversationItemNewResponseDataMcpApprovalResponse) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemNewResponseDataUnion) AsMcpCall() (v ConversationItemNewResponseDataMcpCall) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemNewResponseDataUnion) AsMcpListTools() (v ConversationItemNewResponseDataMcpListTools) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ConversationItemNewResponseDataUnion) RawJSON() string { return u.JSON.raw } + +func (r *ConversationItemNewResponseDataUnion) 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 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"` + // 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 + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemNewResponseDataMessage) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemNewResponseDataMessage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ConversationItemNewResponseDataMessageContentUnion contains all possible +// properties and values from [string], +// [[]ConversationItemNewResponseDataMessageContentArrayItemUnion], +// [[]ConversationItemNewResponseDataMessageContentArrayItemUnion]. +// +// 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 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 + } `json:"-"` +} + +func (u ConversationItemNewResponseDataMessageContentUnion) AsString() (v string) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemNewResponseDataMessageContentUnion) AsConversationItemNewResponseDataMessageContentArray() (v []ConversationItemNewResponseDataMessageContentArrayItemUnion) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemNewResponseDataMessageContentUnion) AsVariant2() (v []ConversationItemNewResponseDataMessageContentArrayItemUnion) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ConversationItemNewResponseDataMessageContentUnion) RawJSON() string { return u.JSON.raw } + +func (r *ConversationItemNewResponseDataMessageContentUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ConversationItemNewResponseDataMessageContentArrayItemUnion contains all +// possible properties and values from +// [ConversationItemNewResponseDataMessageContentArrayItemInputText], +// [ConversationItemNewResponseDataMessageContentArrayItemInputImage], +// [ConversationItemNewResponseDataMessageContentArrayItemInputFile]. +// +// Use the [ConversationItemNewResponseDataMessageContentArrayItemUnion.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 { + // This field is from variant + // [ConversationItemNewResponseDataMessageContentArrayItemInputText]. + 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"` + // This field is from variant + // [ConversationItemNewResponseDataMessageContentArrayItemInputImage]. + ImageURL string `json:"image_url"` + // This field is from variant + // [ConversationItemNewResponseDataMessageContentArrayItemInputFile]. + FileData string `json:"file_data"` + // This field is from variant + // [ConversationItemNewResponseDataMessageContentArrayItemInputFile]. + FileURL string `json:"file_url"` + // This field is from variant + // [ConversationItemNewResponseDataMessageContentArrayItemInputFile]. + 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:"-"` +} + +// anyConversationItemNewResponseDataMessageContentArrayItem is implemented by each +// variant of [ConversationItemNewResponseDataMessageContentArrayItemUnion] to add +// type safety for the return type of +// [ConversationItemNewResponseDataMessageContentArrayItemUnion.AsAny] +type anyConversationItemNewResponseDataMessageContentArrayItem interface { + implConversationItemNewResponseDataMessageContentArrayItemUnion() +} + +func (ConversationItemNewResponseDataMessageContentArrayItemInputText) implConversationItemNewResponseDataMessageContentArrayItemUnion() { +} +func (ConversationItemNewResponseDataMessageContentArrayItemInputImage) implConversationItemNewResponseDataMessageContentArrayItemUnion() { +} +func (ConversationItemNewResponseDataMessageContentArrayItemInputFile) implConversationItemNewResponseDataMessageContentArrayItemUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := ConversationItemNewResponseDataMessageContentArrayItemUnion.AsAny().(type) { +// case llamastackclient.ConversationItemNewResponseDataMessageContentArrayItemInputText: +// case llamastackclient.ConversationItemNewResponseDataMessageContentArrayItemInputImage: +// case llamastackclient.ConversationItemNewResponseDataMessageContentArrayItemInputFile: +// default: +// fmt.Errorf("no variant present") +// } +func (u ConversationItemNewResponseDataMessageContentArrayItemUnion) AsAny() anyConversationItemNewResponseDataMessageContentArrayItem { + 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 ConversationItemNewResponseDataMessageContentArrayItemUnion) AsInputText() (v ConversationItemNewResponseDataMessageContentArrayItemInputText) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemNewResponseDataMessageContentArrayItemUnion) AsInputImage() (v ConversationItemNewResponseDataMessageContentArrayItemInputImage) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemNewResponseDataMessageContentArrayItemUnion) AsInputFile() (v ConversationItemNewResponseDataMessageContentArrayItemInputFile) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ConversationItemNewResponseDataMessageContentArrayItemUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *ConversationItemNewResponseDataMessageContentArrayItemUnion) 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 + Text string `json:"text,required"` + // Content type identifier, always "input_text" + Type constant.InputText `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:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemNewResponseDataMessageContentArrayItemInputText) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemNewResponseDataMessageContentArrayItemInputText) 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" + // + // 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"` + // 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 + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemNewResponseDataMessageContentArrayItemInputImage) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemNewResponseDataMessageContentArrayItemInputImage) 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"` + // 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 + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemNewResponseDataMessageContentArrayItemInputFile) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemNewResponseDataMessageContentArrayItemInputFile) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Level of detail for image processing, can be "low", "high", or "auto" +type ConversationItemNewResponseDataMessageContentArrayItemDetail string + +const ( + ConversationItemNewResponseDataMessageContentArrayItemDetailLow ConversationItemNewResponseDataMessageContentArrayItemDetail = "low" + ConversationItemNewResponseDataMessageContentArrayItemDetailHigh ConversationItemNewResponseDataMessageContentArrayItemDetail = "high" + ConversationItemNewResponseDataMessageContentArrayItemDetailAuto ConversationItemNewResponseDataMessageContentArrayItemDetail = "auto" +) + +type ConversationItemNewResponseDataMessageRole string + +const ( + ConversationItemNewResponseDataMessageRoleSystem ConversationItemNewResponseDataMessageRole = "system" + ConversationItemNewResponseDataMessageRoleDeveloper ConversationItemNewResponseDataMessageRole = "developer" + ConversationItemNewResponseDataMessageRoleUser ConversationItemNewResponseDataMessageRole = "user" + ConversationItemNewResponseDataMessageRoleAssistant ConversationItemNewResponseDataMessageRole = "assistant" +) + +// 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:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemNewResponseDataWebSearchCall) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemNewResponseDataWebSearchCall) 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"` + // 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:"-"` +} + +// 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 { + // (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 + 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) +} + +// 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. +// +// 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:"-"` +} + +func (u ConversationItemNewResponseDataFileSearchCallResultAttributeUnion) AsBool() (v bool) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemNewResponseDataFileSearchCallResultAttributeUnion) AsFloat() (v float64) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemNewResponseDataFileSearchCallResultAttributeUnion) AsString() (v string) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemNewResponseDataFileSearchCallResultAttributeUnion) AsAnyArray() (v []any) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ConversationItemNewResponseDataFileSearchCallResultAttributeUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *ConversationItemNewResponseDataFileSearchCallResultAttributeUnion) 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"` + // 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 + 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 { + 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"` + // 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:"-"` +} + +// 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) +} + +// 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"` + // 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 ConversationItemNewResponseDataMcpApprovalRequest) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemNewResponseDataMcpApprovalRequest) 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"` + // 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:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemNewResponseDataMcpApprovalResponse) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemNewResponseDataMcpApprovalResponse) 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"` + // 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 + 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 { + // 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"` + // 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) +} + +// 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 + Name respjson.Field + Description 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 { + 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 + } `json:"-"` +} + +func (u ConversationItemNewResponseDataMcpListToolsToolInputSchemaUnion) AsBool() (v bool) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemNewResponseDataMcpListToolsToolInputSchemaUnion) AsFloat() (v float64) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemNewResponseDataMcpListToolsToolInputSchemaUnion) AsString() (v string) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemNewResponseDataMcpListToolsToolInputSchemaUnion) AsAnyArray() (v []any) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ConversationItemNewResponseDataMcpListToolsToolInputSchemaUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *ConversationItemNewResponseDataMcpListToolsToolInputSchemaUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type ConversationItemNewResponseDataRole string + +const ( + ConversationItemNewResponseDataRoleSystem ConversationItemNewResponseDataRole = "system" + ConversationItemNewResponseDataRoleDeveloper ConversationItemNewResponseDataRole = "developer" + ConversationItemNewResponseDataRoleUser ConversationItemNewResponseDataRole = "user" + ConversationItemNewResponseDataRoleAssistant ConversationItemNewResponseDataRole = "assistant" +) + +// ConversationItemListResponseUnion contains all possible properties and values +// from [ConversationItemListResponseMessage], +// [ConversationItemListResponseWebSearchCall], +// [ConversationItemListResponseFileSearchCall], +// [ConversationItemListResponseFunctionCall], +// [ConversationItemListResponseFunctionCallOutput], +// [ConversationItemListResponseMcpApprovalRequest], +// [ConversationItemListResponseMcpApprovalResponse], +// [ConversationItemListResponseMcpCall], +// [ConversationItemListResponseMcpListTools]. +// +// Use the [ConversationItemListResponseUnion.AsAny] method to switch on the +// variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ConversationItemListResponseUnion struct { + // This field is from variant [ConversationItemListResponseMessage]. + Content ConversationItemListResponseMessageContentUnion `json:"content"` + // This field is from variant [ConversationItemListResponseMessage]. + Role ConversationItemListResponseMessageRole `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 [ConversationItemListResponseFileSearchCall]. + Queries []string `json:"queries"` + // This field is from variant [ConversationItemListResponseFileSearchCall]. + Results []ConversationItemListResponseFileSearchCallResult `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 [ConversationItemListResponseMcpApprovalResponse]. + ApprovalRequestID string `json:"approval_request_id"` + // This field is from variant [ConversationItemListResponseMcpApprovalResponse]. + Approve bool `json:"approve"` + // This field is from variant [ConversationItemListResponseMcpApprovalResponse]. + Reason string `json:"reason"` + // This field is from variant [ConversationItemListResponseMcpCall]. + Error string `json:"error"` + // This field is from variant [ConversationItemListResponseMcpListTools]. + Tools []ConversationItemListResponseMcpListToolsTool `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 + } `json:"-"` +} + +// anyConversationItemListResponse is implemented by each variant of +// [ConversationItemListResponseUnion] to add type safety for the return type of +// [ConversationItemListResponseUnion.AsAny] +type anyConversationItemListResponse interface { + implConversationItemListResponseUnion() +} + +func (ConversationItemListResponseMessage) implConversationItemListResponseUnion() {} +func (ConversationItemListResponseWebSearchCall) implConversationItemListResponseUnion() {} +func (ConversationItemListResponseFileSearchCall) implConversationItemListResponseUnion() {} +func (ConversationItemListResponseFunctionCall) implConversationItemListResponseUnion() {} +func (ConversationItemListResponseFunctionCallOutput) implConversationItemListResponseUnion() {} +func (ConversationItemListResponseMcpApprovalRequest) implConversationItemListResponseUnion() {} +func (ConversationItemListResponseMcpApprovalResponse) implConversationItemListResponseUnion() {} +func (ConversationItemListResponseMcpCall) implConversationItemListResponseUnion() {} +func (ConversationItemListResponseMcpListTools) implConversationItemListResponseUnion() {} + +// Use the following switch statement to find the correct variant +// +// switch variant := ConversationItemListResponseUnion.AsAny().(type) { +// case llamastackclient.ConversationItemListResponseMessage: +// case llamastackclient.ConversationItemListResponseWebSearchCall: +// case llamastackclient.ConversationItemListResponseFileSearchCall: +// case llamastackclient.ConversationItemListResponseFunctionCall: +// case llamastackclient.ConversationItemListResponseFunctionCallOutput: +// case llamastackclient.ConversationItemListResponseMcpApprovalRequest: +// case llamastackclient.ConversationItemListResponseMcpApprovalResponse: +// case llamastackclient.ConversationItemListResponseMcpCall: +// case llamastackclient.ConversationItemListResponseMcpListTools: +// default: +// fmt.Errorf("no variant present") +// } +func (u ConversationItemListResponseUnion) AsAny() anyConversationItemListResponse { + 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 ConversationItemListResponseUnion) AsMessage() (v ConversationItemListResponseMessage) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemListResponseUnion) AsWebSearchCall() (v ConversationItemListResponseWebSearchCall) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemListResponseUnion) AsFileSearchCall() (v ConversationItemListResponseFileSearchCall) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemListResponseUnion) AsFunctionCall() (v ConversationItemListResponseFunctionCall) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemListResponseUnion) AsFunctionCallOutput() (v ConversationItemListResponseFunctionCallOutput) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemListResponseUnion) AsMcpApprovalRequest() (v ConversationItemListResponseMcpApprovalRequest) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemListResponseUnion) AsMcpApprovalResponse() (v ConversationItemListResponseMcpApprovalResponse) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemListResponseUnion) AsMcpCall() (v ConversationItemListResponseMcpCall) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemListResponseUnion) AsMcpListTools() (v ConversationItemListResponseMcpListTools) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ConversationItemListResponseUnion) RawJSON() string { return u.JSON.raw } + +func (r *ConversationItemListResponseUnion) 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 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"` + // 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 + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemListResponseMessage) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemListResponseMessage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ConversationItemListResponseMessageContentUnion contains all possible properties +// and values from [string], +// [[]ConversationItemListResponseMessageContentArrayItemUnion], +// [[]ConversationItemListResponseMessageContentArrayItemUnion]. +// +// 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 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 + } `json:"-"` +} + +func (u ConversationItemListResponseMessageContentUnion) AsString() (v string) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemListResponseMessageContentUnion) AsConversationItemListResponseMessageContentArray() (v []ConversationItemListResponseMessageContentArrayItemUnion) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemListResponseMessageContentUnion) AsVariant2() (v []ConversationItemListResponseMessageContentArrayItemUnion) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ConversationItemListResponseMessageContentUnion) RawJSON() string { return u.JSON.raw } + +func (r *ConversationItemListResponseMessageContentUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ConversationItemListResponseMessageContentArrayItemUnion contains all possible +// properties and values from +// [ConversationItemListResponseMessageContentArrayItemInputText], +// [ConversationItemListResponseMessageContentArrayItemInputImage], +// [ConversationItemListResponseMessageContentArrayItemInputFile]. +// +// Use the [ConversationItemListResponseMessageContentArrayItemUnion.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 { + // This field is from variant + // [ConversationItemListResponseMessageContentArrayItemInputText]. + 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"` + // This field is from variant + // [ConversationItemListResponseMessageContentArrayItemInputImage]. + ImageURL string `json:"image_url"` + // This field is from variant + // [ConversationItemListResponseMessageContentArrayItemInputFile]. + FileData string `json:"file_data"` + // This field is from variant + // [ConversationItemListResponseMessageContentArrayItemInputFile]. + FileURL string `json:"file_url"` + // This field is from variant + // [ConversationItemListResponseMessageContentArrayItemInputFile]. + 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:"-"` +} + +// anyConversationItemListResponseMessageContentArrayItem is implemented by each +// variant of [ConversationItemListResponseMessageContentArrayItemUnion] to add +// type safety for the return type of +// [ConversationItemListResponseMessageContentArrayItemUnion.AsAny] +type anyConversationItemListResponseMessageContentArrayItem interface { + implConversationItemListResponseMessageContentArrayItemUnion() +} + +func (ConversationItemListResponseMessageContentArrayItemInputText) implConversationItemListResponseMessageContentArrayItemUnion() { +} +func (ConversationItemListResponseMessageContentArrayItemInputImage) implConversationItemListResponseMessageContentArrayItemUnion() { +} +func (ConversationItemListResponseMessageContentArrayItemInputFile) implConversationItemListResponseMessageContentArrayItemUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := ConversationItemListResponseMessageContentArrayItemUnion.AsAny().(type) { +// case llamastackclient.ConversationItemListResponseMessageContentArrayItemInputText: +// case llamastackclient.ConversationItemListResponseMessageContentArrayItemInputImage: +// case llamastackclient.ConversationItemListResponseMessageContentArrayItemInputFile: +// default: +// fmt.Errorf("no variant present") +// } +func (u ConversationItemListResponseMessageContentArrayItemUnion) AsAny() anyConversationItemListResponseMessageContentArrayItem { + 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 ConversationItemListResponseMessageContentArrayItemUnion) AsInputText() (v ConversationItemListResponseMessageContentArrayItemInputText) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemListResponseMessageContentArrayItemUnion) AsInputImage() (v ConversationItemListResponseMessageContentArrayItemInputImage) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemListResponseMessageContentArrayItemUnion) AsInputFile() (v ConversationItemListResponseMessageContentArrayItemInputFile) { + 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 (r *ConversationItemListResponseMessageContentArrayItemUnion) 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 + Text string `json:"text,required"` + // Content type identifier, always "input_text" + Type constant.InputText `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:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemListResponseMessageContentArrayItemInputText) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemListResponseMessageContentArrayItemInputText) 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" + // + // 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"` + // 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 + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemListResponseMessageContentArrayItemInputImage) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemListResponseMessageContentArrayItemInputImage) 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"` + // 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 + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemListResponseMessageContentArrayItemInputFile) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemListResponseMessageContentArrayItemInputFile) 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 + 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 { + // 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:"-"` +} + +// 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 { + // (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"` + // 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) +} + +// ConversationItemListResponseFileSearchCallResultAttributeUnion 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 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 + } `json:"-"` +} + +func (u ConversationItemListResponseFileSearchCallResultAttributeUnion) AsBool() (v bool) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemListResponseFileSearchCallResultAttributeUnion) AsFloat() (v float64) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemListResponseFileSearchCallResultAttributeUnion) AsString() (v string) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemListResponseFileSearchCallResultAttributeUnion) AsAnyArray() (v []any) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ConversationItemListResponseFileSearchCallResultAttributeUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *ConversationItemListResponseFileSearchCallResultAttributeUnion) 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"` + // 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 + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemListResponseFunctionCall) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemListResponseFunctionCall) 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 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"` + // 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:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemListResponseFunctionCallOutput) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemListResponseFunctionCallOutput) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` + // 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 ConversationItemListResponseMcpApprovalRequest) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemListResponseMcpApprovalRequest) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` + // 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:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemListResponseMcpApprovalResponse) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemListResponseMcpApprovalResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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 + 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"` + // 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 + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemListResponseMcpCall) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemListResponseMcpCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` + // 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 ConversationItemListResponseMcpListTools) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemListResponseMcpListTools) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` + // 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 ConversationItemListResponseMcpListToolsTool) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemListResponseMcpListToolsTool) UnmarshalJSON(data []byte) error { + 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 + } `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 { + 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"` + // 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"` + // 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 + 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 { + return apijson.UnmarshalRoot(data, r) +} + +// ConversationItemGetResponseMessageContentUnion contains all possible properties +// and values from [string], +// [[]ConversationItemGetResponseMessageContentArrayItemUnion], +// [[]ConversationItemGetResponseMessageContentArrayItemUnion]. +// +// 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 { + // 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 + } `json:"-"` +} + +func (u ConversationItemGetResponseMessageContentUnion) AsString() (v string) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemGetResponseMessageContentUnion) AsConversationItemGetResponseMessageContentArray() (v []ConversationItemGetResponseMessageContentArrayItemUnion) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemGetResponseMessageContentUnion) AsVariant2() (v []ConversationItemGetResponseMessageContentArrayItemUnion) { + 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 (r *ConversationItemGetResponseMessageContentUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ConversationItemGetResponseMessageContentArrayItemUnion contains all possible +// properties and values from +// [ConversationItemGetResponseMessageContentArrayItemInputText], +// [ConversationItemGetResponseMessageContentArrayItemInputImage], +// [ConversationItemGetResponseMessageContentArrayItemInputFile]. +// +// Use the [ConversationItemGetResponseMessageContentArrayItemUnion.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 { + // This field is from variant + // [ConversationItemGetResponseMessageContentArrayItemInputText]. + 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"` + // This field is from variant + // [ConversationItemGetResponseMessageContentArrayItemInputImage]. + ImageURL string `json:"image_url"` + // This field is from variant + // [ConversationItemGetResponseMessageContentArrayItemInputFile]. + FileData string `json:"file_data"` + // This field is from variant + // [ConversationItemGetResponseMessageContentArrayItemInputFile]. + FileURL string `json:"file_url"` + // This field is from variant + // [ConversationItemGetResponseMessageContentArrayItemInputFile]. + 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:"-"` +} + +// anyConversationItemGetResponseMessageContentArrayItem is implemented by each +// variant of [ConversationItemGetResponseMessageContentArrayItemUnion] to add type +// safety for the return type of +// [ConversationItemGetResponseMessageContentArrayItemUnion.AsAny] +type anyConversationItemGetResponseMessageContentArrayItem interface { + implConversationItemGetResponseMessageContentArrayItemUnion() +} + +func (ConversationItemGetResponseMessageContentArrayItemInputText) implConversationItemGetResponseMessageContentArrayItemUnion() { +} +func (ConversationItemGetResponseMessageContentArrayItemInputImage) implConversationItemGetResponseMessageContentArrayItemUnion() { +} +func (ConversationItemGetResponseMessageContentArrayItemInputFile) implConversationItemGetResponseMessageContentArrayItemUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := ConversationItemGetResponseMessageContentArrayItemUnion.AsAny().(type) { +// case llamastackclient.ConversationItemGetResponseMessageContentArrayItemInputText: +// case llamastackclient.ConversationItemGetResponseMessageContentArrayItemInputImage: +// case llamastackclient.ConversationItemGetResponseMessageContentArrayItemInputFile: +// default: +// fmt.Errorf("no variant present") +// } +func (u ConversationItemGetResponseMessageContentArrayItemUnion) AsAny() anyConversationItemGetResponseMessageContentArrayItem { + 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 ConversationItemGetResponseMessageContentArrayItemUnion) AsInputText() (v ConversationItemGetResponseMessageContentArrayItemInputText) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemGetResponseMessageContentArrayItemUnion) AsInputImage() (v ConversationItemGetResponseMessageContentArrayItemInputImage) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemGetResponseMessageContentArrayItemUnion) AsInputFile() (v ConversationItemGetResponseMessageContentArrayItemInputFile) { + 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 (r *ConversationItemGetResponseMessageContentArrayItemUnion) 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 + Text string `json:"text,required"` + // Content type identifier, always "input_text" + Type constant.InputText `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:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemGetResponseMessageContentArrayItemInputText) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemGetResponseMessageContentArrayItemInputText) 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" + // + // 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"` + // 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 + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemGetResponseMessageContentArrayItemInputImage) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemGetResponseMessageContentArrayItemInputImage) 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"` + // 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 + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemGetResponseMessageContentArrayItemInputFile) RawJSON() string { + return r.JSON.raw +} +func (r *ConversationItemGetResponseMessageContentArrayItemInputFile) 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 + Type respjson.Field + ExtraFields map[string]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) +} + +// 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:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemGetResponseFileSearchCall) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemGetResponseFileSearchCall) 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"` + // 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 ConversationItemGetResponseFileSearchCallResult) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemGetResponseFileSearchCallResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ConversationItemGetResponseFileSearchCallResultAttributeUnion 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 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 + } `json:"-"` +} + +func (u ConversationItemGetResponseFileSearchCallResultAttributeUnion) AsBool() (v bool) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemGetResponseFileSearchCallResultAttributeUnion) AsFloat() (v float64) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemGetResponseFileSearchCallResultAttributeUnion) AsString() (v string) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ConversationItemGetResponseFileSearchCallResultAttributeUnion) AsAnyArray() (v []any) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ConversationItemGetResponseFileSearchCallResultAttributeUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *ConversationItemGetResponseFileSearchCallResultAttributeUnion) 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"` + // 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 + 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:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemGetResponseFunctionCallOutput) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemGetResponseFunctionCallOutput) 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"` + // 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 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:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ConversationItemGetResponseMcpApprovalResponse) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemGetResponseMcpApprovalResponse) 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"` + // 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 + 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 { + 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"` + // 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 ConversationItemGetResponseMcpListTools) RawJSON() string { return r.JSON.raw } +func (r *ConversationItemGetResponseMcpListTools) 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"` + // 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 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 *ConversationItemGetResponseMcpListToolsToolInputSchemaUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type ConversationItemGetResponseRole string + +const ( + ConversationItemGetResponseRoleSystem ConversationItemGetResponseRole = "system" + ConversationItemGetResponseRoleDeveloper ConversationItemGetResponseRole = "developer" + ConversationItemGetResponseRoleUser ConversationItemGetResponseRole = "user" + ConversationItemGetResponseRoleAssistant ConversationItemGetResponseRole = "assistant" +) + +type ConversationItemNewParams struct { + // Items to include in the conversation context. + Items []ConversationItemNewParamsItemUnion `json:"items,omitzero,required"` + paramObj +} + +func (r ConversationItemNewParams) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationItemNewParams) 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 ConversationItemNewParamsItemUnion struct { + OfMessage *ConversationItemNewParamsItemMessage `json:",omitzero,inline"` + OfWebSearchCall *ConversationItemNewParamsItemWebSearchCall `json:",omitzero,inline"` + OfFileSearchCall *ConversationItemNewParamsItemFileSearchCall `json:",omitzero,inline"` + OfFunctionCall *ConversationItemNewParamsItemFunctionCall `json:",omitzero,inline"` + OfFunctionCallOutput *ConversationItemNewParamsItemFunctionCallOutput `json:",omitzero,inline"` + OfMcpApprovalRequest *ConversationItemNewParamsItemMcpApprovalRequest `json:",omitzero,inline"` + OfMcpApprovalResponse *ConversationItemNewParamsItemMcpApprovalResponse `json:",omitzero,inline"` + OfMcpCall *ConversationItemNewParamsItemMcpCall `json:",omitzero,inline"` + OfMcpListTools *ConversationItemNewParamsItemMcpListTools `json:",omitzero,inline"` + paramUnion +} + +func (u ConversationItemNewParamsItemUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfMessage, + u.OfWebSearchCall, + u.OfFileSearchCall, + u.OfFunctionCall, + u.OfFunctionCallOutput, + u.OfMcpApprovalRequest, + u.OfMcpApprovalResponse, + u.OfMcpCall, + u.OfMcpListTools) +} +func (u *ConversationItemNewParamsItemUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *ConversationItemNewParamsItemUnion) asAny() any { + if !param.IsOmitted(u.OfMessage) { + return u.OfMessage + } else if !param.IsOmitted(u.OfWebSearchCall) { + return u.OfWebSearchCall + } else if !param.IsOmitted(u.OfFileSearchCall) { + return u.OfFileSearchCall + } else if !param.IsOmitted(u.OfFunctionCall) { + return u.OfFunctionCall + } else if !param.IsOmitted(u.OfFunctionCallOutput) { + return u.OfFunctionCallOutput + } else if !param.IsOmitted(u.OfMcpApprovalRequest) { + return u.OfMcpApprovalRequest + } else if !param.IsOmitted(u.OfMcpApprovalResponse) { + return u.OfMcpApprovalResponse + } else if !param.IsOmitted(u.OfMcpCall) { + return u.OfMcpCall + } else if !param.IsOmitted(u.OfMcpListTools) { + return u.OfMcpListTools + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemUnion) GetContent() *ConversationItemNewParamsItemMessageContentUnion { + if vt := u.OfMessage; vt != nil { + return &vt.Content + } + return nil +} + +// 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 nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemUnion) GetQueries() []string { + if vt := u.OfFileSearchCall; vt != nil { + return vt.Queries + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemUnion) GetResults() []ConversationItemNewParamsItemFileSearchCallResult { + if vt := u.OfFileSearchCall; vt != nil { + return vt.Results + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemUnion) GetApprovalRequestID() *string { + if vt := u.OfMcpApprovalResponse; vt != nil { + return &vt.ApprovalRequestID + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemUnion) GetApprove() *bool { + if vt := u.OfMcpApprovalResponse; vt != nil { + return &vt.Approve + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemUnion) GetReason() *string { + if vt := u.OfMcpApprovalResponse; vt != nil && vt.Reason.Valid() { + return &vt.Reason.Value + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemUnion) GetError() *string { + if vt := u.OfMcpCall; vt != nil && vt.Error.Valid() { + return &vt.Error.Value + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemUnion) GetTools() []ConversationItemNewParamsItemMcpListToolsTool { + if vt := u.OfMcpListTools; vt != nil { + return vt.Tools + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemUnion) 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 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) 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) + } + 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.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, 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"` + 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) +} + +// 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 +} + +// 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"` + paramUnion +} + +func (u ConversationItemNewParamsItemMessageContentArrayItemUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfInputText, u.OfInputImage, u.OfInputFile) +} +func (u *ConversationItemNewParamsItemMessageContentArrayItemUnion) 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 + } + 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 + } + 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) + } + 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 + } + 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 + } + 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 + } + 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 + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ConversationItemNewParamsItemMessageContentArrayItemUnion) 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 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 + } + return nil +} + +func init() { + apijson.RegisterUnion[ConversationItemNewParamsItemMessageContentArrayItemUnion]( + "type", + apijson.Discriminator[ConversationItemNewParamsItemMessageContentArrayItemInputText]("input_text"), + apijson.Discriminator[ConversationItemNewParamsItemMessageContentArrayItemInputImage]("input_image"), + apijson.Discriminator[ConversationItemNewParamsItemMessageContentArrayItemInputFile]("input_file"), + ) +} + +// Text content for input messages in OpenAI response format. +// +// 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"` + paramObj +} + +func (r ConversationItemNewParamsItemMessageContentArrayItemInputText) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParamsItemMessageContentArrayItemInputText + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationItemNewParamsItemMessageContentArrayItemInputText) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Image content for input messages in OpenAI response format. +// +// 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"` + paramObj +} + +func (r ConversationItemNewParamsItemMessageContentArrayItemInputImage) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParamsItemMessageContentArrayItemInputImage + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationItemNewParamsItemMessageContentArrayItemInputImage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Level of detail for image processing, can be "low", "high", or "auto" +type ConversationItemNewParamsItemMessageContentArrayItemInputImageDetail string + +const ( + ConversationItemNewParamsItemMessageContentArrayItemInputImageDetailLow ConversationItemNewParamsItemMessageContentArrayItemInputImageDetail = "low" + ConversationItemNewParamsItemMessageContentArrayItemInputImageDetailHigh ConversationItemNewParamsItemMessageContentArrayItemInputImageDetail = "high" + ConversationItemNewParamsItemMessageContentArrayItemInputImageDetailAuto ConversationItemNewParamsItemMessageContentArrayItemInputImageDetail = "auto" +) + +// 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"` + paramObj +} + +func (r ConversationItemNewParamsItemMessageContentArrayItemInputFile) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParamsItemMessageContentArrayItemInputFile + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationItemNewParamsItemMessageContentArrayItemInputFile) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type ConversationItemNewParamsItemMessageRole string + +const ( + ConversationItemNewParamsItemMessageRoleSystem ConversationItemNewParamsItemMessageRole = "system" + ConversationItemNewParamsItemMessageRoleDeveloper ConversationItemNewParamsItemMessageRole = "developer" + ConversationItemNewParamsItemMessageRoleUser ConversationItemNewParamsItemMessageRole = "user" + ConversationItemNewParamsItemMessageRoleAssistant ConversationItemNewParamsItemMessageRole = "assistant" +) + +// Web search tool call output message for OpenAI responses. +// +// The properties ID, Status, Type are required. +type ConversationItemNewParamsItemWebSearchCall 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"` + paramObj +} + +func (r ConversationItemNewParamsItemWebSearchCall) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParamsItemWebSearchCall + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationItemNewParamsItemWebSearchCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// File search tool call output message for OpenAI responses. +// +// The properties ID, Queries, Status, Type 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 + 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"` + paramObj +} + +func (r ConversationItemNewParamsItemFileSearchCall) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParamsItemFileSearchCall + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationItemNewParamsItemFileSearchCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` + paramObj +} + +func (r ConversationItemNewParamsItemFileSearchCallResult) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParamsItemFileSearchCallResult + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationItemNewParamsItemFileSearchCallResult) 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 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. +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"` + paramObj +} + +func (r ConversationItemNewParamsItemFunctionCall) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParamsItemFunctionCall + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationItemNewParamsItemFunctionCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// This represents the output of a function call that gets passed back to the +// model. +// +// The properties CallID, Output, Type 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"` + paramObj +} + +func (r ConversationItemNewParamsItemFunctionCallOutput) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParamsItemFunctionCallOutput + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationItemNewParamsItemFunctionCallOutput) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// A request for human approval of a tool invocation. +// +// The properties ID, Arguments, Name, ServerLabel, Type 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"` + paramObj +} + +func (r ConversationItemNewParamsItemMcpApprovalRequest) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParamsItemMcpApprovalRequest + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationItemNewParamsItemMcpApprovalRequest) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// A response to an MCP approval request. +// +// The properties ApprovalRequestID, Approve, Type 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"` + paramObj +} + +func (r ConversationItemNewParamsItemMcpApprovalResponse) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParamsItemMcpApprovalResponse + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationItemNewParamsItemMcpApprovalResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Model Context Protocol (MCP) call output message for OpenAI responses. +// +// The properties ID, Arguments, Name, ServerLabel, Type 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"` + paramObj +} + +func (r ConversationItemNewParamsItemMcpCall) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParamsItemMcpCall + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationItemNewParamsItemMcpCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// MCP list tools output message containing available tools from an MCP server. +// +// The properties ID, ServerLabel, Tools, Type 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"` + paramObj +} + +func (r ConversationItemNewParamsItemMcpListTools) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParamsItemMcpListTools + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationItemNewParamsItemMcpListTools) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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 + Description param.Opt[string] `json:"description,omitzero"` + paramObj +} + +func (r ConversationItemNewParamsItemMcpListToolsTool) MarshalJSON() (data []byte, err error) { + type shadow ConversationItemNewParamsItemMcpListToolsTool + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ConversationItemNewParamsItemMcpListToolsTool) 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 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. + // + // 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 +} + +// URLQuery serializes [ConversationItemListParams]'s query parameters as +// `url.Values`. +func (r ConversationItemListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// The order to return items in (asc or desc, default desc). +type ConversationItemListParamsOrder string + +const ( + ConversationItemListParamsOrderAsc ConversationItemListParamsOrder = "asc" + ConversationItemListParamsOrderDesc ConversationItemListParamsOrder = "desc" +) + +type ConversationItemGetParams struct { + ConversationID string `path:"conversation_id,required" json:"-"` + paramObj +} diff --git a/conversationitem_test.go b/conversationitem_test.go new file mode 100644 index 0000000..02219a1 --- /dev/null +++ b/conversationitem_test.go @@ -0,0 +1,113 @@ +// 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 TestConversationItemNew(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.New( + context.TODO(), + "conversation_id", + llamastackclient.ConversationItemNewParams{ + Items: []llamastackclient.ConversationItemNewParamsItemUnion{{ + OfMessage: &llamastackclient.ConversationItemNewParamsItemMessage{ + Content: llamastackclient.ConversationItemNewParamsItemMessageContentUnion{ + OfString: llamastackclient.String("string"), + }, + Role: llamastackclient.ConversationItemNewParamsItemMessageRoleSystem, + ID: llamastackclient.String("id"), + Status: llamastackclient.String("status"), + }, + }}, + }, + ) + 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 TestConversationItemListWithOptionalParams(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.List( + context.TODO(), + "conversation_id", + llamastackclient.ConversationItemListParams{ + After: llamastackclient.String("after"), + Include: []string{"web_search_call.action.sources"}, + Limit: llamastackclient.Int(0), + Order: llamastackclient.ConversationItemListParamsOrderAsc, + }, + ) + 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 { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := llamastackclient.NewClient( + option.WithBaseURL(baseURL), + ) + _, err := client.Conversations.Items.Get( + context.TODO(), + "item_id", + llamastackclient.ConversationItemGetParams{ + 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()) + } +} diff --git a/embedding.go b/embedding.go index 168acd8..ac37302 100644 --- a/embedding.go +++ b/embedding.go @@ -1,3 +1,9 @@ +// 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 @@ -6,6 +12,7 @@ import ( "context" "encoding/json" "net/http" + "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" "github.com/llamastack/llama-stack-client-go/internal/requestconfig" @@ -34,11 +41,11 @@ func NewEmbeddingService(opts ...option.RequestOption) (r EmbeddingService) { return } -// 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 = append(r.Options[:], opts...) - path := "v1/openai/v1/embeddings" + opts = slices.Concat(r.Options, opts) + path := "v1/embeddings" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return } diff --git a/embedding_test.go b/embedding_test.go index a49b6e7..609d6c6 100644 --- a/embedding_test.go +++ b/embedding_test.go @@ -1,3 +1,9 @@ +// 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 diff --git a/file.go b/file.go index 166eebd..a07d61e 100644 --- a/file.go +++ b/file.go @@ -1,3 +1,9 @@ +// 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 @@ -11,6 +17,7 @@ import ( "mime/multipart" "net/http" "net/url" + "slices" "github.com/llamastack/llama-stack-client-go/internal/apiform" "github.com/llamastack/llama-stack-client-go/internal/apijson" @@ -42,36 +49,38 @@ func NewFileService(opts ...option.RequestOption) (r FileService) { return } -// Upload a file that can be used across various endpoints. The file upload should -// be a multipart form request with: +// Upload file. Upload a file that can be used across various endpoints. +// +// The file upload should be a multipart form request with: // // - file: The File object (not file name) to be uploaded. // - purpose: The intended purpose of the uploaded file. +// - expires_after: Optional form values describing expiration for the file. func (r *FileService) New(ctx context.Context, body FileNewParams, opts ...option.RequestOption) (res *File, err error) { - opts = append(r.Options[:], opts...) - path := "v1/openai/v1/files" + opts = slices.Concat(r.Options, opts) + path := "v1/files" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return } -// 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 = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if fileID == "" { err = errors.New("missing required file_id parameter") return } - path := fmt.Sprintf("v1/openai/v1/files/%s", fileID) + path := fmt.Sprintf("v1/files/%s", fileID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return } -// 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 = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := "v1/openai/v1/files" + path := "v1/files" cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) if err != nil { return nil, err @@ -84,31 +93,31 @@ func (r *FileService) List(ctx context.Context, query FileListParams, opts ...op return res, nil } -// 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...)) } -// Delete a file. +// Delete file. func (r *FileService) Delete(ctx context.Context, fileID string, opts ...option.RequestOption) (res *DeleteFileResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if fileID == "" { err = errors.New("missing required file_id parameter") return } - path := fmt.Sprintf("v1/openai/v1/files/%s", fileID) + path := fmt.Sprintf("v1/files/%s", fileID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) return } -// 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 = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if fileID == "" { err = errors.New("missing required file_id parameter") return } - path := fmt.Sprintf("v1/openai/v1/files/%s/content", fileID) + path := fmt.Sprintf("v1/files/%s/content", fileID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return } @@ -153,7 +162,7 @@ type File struct { Object constant.File `json:"object,required"` // The intended purpose of the file // - // Any of "assistants". + // Any of "assistants", "batch". Purpose FilePurpose `json:"purpose,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { @@ -180,6 +189,7 @@ type FilePurpose string const ( FilePurposeAssistants FilePurpose = "assistants" + FilePurposeBatch FilePurpose = "batch" ) // Response for listing files in OpenAI Files API. @@ -218,8 +228,13 @@ type FileNewParams struct { File io.Reader `json:"file,omitzero,required" format:"binary"` // Valid purpose values for OpenAI Files API. // - // Any of "assistants". + // Any of "assistants", "batch". Purpose FileNewParamsPurpose `json:"purpose,omitzero,required"` + // Control expiration of uploaded files. Params: + // + // - anchor, must be "created_at" + // - seconds, must be int between 3600 and 2592000 (1 hour to 30 days) + ExpiresAfter FileNewParamsExpiresAfter `json:"expires_after,omitzero"` paramObj } @@ -246,8 +261,30 @@ type FileNewParamsPurpose string const ( FileNewParamsPurposeAssistants FileNewParamsPurpose = "assistants" + FileNewParamsPurposeBatch FileNewParamsPurpose = "batch" ) +// Control expiration of uploaded files. Params: +// +// - anchor, must be "created_at" +// - seconds, must be int between 3600 and 2592000 (1 hour to 30 days) +// +// The properties Anchor, Seconds are required. +type FileNewParamsExpiresAfter struct { + Seconds int64 `json:"seconds,required"` + // This field can be elided, and will marshal its zero value as "created_at". + Anchor constant.CreatedAt `json:"anchor,required"` + paramObj +} + +func (r FileNewParamsExpiresAfter) MarshalJSON() (data []byte, err error) { + type shadow FileNewParamsExpiresAfter + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *FileNewParamsExpiresAfter) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + 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, @@ -264,7 +301,7 @@ type FileListParams struct { Order FileListParamsOrder `query:"order,omitzero" json:"-"` // Only return files with the given purpose. // - // Any of "assistants". + // Any of "assistants", "batch". Purpose FileListParamsPurpose `query:"purpose,omitzero" json:"-"` paramObj } @@ -291,4 +328,5 @@ type FileListParamsPurpose string const ( FileListParamsPurposeAssistants FileListParamsPurpose = "assistants" + FileListParamsPurposeBatch FileListParamsPurpose = "batch" ) diff --git a/file_test.go b/file_test.go index 8f6b65c..1622855 100644 --- a/file_test.go +++ b/file_test.go @@ -1,3 +1,9 @@ +// 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 @@ -15,7 +21,7 @@ import ( "github.com/llamastack/llama-stack-client-go/option" ) -func TestFileNew(t *testing.T) { +func TestFileNewWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -29,6 +35,9 @@ func TestFileNew(t *testing.T) { _, err := client.Files.New(context.TODO(), llamastackclient.FileNewParams{ File: io.Reader(bytes.NewBuffer([]byte("some file contents"))), Purpose: llamastackclient.FileNewParamsPurposeAssistants, + ExpiresAfter: llamastackclient.FileNewParamsExpiresAfter{ + Seconds: 0, + }, }) if err != nil { var apierr *llamastackclient.Error diff --git a/go.mod b/go.mod index 40c90a9..5483c07 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,9 @@ module github.com/llamastack/llama-stack-client-go -go 1.21 +go 1.22 require ( - github.com/tidwall/gjson v1.14.4 + github.com/tidwall/gjson v1.18.0 github.com/tidwall/sjson v1.2.5 ) diff --git a/go.sum b/go.sum index a70a5e0..32ba293 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,6 @@ github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= -github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= +github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= diff --git a/inference.go b/inference.go deleted file mode 100644 index 85c0c62..0000000 --- a/inference.go +++ /dev/null @@ -1,654 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package llamastackclient - -import ( - "context" - "net/http" - - "github.com/llamastack/llama-stack-client-go/internal/apijson" - "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/packages/ssestream" - "github.com/llamastack/llama-stack-client-go/shared" -) - -// InferenceService 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 [NewInferenceService] method instead. -type InferenceService struct { - Options []option.RequestOption -} - -// NewInferenceService 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 NewInferenceService(opts ...option.RequestOption) (r InferenceService) { - r = InferenceService{} - r.Options = opts - return -} - -// Generate chat completions for a batch of messages using the specified model. -func (r *InferenceService) BatchChatCompletion(ctx context.Context, body InferenceBatchChatCompletionParams, opts ...option.RequestOption) (res *InferenceBatchChatCompletionResponse, err error) { - opts = append(r.Options[:], opts...) - path := "v1/inference/batch-chat-completion" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) - return -} - -// Generate completions for a batch of content using the specified model. -func (r *InferenceService) BatchCompletion(ctx context.Context, body InferenceBatchCompletionParams, opts ...option.RequestOption) (res *shared.BatchCompletion, err error) { - opts = append(r.Options[:], opts...) - path := "v1/inference/batch-completion" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) - return -} - -// Generate a chat completion for the given messages using the specified model. -// -// Deprecated: /v1/inference/chat-completion is deprecated. Please use -// /v1/openai/v1/chat/completions. -func (r *InferenceService) ChatCompletion(ctx context.Context, body InferenceChatCompletionParams, opts ...option.RequestOption) (res *shared.ChatCompletionResponse, err error) { - opts = append(r.Options[:], opts...) - path := "v1/inference/chat-completion" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) - return -} - -// Generate a chat completion for the given messages using the specified model. -// -// Deprecated: /v1/inference/chat-completion is deprecated. Please use -// /v1/openai/v1/chat/completions. -func (r *InferenceService) ChatCompletionStreaming(ctx context.Context, body InferenceChatCompletionParams, opts ...option.RequestOption) (stream *ssestream.Stream[ChatCompletionResponseStreamChunk]) { - var ( - raw *http.Response - err error - ) - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithJSONSet("stream", true)}, opts...) - path := "v1/inference/chat-completion" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &raw, opts...) - return ssestream.NewStream[ChatCompletionResponseStreamChunk](ssestream.NewDecoder(raw), err) -} - -// Generate a completion for the given content using the specified model. -// -// Deprecated: /v1/inference/completion is deprecated. Please use -// /v1/openai/v1/completions. -func (r *InferenceService) Completion(ctx context.Context, body InferenceCompletionParams, opts ...option.RequestOption) (res *shared.SharedCompletionResponse, err error) { - opts = append(r.Options[:], opts...) - path := "v1/inference/completion" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) - return -} - -// Generate a completion for the given content using the specified model. -// -// Deprecated: /v1/inference/completion is deprecated. Please use -// /v1/openai/v1/completions. -func (r *InferenceService) CompletionStreaming(ctx context.Context, body InferenceCompletionParams, opts ...option.RequestOption) (stream *ssestream.Stream[shared.SharedCompletionResponse]) { - var ( - raw *http.Response - err error - ) - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithJSONSet("stream", true)}, opts...) - path := "v1/inference/completion" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &raw, opts...) - return ssestream.NewStream[shared.SharedCompletionResponse](ssestream.NewDecoder(raw), err) -} - -// Generate embeddings for content pieces using the specified model. -// -// Deprecated: /v1/inference/embeddings is deprecated. Please use -// /v1/openai/v1/embeddings. -func (r *InferenceService) Embeddings(ctx context.Context, body InferenceEmbeddingsParams, opts ...option.RequestOption) (res *EmbeddingsResponse, err error) { - opts = append(r.Options[:], opts...) - path := "v1/inference/embeddings" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) - return -} - -// A chunk of a streamed chat completion response. -type ChatCompletionResponseStreamChunk struct { - // The event containing the new content - Event ChatCompletionResponseStreamChunkEvent `json:"event,required"` - // (Optional) List of metrics associated with the API response - Metrics []ChatCompletionResponseStreamChunkMetric `json:"metrics"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Event respjson.Field - Metrics respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ChatCompletionResponseStreamChunk) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionResponseStreamChunk) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// The event containing the new content -type ChatCompletionResponseStreamChunkEvent struct { - // Content generated since last event. This can be one or more tokens, or a tool - // call. - Delta shared.ContentDeltaUnion `json:"delta,required"` - // Type of the event - // - // Any of "start", "complete", "progress". - EventType string `json:"event_type,required"` - // Optional log probabilities for generated tokens - Logprobs []ChatCompletionResponseStreamChunkEventLogprob `json:"logprobs"` - // Optional reason why generation stopped, if complete - // - // Any of "end_of_turn", "end_of_message", "out_of_tokens". - StopReason string `json:"stop_reason"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Delta respjson.Field - EventType respjson.Field - Logprobs respjson.Field - StopReason respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ChatCompletionResponseStreamChunkEvent) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionResponseStreamChunkEvent) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Log probabilities for generated tokens. -type ChatCompletionResponseStreamChunkEventLogprob struct { - // Dictionary mapping tokens to their log probabilities - LogprobsByToken map[string]float64 `json:"logprobs_by_token,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - LogprobsByToken respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ChatCompletionResponseStreamChunkEventLogprob) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionResponseStreamChunkEventLogprob) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A metric value included in API responses. -type ChatCompletionResponseStreamChunkMetric struct { - // The name of the metric - Metric string `json:"metric,required"` - // The numeric value of the metric - Value float64 `json:"value,required"` - // (Optional) The unit of measurement for the metric value - Unit string `json:"unit"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Metric respjson.Field - Value respjson.Field - Unit respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ChatCompletionResponseStreamChunkMetric) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionResponseStreamChunkMetric) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Response containing generated embeddings. -type EmbeddingsResponse struct { - // List of embedding vectors, one per input content. Each embedding is a list of - // floats. The dimensionality of the embedding is model-specific; you can check - // model metadata using /models/{model_id} - Embeddings [][]float64 `json:"embeddings,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Embeddings respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r EmbeddingsResponse) RawJSON() string { return r.JSON.raw } -func (r *EmbeddingsResponse) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Response from a batch chat completion request. -type InferenceBatchChatCompletionResponse struct { - // List of chat completion responses, one for each conversation in the batch - Batch []shared.ChatCompletionResponse `json:"batch,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Batch respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r InferenceBatchChatCompletionResponse) RawJSON() string { return r.JSON.raw } -func (r *InferenceBatchChatCompletionResponse) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type InferenceBatchChatCompletionParams struct { - // The messages to generate completions for. - MessagesBatch [][]shared.MessageUnionParam `json:"messages_batch,omitzero,required"` - // The identifier of the model to use. The model must be registered with Llama - // Stack and available via the /models endpoint. - ModelID string `json:"model_id,required"` - // (Optional) If specified, log probabilities for each token position will be - // returned. - Logprobs InferenceBatchChatCompletionParamsLogprobs `json:"logprobs,omitzero"` - // (Optional) Grammar specification for guided (structured) decoding. - ResponseFormat shared.ResponseFormatUnionParam `json:"response_format,omitzero"` - // (Optional) Parameters to control the sampling strategy. - SamplingParams shared.SamplingParams `json:"sampling_params,omitzero"` - // (Optional) Configuration for tool use. - ToolConfig InferenceBatchChatCompletionParamsToolConfig `json:"tool_config,omitzero"` - // (Optional) List of tool definitions available to the model. - Tools []InferenceBatchChatCompletionParamsTool `json:"tools,omitzero"` - paramObj -} - -func (r InferenceBatchChatCompletionParams) MarshalJSON() (data []byte, err error) { - type shadow InferenceBatchChatCompletionParams - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *InferenceBatchChatCompletionParams) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// (Optional) If specified, log probabilities for each token position will be -// returned. -type InferenceBatchChatCompletionParamsLogprobs struct { - // How many tokens (for each position) to return log probabilities for. - TopK param.Opt[int64] `json:"top_k,omitzero"` - paramObj -} - -func (r InferenceBatchChatCompletionParamsLogprobs) MarshalJSON() (data []byte, err error) { - type shadow InferenceBatchChatCompletionParamsLogprobs - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *InferenceBatchChatCompletionParamsLogprobs) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// (Optional) Configuration for tool use. -type InferenceBatchChatCompletionParamsToolConfig struct { - // (Optional) Config for how to override the default system prompt. - - // `SystemMessageBehavior.append`: Appends the provided system message to the - // default system prompt. - `SystemMessageBehavior.replace`: Replaces the default - // system prompt with the provided system message. The system message can include - // the string '{{function_definitions}}' to indicate where the function definitions - // should be inserted. - // - // Any of "append", "replace". - SystemMessageBehavior string `json:"system_message_behavior,omitzero"` - // (Optional) Whether tool use is automatic, required, or none. Can also specify a - // tool name to use a specific tool. Defaults to ToolChoice.auto. - ToolChoice string `json:"tool_choice,omitzero"` - // (Optional) Instructs the model how to format tool calls. By default, Llama Stack - // will attempt to use a format that is best adapted to the model. - - // `ToolPromptFormat.json`: The tool calls are formatted as a JSON object. - - // `ToolPromptFormat.function_tag`: The tool calls are enclosed in a - // tag. - `ToolPromptFormat.python_list`: The tool calls - // are output as Python syntax -- a list of function calls. - // - // Any of "json", "function_tag", "python_list". - ToolPromptFormat string `json:"tool_prompt_format,omitzero"` - paramObj -} - -func (r InferenceBatchChatCompletionParamsToolConfig) MarshalJSON() (data []byte, err error) { - type shadow InferenceBatchChatCompletionParamsToolConfig - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *InferenceBatchChatCompletionParamsToolConfig) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -func init() { - apijson.RegisterFieldValidator[InferenceBatchChatCompletionParamsToolConfig]( - "system_message_behavior", "append", "replace", - ) - apijson.RegisterFieldValidator[InferenceBatchChatCompletionParamsToolConfig]( - "tool_prompt_format", "json", "function_tag", "python_list", - ) -} - -// The property ToolName is required. -type InferenceBatchChatCompletionParamsTool struct { - ToolName string `json:"tool_name,omitzero,required"` - Description param.Opt[string] `json:"description,omitzero"` - Parameters map[string]shared.ToolParamDefinition `json:"parameters,omitzero"` - paramObj -} - -func (r InferenceBatchChatCompletionParamsTool) MarshalJSON() (data []byte, err error) { - type shadow InferenceBatchChatCompletionParamsTool - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *InferenceBatchChatCompletionParamsTool) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type InferenceBatchCompletionParams struct { - // The content to generate completions for. - ContentBatch []shared.InterleavedContentUnionParam `json:"content_batch,omitzero,required"` - // The identifier of the model to use. The model must be registered with Llama - // Stack and available via the /models endpoint. - ModelID string `json:"model_id,required"` - // (Optional) If specified, log probabilities for each token position will be - // returned. - Logprobs InferenceBatchCompletionParamsLogprobs `json:"logprobs,omitzero"` - // (Optional) Grammar specification for guided (structured) decoding. - ResponseFormat shared.ResponseFormatUnionParam `json:"response_format,omitzero"` - // (Optional) Parameters to control the sampling strategy. - SamplingParams shared.SamplingParams `json:"sampling_params,omitzero"` - paramObj -} - -func (r InferenceBatchCompletionParams) MarshalJSON() (data []byte, err error) { - type shadow InferenceBatchCompletionParams - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *InferenceBatchCompletionParams) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// (Optional) If specified, log probabilities for each token position will be -// returned. -type InferenceBatchCompletionParamsLogprobs struct { - // How many tokens (for each position) to return log probabilities for. - TopK param.Opt[int64] `json:"top_k,omitzero"` - paramObj -} - -func (r InferenceBatchCompletionParamsLogprobs) MarshalJSON() (data []byte, err error) { - type shadow InferenceBatchCompletionParamsLogprobs - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *InferenceBatchCompletionParamsLogprobs) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type InferenceChatCompletionParams struct { - // List of messages in the conversation. - Messages []shared.MessageUnionParam `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. - ModelID string `json:"model_id,required"` - // (Optional) If specified, log probabilities for each token position will be - // returned. - Logprobs InferenceChatCompletionParamsLogprobs `json:"logprobs,omitzero"` - // (Optional) Grammar specification for guided (structured) decoding. There are two - // options: - `ResponseFormat.json_schema`: The grammar is a JSON schema. Most - // providers support this format. - `ResponseFormat.grammar`: The grammar is a BNF - // grammar. This format is more flexible, but not all providers support it. - ResponseFormat shared.ResponseFormatUnionParam `json:"response_format,omitzero"` - // Parameters to control the sampling strategy. - SamplingParams shared.SamplingParams `json:"sampling_params,omitzero"` - // (Optional) Whether tool use is required or automatic. Defaults to - // ToolChoice.auto. .. deprecated:: Use tool_config instead. - // - // Any of "auto", "required", "none". - ToolChoice InferenceChatCompletionParamsToolChoice `json:"tool_choice,omitzero"` - // (Optional) Configuration for tool use. - ToolConfig InferenceChatCompletionParamsToolConfig `json:"tool_config,omitzero"` - // (Optional) Instructs the model how to format tool calls. By default, Llama Stack - // will attempt to use a format that is best adapted to the model. - - // `ToolPromptFormat.json`: The tool calls are formatted as a JSON object. - - // `ToolPromptFormat.function_tag`: The tool calls are enclosed in a - // tag. - `ToolPromptFormat.python_list`: The tool calls - // are output as Python syntax -- a list of function calls. .. deprecated:: Use - // tool_config instead. - // - // Any of "json", "function_tag", "python_list". - ToolPromptFormat InferenceChatCompletionParamsToolPromptFormat `json:"tool_prompt_format,omitzero"` - // (Optional) List of tool definitions available to the model. - Tools []InferenceChatCompletionParamsTool `json:"tools,omitzero"` - paramObj -} - -func (r InferenceChatCompletionParams) MarshalJSON() (data []byte, err error) { - type shadow InferenceChatCompletionParams - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *InferenceChatCompletionParams) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// (Optional) If specified, log probabilities for each token position will be -// returned. -type InferenceChatCompletionParamsLogprobs struct { - // How many tokens (for each position) to return log probabilities for. - TopK param.Opt[int64] `json:"top_k,omitzero"` - paramObj -} - -func (r InferenceChatCompletionParamsLogprobs) MarshalJSON() (data []byte, err error) { - type shadow InferenceChatCompletionParamsLogprobs - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *InferenceChatCompletionParamsLogprobs) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// (Optional) Whether tool use is required or automatic. Defaults to -// ToolChoice.auto. .. deprecated:: Use tool_config instead. -type InferenceChatCompletionParamsToolChoice string - -const ( - InferenceChatCompletionParamsToolChoiceAuto InferenceChatCompletionParamsToolChoice = "auto" - InferenceChatCompletionParamsToolChoiceRequired InferenceChatCompletionParamsToolChoice = "required" - InferenceChatCompletionParamsToolChoiceNone InferenceChatCompletionParamsToolChoice = "none" -) - -// (Optional) Configuration for tool use. -type InferenceChatCompletionParamsToolConfig struct { - // (Optional) Config for how to override the default system prompt. - - // `SystemMessageBehavior.append`: Appends the provided system message to the - // default system prompt. - `SystemMessageBehavior.replace`: Replaces the default - // system prompt with the provided system message. The system message can include - // the string '{{function_definitions}}' to indicate where the function definitions - // should be inserted. - // - // Any of "append", "replace". - SystemMessageBehavior string `json:"system_message_behavior,omitzero"` - // (Optional) Whether tool use is automatic, required, or none. Can also specify a - // tool name to use a specific tool. Defaults to ToolChoice.auto. - ToolChoice string `json:"tool_choice,omitzero"` - // (Optional) Instructs the model how to format tool calls. By default, Llama Stack - // will attempt to use a format that is best adapted to the model. - - // `ToolPromptFormat.json`: The tool calls are formatted as a JSON object. - - // `ToolPromptFormat.function_tag`: The tool calls are enclosed in a - // tag. - `ToolPromptFormat.python_list`: The tool calls - // are output as Python syntax -- a list of function calls. - // - // Any of "json", "function_tag", "python_list". - ToolPromptFormat string `json:"tool_prompt_format,omitzero"` - paramObj -} - -func (r InferenceChatCompletionParamsToolConfig) MarshalJSON() (data []byte, err error) { - type shadow InferenceChatCompletionParamsToolConfig - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *InferenceChatCompletionParamsToolConfig) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -func init() { - apijson.RegisterFieldValidator[InferenceChatCompletionParamsToolConfig]( - "system_message_behavior", "append", "replace", - ) - apijson.RegisterFieldValidator[InferenceChatCompletionParamsToolConfig]( - "tool_prompt_format", "json", "function_tag", "python_list", - ) -} - -// (Optional) Instructs the model how to format tool calls. By default, Llama Stack -// will attempt to use a format that is best adapted to the model. - -// `ToolPromptFormat.json`: The tool calls are formatted as a JSON object. - -// `ToolPromptFormat.function_tag`: The tool calls are enclosed in a -// tag. - `ToolPromptFormat.python_list`: The tool calls -// are output as Python syntax -- a list of function calls. .. deprecated:: Use -// tool_config instead. -type InferenceChatCompletionParamsToolPromptFormat string - -const ( - InferenceChatCompletionParamsToolPromptFormatJson InferenceChatCompletionParamsToolPromptFormat = "json" - InferenceChatCompletionParamsToolPromptFormatFunctionTag InferenceChatCompletionParamsToolPromptFormat = "function_tag" - InferenceChatCompletionParamsToolPromptFormatPythonList InferenceChatCompletionParamsToolPromptFormat = "python_list" -) - -// The property ToolName is required. -type InferenceChatCompletionParamsTool struct { - ToolName string `json:"tool_name,omitzero,required"` - Description param.Opt[string] `json:"description,omitzero"` - Parameters map[string]shared.ToolParamDefinition `json:"parameters,omitzero"` - paramObj -} - -func (r InferenceChatCompletionParamsTool) MarshalJSON() (data []byte, err error) { - type shadow InferenceChatCompletionParamsTool - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *InferenceChatCompletionParamsTool) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type InferenceCompletionParams struct { - // The content to generate a completion for. - Content shared.InterleavedContentUnionParam `json:"content,omitzero,required"` - // The identifier of the model to use. The model must be registered with Llama - // Stack and available via the /models endpoint. - ModelID string `json:"model_id,required"` - // (Optional) If specified, log probabilities for each token position will be - // returned. - Logprobs InferenceCompletionParamsLogprobs `json:"logprobs,omitzero"` - // (Optional) Grammar specification for guided (structured) decoding. - ResponseFormat shared.ResponseFormatUnionParam `json:"response_format,omitzero"` - // (Optional) Parameters to control the sampling strategy. - SamplingParams shared.SamplingParams `json:"sampling_params,omitzero"` - paramObj -} - -func (r InferenceCompletionParams) MarshalJSON() (data []byte, err error) { - type shadow InferenceCompletionParams - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *InferenceCompletionParams) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// (Optional) If specified, log probabilities for each token position will be -// returned. -type InferenceCompletionParamsLogprobs struct { - // How many tokens (for each position) to return log probabilities for. - TopK param.Opt[int64] `json:"top_k,omitzero"` - paramObj -} - -func (r InferenceCompletionParamsLogprobs) MarshalJSON() (data []byte, err error) { - type shadow InferenceCompletionParamsLogprobs - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *InferenceCompletionParamsLogprobs) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type InferenceEmbeddingsParams struct { - // List of contents to generate embeddings for. Each content can be a string or an - // InterleavedContentItem (and hence can be multimodal). The behavior depends on - // the model and provider. Some models may only support text. - Contents InferenceEmbeddingsParamsContentsUnion `json:"contents,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. - ModelID string `json:"model_id,required"` - // (Optional) Output dimensionality for the embeddings. Only supported by - // Matryoshka models. - OutputDimension param.Opt[int64] `json:"output_dimension,omitzero"` - // (Optional) How is the embedding being used? This is only supported by asymmetric - // embedding models. - // - // Any of "query", "document". - TaskType InferenceEmbeddingsParamsTaskType `json:"task_type,omitzero"` - // (Optional) Config for how to truncate text for embedding when text is longer - // than the model's max sequence length. - // - // Any of "none", "start", "end". - TextTruncation InferenceEmbeddingsParamsTextTruncation `json:"text_truncation,omitzero"` - paramObj -} - -func (r InferenceEmbeddingsParams) MarshalJSON() (data []byte, err error) { - type shadow InferenceEmbeddingsParams - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *InferenceEmbeddingsParams) 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 InferenceEmbeddingsParamsContentsUnion struct { - OfStringArray []string `json:",omitzero,inline"` - OfInterleavedContentItemArray []shared.InterleavedContentItemUnionParam `json:",omitzero,inline"` - paramUnion -} - -func (u InferenceEmbeddingsParamsContentsUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfStringArray, u.OfInterleavedContentItemArray) -} -func (u *InferenceEmbeddingsParamsContentsUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *InferenceEmbeddingsParamsContentsUnion) asAny() any { - if !param.IsOmitted(u.OfStringArray) { - return &u.OfStringArray - } else if !param.IsOmitted(u.OfInterleavedContentItemArray) { - return &u.OfInterleavedContentItemArray - } - return nil -} - -// (Optional) How is the embedding being used? This is only supported by asymmetric -// embedding models. -type InferenceEmbeddingsParamsTaskType string - -const ( - InferenceEmbeddingsParamsTaskTypeQuery InferenceEmbeddingsParamsTaskType = "query" - InferenceEmbeddingsParamsTaskTypeDocument InferenceEmbeddingsParamsTaskType = "document" -) - -// (Optional) Config for how to truncate text for embedding when text is longer -// than the model's max sequence length. -type InferenceEmbeddingsParamsTextTruncation string - -const ( - InferenceEmbeddingsParamsTextTruncationNone InferenceEmbeddingsParamsTextTruncation = "none" - InferenceEmbeddingsParamsTextTruncationStart InferenceEmbeddingsParamsTextTruncation = "start" - InferenceEmbeddingsParamsTextTruncationEnd InferenceEmbeddingsParamsTextTruncation = "end" -) diff --git a/inference_test.go b/inference_test.go deleted file mode 100644 index efec760..0000000 --- a/inference_test.go +++ /dev/null @@ -1,282 +0,0 @@ -// 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" - "github.com/llamastack/llama-stack-client-go/shared" -) - -func TestInferenceBatchChatCompletionWithOptionalParams(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.Inference.BatchChatCompletion(context.TODO(), llamastackclient.InferenceBatchChatCompletionParams{ - MessagesBatch: [][]shared.MessageUnionParam{{{ - OfUser: &shared.UserMessageParam{ - Content: shared.InterleavedContentUnionParam{ - OfString: llamastackclient.String("string"), - }, - Context: shared.InterleavedContentUnionParam{ - OfString: llamastackclient.String("string"), - }, - }, - }}}, - ModelID: "model_id", - Logprobs: llamastackclient.InferenceBatchChatCompletionParamsLogprobs{ - TopK: llamastackclient.Int(0), - }, - ResponseFormat: shared.ResponseFormatUnionParam{ - OfJsonSchema: &shared.ResponseFormatJsonSchemaParam{ - JsonSchema: map[string]shared.ResponseFormatJsonSchemaJsonSchemaUnionParam{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, - }, - }, - }, - SamplingParams: shared.SamplingParams{ - Strategy: shared.SamplingParamsStrategyUnion{ - OfGreedy: &shared.SamplingParamsStrategyGreedy{}, - }, - MaxTokens: llamastackclient.Int(0), - RepetitionPenalty: llamastackclient.Float(0), - Stop: []string{"string"}, - }, - ToolConfig: llamastackclient.InferenceBatchChatCompletionParamsToolConfig{ - SystemMessageBehavior: "append", - ToolChoice: "auto", - ToolPromptFormat: "json", - }, - Tools: []llamastackclient.InferenceBatchChatCompletionParamsTool{{ - ToolName: "brave_search", - Description: llamastackclient.String("description"), - Parameters: map[string]shared.ToolParamDefinition{ - "foo": { - ParamType: "param_type", - Default: shared.ToolParamDefinitionDefaultUnion{ - OfBool: llamastackclient.Bool(true), - }, - Description: llamastackclient.String("description"), - Required: llamastackclient.Bool(true), - }, - }, - }}, - }) - 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 TestInferenceBatchCompletionWithOptionalParams(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.Inference.BatchCompletion(context.TODO(), llamastackclient.InferenceBatchCompletionParams{ - ContentBatch: []shared.InterleavedContentUnionParam{{ - OfString: llamastackclient.String("string"), - }}, - ModelID: "model_id", - Logprobs: llamastackclient.InferenceBatchCompletionParamsLogprobs{ - TopK: llamastackclient.Int(0), - }, - ResponseFormat: shared.ResponseFormatUnionParam{ - OfJsonSchema: &shared.ResponseFormatJsonSchemaParam{ - JsonSchema: map[string]shared.ResponseFormatJsonSchemaJsonSchemaUnionParam{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, - }, - }, - }, - SamplingParams: shared.SamplingParams{ - Strategy: shared.SamplingParamsStrategyUnion{ - OfGreedy: &shared.SamplingParamsStrategyGreedy{}, - }, - MaxTokens: llamastackclient.Int(0), - RepetitionPenalty: llamastackclient.Float(0), - Stop: []string{"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 TestInferenceChatCompletionWithOptionalParams(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.Inference.ChatCompletion(context.TODO(), llamastackclient.InferenceChatCompletionParams{ - Messages: []shared.MessageUnionParam{{ - OfUser: &shared.UserMessageParam{ - Content: shared.InterleavedContentUnionParam{ - OfString: llamastackclient.String("string"), - }, - Context: shared.InterleavedContentUnionParam{ - OfString: llamastackclient.String("string"), - }, - }, - }}, - ModelID: "model_id", - Logprobs: llamastackclient.InferenceChatCompletionParamsLogprobs{ - TopK: llamastackclient.Int(0), - }, - ResponseFormat: shared.ResponseFormatUnionParam{ - OfJsonSchema: &shared.ResponseFormatJsonSchemaParam{ - JsonSchema: map[string]shared.ResponseFormatJsonSchemaJsonSchemaUnionParam{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, - }, - }, - }, - SamplingParams: shared.SamplingParams{ - Strategy: shared.SamplingParamsStrategyUnion{ - OfGreedy: &shared.SamplingParamsStrategyGreedy{}, - }, - MaxTokens: llamastackclient.Int(0), - RepetitionPenalty: llamastackclient.Float(0), - Stop: []string{"string"}, - }, - ToolChoice: llamastackclient.InferenceChatCompletionParamsToolChoiceAuto, - ToolConfig: llamastackclient.InferenceChatCompletionParamsToolConfig{ - SystemMessageBehavior: "append", - ToolChoice: "auto", - ToolPromptFormat: "json", - }, - ToolPromptFormat: llamastackclient.InferenceChatCompletionParamsToolPromptFormatJson, - Tools: []llamastackclient.InferenceChatCompletionParamsTool{{ - ToolName: "brave_search", - Description: llamastackclient.String("description"), - Parameters: map[string]shared.ToolParamDefinition{ - "foo": { - ParamType: "param_type", - Default: shared.ToolParamDefinitionDefaultUnion{ - OfBool: llamastackclient.Bool(true), - }, - Description: llamastackclient.String("description"), - Required: llamastackclient.Bool(true), - }, - }, - }}, - }) - 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 TestInferenceCompletionWithOptionalParams(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.Inference.Completion(context.TODO(), llamastackclient.InferenceCompletionParams{ - Content: shared.InterleavedContentUnionParam{ - OfString: llamastackclient.String("string"), - }, - ModelID: "model_id", - Logprobs: llamastackclient.InferenceCompletionParamsLogprobs{ - TopK: llamastackclient.Int(0), - }, - ResponseFormat: shared.ResponseFormatUnionParam{ - OfJsonSchema: &shared.ResponseFormatJsonSchemaParam{ - JsonSchema: map[string]shared.ResponseFormatJsonSchemaJsonSchemaUnionParam{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, - }, - }, - }, - SamplingParams: shared.SamplingParams{ - Strategy: shared.SamplingParamsStrategyUnion{ - OfGreedy: &shared.SamplingParamsStrategyGreedy{}, - }, - MaxTokens: llamastackclient.Int(0), - RepetitionPenalty: llamastackclient.Float(0), - Stop: []string{"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 TestInferenceEmbeddingsWithOptionalParams(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.Inference.Embeddings(context.TODO(), llamastackclient.InferenceEmbeddingsParams{ - Contents: llamastackclient.InferenceEmbeddingsParamsContentsUnion{ - OfStringArray: []string{"string"}, - }, - ModelID: "model_id", - OutputDimension: llamastackclient.Int(0), - TaskType: llamastackclient.InferenceEmbeddingsParamsTaskTypeQuery, - TextTruncation: llamastackclient.InferenceEmbeddingsParamsTextTruncationNone, - }) - 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/inspect.go b/inspect.go index 3713218..868a391 100644 --- a/inspect.go +++ b/inspect.go @@ -1,3 +1,9 @@ +// 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 @@ -6,6 +12,7 @@ import ( "context" "encoding/json" "net/http" + "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" "github.com/llamastack/llama-stack-client-go/internal/requestconfig" @@ -32,17 +39,17 @@ func NewInspectService(opts ...option.RequestOption) (r InspectService) { return } -// 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 = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v1/health" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return } -// 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 = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v1/version" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return diff --git a/inspect_test.go b/inspect_test.go index 7a8631b..24e6ee9 100644 --- a/inspect_test.go +++ b/inspect_test.go @@ -1,3 +1,9 @@ +// 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 diff --git a/internal/apierror/apierror.go b/internal/apierror/apierror.go index 628c206..cf654da 100644 --- a/internal/apierror/apierror.go +++ b/internal/apierror/apierror.go @@ -1,3 +1,9 @@ +// 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 apierror diff --git a/internal/apijson/decodeparam_test.go b/internal/apijson/decodeparam_test.go index b3762d1..f10eaba 100644 --- a/internal/apijson/decodeparam_test.go +++ b/internal/apijson/decodeparam_test.go @@ -351,6 +351,36 @@ func init() { }) } +type FooVariant struct { + Type string `json:"type,required"` + Value string `json:"value,required"` +} + +type BarVariant struct { + Type string `json:"type,required"` + Enable bool `json:"enable,required"` +} + +type MultiDiscriminatorUnion struct { + OfFoo *FooVariant `json:",inline"` + OfBar *BarVariant `json:",inline"` + + paramUnion +} + +func init() { + apijson.RegisterDiscriminatedUnion[MultiDiscriminatorUnion]("type", map[string]reflect.Type{ + "foo": reflect.TypeOf(FooVariant{}), + "foo_v2": reflect.TypeOf(FooVariant{}), + "bar": reflect.TypeOf(BarVariant{}), + "bar_legacy": reflect.TypeOf(BarVariant{}), + }) +} + +func (m *MultiDiscriminatorUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, m) +} + func (d *DiscriminatedUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, d) } @@ -408,3 +438,61 @@ func TestDiscriminatedUnion(t *testing.T) { }) } } + +func TestMultiDiscriminatorUnion(t *testing.T) { + tests := map[string]struct { + raw string + target MultiDiscriminatorUnion + shouldFail bool + }{ + "foo_variant": { + raw: `{"type":"foo","value":"test"}`, + target: MultiDiscriminatorUnion{OfFoo: &FooVariant{ + Type: "foo", + Value: "test", + }}, + }, + "foo_v2_variant": { + raw: `{"type":"foo_v2","value":"test_v2"}`, + target: MultiDiscriminatorUnion{OfFoo: &FooVariant{ + Type: "foo_v2", + Value: "test_v2", + }}, + }, + "bar_variant": { + raw: `{"type":"bar","enable":true}`, + target: MultiDiscriminatorUnion{OfBar: &BarVariant{ + Type: "bar", + Enable: true, + }}, + }, + "bar_legacy_variant": { + raw: `{"type":"bar_legacy","enable":false}`, + target: MultiDiscriminatorUnion{OfBar: &BarVariant{ + Type: "bar_legacy", + Enable: false, + }}, + }, + "invalid_type": { + raw: `{"type":"unknown","value":"test"}`, + target: MultiDiscriminatorUnion{}, + shouldFail: true, + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + var dst MultiDiscriminatorUnion + err := json.Unmarshal([]byte(test.raw), &dst) + if err != nil && !test.shouldFail { + t.Fatalf("failed unmarshal with err: %v", err) + } + if err == nil && test.shouldFail { + t.Fatalf("expected unmarshal to fail but it succeeded") + } + if !reflect.DeepEqual(dst, test.target) { + t.Fatalf("failed equality, got %#v but expected %#v", dst, test.target) + } + }) + } +} diff --git a/internal/apijson/encoder.go b/internal/apijson/encoder.go index 8358a2f..ab7a3c1 100644 --- a/internal/apijson/encoder.go +++ b/internal/apijson/encoder.go @@ -16,6 +16,10 @@ import ( var encoders sync.Map // map[encoderEntry]encoderFunc +// If we want to set a literal key value into JSON using sjson, we need to make sure it doesn't have +// special characters that sjson interprets as a path. +var EscapeSJSONKey = strings.NewReplacer("\\", "\\\\", "|", "\\|", "#", "\\#", "@", "\\@", "*", "\\*", ".", "\\.", ":", "\\:", "?", "\\?").Replace + func Marshal(value any) ([]byte, error) { e := &encoder{dateFormat: time.RFC3339} return e.marshal(value) @@ -270,7 +274,7 @@ func (e *encoder) newStructTypeEncoder(t reflect.Type) encoderFunc { if encoded == nil { continue } - json, err = sjson.SetRawBytes(json, ef.tag.name, encoded) + json, err = sjson.SetRawBytes(json, EscapeSJSONKey(ef.tag.name), encoded) if err != nil { return nil, err } @@ -348,7 +352,7 @@ func (e *encoder) encodeMapEntries(json []byte, v reflect.Value) ([]byte, error) } encodedKeyString = string(encodedKeyBytes) } - encodedKey := []byte(sjsonReplacer.Replace(encodedKeyString)) + encodedKey := []byte(encodedKeyString) pairs = append(pairs, mapPair{key: encodedKey, value: iter.Value()}) } @@ -366,7 +370,7 @@ func (e *encoder) encodeMapEntries(json []byte, v reflect.Value) ([]byte, error) if len(encodedValue) == 0 { continue } - json, err = sjson.SetRawBytes(json, string(p.key), encodedValue) + json, err = sjson.SetRawBytes(json, EscapeSJSONKey(string(p.key)), encodedValue) if err != nil { return nil, err } @@ -386,7 +390,3 @@ func (e *encoder) newMapEncoder(_ reflect.Type) encoderFunc { return json, nil } } - -// If we want to set a literal key value into JSON using sjson, we need to make sure it doesn't have -// special characters that sjson interprets as a path. -var sjsonReplacer *strings.Replacer = strings.NewReplacer(".", "\\.", ":", "\\:", "*", "\\*") diff --git a/internal/apijson/union.go b/internal/apijson/union.go index d02daf0..3222ae3 100644 --- a/internal/apijson/union.go +++ b/internal/apijson/union.go @@ -39,12 +39,10 @@ func RegisterDiscriminatedUnion[T any](key string, mappings map[string]reflect.T func (d *decoderBuilder) newStructUnionDecoder(t reflect.Type) decoderFunc { type variantDecoder struct { - decoder decoderFunc - field reflect.StructField - discriminatorValue any + decoder decoderFunc + field reflect.StructField } - - variants := []variantDecoder{} + decoders := []variantDecoder{} for i := 0; i < t.NumField(); i++ { field := t.Field(i) @@ -53,18 +51,26 @@ func (d *decoderBuilder) newStructUnionDecoder(t reflect.Type) decoderFunc { } decoder := d.typeDecoder(field.Type) - variants = append(variants, variantDecoder{ + decoders = append(decoders, variantDecoder{ decoder: decoder, field: field, }) } + type discriminatedDecoder struct { + variantDecoder + discriminator any + } + discriminatedDecoders := []discriminatedDecoder{} unionEntry, discriminated := unionRegistry[t] - for _, unionVariant := range unionEntry.variants { - for i := 0; i < len(variants); i++ { - variant := &variants[i] - if variant.field.Type.Elem() == unionVariant.Type { - variant.discriminatorValue = unionVariant.DiscriminatorValue + for _, variant := range unionEntry.variants { + // For each union variant, find a matching decoder and save it + for _, decoder := range decoders { + if decoder.field.Type.Elem() == variant.Type { + discriminatedDecoders = append(discriminatedDecoders, discriminatedDecoder{ + decoder, + variant.DiscriminatorValue, + }) break } } @@ -72,11 +78,11 @@ func (d *decoderBuilder) newStructUnionDecoder(t reflect.Type) decoderFunc { return func(n gjson.Result, v reflect.Value, state *decoderState) error { if discriminated && n.Type == gjson.JSON && len(unionEntry.discriminatorKey) != 0 { - discriminator := n.Get(unionEntry.discriminatorKey).Value() - for _, variant := range variants { - if discriminator == variant.discriminatorValue { - inner := v.FieldByIndex(variant.field.Index) - return variant.decoder(n, inner, state) + discriminator := n.Get(EscapeSJSONKey(unionEntry.discriminatorKey)).Value() + for _, decoder := range discriminatedDecoders { + if discriminator == decoder.discriminator { + inner := v.FieldByIndex(decoder.field.Index) + return decoder.decoder(n, inner, state) } } return errors.New("apijson: was not able to find discriminated union variant") @@ -85,15 +91,15 @@ func (d *decoderBuilder) newStructUnionDecoder(t reflect.Type) decoderFunc { // Set bestExactness to worse than loose bestExactness := loose - 1 bestVariant := -1 - for i, variant := range variants { + for i, decoder := range decoders { // Pointers are used to discern JSON object variants from value variants - if n.Type != gjson.JSON && variant.field.Type.Kind() == reflect.Ptr { + if n.Type != gjson.JSON && decoder.field.Type.Kind() == reflect.Ptr { continue } sub := decoderState{strict: state.strict, exactness: exact} - inner := v.FieldByIndex(variant.field.Index) - err := variant.decoder(n, inner, &sub) + inner := v.FieldByIndex(decoder.field.Index) + err := decoder.decoder(n, inner, &sub) if err != nil { continue } @@ -116,11 +122,11 @@ func (d *decoderBuilder) newStructUnionDecoder(t reflect.Type) decoderFunc { return errors.New("apijson: was not able to coerce type as union strictly") } - for i := 0; i < len(variants); i++ { + for i := 0; i < len(decoders); i++ { if i == bestVariant { continue } - v.FieldByIndex(variants[i].field.Index).SetZero() + v.FieldByIndex(decoders[i].field.Index).SetZero() } return nil @@ -156,7 +162,7 @@ func (d *decoderBuilder) newUnionDecoder(t reflect.Type) decoderFunc { } if len(unionEntry.discriminatorKey) != 0 { - discriminatorValue := n.Get(unionEntry.discriminatorKey).Value() + discriminatorValue := n.Get(EscapeSJSONKey(unionEntry.discriminatorKey)).Value() if discriminatorValue == variant.DiscriminatorValue { inner := reflect.New(variant.Type).Elem() err := decoder(n, inner, state) diff --git a/internal/encoding/json/shims/shims.go b/internal/encoding/json/shims/shims.go index b65a016..fe9a71a 100644 --- a/internal/encoding/json/shims/shims.go +++ b/internal/encoding/json/shims/shims.go @@ -1,5 +1,5 @@ // This package provides shims over Go 1.2{2,3} APIs -// which are missing from Go 1.21, and used by the Go 1.24 encoding/json package. +// which are missing from Go 1.22, and used by the Go 1.24 encoding/json package. // // Inside the vendored package, all shim code has comments that begin look like // // SHIM(...): ... diff --git a/internal/requestconfig/requestconfig.go b/internal/requestconfig/requestconfig.go index 6760966..7a0c034 100644 --- a/internal/requestconfig/requestconfig.go +++ b/internal/requestconfig/requestconfig.go @@ -1,3 +1,9 @@ +// 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 requestconfig @@ -461,6 +467,11 @@ func (cfg *RequestConfig) Execute() (err error) { break } + // Close the response body before retrying to prevent connection leaks + if res != nil && res.Body != nil { + res.Body.Close() + } + time.Sleep(retryDelay(res, retryCount)) } diff --git a/internal/version.go b/internal/version.go index 5ed22d7..051f665 100644 --- a/internal/version.go +++ b/internal/version.go @@ -1,5 +1,11 @@ +// 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 internal -const PackageVersion = "0.1.0-alpha.1" // x-release-please-version +const PackageVersion = "0.4.0-alpha.1" // x-release-please-version diff --git a/model.go b/model.go index d3cc1d2..b3d163b 100644 --- a/model.go +++ b/model.go @@ -1,3 +1,9 @@ +// 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 @@ -8,6 +14,7 @@ import ( "errors" "fmt" "net/http" + "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" "github.com/llamastack/llama-stack-client-go/internal/requestconfig" @@ -25,6 +32,7 @@ import ( // the [NewModelService] method instead. type ModelService struct { Options []option.RequestOption + OpenAI ModelOpenAIService } // NewModelService generates a new service that applies the given options to each @@ -33,12 +41,13 @@ type ModelService struct { func NewModelService(opts ...option.RequestOption) (r ModelService) { r = ModelService{} r.Options = opts + r.OpenAI = NewModelOpenAIService(opts...) return } -// Get a model by its identifier. -func (r *ModelService) Get(ctx context.Context, modelID string, opts ...option.RequestOption) (res *Model, err error) { - opts = append(r.Options[:], opts...) +// 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 == "" { err = errors.New("missing required model_id parameter") return @@ -48,10 +57,10 @@ func (r *ModelService) Get(ctx context.Context, modelID string, opts ...option.R return } -// List all models. +// List models using the OpenAI API. func (r *ModelService) List(ctx context.Context, opts ...option.RequestOption) (res *[]Model, err error) { var env ListModelsResponse - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v1/models" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) if err != nil { @@ -61,17 +70,21 @@ func (r *ModelService) List(ctx context.Context, opts ...option.RequestOption) ( return } -// Register a model. -func (r *ModelService) Register(ctx context.Context, body ModelRegisterParams, opts ...option.RequestOption) (res *Model, err error) { - opts = append(r.Options[:], opts...) +// Register model. Register a model. +// +// Deprecated: deprecated +func (r *ModelService) Register(ctx context.Context, body ModelRegisterParams, opts ...option.RequestOption) (res *ModelRegisterResponse, err error) { + opts = slices.Concat(r.Options, opts) path := "v1/models" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return } -// Unregister a model. +// Unregister model. Unregister a model. +// +// Deprecated: deprecated func (r *ModelService) Unregister(ctx context.Context, modelID string, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if modelID == "" { err = errors.New("missing required model_id parameter") @@ -98,16 +111,93 @@ func (r *ListModelsResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// A model resource representing an AI model registered in Llama Stack. +// A model from OpenAI. 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"` + // 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 + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r Model) RawJSON() string { return r.JSON.raw } +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 +} + +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) +} + +// 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"` // Any additional metadata for this model - Metadata map[string]ModelMetadataUnion `json:"metadata,required"` + Metadata map[string]ModelGetResponseMetadataUnion `json:"metadata,required"` // The type of model (LLM or embedding model) // - // Any of "llm", "embedding". - ModelType ModelModelType `json:"model_type,required"` + // 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 @@ -128,19 +218,115 @@ type Model struct { } // Returns the unmodified JSON received from the API -func (r Model) RawJSON() string { return r.JSON.raw } -func (r *Model) UnmarshalJSON(data []byte) error { +func (r ModelGetResponse) RawJSON() string { return r.JSON.raw } +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) +type ModelGetResponseModelType string + +const ( + ModelGetResponseModelTypeLlm ModelGetResponseModelType = "llm" + ModelGetResponseModelTypeEmbedding ModelGetResponseModelType = "embedding" + ModelGetResponseModelTypeRerank ModelGetResponseModelType = "rerank" +) + +// 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"` + // Any additional metadata for this model + Metadata map[string]ModelRegisterResponseMetadataUnion `json:"metadata,required"` + // The type of model (LLM or embedding model) + // + // 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"` + // Unique identifier for this resource in the provider + ProviderResourceID string `json:"provider_resource_id"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Identifier respjson.Field + Metadata respjson.Field + ModelType respjson.Field + ProviderID respjson.Field + Type respjson.Field + ProviderResourceID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ModelRegisterResponse) RawJSON() string { return r.JSON.raw } +func (r *ModelRegisterResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ModelMetadataUnion contains all possible properties and values from [bool], -// [float64], [string], [[]any]. +// 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 ModelMetadataUnion struct { +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. @@ -158,39 +344,40 @@ type ModelMetadataUnion struct { } `json:"-"` } -func (u ModelMetadataUnion) AsBool() (v bool) { +func (u ModelRegisterResponseMetadataUnion) AsBool() (v bool) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ModelMetadataUnion) AsFloat() (v float64) { +func (u ModelRegisterResponseMetadataUnion) AsFloat() (v float64) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ModelMetadataUnion) AsString() (v string) { +func (u ModelRegisterResponseMetadataUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ModelMetadataUnion) AsAnyArray() (v []any) { +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 ModelMetadataUnion) RawJSON() string { return u.JSON.raw } +func (u ModelRegisterResponseMetadataUnion) RawJSON() string { return u.JSON.raw } -func (r *ModelMetadataUnion) UnmarshalJSON(data []byte) error { +func (r *ModelRegisterResponseMetadataUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // The type of model (LLM or embedding model) -type ModelModelType string +type ModelRegisterResponseModelType string const ( - ModelModelTypeLlm ModelModelType = "llm" - ModelModelTypeEmbedding ModelModelType = "embedding" + ModelRegisterResponseModelTypeLlm ModelRegisterResponseModelType = "llm" + ModelRegisterResponseModelTypeEmbedding ModelRegisterResponseModelType = "embedding" + ModelRegisterResponseModelTypeRerank ModelRegisterResponseModelType = "rerank" ) type ModelRegisterParams struct { @@ -204,7 +391,7 @@ type ModelRegisterParams struct { Metadata map[string]ModelRegisterParamsMetadataUnion `json:"metadata,omitzero"` // The type of model to register. // - // Any of "llm", "embedding". + // Any of "llm", "embedding", "rerank". ModelType ModelRegisterParamsModelType `json:"model_type,omitzero"` paramObj } @@ -254,4 +441,5 @@ type ModelRegisterParamsModelType string const ( ModelRegisterParamsModelTypeLlm ModelRegisterParamsModelType = "llm" ModelRegisterParamsModelTypeEmbedding ModelRegisterParamsModelType = "embedding" + ModelRegisterParamsModelTypeRerank ModelRegisterParamsModelType = "rerank" ) diff --git a/model_test.go b/model_test.go index df3c766..4b9124d 100644 --- a/model_test.go +++ b/model_test.go @@ -1,3 +1,9 @@ +// 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 diff --git a/modelopenai.go b/modelopenai.go new file mode 100644 index 0000000..dc546b0 --- /dev/null +++ b/modelopenai.go @@ -0,0 +1,50 @@ +// 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" + "net/http" + "slices" + + "github.com/llamastack/llama-stack-client-go/internal/requestconfig" + "github.com/llamastack/llama-stack-client-go/option" +) + +// ModelOpenAIService 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 [NewModelOpenAIService] method instead. +type ModelOpenAIService struct { + Options []option.RequestOption +} + +// NewModelOpenAIService 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 NewModelOpenAIService(opts ...option.RequestOption) (r ModelOpenAIService) { + r = ModelOpenAIService{} + r.Options = opts + return +} + +// List models using the OpenAI API. +func (r *ModelOpenAIService) List(ctx context.Context, opts ...option.RequestOption) (res *[]Model, err error) { + var env ListModelsResponse + opts = slices.Concat(r.Options, opts) + path := "v1/models" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Data + return +} diff --git a/agentstep_test.go b/modelopenai_test.go similarity index 71% rename from agentstep_test.go rename to modelopenai_test.go index 7e8f080..38c7287 100644 --- a/agentstep_test.go +++ b/modelopenai_test.go @@ -1,3 +1,9 @@ +// 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 @@ -13,7 +19,7 @@ import ( "github.com/llamastack/llama-stack-client-go/option" ) -func TestAgentStepGet(t *testing.T) { +func TestModelOpenAIList(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -24,15 +30,7 @@ func TestAgentStepGet(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.Agents.Steps.Get( - context.TODO(), - "step_id", - llamastackclient.AgentStepGetParams{ - AgentID: "agent_id", - SessionID: "session_id", - TurnID: "turn_id", - }, - ) + _, err := client.Models.OpenAI.List(context.TODO()) if err != nil { var apierr *llamastackclient.Error if errors.As(err, &apierr) { diff --git a/moderation.go b/moderation.go index fe54384..76d082c 100644 --- a/moderation.go +++ b/moderation.go @@ -1,3 +1,9 @@ +// 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 @@ -6,6 +12,7 @@ import ( "context" "encoding/json" "net/http" + "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" "github.com/llamastack/llama-stack-client-go/internal/requestconfig" @@ -33,10 +40,11 @@ func NewModerationService(opts ...option.RequestOption) (r ModerationService) { return } -// 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 = append(r.Options[:], opts...) - path := "v1/openai/v1/moderations" + opts = slices.Concat(r.Options, opts) + path := "v1/moderations" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return } @@ -74,11 +82,7 @@ type CreateResponseResult struct { 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. Required - // set of categories that need to be in response - violence - violence/graphic - - // harassment - harassment/threatening - hate - hate/threatening - illicit - - // illicit/violent - sexual - sexual/minors - self-harm - self-harm/intent - - // self-harm/instructions + // 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. @@ -156,8 +160,8 @@ 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"` - // The content moderation model you would like to use. - Model string `json:"model,required"` + // (Optional) The content moderation model you would like to use. + Model param.Opt[string] `json:"model,omitzero"` paramObj } diff --git a/moderation_test.go b/moderation_test.go index dc46200..ed38956 100644 --- a/moderation_test.go +++ b/moderation_test.go @@ -1,3 +1,9 @@ +// 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 @@ -13,7 +19,7 @@ import ( "github.com/llamastack/llama-stack-client-go/option" ) -func TestModerationNew(t *testing.T) { +func TestModerationNewWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -28,7 +34,7 @@ func TestModerationNew(t *testing.T) { Input: llamastackclient.ModerationNewParamsInputUnion{ OfString: llamastackclient.String("string"), }, - Model: "model", + Model: llamastackclient.String("model"), }) if err != nil { var apierr *llamastackclient.Error diff --git a/option/middleware.go b/option/middleware.go index 8ec9dd6..e5f4e02 100644 --- a/option/middleware.go +++ b/option/middleware.go @@ -1,3 +1,9 @@ +// 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 option diff --git a/option/requestoption.go b/option/requestoption.go index 7115685..e1323c5 100644 --- a/option/requestoption.go +++ b/option/requestoption.go @@ -1,3 +1,9 @@ +// 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 option diff --git a/packages/pagination/pagination.go b/packages/pagination/pagination.go index 9056b77..1057f78 100644 --- a/packages/pagination/pagination.go +++ b/packages/pagination/pagination.go @@ -1,3 +1,9 @@ +// 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 pagination diff --git a/packages/param/encoder.go b/packages/param/encoder.go index e403436..027f9bd 100644 --- a/packages/param/encoder.go +++ b/packages/param/encoder.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "reflect" + "strings" "time" shimjson "github.com/llamastack/llama-stack-client-go/internal/encoding/json" @@ -14,6 +15,10 @@ import ( // EncodedAsDate is not be stable and shouldn't be relied upon type EncodedAsDate Opt[time.Time] +// If we want to set a literal key value into JSON using sjson, we need to make sure it doesn't have +// special characters that sjson interprets as a path. +var EscapeSJSONKey = strings.NewReplacer("\\", "\\\\", "|", "\\|", "#", "\\#", "@", "\\@", "*", "\\*", ".", "\\.", ":", "\\:", "?", "\\?").Replace + type forceOmit int func (m EncodedAsDate) MarshalJSON() ([]byte, error) { @@ -52,7 +57,7 @@ func MarshalWithExtras[T ParamStruct, R any](f T, underlying any, extras map[str } continue } - bytes, err = sjson.SetBytes(bytes, k, v) + bytes, err = sjson.SetBytes(bytes, EscapeSJSONKey(k), v) if err != nil { return nil, err } diff --git a/packages/respjson/respjson.go b/packages/respjson/respjson.go index cc0088c..9e61c5c 100644 --- a/packages/respjson/respjson.go +++ b/packages/respjson/respjson.go @@ -5,7 +5,7 @@ package respjson // Use [Field.Valid] to check if an optional value was null or omitted. // // A Field will always occur in the following structure, where it -// mirrors the original field in it's parent struct: +// mirrors the original field in its parent struct: // // type ExampleObject struct { // Foo bool `json:"foo"` diff --git a/packages/ssestream/ssestream.go b/packages/ssestream/ssestream.go index cc0afb7..3e9def1 100644 --- a/packages/ssestream/ssestream.go +++ b/packages/ssestream/ssestream.go @@ -1,3 +1,9 @@ +// 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 ssestream diff --git a/prompt.go b/prompt.go new file mode 100644 index 0000000..12d6b77 --- /dev/null +++ b/prompt.go @@ -0,0 +1,230 @@ +// 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/param" + "github.com/llamastack/llama-stack-client-go/packages/respjson" +) + +// PromptService 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 [NewPromptService] method instead. +type PromptService struct { + Options []option.RequestOption + Versions PromptVersionService +} + +// NewPromptService 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 NewPromptService(opts ...option.RequestOption) (r PromptService) { + r = PromptService{} + r.Options = opts + r.Versions = NewPromptVersionService(opts...) + return +} + +// 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" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return +} + +// 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 == "" { + err = errors.New("missing required prompt_id parameter") + return + } + path := fmt.Sprintf("v1/prompts/%s", promptID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return +} + +// 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 == "" { + err = errors.New("missing required prompt_id parameter") + return + } + path := fmt.Sprintf("v1/prompts/%s", promptID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return +} + +// List all prompts. +func (r *PromptService) List(ctx context.Context, opts ...option.RequestOption) (res *[]Prompt, err error) { + var env ListPromptsResponse + opts = slices.Concat(r.Options, opts) + path := "v1/prompts" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Data + return +} + +// 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...) + if promptID == "" { + err = errors.New("missing required prompt_id parameter") + return + } + path := fmt.Sprintf("v1/prompts/%s", promptID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...) + return +} + +// 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 == "" { + err = errors.New("missing required prompt_id parameter") + return + } + path := fmt.Sprintf("v1/prompts/%s/set-default-version", promptID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return +} + +// Response model to list prompts. +type ListPromptsResponse struct { + Data []Prompt `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:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ListPromptsResponse) RawJSON() string { return r.JSON.raw } +func (r *ListPromptsResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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>' + 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"` + // 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 + Prompt respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r Prompt) RawJSON() string { return r.JSON.raw } +func (r *Prompt) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +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. + Variables []string `json:"variables,omitzero"` + paramObj +} + +func (r PromptNewParams) MarshalJSON() (data []byte, err error) { + type shadow PromptNewParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *PromptNewParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type PromptGetParams struct { + // The version of the prompt to get (defaults to latest). + Version param.Opt[int64] `query:"version,omitzero" json:"-"` + paramObj +} + +// URLQuery serializes [PromptGetParams]'s query parameters as `url.Values`. +func (r PromptGetParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +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"` + paramObj +} + +func (r PromptUpdateParams) MarshalJSON() (data []byte, err error) { + type shadow PromptUpdateParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *PromptUpdateParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type PromptSetDefaultVersionParams struct { + // The version to set as default. + Version int64 `json:"version,required"` + paramObj +} + +func (r PromptSetDefaultVersionParams) MarshalJSON() (data []byte, err error) { + type shadow PromptSetDefaultVersionParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *PromptSetDefaultVersionParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} diff --git a/prompt_test.go b/prompt_test.go new file mode 100644 index 0000000..097cfdf --- /dev/null +++ b/prompt_test.go @@ -0,0 +1,170 @@ +// 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 TestPromptNewWithOptionalParams(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.Prompts.New(context.TODO(), llamastackclient.PromptNewParams{ + Prompt: "prompt", + Variables: []string{"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 TestPromptGetWithOptionalParams(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.Prompts.Get( + context.TODO(), + "prompt_id", + llamastackclient.PromptGetParams{ + Version: 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 TestPromptUpdateWithOptionalParams(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.Prompts.Update( + context.TODO(), + "prompt_id", + llamastackclient.PromptUpdateParams{ + Prompt: "prompt", + SetAsDefault: true, + Version: 0, + Variables: []string{"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 TestPromptList(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.Prompts.List(context.TODO()) + 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 TestPromptDelete(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.Prompts.Delete(context.TODO(), "prompt_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 TestPromptSetDefaultVersion(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.Prompts.SetDefaultVersion( + context.TODO(), + "prompt_id", + llamastackclient.PromptSetDefaultVersionParams{ + Version: 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()) + } +} diff --git a/promptversion.go b/promptversion.go new file mode 100644 index 0000000..d81aa41 --- /dev/null +++ b/promptversion.go @@ -0,0 +1,56 @@ +// 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" + "slices" + + "github.com/llamastack/llama-stack-client-go/internal/requestconfig" + "github.com/llamastack/llama-stack-client-go/option" +) + +// PromptVersionService 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 [NewPromptVersionService] method instead. +type PromptVersionService struct { + Options []option.RequestOption +} + +// NewPromptVersionService 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 NewPromptVersionService(opts ...option.RequestOption) (r PromptVersionService) { + r = PromptVersionService{} + r.Options = opts + return +} + +// 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) + if promptID == "" { + err = errors.New("missing required prompt_id parameter") + return + } + path := fmt.Sprintf("v1/prompts/%s/versions", promptID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Data + return +} diff --git a/promptversion_test.go b/promptversion_test.go new file mode 100644 index 0000000..9b982cd --- /dev/null +++ b/promptversion_test.go @@ -0,0 +1,41 @@ +// 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 TestPromptVersionList(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.Prompts.Versions.List(context.TODO(), "prompt_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/provider.go b/provider.go index 87e7f3c..9d5506b 100644 --- a/provider.go +++ b/provider.go @@ -1,3 +1,9 @@ +// 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 @@ -7,6 +13,7 @@ import ( "errors" "fmt" "net/http" + "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" "github.com/llamastack/llama-stack-client-go/internal/requestconfig" @@ -33,9 +40,9 @@ func NewProviderService(opts ...option.RequestOption) (r ProviderService) { return } -// 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 = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if providerID == "" { err = errors.New("missing required provider_id parameter") return @@ -45,10 +52,10 @@ func (r *ProviderService) Get(ctx context.Context, providerID string, opts ...op return } -// 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 = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v1/providers" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) if err != nil { diff --git a/provider_test.go b/provider_test.go index fa920e8..be61435 100644 --- a/provider_test.go +++ b/provider_test.go @@ -1,3 +1,9 @@ +// 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 diff --git a/response.go b/response.go index a58d06e..6e3f14e 100644 --- a/response.go +++ b/response.go @@ -1,3 +1,9 @@ +// 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 @@ -9,6 +15,7 @@ import ( "fmt" "net/http" "net/url" + "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" "github.com/llamastack/llama-stack-client-go/internal/apiquery" @@ -42,45 +49,45 @@ func NewResponseService(opts ...option.RequestOption) (r ResponseService) { return } -// Create a new OpenAI response. +// Create a model response. func (r *ResponseService) New(ctx context.Context, body ResponseNewParams, opts ...option.RequestOption) (res *ResponseObject, err error) { - opts = append(r.Options[:], opts...) - path := "v1/openai/v1/responses" + opts = slices.Concat(r.Options, opts) + path := "v1/responses" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return } -// Create a new OpenAI response. +// Create a model response. func (r *ResponseService) NewStreaming(ctx context.Context, body ResponseNewParams, opts ...option.RequestOption) (stream *ssestream.Stream[ResponseObjectStreamUnion]) { var ( raw *http.Response err error ) - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithJSONSet("stream", true)}, opts...) - path := "v1/openai/v1/responses" + path := "v1/responses" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &raw, opts...) return ssestream.NewStream[ResponseObjectStreamUnion](ssestream.NewDecoder(raw), err) } -// Retrieve an OpenAI response by its ID. +// Get a model response. func (r *ResponseService) Get(ctx context.Context, responseID string, opts ...option.RequestOption) (res *ResponseObject, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if responseID == "" { err = errors.New("missing required response_id parameter") return } - path := fmt.Sprintf("v1/openai/v1/responses/%s", responseID) + path := fmt.Sprintf("v1/responses/%s", responseID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return } -// List all OpenAI responses. +// List all responses. func (r *ResponseService) List(ctx context.Context, query ResponseListParams, opts ...option.RequestOption) (res *pagination.OpenAICursorPage[ResponseListResponse], err error) { var raw *http.Response - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := "v1/openai/v1/responses" + path := "v1/responses" cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) if err != nil { return nil, err @@ -93,11 +100,23 @@ func (r *ResponseService) List(ctx context.Context, query ResponseListParams, op return res, nil } -// List all OpenAI responses. +// List all responses. func (r *ResponseService) ListAutoPaging(ctx context.Context, query ResponseListParams, opts ...option.RequestOption) *pagination.OpenAICursorPageAutoPager[ResponseListResponse] { return pagination.NewOpenAICursorPageAutoPager(r.List(ctx, query, opts...)) } +// Delete a response. +func (r *ResponseService) Delete(ctx context.Context, responseID string, opts ...option.RequestOption) (res *ResponseDeleteResponse, err error) { + opts = slices.Concat(r.Options, opts) + if responseID == "" { + err = errors.New("missing required response_id parameter") + return + } + path := fmt.Sprintf("v1/responses/%s", responseID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return +} + // Complete OpenAI response object containing generation results and metadata. type ResponseObject struct { // Unique identifier for this response @@ -118,16 +137,25 @@ type ResponseObject struct { 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) User identifier associated with the request - User string `json:"user"` + // (Optional) Token usage information for the response + Usage ResponseObjectUsage `json:"usage"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -139,11 +167,15 @@ type ResponseObject struct { Status respjson.Field Text respjson.Field Error respjson.Field + Instructions respjson.Field + MaxToolCalls respjson.Field PreviousResponseID respjson.Field + Prompt respjson.Field Temperature respjson.Field + Tools respjson.Field TopP respjson.Field Truncation respjson.Field - User respjson.Field + Usage respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -158,7 +190,8 @@ func (r *ResponseObject) UnmarshalJSON(data []byte) error { // ResponseObjectOutputUnion contains all possible properties and values from // [ResponseObjectOutputMessage], [ResponseObjectOutputWebSearchCall], // [ResponseObjectOutputFileSearchCall], [ResponseObjectOutputFunctionCall], -// [ResponseObjectOutputMcpCall], [ResponseObjectOutputMcpListTools]. +// [ResponseObjectOutputMcpCall], [ResponseObjectOutputMcpListTools], +// [ResponseObjectOutputMcpApprovalRequest]. // // Use the [ResponseObjectOutputUnion.AsAny] method to switch on the variant. // @@ -169,7 +202,7 @@ type ResponseObjectOutputUnion struct { // 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_call", "mcp_list_tools", "mcp_approval_request". Type string `json:"type"` ID string `json:"id"` Status string `json:"status"` @@ -214,12 +247,13 @@ type anyResponseObjectOutput interface { implResponseObjectOutputUnion() } -func (ResponseObjectOutputMessage) implResponseObjectOutputUnion() {} -func (ResponseObjectOutputWebSearchCall) implResponseObjectOutputUnion() {} -func (ResponseObjectOutputFileSearchCall) implResponseObjectOutputUnion() {} -func (ResponseObjectOutputFunctionCall) implResponseObjectOutputUnion() {} -func (ResponseObjectOutputMcpCall) implResponseObjectOutputUnion() {} -func (ResponseObjectOutputMcpListTools) implResponseObjectOutputUnion() {} +func (ResponseObjectOutputMessage) implResponseObjectOutputUnion() {} +func (ResponseObjectOutputWebSearchCall) implResponseObjectOutputUnion() {} +func (ResponseObjectOutputFileSearchCall) implResponseObjectOutputUnion() {} +func (ResponseObjectOutputFunctionCall) implResponseObjectOutputUnion() {} +func (ResponseObjectOutputMcpCall) implResponseObjectOutputUnion() {} +func (ResponseObjectOutputMcpListTools) implResponseObjectOutputUnion() {} +func (ResponseObjectOutputMcpApprovalRequest) implResponseObjectOutputUnion() {} // Use the following switch statement to find the correct variant // @@ -230,6 +264,7 @@ func (ResponseObjectOutputMcpListTools) implResponseObjectOutputUnion() {} // case llamastackclient.ResponseObjectOutputFunctionCall: // case llamastackclient.ResponseObjectOutputMcpCall: // case llamastackclient.ResponseObjectOutputMcpListTools: +// case llamastackclient.ResponseObjectOutputMcpApprovalRequest: // default: // fmt.Errorf("no variant present") // } @@ -247,6 +282,8 @@ func (u ResponseObjectOutputUnion) AsAny() anyResponseObjectOutput { return u.AsMcpCall() case "mcp_list_tools": return u.AsMcpListTools() + case "mcp_approval_request": + return u.AsMcpApprovalRequest() } return nil } @@ -281,6 +318,11 @@ func (u ResponseObjectOutputUnion) AsMcpListTools() (v ResponseObjectOutputMcpLi return } +func (u ResponseObjectOutputUnion) AsMcpApprovalRequest() (v ResponseObjectOutputMcpApprovalRequest) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + // Returns the unmodified JSON received from the API func (u ResponseObjectOutputUnion) RawJSON() string { return u.JSON.raw } @@ -318,26 +360,22 @@ func (r *ResponseObjectOutputMessage) UnmarshalJSON(data []byte) error { // ResponseObjectOutputMessageContentUnion contains all possible properties and // values from [string], [[]ResponseObjectOutputMessageContentArrayItemUnion], -// [[]ResponseObjectOutputMessageContentArrayItem]. +// [[]ResponseObjectOutputMessageContentArrayItemUnion]. // // 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 OfResponseObjectOutputMessageContentArray OfVariant2] +// will be valid: OfString OfVariant2] 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. - OfResponseObjectOutputMessageContentArray []ResponseObjectOutputMessageContentArrayItemUnion `json:",inline"` - // This field will be present if the value is a - // [[]ResponseObjectOutputMessageContentArrayItem] instead of an object. - OfVariant2 []ResponseObjectOutputMessageContentArrayItem `json:",inline"` + OfVariant2 []ResponseObjectOutputMessageContentArrayItemUnion `json:",inline"` JSON struct { - OfString respjson.Field - OfResponseObjectOutputMessageContentArray respjson.Field - OfVariant2 respjson.Field - raw string + OfString respjson.Field + OfVariant2 respjson.Field + raw string } `json:"-"` } @@ -351,7 +389,7 @@ func (u ResponseObjectOutputMessageContentUnion) AsResponseObjectOutputMessageCo return } -func (u ResponseObjectOutputMessageContentUnion) AsVariant2() (v []ResponseObjectOutputMessageContentArrayItem) { +func (u ResponseObjectOutputMessageContentUnion) AsVariant2() (v []ResponseObjectOutputMessageContentArrayItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -366,7 +404,8 @@ func (r *ResponseObjectOutputMessageContentUnion) UnmarshalJSON(data []byte) err // ResponseObjectOutputMessageContentArrayItemUnion contains all possible // properties and values from // [ResponseObjectOutputMessageContentArrayItemInputText], -// [ResponseObjectOutputMessageContentArrayItemInputImage]. +// [ResponseObjectOutputMessageContentArrayItemInputImage], +// [ResponseObjectOutputMessageContentArrayItemInputFile]. // // Use the [ResponseObjectOutputMessageContentArrayItemUnion.AsAny] method to // switch on the variant. @@ -376,19 +415,33 @@ type ResponseObjectOutputMessageContentArrayItemUnion struct { // This field is from variant // [ResponseObjectOutputMessageContentArrayItemInputText]. Text string `json:"text"` - // Any of "input_text", "input_image". + // 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"` // This field is from variant // [ResponseObjectOutputMessageContentArrayItemInputImage]. ImageURL string `json:"image_url"` + // This field is from variant + // [ResponseObjectOutputMessageContentArrayItemInputFile]. + FileData string `json:"file_data"` + // This field is from variant + // [ResponseObjectOutputMessageContentArrayItemInputFile]. + FileURL string `json:"file_url"` + // This field is from variant + // [ResponseObjectOutputMessageContentArrayItemInputFile]. + 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:"-"` } @@ -404,12 +457,15 @@ func (ResponseObjectOutputMessageContentArrayItemInputText) implResponseObjectOu } func (ResponseObjectOutputMessageContentArrayItemInputImage) implResponseObjectOutputMessageContentArrayItemUnion() { } +func (ResponseObjectOutputMessageContentArrayItemInputFile) implResponseObjectOutputMessageContentArrayItemUnion() { +} // Use the following switch statement to find the correct variant // // switch variant := ResponseObjectOutputMessageContentArrayItemUnion.AsAny().(type) { // case llamastackclient.ResponseObjectOutputMessageContentArrayItemInputText: // case llamastackclient.ResponseObjectOutputMessageContentArrayItemInputImage: +// case llamastackclient.ResponseObjectOutputMessageContentArrayItemInputFile: // default: // fmt.Errorf("no variant present") // } @@ -419,6 +475,8 @@ func (u ResponseObjectOutputMessageContentArrayItemUnion) AsAny() anyResponseObj return u.AsInputText() case "input_image": return u.AsInputImage() + case "input_file": + return u.AsInputFile() } return nil } @@ -433,6 +491,11 @@ func (u ResponseObjectOutputMessageContentArrayItemUnion) AsInputImage() (v Resp return } +func (u ResponseObjectOutputMessageContentArrayItemUnion) AsInputFile() (v ResponseObjectOutputMessageContentArrayItemInputFile) { + 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 } @@ -469,12 +532,15 @@ type ResponseObjectOutputMessageContentArrayItemInputImage struct { 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"` // 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 ExtraFields map[string]respjson.Field raw string @@ -496,257 +562,44 @@ const ( ResponseObjectOutputMessageContentArrayItemInputImageDetailAuto ResponseObjectOutputMessageContentArrayItemInputImageDetail = "auto" ) -// Level of detail for image processing, can be "low", "high", or "auto" -type ResponseObjectOutputMessageContentArrayItemDetail string - -const ( - ResponseObjectOutputMessageContentArrayItemDetailLow ResponseObjectOutputMessageContentArrayItemDetail = "low" - ResponseObjectOutputMessageContentArrayItemDetailHigh ResponseObjectOutputMessageContentArrayItemDetail = "high" - ResponseObjectOutputMessageContentArrayItemDetailAuto ResponseObjectOutputMessageContentArrayItemDetail = "auto" -) - -type ResponseObjectOutputMessageContentArrayItem struct { - Annotations []ResponseObjectOutputMessageContentArrayItemAnnotationUnion `json:"annotations,required"` - Text string `json:"text,required"` - Type constant.OutputText `json:"type,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Annotations respjson.Field - Text respjson.Field - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ResponseObjectOutputMessageContentArrayItem) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectOutputMessageContentArrayItem) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ResponseObjectOutputMessageContentArrayItemAnnotationUnion contains all possible -// properties and values from -// [ResponseObjectOutputMessageContentArrayItemAnnotationFileCitation], -// [ResponseObjectOutputMessageContentArrayItemAnnotationURLCitation], -// [ResponseObjectOutputMessageContentArrayItemAnnotationContainerFileCitation], -// [ResponseObjectOutputMessageContentArrayItemAnnotationFilePath]. -// -// Use the [ResponseObjectOutputMessageContentArrayItemAnnotationUnion.AsAny] -// method to switch on the variant. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -type ResponseObjectOutputMessageContentArrayItemAnnotationUnion struct { - FileID string `json:"file_id"` +// 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"` - 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 - // [ResponseObjectOutputMessageContentArrayItemAnnotationURLCitation]. - Title string `json:"title"` - // This field is from variant - // [ResponseObjectOutputMessageContentArrayItemAnnotationURLCitation]. - URL string `json:"url"` - // This field is from variant - // [ResponseObjectOutputMessageContentArrayItemAnnotationContainerFileCitation]. - 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:"-"` -} - -// anyResponseObjectOutputMessageContentArrayItemAnnotation is implemented by each -// variant of [ResponseObjectOutputMessageContentArrayItemAnnotationUnion] to add -// type safety for the return type of -// [ResponseObjectOutputMessageContentArrayItemAnnotationUnion.AsAny] -type anyResponseObjectOutputMessageContentArrayItemAnnotation interface { - implResponseObjectOutputMessageContentArrayItemAnnotationUnion() -} - -func (ResponseObjectOutputMessageContentArrayItemAnnotationFileCitation) implResponseObjectOutputMessageContentArrayItemAnnotationUnion() { -} -func (ResponseObjectOutputMessageContentArrayItemAnnotationURLCitation) implResponseObjectOutputMessageContentArrayItemAnnotationUnion() { -} -func (ResponseObjectOutputMessageContentArrayItemAnnotationContainerFileCitation) implResponseObjectOutputMessageContentArrayItemAnnotationUnion() { -} -func (ResponseObjectOutputMessageContentArrayItemAnnotationFilePath) implResponseObjectOutputMessageContentArrayItemAnnotationUnion() { -} - -// Use the following switch statement to find the correct variant -// -// switch variant := ResponseObjectOutputMessageContentArrayItemAnnotationUnion.AsAny().(type) { -// case llamastackclient.ResponseObjectOutputMessageContentArrayItemAnnotationFileCitation: -// case llamastackclient.ResponseObjectOutputMessageContentArrayItemAnnotationURLCitation: -// case llamastackclient.ResponseObjectOutputMessageContentArrayItemAnnotationContainerFileCitation: -// case llamastackclient.ResponseObjectOutputMessageContentArrayItemAnnotationFilePath: -// default: -// fmt.Errorf("no variant present") -// } -func (u ResponseObjectOutputMessageContentArrayItemAnnotationUnion) AsAny() anyResponseObjectOutputMessageContentArrayItemAnnotation { - 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 ResponseObjectOutputMessageContentArrayItemAnnotationUnion) AsFileCitation() (v ResponseObjectOutputMessageContentArrayItemAnnotationFileCitation) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectOutputMessageContentArrayItemAnnotationUnion) AsURLCitation() (v ResponseObjectOutputMessageContentArrayItemAnnotationURLCitation) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectOutputMessageContentArrayItemAnnotationUnion) AsContainerFileCitation() (v ResponseObjectOutputMessageContentArrayItemAnnotationContainerFileCitation) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectOutputMessageContentArrayItemAnnotationUnion) AsFilePath() (v ResponseObjectOutputMessageContentArrayItemAnnotationFilePath) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ResponseObjectOutputMessageContentArrayItemAnnotationUnion) RawJSON() string { - return u.JSON.raw -} - -func (r *ResponseObjectOutputMessageContentArrayItemAnnotationUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// File citation annotation for referencing specific files in response content. -type ResponseObjectOutputMessageContentArrayItemAnnotationFileCitation struct { - // Unique identifier of the referenced file - FileID string `json:"file_id,required"` - // Name of the referenced file - 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"` - // 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 ResponseObjectOutputMessageContentArrayItemAnnotationFileCitation) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseObjectOutputMessageContentArrayItemAnnotationFileCitation) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// URL citation annotation for referencing external web resources. -type ResponseObjectOutputMessageContentArrayItemAnnotationURLCitation 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"` // 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 - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ResponseObjectOutputMessageContentArrayItemAnnotationURLCitation) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseObjectOutputMessageContentArrayItemAnnotationURLCitation) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type ResponseObjectOutputMessageContentArrayItemAnnotationContainerFileCitation 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"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - ContainerID respjson.Field - EndIndex respjson.Field + FileData 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 ResponseObjectOutputMessageContentArrayItemAnnotationContainerFileCitation) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseObjectOutputMessageContentArrayItemAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error { +func (r ResponseObjectOutputMessageContentArrayItemInputFile) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectOutputMessageContentArrayItemInputFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ResponseObjectOutputMessageContentArrayItemAnnotationFilePath struct { - FileID string `json:"file_id,required"` - Index int64 `json:"index,required"` - Type constant.FilePath `json:"type,required"` - // 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:"-"` -} +// Level of detail for image processing, can be "low", "high", or "auto" +type ResponseObjectOutputMessageContentArrayItemDetail string -// Returns the unmodified JSON received from the API -func (r ResponseObjectOutputMessageContentArrayItemAnnotationFilePath) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseObjectOutputMessageContentArrayItemAnnotationFilePath) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} +const ( + ResponseObjectOutputMessageContentArrayItemDetailLow ResponseObjectOutputMessageContentArrayItemDetail = "low" + ResponseObjectOutputMessageContentArrayItemDetailHigh ResponseObjectOutputMessageContentArrayItemDetail = "high" + ResponseObjectOutputMessageContentArrayItemDetailAuto ResponseObjectOutputMessageContentArrayItemDetail = "auto" +) type ResponseObjectOutputMessageRole string @@ -1065,6 +918,31 @@ func (r *ResponseObjectOutputMcpListToolsToolInputSchemaUnion) UnmarshalJSON(dat 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"` + // 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 ResponseObjectOutputMcpApprovalRequest) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectOutputMcpApprovalRequest) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + type ResponseObjectOutputRole string const ( @@ -1208,818 +1086,1766 @@ func (r *ResponseObjectError) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamUnion contains all possible properties and values from -// [ResponseObjectStreamResponseCreated], -// [ResponseObjectStreamResponseOutputItemAdded], -// [ResponseObjectStreamResponseOutputItemDone], -// [ResponseObjectStreamResponseOutputTextDelta], -// [ResponseObjectStreamResponseOutputTextDone], -// [ResponseObjectStreamResponseFunctionCallArgumentsDelta], -// [ResponseObjectStreamResponseFunctionCallArgumentsDone], -// [ResponseObjectStreamResponseWebSearchCallInProgress], -// [ResponseObjectStreamResponseWebSearchCallSearching], -// [ResponseObjectStreamResponseWebSearchCallCompleted], -// [ResponseObjectStreamResponseMcpListToolsInProgress], -// [ResponseObjectStreamResponseMcpListToolsFailed], -// [ResponseObjectStreamResponseMcpListToolsCompleted], -// [ResponseObjectStreamResponseMcpCallArgumentsDelta], -// [ResponseObjectStreamResponseMcpCallArgumentsDone], -// [ResponseObjectStreamResponseMcpCallInProgress], -// [ResponseObjectStreamResponseMcpCallFailed], -// [ResponseObjectStreamResponseMcpCallCompleted], -// [ResponseObjectStreamResponseContentPartAdded], -// [ResponseObjectStreamResponseContentPartDone], -// [ResponseObjectStreamResponseCompleted]. +// (Optional) Reference to a prompt template and its variables. +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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ID respjson.Field + Variables respjson.Field + Version respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseObjectPrompt) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectPrompt) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ResponseObjectPromptVariableUnion contains all possible properties and values +// from [ResponseObjectPromptVariableInputText], +// [ResponseObjectPromptVariableInputImage], +// [ResponseObjectPromptVariableInputFile]. // -// Use the [ResponseObjectStreamUnion.AsAny] method to switch on the variant. +// Use the [ResponseObjectPromptVariableUnion.AsAny] method to switch on the +// variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type ResponseObjectStreamUnion struct { - // This field is from variant [ResponseObjectStreamResponseCreated]. - Response ResponseObject `json:"response"` - // Any of "response.created", "response.output_item.added", - // "response.output_item.done", "response.output_text.delta", - // "response.output_text.done", "response.function_call_arguments.delta", - // "response.function_call_arguments.done", "response.web_search_call.in_progress", - // "response.web_search_call.searching", "response.web_search_call.completed", - // "response.mcp_list_tools.in_progress", "response.mcp_list_tools.failed", - // "response.mcp_list_tools.completed", "response.mcp_call.arguments.delta", - // "response.mcp_call.arguments.done", "response.mcp_call.in_progress", - // "response.mcp_call.failed", "response.mcp_call.completed", - // "response.content_part.added", "response.content_part.done", - // "response.completed". +type ResponseObjectPromptVariableUnion struct { + // This field is from variant [ResponseObjectPromptVariableInputText]. + Text string `json:"text"` + // Any of "input_text", "input_image", "input_file". Type string `json:"type"` - // This field is a union of [ResponseObjectStreamResponseOutputItemAddedItemUnion], - // [ResponseObjectStreamResponseOutputItemDoneItemUnion] - Item ResponseObjectStreamUnionItem `json:"item"` - OutputIndex int64 `json:"output_index"` - ResponseID string `json:"response_id"` - SequenceNumber int64 `json:"sequence_number"` - ContentIndex int64 `json:"content_index"` - Delta string `json:"delta"` - ItemID string `json:"item_id"` - // This field is from variant [ResponseObjectStreamResponseOutputTextDone]. - Text string `json:"text"` - Arguments string `json:"arguments"` - // This field is a union of - // [ResponseObjectStreamResponseContentPartAddedPartUnion], - // [ResponseObjectStreamResponseContentPartDonePartUnion] - Part ResponseObjectStreamUnionPart `json:"part"` - JSON struct { - Response respjson.Field - Type respjson.Field - Item respjson.Field - OutputIndex respjson.Field - ResponseID respjson.Field - SequenceNumber respjson.Field - ContentIndex respjson.Field - Delta respjson.Field - ItemID respjson.Field - Text respjson.Field - Arguments respjson.Field - Part respjson.Field - raw string + // This field is from variant [ResponseObjectPromptVariableInputImage]. + Detail ResponseObjectPromptVariableInputImageDetail `json:"detail"` + FileID string `json:"file_id"` + // This field is from variant [ResponseObjectPromptVariableInputImage]. + ImageURL string `json:"image_url"` + // This field is from variant [ResponseObjectPromptVariableInputFile]. + FileData string `json:"file_data"` + // This field is from variant [ResponseObjectPromptVariableInputFile]. + FileURL string `json:"file_url"` + // This field is from variant [ResponseObjectPromptVariableInputFile]. + 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:"-"` } -// anyResponseObjectStream is implemented by each variant of -// [ResponseObjectStreamUnion] to add type safety for the return type of -// [ResponseObjectStreamUnion.AsAny] -type anyResponseObjectStream interface { - implResponseObjectStreamUnion() +// anyResponseObjectPromptVariable is implemented by each variant of +// [ResponseObjectPromptVariableUnion] to add type safety for the return type of +// [ResponseObjectPromptVariableUnion.AsAny] +type anyResponseObjectPromptVariable interface { + implResponseObjectPromptVariableUnion() } -func (ResponseObjectStreamResponseCreated) implResponseObjectStreamUnion() {} -func (ResponseObjectStreamResponseOutputItemAdded) implResponseObjectStreamUnion() {} -func (ResponseObjectStreamResponseOutputItemDone) implResponseObjectStreamUnion() {} -func (ResponseObjectStreamResponseOutputTextDelta) implResponseObjectStreamUnion() {} -func (ResponseObjectStreamResponseOutputTextDone) implResponseObjectStreamUnion() {} -func (ResponseObjectStreamResponseFunctionCallArgumentsDelta) implResponseObjectStreamUnion() {} -func (ResponseObjectStreamResponseFunctionCallArgumentsDone) implResponseObjectStreamUnion() {} -func (ResponseObjectStreamResponseWebSearchCallInProgress) implResponseObjectStreamUnion() {} -func (ResponseObjectStreamResponseWebSearchCallSearching) implResponseObjectStreamUnion() {} -func (ResponseObjectStreamResponseWebSearchCallCompleted) implResponseObjectStreamUnion() {} -func (ResponseObjectStreamResponseMcpListToolsInProgress) implResponseObjectStreamUnion() {} -func (ResponseObjectStreamResponseMcpListToolsFailed) implResponseObjectStreamUnion() {} -func (ResponseObjectStreamResponseMcpListToolsCompleted) implResponseObjectStreamUnion() {} -func (ResponseObjectStreamResponseMcpCallArgumentsDelta) implResponseObjectStreamUnion() {} -func (ResponseObjectStreamResponseMcpCallArgumentsDone) implResponseObjectStreamUnion() {} -func (ResponseObjectStreamResponseMcpCallInProgress) implResponseObjectStreamUnion() {} -func (ResponseObjectStreamResponseMcpCallFailed) implResponseObjectStreamUnion() {} -func (ResponseObjectStreamResponseMcpCallCompleted) implResponseObjectStreamUnion() {} -func (ResponseObjectStreamResponseContentPartAdded) implResponseObjectStreamUnion() {} -func (ResponseObjectStreamResponseContentPartDone) implResponseObjectStreamUnion() {} -func (ResponseObjectStreamResponseCompleted) implResponseObjectStreamUnion() {} +func (ResponseObjectPromptVariableInputText) implResponseObjectPromptVariableUnion() {} +func (ResponseObjectPromptVariableInputImage) implResponseObjectPromptVariableUnion() {} +func (ResponseObjectPromptVariableInputFile) implResponseObjectPromptVariableUnion() {} // Use the following switch statement to find the correct variant // -// switch variant := ResponseObjectStreamUnion.AsAny().(type) { -// case llamastackclient.ResponseObjectStreamResponseCreated: -// case llamastackclient.ResponseObjectStreamResponseOutputItemAdded: -// case llamastackclient.ResponseObjectStreamResponseOutputItemDone: -// case llamastackclient.ResponseObjectStreamResponseOutputTextDelta: -// case llamastackclient.ResponseObjectStreamResponseOutputTextDone: -// case llamastackclient.ResponseObjectStreamResponseFunctionCallArgumentsDelta: -// case llamastackclient.ResponseObjectStreamResponseFunctionCallArgumentsDone: -// case llamastackclient.ResponseObjectStreamResponseWebSearchCallInProgress: -// case llamastackclient.ResponseObjectStreamResponseWebSearchCallSearching: -// case llamastackclient.ResponseObjectStreamResponseWebSearchCallCompleted: -// case llamastackclient.ResponseObjectStreamResponseMcpListToolsInProgress: -// case llamastackclient.ResponseObjectStreamResponseMcpListToolsFailed: -// case llamastackclient.ResponseObjectStreamResponseMcpListToolsCompleted: -// case llamastackclient.ResponseObjectStreamResponseMcpCallArgumentsDelta: -// case llamastackclient.ResponseObjectStreamResponseMcpCallArgumentsDone: -// case llamastackclient.ResponseObjectStreamResponseMcpCallInProgress: -// case llamastackclient.ResponseObjectStreamResponseMcpCallFailed: -// case llamastackclient.ResponseObjectStreamResponseMcpCallCompleted: -// case llamastackclient.ResponseObjectStreamResponseContentPartAdded: -// case llamastackclient.ResponseObjectStreamResponseContentPartDone: -// case llamastackclient.ResponseObjectStreamResponseCompleted: +// switch variant := ResponseObjectPromptVariableUnion.AsAny().(type) { +// case llamastackclient.ResponseObjectPromptVariableInputText: +// case llamastackclient.ResponseObjectPromptVariableInputImage: +// case llamastackclient.ResponseObjectPromptVariableInputFile: // default: // fmt.Errorf("no variant present") // } -func (u ResponseObjectStreamUnion) AsAny() anyResponseObjectStream { +func (u ResponseObjectPromptVariableUnion) AsAny() anyResponseObjectPromptVariable { switch u.Type { - case "response.created": - return u.AsResponseCreated() - case "response.output_item.added": - return u.AsResponseOutputItemAdded() - case "response.output_item.done": - return u.AsResponseOutputItemDone() - case "response.output_text.delta": - return u.AsResponseOutputTextDelta() - case "response.output_text.done": - return u.AsResponseOutputTextDone() - case "response.function_call_arguments.delta": - return u.AsResponseFunctionCallArgumentsDelta() - case "response.function_call_arguments.done": - return u.AsResponseFunctionCallArgumentsDone() - case "response.web_search_call.in_progress": - return u.AsResponseWebSearchCallInProgress() - case "response.web_search_call.searching": - return u.AsResponseWebSearchCallSearching() - case "response.web_search_call.completed": - return u.AsResponseWebSearchCallCompleted() - case "response.mcp_list_tools.in_progress": - return u.AsResponseMcpListToolsInProgress() - case "response.mcp_list_tools.failed": - return u.AsResponseMcpListToolsFailed() - case "response.mcp_list_tools.completed": - return u.AsResponseMcpListToolsCompleted() - case "response.mcp_call.arguments.delta": - return u.AsResponseMcpCallArgumentsDelta() - case "response.mcp_call.arguments.done": - return u.AsResponseMcpCallArgumentsDone() - case "response.mcp_call.in_progress": - return u.AsResponseMcpCallInProgress() - case "response.mcp_call.failed": - return u.AsResponseMcpCallFailed() - case "response.mcp_call.completed": - return u.AsResponseMcpCallCompleted() - case "response.content_part.added": - return u.AsResponseContentPartAdded() - case "response.content_part.done": - return u.AsResponseContentPartDone() - case "response.completed": - return u.AsResponseCompleted() + case "input_text": + return u.AsInputText() + case "input_image": + return u.AsInputImage() + case "input_file": + return u.AsInputFile() } return nil } -func (u ResponseObjectStreamUnion) AsResponseCreated() (v ResponseObjectStreamResponseCreated) { +func (u ResponseObjectPromptVariableUnion) AsInputText() (v ResponseObjectPromptVariableInputText) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamUnion) AsResponseOutputItemAdded() (v ResponseObjectStreamResponseOutputItemAdded) { +func (u ResponseObjectPromptVariableUnion) AsInputImage() (v ResponseObjectPromptVariableInputImage) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamUnion) AsResponseOutputItemDone() (v ResponseObjectStreamResponseOutputItemDone) { +func (u ResponseObjectPromptVariableUnion) AsInputFile() (v ResponseObjectPromptVariableInputFile) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamUnion) AsResponseOutputTextDelta() (v ResponseObjectStreamResponseOutputTextDelta) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} +// Returns the unmodified JSON received from the API +func (u ResponseObjectPromptVariableUnion) RawJSON() string { return u.JSON.raw } -func (u ResponseObjectStreamUnion) AsResponseOutputTextDone() (v ResponseObjectStreamResponseOutputTextDone) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +func (r *ResponseObjectPromptVariableUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ResponseObjectStreamUnion) AsResponseFunctionCallArgumentsDelta() (v ResponseObjectStreamResponseFunctionCallArgumentsDelta) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// 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"` + // 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 (u ResponseObjectStreamUnion) AsResponseFunctionCallArgumentsDone() (v ResponseObjectStreamResponseFunctionCallArgumentsDone) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Returns the unmodified JSON received from the API +func (r ResponseObjectPromptVariableInputText) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectPromptVariableInputText) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ResponseObjectStreamUnion) AsResponseWebSearchCallInProgress() (v ResponseObjectStreamResponseWebSearchCallInProgress) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// 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"` + // 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 + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } -func (u ResponseObjectStreamUnion) AsResponseWebSearchCallSearching() (v ResponseObjectStreamResponseWebSearchCallSearching) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Returns the unmodified JSON received from the API +func (r ResponseObjectPromptVariableInputImage) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectPromptVariableInputImage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ResponseObjectStreamUnion) AsResponseWebSearchCallCompleted() (v ResponseObjectStreamResponseWebSearchCallCompleted) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} +// Level of detail for image processing, can be "low", "high", or "auto" +type ResponseObjectPromptVariableInputImageDetail string -func (u ResponseObjectStreamUnion) AsResponseMcpListToolsInProgress() (v ResponseObjectStreamResponseMcpListToolsInProgress) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} +const ( + ResponseObjectPromptVariableInputImageDetailLow ResponseObjectPromptVariableInputImageDetail = "low" + ResponseObjectPromptVariableInputImageDetailHigh ResponseObjectPromptVariableInputImageDetail = "high" + ResponseObjectPromptVariableInputImageDetailAuto ResponseObjectPromptVariableInputImageDetail = "auto" +) -func (u ResponseObjectStreamUnion) AsResponseMcpListToolsFailed() (v ResponseObjectStreamResponseMcpListToolsFailed) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// 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"` + // 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 + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } -func (u ResponseObjectStreamUnion) AsResponseMcpListToolsCompleted() (v ResponseObjectStreamResponseMcpListToolsCompleted) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Returns the unmodified JSON received from the API +func (r ResponseObjectPromptVariableInputFile) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectPromptVariableInputFile) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ResponseObjectStreamUnion) AsResponseMcpCallArgumentsDelta() (v ResponseObjectStreamResponseMcpCallArgumentsDelta) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Level of detail for image processing, can be "low", "high", or "auto" +type ResponseObjectPromptVariableDetail string + +const ( + ResponseObjectPromptVariableDetailLow ResponseObjectPromptVariableDetail = "low" + ResponseObjectPromptVariableDetailHigh ResponseObjectPromptVariableDetail = "high" + ResponseObjectPromptVariableDetailAuto ResponseObjectPromptVariableDetail = "auto" +) + +// 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"` + // This field is from variant [ResponseObjectToolOpenAIResponseInputToolWebSearch]. + SearchContextSize string `json:"search_context_size"` + // This field is from variant [ResponseObjectToolFileSearch]. + VectorStoreIDs []string `json:"vector_store_ids"` + // This field is from variant [ResponseObjectToolFileSearch]. + Filters map[string]ResponseObjectToolFileSearchFilterUnion `json:"filters"` + // This field is from variant [ResponseObjectToolFileSearch]. + MaxNumResults int64 `json:"max_num_results"` + // This field is from variant [ResponseObjectToolFileSearch]. + RankingOptions ResponseObjectToolFileSearchRankingOptions `json:"ranking_options"` + // This field is from variant [ResponseObjectToolFunction]. + Name string `json:"name"` + // This field is from variant [ResponseObjectToolFunction]. + Description string `json:"description"` + // This field is from variant [ResponseObjectToolFunction]. + Parameters map[string]ResponseObjectToolFunctionParameterUnion `json:"parameters"` + // This field is from variant [ResponseObjectToolFunction]. + Strict bool `json:"strict"` + // This field is from variant [ResponseObjectToolMcp]. + ServerLabel string `json:"server_label"` + // This field is from variant [ResponseObjectToolMcp]. + AllowedTools ResponseObjectToolMcpAllowedToolsUnion `json:"allowed_tools"` + JSON struct { + Type respjson.Field + SearchContextSize respjson.Field + VectorStoreIDs respjson.Field + Filters respjson.Field + MaxNumResults respjson.Field + RankingOptions respjson.Field + Name respjson.Field + Description respjson.Field + Parameters respjson.Field + Strict respjson.Field + ServerLabel respjson.Field + AllowedTools respjson.Field + raw string + } `json:"-"` } -func (u ResponseObjectStreamUnion) AsResponseMcpCallArgumentsDone() (v ResponseObjectStreamResponseMcpCallArgumentsDone) { +func (u ResponseObjectToolUnion) AsOpenAIResponseInputToolWebSearch() (v ResponseObjectToolOpenAIResponseInputToolWebSearch) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamUnion) AsResponseMcpCallInProgress() (v ResponseObjectStreamResponseMcpCallInProgress) { +func (u ResponseObjectToolUnion) AsFileSearch() (v ResponseObjectToolFileSearch) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamUnion) AsResponseMcpCallFailed() (v ResponseObjectStreamResponseMcpCallFailed) { +func (u ResponseObjectToolUnion) AsFunction() (v ResponseObjectToolFunction) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamUnion) AsResponseMcpCallCompleted() (v ResponseObjectStreamResponseMcpCallCompleted) { +func (u ResponseObjectToolUnion) AsMcp() (v ResponseObjectToolMcp) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamUnion) AsResponseContentPartAdded() (v ResponseObjectStreamResponseContentPartAdded) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} +// Returns the unmodified JSON received from the API +func (u ResponseObjectToolUnion) RawJSON() string { return u.JSON.raw } -func (u ResponseObjectStreamUnion) AsResponseContentPartDone() (v ResponseObjectStreamResponseContentPartDone) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +func (r *ResponseObjectToolUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ResponseObjectStreamUnion) AsResponseCompleted() (v ResponseObjectStreamResponseCompleted) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Web search tool configuration for OpenAI response inputs. +type ResponseObjectToolOpenAIResponseInputToolWebSearch struct { + // Web search tool type variant to use + // + // 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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Type respjson.Field + SearchContextSize respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } // Returns the unmodified JSON received from the API -func (u ResponseObjectStreamUnion) RawJSON() string { return u.JSON.raw } - -func (r *ResponseObjectStreamUnion) UnmarshalJSON(data []byte) error { +func (r ResponseObjectToolOpenAIResponseInputToolWebSearch) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectToolOpenAIResponseInputToolWebSearch) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamUnionItem is an implicit subunion of -// [ResponseObjectStreamUnion]. ResponseObjectStreamUnionItem provides convenient -// access to the sub-properties of the union. -// -// For type safety it is recommended to directly use a variant of the -// [ResponseObjectStreamUnion]. -type ResponseObjectStreamUnionItem struct { - // This field is a union of - // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion], - // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion] - Content ResponseObjectStreamUnionItemContent `json:"content"` - Role string `json:"role"` - Type string `json:"type"` - ID string `json:"id"` - Status string `json:"status"` - Queries []string `json:"queries"` - // This field is a union of - // [[]ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult], - // [[]ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResult] - Results ResponseObjectStreamUnionItemResults `json:"results"` - Arguments string `json:"arguments"` - CallID string `json:"call_id"` - Name string `json:"name"` - ServerLabel string `json:"server_label"` - Error string `json:"error"` - Output string `json:"output"` - // This field is a union of - // [[]ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTool], - // [[]ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsTool] - Tools ResponseObjectStreamUnionItemTools `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 - ServerLabel respjson.Field - Error respjson.Field - Output respjson.Field - Tools respjson.Field - raw string +// 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"` + // 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 + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } -func (r *ResponseObjectStreamUnionItem) UnmarshalJSON(data []byte) error { +// Returns the unmodified JSON received from the API +func (r ResponseObjectToolFileSearch) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectToolFileSearch) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamUnionItemContent is an implicit subunion of -// [ResponseObjectStreamUnion]. ResponseObjectStreamUnionItemContent provides -// convenient access to the sub-properties of the union. +// ResponseObjectToolFileSearchFilterUnion contains all possible properties and +// values from [bool], [float64], [string], [[]any]. // -// For type safety it is recommended to directly use a variant of the -// [ResponseObjectStreamUnion]. +// 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 -// OfResponseObjectStreamResponseOutputItemAddedItemMessageContentArray OfVariant2 -// OfResponseObjectStreamResponseOutputItemDoneItemMessageContentArray] -type ResponseObjectStreamUnionItemContent struct { +// 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 - // [[]ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion] - // instead of an object. - OfResponseObjectStreamResponseOutputItemAddedItemMessageContentArray []ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion `json:",inline"` - // This field will be present if the value is a - // [[]ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItem] - // instead of an object. - OfVariant2 []ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItem `json:",inline"` - // This field will be present if the value is a - // [[]ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion] - // instead of an object. - OfResponseObjectStreamResponseOutputItemDoneItemMessageContentArray []ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion `json:",inline"` - JSON struct { - OfString respjson.Field - OfResponseObjectStreamResponseOutputItemAddedItemMessageContentArray respjson.Field - OfVariant2 respjson.Field - OfResponseObjectStreamResponseOutputItemDoneItemMessageContentArray respjson.Field - raw string + // 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 (r *ResponseObjectStreamUnionItemContent) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ResponseObjectStreamUnionItemResults is an implicit subunion of -// [ResponseObjectStreamUnion]. ResponseObjectStreamUnionItemResults 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: -// OfResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResults -// OfResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResults] -type ResponseObjectStreamUnionItemResults struct { - // This field will be present if the value is a - // [[]ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult] instead - // of an object. - OfResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResults []ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult `json:",inline"` - // This field will be present if the value is a - // [[]ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResult] instead - // of an object. - OfResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResults []ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResult `json:",inline"` - JSON struct { - OfResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResults respjson.Field - OfResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResults respjson.Field - raw string - } `json:"-"` +func (u ResponseObjectToolFileSearchFilterUnion) AsBool() (v bool) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return } -func (r *ResponseObjectStreamUnionItemResults) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) +func (u ResponseObjectToolFileSearchFilterUnion) AsFloat() (v float64) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return } -// ResponseObjectStreamUnionItemTools is an implicit subunion of -// [ResponseObjectStreamUnion]. ResponseObjectStreamUnionItemTools 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: -// OfResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTools -// OfResponseObjectStreamResponseOutputItemDoneItemMcpListToolsTools] -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 - } `json:"-"` +func (u ResponseObjectToolFileSearchFilterUnion) AsString() (v string) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return } -func (r *ResponseObjectStreamUnionItemTools) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) +func (u ResponseObjectToolFileSearchFilterUnion) AsAnyArray() (v []any) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return } -// ResponseObjectStreamUnionPart is an implicit subunion of -// [ResponseObjectStreamUnion]. ResponseObjectStreamUnionPart provides convenient -// access to the sub-properties of the union. -// -// For type safety it is recommended to directly use a variant of the -// [ResponseObjectStreamUnion]. -type ResponseObjectStreamUnionPart struct { - Text string `json:"text"` - Type string `json:"type"` - Refusal string `json:"refusal"` - JSON struct { - Text respjson.Field - Type respjson.Field - Refusal respjson.Field - raw string - } `json:"-"` -} +// Returns the unmodified JSON received from the API +func (u ResponseObjectToolFileSearchFilterUnion) RawJSON() string { return u.JSON.raw } -func (r *ResponseObjectStreamUnionPart) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectToolFileSearchFilterUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Streaming event indicating a new response has been created. -type ResponseObjectStreamResponseCreated struct { - // The newly created response object - Response ResponseObject `json:"response,required"` - // Event type identifier, always "response.created" - Type constant.ResponseCreated `json:"type,required"` +// (Optional) Options for ranking and scoring 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Response respjson.Field - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string + Ranker respjson.Field + ScoreThreshold respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseCreated) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseCreated) UnmarshalJSON(data []byte) error { +func (r ResponseObjectToolFileSearchRankingOptions) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectToolFileSearchRankingOptions) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// 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"` +// 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"` // 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 + Name respjson.Field + Type respjson.Field + Description respjson.Field + Parameters respjson.Field + Strict respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemAdded) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAdded) UnmarshalJSON(data []byte) error { +func (r ResponseObjectToolFunction) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectToolFunction) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamResponseOutputItemAddedItemUnion contains all possible -// properties and values from -// [ResponseObjectStreamResponseOutputItemAddedItemMessage], -// [ResponseObjectStreamResponseOutputItemAddedItemWebSearchCall], -// [ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall], -// [ResponseObjectStreamResponseOutputItemAddedItemFunctionCall], -// [ResponseObjectStreamResponseOutputItemAddedItemMcpCall], -// [ResponseObjectStreamResponseOutputItemAddedItemMcpListTools]. -// -// Use the [ResponseObjectStreamResponseOutputItemAddedItemUnion.AsAny] method to -// switch on the variant. +// 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. -type ResponseObjectStreamResponseOutputItemAddedItemUnion struct { - // This field is from variant - // [ResponseObjectStreamResponseOutputItemAddedItemMessage]. - 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". - Type string `json:"type"` - ID string `json:"id"` - Status string `json:"status"` - // This field is from variant - // [ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall]. - Queries []string `json:"queries"` - // This field is from variant - // [ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall]. - Results []ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult `json:"results"` - Arguments string `json:"arguments"` - // This field is from variant - // [ResponseObjectStreamResponseOutputItemAddedItemFunctionCall]. - CallID string `json:"call_id"` - Name string `json:"name"` - ServerLabel string `json:"server_label"` - // This field is from variant - // [ResponseObjectStreamResponseOutputItemAddedItemMcpCall]. - Error string `json:"error"` - // This field is from variant - // [ResponseObjectStreamResponseOutputItemAddedItemMcpCall]. - Output string `json:"output"` - // This field is from variant - // [ResponseObjectStreamResponseOutputItemAddedItemMcpListTools]. - Tools []ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTool `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 - ServerLabel respjson.Field - Error respjson.Field - Output respjson.Field - Tools respjson.Field - raw string - } `json:"-"` -} - -// anyResponseObjectStreamResponseOutputItemAddedItem is implemented by each -// variant of [ResponseObjectStreamResponseOutputItemAddedItemUnion] to add type -// safety for the return type of -// [ResponseObjectStreamResponseOutputItemAddedItemUnion.AsAny] -type anyResponseObjectStreamResponseOutputItemAddedItem interface { - implResponseObjectStreamResponseOutputItemAddedItemUnion() -} - -func (ResponseObjectStreamResponseOutputItemAddedItemMessage) implResponseObjectStreamResponseOutputItemAddedItemUnion() { -} -func (ResponseObjectStreamResponseOutputItemAddedItemWebSearchCall) implResponseObjectStreamResponseOutputItemAddedItemUnion() { -} -func (ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall) implResponseObjectStreamResponseOutputItemAddedItemUnion() { -} -func (ResponseObjectStreamResponseOutputItemAddedItemFunctionCall) implResponseObjectStreamResponseOutputItemAddedItemUnion() { -} -func (ResponseObjectStreamResponseOutputItemAddedItemMcpCall) implResponseObjectStreamResponseOutputItemAddedItemUnion() { -} -func (ResponseObjectStreamResponseOutputItemAddedItemMcpListTools) implResponseObjectStreamResponseOutputItemAddedItemUnion() { -} - -// Use the following switch statement to find the correct variant // -// switch variant := ResponseObjectStreamResponseOutputItemAddedItemUnion.AsAny().(type) { -// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMessage: -// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemWebSearchCall: -// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall: -// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemFunctionCall: -// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMcpCall: -// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMcpListTools: -// default: -// fmt.Errorf("no variant present") -// } -func (u ResponseObjectStreamResponseOutputItemAddedItemUnion) AsAny() anyResponseObjectStreamResponseOutputItemAddedItem { - 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 "mcp_call": - return u.AsMcpCall() - case "mcp_list_tools": - return u.AsMcpListTools() - } - return nil -} - -func (u ResponseObjectStreamResponseOutputItemAddedItemUnion) AsMessage() (v ResponseObjectStreamResponseOutputItemAddedItemMessage) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectStreamResponseOutputItemAddedItemUnion) AsWebSearchCall() (v ResponseObjectStreamResponseOutputItemAddedItemWebSearchCall) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// 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 ResponseObjectStreamResponseOutputItemAddedItemUnion) AsFileSearchCall() (v ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall) { +func (u ResponseObjectToolFunctionParameterUnion) AsBool() (v bool) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemAddedItemUnion) AsFunctionCall() (v ResponseObjectStreamResponseOutputItemAddedItemFunctionCall) { +func (u ResponseObjectToolFunctionParameterUnion) AsFloat() (v float64) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemAddedItemUnion) AsMcpCall() (v ResponseObjectStreamResponseOutputItemAddedItemMcpCall) { +func (u ResponseObjectToolFunctionParameterUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemAddedItemUnion) AsMcpListTools() (v ResponseObjectStreamResponseOutputItemAddedItemMcpListTools) { +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 ResponseObjectStreamResponseOutputItemAddedItemUnion) RawJSON() string { return u.JSON.raw } +func (u ResponseObjectToolFunctionParameterUnion) RawJSON() string { return u.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectToolFunctionParameterUnion) 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 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"` +// 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"` // 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 - ExtraFields map[string]respjson.Field - raw string + ServerLabel respjson.Field + Type respjson.Field + AllowedTools respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemAddedItemMessage) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemMessage) UnmarshalJSON(data []byte) error { +func (r ResponseObjectToolMcp) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectToolMcp) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion contains all -// possible properties and values from [string], -// [[]ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion], -// [[]ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItem]. +// ResponseObjectToolMcpAllowedToolsUnion contains all possible properties and +// values from [[]string], [ResponseObjectToolMcpAllowedToolsAllowedToolsFilter]. // // 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 -// OfResponseObjectStreamResponseOutputItemAddedItemMessageContentArray OfVariant2] -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] - // instead of an object. - OfResponseObjectStreamResponseOutputItemAddedItemMessageContentArray []ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion `json:",inline"` - // This field will be present if the value is a - // [[]ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItem] - // instead of an object. - OfVariant2 []ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfResponseObjectStreamResponseOutputItemAddedItemMessageContentArray respjson.Field - OfVariant2 respjson.Field - raw string +// will be valid: OfStringArray] +type ResponseObjectToolMcpAllowedToolsUnion struct { + // This field will be present if the value is a [[]string] instead of an object. + OfStringArray []string `json:",inline"` + // This field is from variant + // [ResponseObjectToolMcpAllowedToolsAllowedToolsFilter]. + ToolNames []string `json:"tool_names"` + JSON struct { + OfStringArray respjson.Field + ToolNames respjson.Field + raw string } `json:"-"` } -func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion) AsString() (v string) { +func (u ResponseObjectToolMcpAllowedToolsUnion) AsStringArray() (v []string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion) AsResponseObjectStreamResponseOutputItemAddedItemMessageContentArray() (v []ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion) { +func (u ResponseObjectToolMcpAllowedToolsUnion) AsAllowedToolsFilter() (v ResponseObjectToolMcpAllowedToolsAllowedToolsFilter) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion) AsVariant2() (v []ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItem) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Returns the unmodified JSON received from the API +func (u ResponseObjectToolMcpAllowedToolsUnion) RawJSON() string { return u.JSON.raw } + +func (r *ResponseObjectToolMcpAllowedToolsUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -// Returns the unmodified JSON received from the API -func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion) RawJSON() string { - return u.JSON.raw +// 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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ToolNames respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } -func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion) UnmarshalJSON(data []byte) error { +// Returns the unmodified JSON received from the API +func (r ResponseObjectToolMcpAllowedToolsAllowedToolsFilter) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectToolMcpAllowedToolsAllowedToolsFilter) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion -// contains all possible properties and values from -// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputText], -// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage]. -// -// Use the -// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion.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 { - // This field is from variant - // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputText]. - Text string `json:"text"` - // Any of "input_text", "input_image". - Type string `json:"type"` - // This field is from variant - // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage]. - Detail ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImageDetail `json:"detail"` - // This field is from variant - // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage]. - ImageURL string `json:"image_url"` - JSON struct { - Text respjson.Field - Type respjson.Field - Detail respjson.Field - ImageURL respjson.Field - raw string +// 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 +type ResponseObjectUsage struct { + // Number of tokens in the input + InputTokens int64 `json:"input_tokens,required"` + // Number of tokens in the output + 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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + OutputTokens respjson.Field + TotalTokens respjson.Field + InputTokensDetails respjson.Field + OutputTokensDetails respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } -// anyResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItem is -// implemented by each variant of -// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion] to -// add type safety for the return type of -// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion.AsAny] -type anyResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItem interface { - implResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion() +// Returns the unmodified JSON received from the API +func (r ResponseObjectUsage) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectUsage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputText) implResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion() { -} -func (ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage) implResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion() { +// Detailed breakdown of input token usage +type ResponseObjectUsageInputTokensDetails struct { + // Number of tokens retrieved from cache + CachedTokens int64 `json:"cached_tokens"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + CachedTokens respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } -// Use the following switch statement to find the correct variant -// -// switch variant := ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion.AsAny().(type) { -// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputText: -// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage: -// default: -// fmt.Errorf("no variant present") -// } -func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion) AsAny() anyResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItem { - switch u.Type { - case "input_text": - return u.AsInputText() - case "input_image": - return u.AsInputImage() - } - return nil +// Returns the unmodified JSON received from the API +func (r ResponseObjectUsageInputTokensDetails) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectUsageInputTokensDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Detailed breakdown of output token usage +type ResponseObjectUsageOutputTokensDetails struct { + // Number of tokens used for reasoning (o1/o3 models) + ReasoningTokens int64 `json:"reasoning_tokens"` + // 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 ResponseObjectUsageOutputTokensDetails) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectUsageOutputTokensDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ResponseObjectStreamUnion contains all possible properties and values from +// [ResponseObjectStreamResponseCreated], [ResponseObjectStreamResponseInProgress], +// [ResponseObjectStreamResponseOutputItemAdded], +// [ResponseObjectStreamResponseOutputItemDone], +// [ResponseObjectStreamResponseOutputTextDelta], +// [ResponseObjectStreamResponseOutputTextDone], +// [ResponseObjectStreamResponseFunctionCallArgumentsDelta], +// [ResponseObjectStreamResponseFunctionCallArgumentsDone], +// [ResponseObjectStreamResponseWebSearchCallInProgress], +// [ResponseObjectStreamResponseWebSearchCallSearching], +// [ResponseObjectStreamResponseWebSearchCallCompleted], +// [ResponseObjectStreamResponseMcpListToolsInProgress], +// [ResponseObjectStreamResponseMcpListToolsFailed], +// [ResponseObjectStreamResponseMcpListToolsCompleted], +// [ResponseObjectStreamResponseMcpCallArgumentsDelta], +// [ResponseObjectStreamResponseMcpCallArgumentsDone], +// [ResponseObjectStreamResponseMcpCallInProgress], +// [ResponseObjectStreamResponseMcpCallFailed], +// [ResponseObjectStreamResponseMcpCallCompleted], +// [ResponseObjectStreamResponseContentPartAdded], +// [ResponseObjectStreamResponseContentPartDone], +// [ResponseObjectStreamResponseReasoningTextDelta], +// [ResponseObjectStreamResponseReasoningTextDone], +// [ResponseObjectStreamResponseReasoningSummaryPartAdded], +// [ResponseObjectStreamResponseReasoningSummaryPartDone], +// [ResponseObjectStreamResponseReasoningSummaryTextDelta], +// [ResponseObjectStreamResponseReasoningSummaryTextDone], +// [ResponseObjectStreamResponseRefusalDelta], +// [ResponseObjectStreamResponseRefusalDone], +// [ResponseObjectStreamResponseOutputTextAnnotationAdded], +// [ResponseObjectStreamResponseFileSearchCallInProgress], +// [ResponseObjectStreamResponseFileSearchCallSearching], +// [ResponseObjectStreamResponseFileSearchCallCompleted], +// [ResponseObjectStreamResponseIncomplete], [ResponseObjectStreamResponseFailed], +// [ResponseObjectStreamResponseCompleted]. +// +// Use the [ResponseObjectStreamUnion.AsAny] method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ResponseObjectStreamUnion struct { + // This field is from variant [ResponseObjectStreamResponseCreated]. + Response ResponseObject `json:"response"` + // Any of "response.created", "response.in_progress", "response.output_item.added", + // "response.output_item.done", "response.output_text.delta", + // "response.output_text.done", "response.function_call_arguments.delta", + // "response.function_call_arguments.done", "response.web_search_call.in_progress", + // "response.web_search_call.searching", "response.web_search_call.completed", + // "response.mcp_list_tools.in_progress", "response.mcp_list_tools.failed", + // "response.mcp_list_tools.completed", "response.mcp_call.arguments.delta", + // "response.mcp_call.arguments.done", "response.mcp_call.in_progress", + // "response.mcp_call.failed", "response.mcp_call.completed", + // "response.content_part.added", "response.content_part.done", + // "response.reasoning_text.delta", "response.reasoning_text.done", + // "response.reasoning_summary_part.added", "response.reasoning_summary_part.done", + // "response.reasoning_summary_text.delta", "response.reasoning_summary_text.done", + // "response.refusal.delta", "response.refusal.done", + // "response.output_text.annotation.added", + // "response.file_search_call.in_progress", "response.file_search_call.searching", + // "response.file_search_call.completed", "response.incomplete", "response.failed", + // "response.completed". + Type string `json:"type"` + SequenceNumber int64 `json:"sequence_number"` + // This field is a union of [ResponseObjectStreamResponseOutputItemAddedItemUnion], + // [ResponseObjectStreamResponseOutputItemDoneItemUnion] + Item ResponseObjectStreamUnionItem `json:"item"` + OutputIndex int64 `json:"output_index"` + ResponseID string `json:"response_id"` + ContentIndex int64 `json:"content_index"` + Delta string `json:"delta"` + ItemID string `json:"item_id"` + Text string `json:"text"` + Arguments string `json:"arguments"` + // This field is a union of + // [ResponseObjectStreamResponseContentPartAddedPartUnion], + // [ResponseObjectStreamResponseContentPartDonePartUnion], + // [ResponseObjectStreamResponseReasoningSummaryPartAddedPart], + // [ResponseObjectStreamResponseReasoningSummaryPartDonePart] + Part ResponseObjectStreamUnionPart `json:"part"` + SummaryIndex int64 `json:"summary_index"` + // This field is from variant [ResponseObjectStreamResponseRefusalDone]. + Refusal string `json:"refusal"` + // This field is from variant + // [ResponseObjectStreamResponseOutputTextAnnotationAdded]. + Annotation ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationUnion `json:"annotation"` + // This field is from variant + // [ResponseObjectStreamResponseOutputTextAnnotationAdded]. + AnnotationIndex int64 `json:"annotation_index"` + JSON struct { + Response respjson.Field + Type respjson.Field + SequenceNumber respjson.Field + Item respjson.Field + OutputIndex respjson.Field + ResponseID respjson.Field + ContentIndex respjson.Field + Delta respjson.Field + ItemID respjson.Field + Text respjson.Field + Arguments respjson.Field + Part respjson.Field + SummaryIndex respjson.Field + Refusal respjson.Field + Annotation respjson.Field + AnnotationIndex respjson.Field + raw string + } `json:"-"` +} + +// anyResponseObjectStream is implemented by each variant of +// [ResponseObjectStreamUnion] to add type safety for the return type of +// [ResponseObjectStreamUnion.AsAny] +type anyResponseObjectStream interface { + implResponseObjectStreamUnion() +} + +func (ResponseObjectStreamResponseCreated) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseInProgress) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseOutputItemAdded) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseOutputItemDone) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseOutputTextDelta) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseOutputTextDone) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseFunctionCallArgumentsDelta) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseFunctionCallArgumentsDone) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseWebSearchCallInProgress) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseWebSearchCallSearching) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseWebSearchCallCompleted) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseMcpListToolsInProgress) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseMcpListToolsFailed) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseMcpListToolsCompleted) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseMcpCallArgumentsDelta) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseMcpCallArgumentsDone) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseMcpCallInProgress) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseMcpCallFailed) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseMcpCallCompleted) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseContentPartAdded) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseContentPartDone) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseReasoningTextDelta) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseReasoningTextDone) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseReasoningSummaryPartAdded) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseReasoningSummaryPartDone) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseReasoningSummaryTextDelta) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseReasoningSummaryTextDone) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseRefusalDelta) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseRefusalDone) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseOutputTextAnnotationAdded) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseFileSearchCallInProgress) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseFileSearchCallSearching) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseFileSearchCallCompleted) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseIncomplete) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseFailed) implResponseObjectStreamUnion() {} +func (ResponseObjectStreamResponseCompleted) implResponseObjectStreamUnion() {} + +// Use the following switch statement to find the correct variant +// +// switch variant := ResponseObjectStreamUnion.AsAny().(type) { +// case llamastackclient.ResponseObjectStreamResponseCreated: +// case llamastackclient.ResponseObjectStreamResponseInProgress: +// case llamastackclient.ResponseObjectStreamResponseOutputItemAdded: +// case llamastackclient.ResponseObjectStreamResponseOutputItemDone: +// case llamastackclient.ResponseObjectStreamResponseOutputTextDelta: +// case llamastackclient.ResponseObjectStreamResponseOutputTextDone: +// case llamastackclient.ResponseObjectStreamResponseFunctionCallArgumentsDelta: +// case llamastackclient.ResponseObjectStreamResponseFunctionCallArgumentsDone: +// case llamastackclient.ResponseObjectStreamResponseWebSearchCallInProgress: +// case llamastackclient.ResponseObjectStreamResponseWebSearchCallSearching: +// case llamastackclient.ResponseObjectStreamResponseWebSearchCallCompleted: +// case llamastackclient.ResponseObjectStreamResponseMcpListToolsInProgress: +// case llamastackclient.ResponseObjectStreamResponseMcpListToolsFailed: +// case llamastackclient.ResponseObjectStreamResponseMcpListToolsCompleted: +// case llamastackclient.ResponseObjectStreamResponseMcpCallArgumentsDelta: +// case llamastackclient.ResponseObjectStreamResponseMcpCallArgumentsDone: +// case llamastackclient.ResponseObjectStreamResponseMcpCallInProgress: +// case llamastackclient.ResponseObjectStreamResponseMcpCallFailed: +// case llamastackclient.ResponseObjectStreamResponseMcpCallCompleted: +// case llamastackclient.ResponseObjectStreamResponseContentPartAdded: +// case llamastackclient.ResponseObjectStreamResponseContentPartDone: +// case llamastackclient.ResponseObjectStreamResponseReasoningTextDelta: +// case llamastackclient.ResponseObjectStreamResponseReasoningTextDone: +// case llamastackclient.ResponseObjectStreamResponseReasoningSummaryPartAdded: +// case llamastackclient.ResponseObjectStreamResponseReasoningSummaryPartDone: +// case llamastackclient.ResponseObjectStreamResponseReasoningSummaryTextDelta: +// case llamastackclient.ResponseObjectStreamResponseReasoningSummaryTextDone: +// case llamastackclient.ResponseObjectStreamResponseRefusalDelta: +// case llamastackclient.ResponseObjectStreamResponseRefusalDone: +// case llamastackclient.ResponseObjectStreamResponseOutputTextAnnotationAdded: +// case llamastackclient.ResponseObjectStreamResponseFileSearchCallInProgress: +// case llamastackclient.ResponseObjectStreamResponseFileSearchCallSearching: +// case llamastackclient.ResponseObjectStreamResponseFileSearchCallCompleted: +// case llamastackclient.ResponseObjectStreamResponseIncomplete: +// case llamastackclient.ResponseObjectStreamResponseFailed: +// case llamastackclient.ResponseObjectStreamResponseCompleted: +// default: +// fmt.Errorf("no variant present") +// } +func (u ResponseObjectStreamUnion) AsAny() anyResponseObjectStream { + switch u.Type { + case "response.created": + return u.AsResponseCreated() + case "response.in_progress": + return u.AsResponseInProgress() + case "response.output_item.added": + return u.AsResponseOutputItemAdded() + case "response.output_item.done": + return u.AsResponseOutputItemDone() + case "response.output_text.delta": + return u.AsResponseOutputTextDelta() + case "response.output_text.done": + return u.AsResponseOutputTextDone() + case "response.function_call_arguments.delta": + return u.AsResponseFunctionCallArgumentsDelta() + case "response.function_call_arguments.done": + return u.AsResponseFunctionCallArgumentsDone() + case "response.web_search_call.in_progress": + return u.AsResponseWebSearchCallInProgress() + case "response.web_search_call.searching": + return u.AsResponseWebSearchCallSearching() + case "response.web_search_call.completed": + return u.AsResponseWebSearchCallCompleted() + case "response.mcp_list_tools.in_progress": + return u.AsResponseMcpListToolsInProgress() + case "response.mcp_list_tools.failed": + return u.AsResponseMcpListToolsFailed() + case "response.mcp_list_tools.completed": + return u.AsResponseMcpListToolsCompleted() + case "response.mcp_call.arguments.delta": + return u.AsResponseMcpCallArgumentsDelta() + case "response.mcp_call.arguments.done": + return u.AsResponseMcpCallArgumentsDone() + case "response.mcp_call.in_progress": + return u.AsResponseMcpCallInProgress() + case "response.mcp_call.failed": + return u.AsResponseMcpCallFailed() + case "response.mcp_call.completed": + return u.AsResponseMcpCallCompleted() + case "response.content_part.added": + return u.AsResponseContentPartAdded() + case "response.content_part.done": + return u.AsResponseContentPartDone() + case "response.reasoning_text.delta": + return u.AsResponseReasoningTextDelta() + case "response.reasoning_text.done": + return u.AsResponseReasoningTextDone() + case "response.reasoning_summary_part.added": + return u.AsResponseReasoningSummaryPartAdded() + case "response.reasoning_summary_part.done": + return u.AsResponseReasoningSummaryPartDone() + case "response.reasoning_summary_text.delta": + return u.AsResponseReasoningSummaryTextDelta() + case "response.reasoning_summary_text.done": + return u.AsResponseReasoningSummaryTextDone() + case "response.refusal.delta": + return u.AsResponseRefusalDelta() + case "response.refusal.done": + return u.AsResponseRefusalDone() + case "response.output_text.annotation.added": + return u.AsResponseOutputTextAnnotationAdded() + case "response.file_search_call.in_progress": + return u.AsResponseFileSearchCallInProgress() + case "response.file_search_call.searching": + return u.AsResponseFileSearchCallSearching() + case "response.file_search_call.completed": + return u.AsResponseFileSearchCallCompleted() + case "response.incomplete": + return u.AsResponseIncomplete() + case "response.failed": + return u.AsResponseFailed() + case "response.completed": + return u.AsResponseCompleted() + } + return nil +} + +func (u ResponseObjectStreamUnion) AsResponseCreated() (v ResponseObjectStreamResponseCreated) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseInProgress() (v ResponseObjectStreamResponseInProgress) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseOutputItemAdded() (v ResponseObjectStreamResponseOutputItemAdded) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseOutputItemDone() (v ResponseObjectStreamResponseOutputItemDone) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseOutputTextDelta() (v ResponseObjectStreamResponseOutputTextDelta) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseOutputTextDone() (v ResponseObjectStreamResponseOutputTextDone) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseFunctionCallArgumentsDelta() (v ResponseObjectStreamResponseFunctionCallArgumentsDelta) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseFunctionCallArgumentsDone() (v ResponseObjectStreamResponseFunctionCallArgumentsDone) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseWebSearchCallInProgress() (v ResponseObjectStreamResponseWebSearchCallInProgress) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseWebSearchCallSearching() (v ResponseObjectStreamResponseWebSearchCallSearching) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseWebSearchCallCompleted() (v ResponseObjectStreamResponseWebSearchCallCompleted) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseMcpListToolsInProgress() (v ResponseObjectStreamResponseMcpListToolsInProgress) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseMcpListToolsFailed() (v ResponseObjectStreamResponseMcpListToolsFailed) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseMcpListToolsCompleted() (v ResponseObjectStreamResponseMcpListToolsCompleted) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseMcpCallArgumentsDelta() (v ResponseObjectStreamResponseMcpCallArgumentsDelta) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseMcpCallArgumentsDone() (v ResponseObjectStreamResponseMcpCallArgumentsDone) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseMcpCallInProgress() (v ResponseObjectStreamResponseMcpCallInProgress) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseMcpCallFailed() (v ResponseObjectStreamResponseMcpCallFailed) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseMcpCallCompleted() (v ResponseObjectStreamResponseMcpCallCompleted) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseContentPartAdded() (v ResponseObjectStreamResponseContentPartAdded) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseContentPartDone() (v ResponseObjectStreamResponseContentPartDone) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseReasoningTextDelta() (v ResponseObjectStreamResponseReasoningTextDelta) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseReasoningTextDone() (v ResponseObjectStreamResponseReasoningTextDone) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseReasoningSummaryPartAdded() (v ResponseObjectStreamResponseReasoningSummaryPartAdded) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseReasoningSummaryPartDone() (v ResponseObjectStreamResponseReasoningSummaryPartDone) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseReasoningSummaryTextDelta() (v ResponseObjectStreamResponseReasoningSummaryTextDelta) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseReasoningSummaryTextDone() (v ResponseObjectStreamResponseReasoningSummaryTextDone) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseRefusalDelta() (v ResponseObjectStreamResponseRefusalDelta) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseRefusalDone() (v ResponseObjectStreamResponseRefusalDone) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseOutputTextAnnotationAdded() (v ResponseObjectStreamResponseOutputTextAnnotationAdded) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseFileSearchCallInProgress() (v ResponseObjectStreamResponseFileSearchCallInProgress) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseFileSearchCallSearching() (v ResponseObjectStreamResponseFileSearchCallSearching) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseFileSearchCallCompleted() (v ResponseObjectStreamResponseFileSearchCallCompleted) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseIncomplete() (v ResponseObjectStreamResponseIncomplete) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseFailed() (v ResponseObjectStreamResponseFailed) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamUnion) AsResponseCompleted() (v ResponseObjectStreamResponseCompleted) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ResponseObjectStreamUnion) RawJSON() string { return u.JSON.raw } + +func (r *ResponseObjectStreamUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ResponseObjectStreamUnionItem is an implicit subunion of +// [ResponseObjectStreamUnion]. ResponseObjectStreamUnionItem provides convenient +// access to the sub-properties of the union. +// +// For type safety it is recommended to directly use a variant of the +// [ResponseObjectStreamUnion]. +type ResponseObjectStreamUnionItem struct { + // This field is a union of + // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion], + // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion] + Content ResponseObjectStreamUnionItemContent `json:"content"` + Role string `json:"role"` + Type string `json:"type"` + ID string `json:"id"` + Status string `json:"status"` + Queries []string `json:"queries"` + // This field is a union of + // [[]ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult], + // [[]ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResult] + Results ResponseObjectStreamUnionItemResults `json:"results"` + Arguments string `json:"arguments"` + CallID string `json:"call_id"` + Name string `json:"name"` + ServerLabel string `json:"server_label"` + Error string `json:"error"` + Output string `json:"output"` + // This field is a union of + // [[]ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTool], + // [[]ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsTool] + Tools ResponseObjectStreamUnionItemTools `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 + ServerLabel respjson.Field + Error respjson.Field + Output respjson.Field + Tools respjson.Field + raw string + } `json:"-"` +} + +func (r *ResponseObjectStreamUnionItem) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ResponseObjectStreamUnionItemContent is an implicit subunion of +// [ResponseObjectStreamUnion]. ResponseObjectStreamUnionItemContent 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: OfString OfVariant2] +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] + // instead of an object. + OfVariant2 []ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion `json:",inline"` + JSON struct { + OfString respjson.Field + OfVariant2 respjson.Field + raw string + } `json:"-"` +} + +func (r *ResponseObjectStreamUnionItemContent) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ResponseObjectStreamUnionItemResults is an implicit subunion of +// [ResponseObjectStreamUnion]. ResponseObjectStreamUnionItemResults 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: +// OfResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResults +// OfResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResults] +type ResponseObjectStreamUnionItemResults struct { + // This field will be present if the value is a + // [[]ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult] instead + // of an object. + OfResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResults []ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult `json:",inline"` + // This field will be present if the value is a + // [[]ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResult] instead + // of an object. + OfResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResults []ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResult `json:",inline"` + JSON struct { + OfResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResults respjson.Field + OfResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResults respjson.Field + raw string + } `json:"-"` +} + +func (r *ResponseObjectStreamUnionItemResults) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ResponseObjectStreamUnionItemTools is an implicit subunion of +// [ResponseObjectStreamUnion]. ResponseObjectStreamUnionItemTools 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: +// OfResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTools +// OfResponseObjectStreamResponseOutputItemDoneItemMcpListToolsTools] +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 + } `json:"-"` +} + +func (r *ResponseObjectStreamUnionItemTools) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ResponseObjectStreamUnionPart is an implicit subunion of +// [ResponseObjectStreamUnion]. ResponseObjectStreamUnionPart provides convenient +// access to the sub-properties of the union. +// +// For type safety it is recommended to directly use a variant of the +// [ResponseObjectStreamUnion]. +type ResponseObjectStreamUnionPart struct { + // This field is a union of + // [[]ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion], + // [[]ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion] + Annotations ResponseObjectStreamUnionPartAnnotations `json:"annotations"` + Text string `json:"text"` + 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 + Text respjson.Field + Type respjson.Field + Logprobs respjson.Field + Refusal respjson.Field + raw string + } `json:"-"` +} + +func (r *ResponseObjectStreamUnionPart) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ResponseObjectStreamUnionPartAnnotations is an implicit subunion of +// [ResponseObjectStreamUnion]. ResponseObjectStreamUnionPartAnnotations 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: +// OfResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotations +// OfResponseObjectStreamResponseContentPartDonePartOutputTextAnnotations] +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 + } `json:"-"` +} + +func (r *ResponseObjectStreamUnionPartAnnotations) UnmarshalJSON(data []byte) error { + 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 + Response ResponseObject `json:"response,required"` + // Event type identifier, always "response.created" + Type constant.ResponseCreated `json:"type,required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Response respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseCreated) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseCreated) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Response 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 ResponseObjectStreamResponseInProgress) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseInProgress) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` + // 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 ResponseObjectStreamResponseOutputItemAdded) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseOutputItemAdded) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ResponseObjectStreamResponseOutputItemAddedItemUnion contains all possible +// properties and values from +// [ResponseObjectStreamResponseOutputItemAddedItemMessage], +// [ResponseObjectStreamResponseOutputItemAddedItemWebSearchCall], +// [ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall], +// [ResponseObjectStreamResponseOutputItemAddedItemFunctionCall], +// [ResponseObjectStreamResponseOutputItemAddedItemMcpCall], +// [ResponseObjectStreamResponseOutputItemAddedItemMcpListTools], +// [ResponseObjectStreamResponseOutputItemAddedItemMcpApprovalRequest]. +// +// Use the [ResponseObjectStreamResponseOutputItemAddedItemUnion.AsAny] method to +// switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ResponseObjectStreamResponseOutputItemAddedItemUnion struct { + // This field is from variant + // [ResponseObjectStreamResponseOutputItemAddedItemMessage]. + 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"` + ID string `json:"id"` + Status string `json:"status"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall]. + Queries []string `json:"queries"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall]. + Results []ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult `json:"results"` + Arguments string `json:"arguments"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemAddedItemFunctionCall]. + CallID string `json:"call_id"` + Name string `json:"name"` + ServerLabel string `json:"server_label"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemAddedItemMcpCall]. + Error string `json:"error"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemAddedItemMcpCall]. + Output string `json:"output"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemAddedItemMcpListTools]. + Tools []ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTool `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 + ServerLabel respjson.Field + Error respjson.Field + Output respjson.Field + Tools respjson.Field + raw string + } `json:"-"` +} + +// anyResponseObjectStreamResponseOutputItemAddedItem is implemented by each +// variant of [ResponseObjectStreamResponseOutputItemAddedItemUnion] to add type +// safety for the return type of +// [ResponseObjectStreamResponseOutputItemAddedItemUnion.AsAny] +type anyResponseObjectStreamResponseOutputItemAddedItem interface { + implResponseObjectStreamResponseOutputItemAddedItemUnion() +} + +func (ResponseObjectStreamResponseOutputItemAddedItemMessage) implResponseObjectStreamResponseOutputItemAddedItemUnion() { +} +func (ResponseObjectStreamResponseOutputItemAddedItemWebSearchCall) implResponseObjectStreamResponseOutputItemAddedItemUnion() { +} +func (ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall) implResponseObjectStreamResponseOutputItemAddedItemUnion() { +} +func (ResponseObjectStreamResponseOutputItemAddedItemFunctionCall) implResponseObjectStreamResponseOutputItemAddedItemUnion() { +} +func (ResponseObjectStreamResponseOutputItemAddedItemMcpCall) implResponseObjectStreamResponseOutputItemAddedItemUnion() { +} +func (ResponseObjectStreamResponseOutputItemAddedItemMcpListTools) implResponseObjectStreamResponseOutputItemAddedItemUnion() { +} +func (ResponseObjectStreamResponseOutputItemAddedItemMcpApprovalRequest) implResponseObjectStreamResponseOutputItemAddedItemUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := ResponseObjectStreamResponseOutputItemAddedItemUnion.AsAny().(type) { +// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMessage: +// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemWebSearchCall: +// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall: +// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemFunctionCall: +// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMcpCall: +// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMcpListTools: +// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMcpApprovalRequest: +// default: +// fmt.Errorf("no variant present") +// } +func (u ResponseObjectStreamResponseOutputItemAddedItemUnion) AsAny() anyResponseObjectStreamResponseOutputItemAddedItem { + 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 "mcp_call": + return u.AsMcpCall() + case "mcp_list_tools": + return u.AsMcpListTools() + case "mcp_approval_request": + return u.AsMcpApprovalRequest() + } + return nil +} + +func (u ResponseObjectStreamResponseOutputItemAddedItemUnion) AsMessage() (v ResponseObjectStreamResponseOutputItemAddedItemMessage) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputItemAddedItemUnion) AsWebSearchCall() (v ResponseObjectStreamResponseOutputItemAddedItemWebSearchCall) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputItemAddedItemUnion) AsFileSearchCall() (v ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputItemAddedItemUnion) AsFunctionCall() (v ResponseObjectStreamResponseOutputItemAddedItemFunctionCall) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputItemAddedItemUnion) AsMcpCall() (v ResponseObjectStreamResponseOutputItemAddedItemMcpCall) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputItemAddedItemUnion) AsMcpListTools() (v ResponseObjectStreamResponseOutputItemAddedItemMcpListTools) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputItemAddedItemUnion) AsMcpApprovalRequest() (v ResponseObjectStreamResponseOutputItemAddedItemMcpApprovalRequest) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ResponseObjectStreamResponseOutputItemAddedItemUnion) RawJSON() string { return u.JSON.raw } + +func (r *ResponseObjectStreamResponseOutputItemAddedItemUnion) 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 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"` + // 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 + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseOutputItemAddedItemMessage) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseOutputItemAddedItemMessage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion contains all +// possible properties and values from [string], +// [[]ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion], +// [[]ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion]. +// +// 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 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] + // instead of an object. + OfVariant2 []ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion `json:",inline"` + JSON struct { + OfString respjson.Field + OfVariant2 respjson.Field + raw string + } `json:"-"` +} + +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion) AsString() (v string) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion) AsResponseObjectStreamResponseOutputItemAddedItemMessageContentArray() (v []ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion) AsVariant2() (v []ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion +// contains all possible properties and values from +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputText], +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage], +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputFile]. +// +// Use the +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion.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 { + // This field is from variant + // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputText]. + 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"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage]. + ImageURL string `json:"image_url"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputFile]. + FileData string `json:"file_data"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputFile]. + FileURL string `json:"file_url"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputFile]. + 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:"-"` +} + +// anyResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItem is +// implemented by each variant of +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion] to +// add type safety for the return type of +// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion.AsAny] +type anyResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItem interface { + implResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion() +} + +func (ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputText) implResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion() { +} +func (ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage) implResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion() { +} +func (ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputFile) implResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion.AsAny().(type) { +// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputText: +// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage: +// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputFile: +// default: +// fmt.Errorf("no variant present") +// } +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion) AsAny() anyResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItem { + 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 ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion) AsInputText() (v ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputText) { @@ -2027,240 +2853,884 @@ func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUn return } -func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion) AsInputImage() (v ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage) { +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion) AsInputImage() (v ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion) AsInputFile() (v ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputFile) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion) 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 + Text string `json:"text,required"` + // Content type identifier, always "input_text" + Type constant.InputText `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:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputText) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputText) 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" + // + // 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"` + // 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 + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage) 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"` + // 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 + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputFile) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputFile) 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 + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseOutputItemAddedItemWebSearchCall) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseOutputItemAddedItemWebSearchCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall) 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"` + // 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 ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion +// 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 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 + } `json:"-"` +} + +func (u ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion) AsBool() (v bool) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion) AsFloat() (v float64) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion) AsString() (v string) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion) AsAnyArray() (v []any) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion) 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"` + // 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 + 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 { + // 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"` + // 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 + 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 { + // 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"` + // 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 { + // 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"` + // 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) +} + +// 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 + } `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 +} + +func (u ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSchemaUnion) AsString() (v string) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSchemaUnion) AsAnyArray() (v []any) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSchemaUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSchemaUnion) 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"` + // 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) +} + +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"` + // 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 +// [ResponseObjectStreamResponseOutputItemDoneItemMessage], +// [ResponseObjectStreamResponseOutputItemDoneItemWebSearchCall], +// [ResponseObjectStreamResponseOutputItemDoneItemFileSearchCall], +// [ResponseObjectStreamResponseOutputItemDoneItemFunctionCall], +// [ResponseObjectStreamResponseOutputItemDoneItemMcpCall], +// [ResponseObjectStreamResponseOutputItemDoneItemMcpListTools], +// [ResponseObjectStreamResponseOutputItemDoneItemMcpApprovalRequest]. +// +// Use the [ResponseObjectStreamResponseOutputItemDoneItemUnion.AsAny] method to +// switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ResponseObjectStreamResponseOutputItemDoneItemUnion struct { + // This field is from variant + // [ResponseObjectStreamResponseOutputItemDoneItemMessage]. + 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"` + ID string `json:"id"` + Status string `json:"status"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemDoneItemFileSearchCall]. + Queries []string `json:"queries"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemDoneItemFileSearchCall]. + Results []ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResult `json:"results"` + Arguments string `json:"arguments"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemDoneItemFunctionCall]. + CallID string `json:"call_id"` + Name string `json:"name"` + ServerLabel string `json:"server_label"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemDoneItemMcpCall]. + Error string `json:"error"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemDoneItemMcpCall]. + Output string `json:"output"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemDoneItemMcpListTools]. + Tools []ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsTool `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 + ServerLabel respjson.Field + Error respjson.Field + Output respjson.Field + Tools respjson.Field + raw string + } `json:"-"` +} + +// anyResponseObjectStreamResponseOutputItemDoneItem is implemented by each variant +// of [ResponseObjectStreamResponseOutputItemDoneItemUnion] to add type safety for +// the return type of [ResponseObjectStreamResponseOutputItemDoneItemUnion.AsAny] +type anyResponseObjectStreamResponseOutputItemDoneItem interface { + implResponseObjectStreamResponseOutputItemDoneItemUnion() +} + +func (ResponseObjectStreamResponseOutputItemDoneItemMessage) implResponseObjectStreamResponseOutputItemDoneItemUnion() { +} +func (ResponseObjectStreamResponseOutputItemDoneItemWebSearchCall) implResponseObjectStreamResponseOutputItemDoneItemUnion() { +} +func (ResponseObjectStreamResponseOutputItemDoneItemFileSearchCall) implResponseObjectStreamResponseOutputItemDoneItemUnion() { +} +func (ResponseObjectStreamResponseOutputItemDoneItemFunctionCall) implResponseObjectStreamResponseOutputItemDoneItemUnion() { +} +func (ResponseObjectStreamResponseOutputItemDoneItemMcpCall) implResponseObjectStreamResponseOutputItemDoneItemUnion() { +} +func (ResponseObjectStreamResponseOutputItemDoneItemMcpListTools) implResponseObjectStreamResponseOutputItemDoneItemUnion() { +} +func (ResponseObjectStreamResponseOutputItemDoneItemMcpApprovalRequest) implResponseObjectStreamResponseOutputItemDoneItemUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := ResponseObjectStreamResponseOutputItemDoneItemUnion.AsAny().(type) { +// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMessage: +// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemWebSearchCall: +// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemFileSearchCall: +// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemFunctionCall: +// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMcpCall: +// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMcpListTools: +// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMcpApprovalRequest: +// default: +// fmt.Errorf("no variant present") +// } +func (u ResponseObjectStreamResponseOutputItemDoneItemUnion) AsAny() anyResponseObjectStreamResponseOutputItemDoneItem { + 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 "mcp_call": + return u.AsMcpCall() + case "mcp_list_tools": + return u.AsMcpListTools() + case "mcp_approval_request": + return u.AsMcpApprovalRequest() + } + return nil +} + +func (u ResponseObjectStreamResponseOutputItemDoneItemUnion) AsMessage() (v ResponseObjectStreamResponseOutputItemDoneItemMessage) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputItemDoneItemUnion) AsWebSearchCall() (v ResponseObjectStreamResponseOutputItemDoneItemWebSearchCall) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -// Returns the unmodified JSON received from the API -func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion) RawJSON() string { - return u.JSON.raw +func (u ResponseObjectStreamResponseOutputItemDoneItemUnion) AsFileSearchCall() (v ResponseObjectStreamResponseOutputItemDoneItemFileSearchCall) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return } -func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemUnion) UnmarshalJSON(data []byte) error { +func (u ResponseObjectStreamResponseOutputItemDoneItemUnion) AsFunctionCall() (v ResponseObjectStreamResponseOutputItemDoneItemFunctionCall) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputItemDoneItemUnion) AsMcpCall() (v ResponseObjectStreamResponseOutputItemDoneItemMcpCall) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputItemDoneItemUnion) AsMcpListTools() (v ResponseObjectStreamResponseOutputItemDoneItemMcpListTools) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputItemDoneItemUnion) AsMcpApprovalRequest() (v ResponseObjectStreamResponseOutputItemDoneItemMcpApprovalRequest) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ResponseObjectStreamResponseOutputItemDoneItemUnion) RawJSON() string { return u.JSON.raw } + +func (r *ResponseObjectStreamResponseOutputItemDoneItemUnion) 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 - Text string `json:"text,required"` - // Content type identifier, always "input_text" - Type constant.InputText `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. +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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Text respjson.Field + Content respjson.Field + Role 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 ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputText) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputText) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseOutputItemDoneItemMessage) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseOutputItemDoneItemMessage) 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" - // - // Any of "low", "high", "auto". - Detail ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImageDetail `json:"detail,required"` - // Content type identifier, always "input_image" - Type constant.InputImage `json:"type,required"` - // (Optional) URL of the image content - ImageURL string `json:"image_url"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Detail respjson.Field - Type respjson.Field - ImageURL respjson.Field - ExtraFields map[string]respjson.Field - raw string +// ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion contains all +// possible properties and values from [string], +// [[]ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion], +// [[]ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion]. +// +// 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 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] + // instead of an object. + OfVariant2 []ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion `json:",inline"` + JSON struct { + OfString respjson.Field + OfVariant2 respjson.Field + raw string } `json:"-"` } -// Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemInputImage) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion) AsString() (v string) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return } -// 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" -) - -// 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" -) +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion) AsResponseObjectStreamResponseOutputItemDoneItemMessageContentArray() (v []ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} -type ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItem struct { - Annotations []ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationUnion `json:"annotations,required"` - Text string `json:"text,required"` - Type constant.OutputText `json:"type,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Annotations respjson.Field - Text respjson.Field - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion) AsVariant2() (v []ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItem) RawJSON() string { - return r.JSON.raw +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion) RawJSON() string { + return u.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItem) UnmarshalJSON(data []byte) error { + +func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationUnion +// ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion // contains all possible properties and values from -// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationFileCitation], -// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationURLCitation], -// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationContainerFileCitation], -// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationFilePath]. +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputText], +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage], +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputFile]. // // Use the -// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationUnion.AsAny] +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion.AsAny] // method to switch on the variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationUnion 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"` +type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion struct { // This field is from variant - // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationURLCitation]. - Title string `json:"title"` + // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputText]. + Text string `json:"text"` + // Any of "input_text", "input_image", "input_file". + Type string `json:"type"` // This field is from variant - // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationURLCitation]. - URL string `json:"url"` + // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage]. + Detail ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetail `json:"detail"` + FileID string `json:"file_id"` // This field is from variant - // [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationContainerFileCitation]. - 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 + // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage]. + ImageURL string `json:"image_url"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputFile]. + FileData string `json:"file_data"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputFile]. + FileURL string `json:"file_url"` + // This field is from variant + // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputFile]. + 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:"-"` } -// anyResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotation -// is implemented by each variant of -// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationUnion] -// to add type safety for the return type of -// [ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationUnion.AsAny] -type anyResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotation interface { - implResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationUnion() +// anyResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItem is +// implemented by each variant of +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion] to +// add type safety for the return type of +// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion.AsAny] +type anyResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItem interface { + implResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion() } -func (ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationFileCitation) implResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationUnion() { -} -func (ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationURLCitation) implResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationUnion() { +func (ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputText) implResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion() { } -func (ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationContainerFileCitation) implResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationUnion() { +func (ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage) implResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion() { } -func (ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationFilePath) implResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationUnion() { +func (ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputFile) implResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion() { } // Use the following switch statement to find the correct variant // -// switch variant := ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationUnion.AsAny().(type) { -// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationFileCitation: -// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationURLCitation: -// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationContainerFileCitation: -// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationFilePath: +// switch variant := ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion.AsAny().(type) { +// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputText: +// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage: +// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputFile: // default: // fmt.Errorf("no variant present") // } -func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationUnion) AsAny() anyResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotation { +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion) AsAny() anyResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItem { 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() + case "input_text": + return u.AsInputText() + case "input_image": + return u.AsInputImage() + case "input_file": + return u.AsInputFile() } return nil } -func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationUnion) AsFileCitation() (v ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationFileCitation) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationUnion) AsURLCitation() (v ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationURLCitation) { +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion) AsInputText() (v ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputText) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationUnion) AsContainerFileCitation() (v ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationContainerFileCitation) { +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion) AsInputImage() (v ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationUnion) AsFilePath() (v ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationFilePath) { +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion) AsInputFile() (v ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputFile) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationUnion) RawJSON() string { +func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion) RawJSON() string { return u.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// File citation annotation for referencing specific files in response content. -type ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationFileCitation struct { - // Unique identifier of the referenced file - FileID string `json:"file_id,required"` - // Name of the referenced file - 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"` +// Text content for input messages in OpenAI response format. +type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputText 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - FileID respjson.Field - Filename respjson.Field - Index respjson.Field + Text respjson.Field Type respjson.Field ExtraFields map[string]respjson.Field raw string @@ -2268,106 +3738,105 @@ type ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnot } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationFileCitation) RawJSON() string { +func (r ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputText) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationFileCitation) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// URL citation annotation for referencing external web resources. -type ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationURLCitation 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"` +// Image content for input messages in OpenAI response format. +type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage struct { + // Level of detail for image processing, can be "low", "high", or "auto" + // + // 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - EndIndex respjson.Field - StartIndex respjson.Field - Title respjson.Field + Detail respjson.Field Type respjson.Field - URL 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 ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationURLCitation) RawJSON() string { +func (r ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationURLCitation) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationContainerFileCitation 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"` +// Level of detail for image processing, can be "low", "high", or "auto" +type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetail string + +const ( + ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetailLow ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetail = "low" + ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetailHigh ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetail = "high" + ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetailAuto ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetail = "auto" +) + +// 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. + Filename string `json:"filename"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - ContainerID respjson.Field - EndIndex respjson.Field + Type respjson.Field + FileData 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 ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationContainerFileCitation) RawJSON() string { +func (r ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputFile) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationFilePath struct { - FileID string `json:"file_id,required"` - Index int64 `json:"index,required"` - Type constant.FilePath `json:"type,required"` - // 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:"-"` -} +// Level of detail for image processing, can be "low", "high", or "auto" +type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemDetail string -// Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationFilePath) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseObjectStreamResponseOutputItemAddedItemMessageContentArrayItemAnnotationFilePath) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} +const ( + ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemDetailLow ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemDetail = "low" + ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemDetailHigh ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemDetail = "high" + ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemDetailAuto ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemDetail = "auto" +) -type ResponseObjectStreamResponseOutputItemAddedItemMessageRole string +type ResponseObjectStreamResponseOutputItemDoneItemMessageRole string const ( - ResponseObjectStreamResponseOutputItemAddedItemMessageRoleSystem ResponseObjectStreamResponseOutputItemAddedItemMessageRole = "system" - ResponseObjectStreamResponseOutputItemAddedItemMessageRoleDeveloper ResponseObjectStreamResponseOutputItemAddedItemMessageRole = "developer" - ResponseObjectStreamResponseOutputItemAddedItemMessageRoleUser ResponseObjectStreamResponseOutputItemAddedItemMessageRole = "user" - ResponseObjectStreamResponseOutputItemAddedItemMessageRoleAssistant ResponseObjectStreamResponseOutputItemAddedItemMessageRole = "assistant" + ResponseObjectStreamResponseOutputItemDoneItemMessageRoleSystem ResponseObjectStreamResponseOutputItemDoneItemMessageRole = "system" + ResponseObjectStreamResponseOutputItemDoneItemMessageRoleDeveloper ResponseObjectStreamResponseOutputItemDoneItemMessageRole = "developer" + ResponseObjectStreamResponseOutputItemDoneItemMessageRoleUser ResponseObjectStreamResponseOutputItemDoneItemMessageRole = "user" + ResponseObjectStreamResponseOutputItemDoneItemMessageRoleAssistant ResponseObjectStreamResponseOutputItemDoneItemMessageRole = "assistant" ) // Web search tool call output message for OpenAI responses. -type ResponseObjectStreamResponseOutputItemAddedItemWebSearchCall struct { +type ResponseObjectStreamResponseOutputItemDoneItemWebSearchCall struct { // Unique identifier for this tool call ID string `json:"id,required"` // Current status of the web search operation @@ -2385,15 +3854,15 @@ type ResponseObjectStreamResponseOutputItemAddedItemWebSearchCall struct { } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemAddedItemWebSearchCall) RawJSON() string { +func (r ResponseObjectStreamResponseOutputItemDoneItemWebSearchCall) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemWebSearchCall) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemDoneItemWebSearchCall) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // File search tool call output message for OpenAI responses. -type ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall struct { +type ResponseObjectStreamResponseOutputItemDoneItemFileSearchCall struct { // Unique identifier for this tool call ID string `json:"id,required"` // List of search queries executed @@ -2403,7 +3872,7 @@ type ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall struct { // 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"` + Results []ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResult `json:"results"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -2417,17 +3886,17 @@ type ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall struct { } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall) RawJSON() string { +func (r ResponseObjectStreamResponseOutputItemDoneItemFileSearchCall) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemDoneItemFileSearchCall) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Search results returned by the file search operation. -type ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult struct { +type ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResult struct { // (Optional) Key-value attributes associated with the file - Attributes map[string]ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion `json:"attributes,required"` + 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 @@ -2449,14 +3918,14 @@ type ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult struct } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult) RawJSON() string { +func (r ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResult) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResult) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion +// ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResultAttributeUnion // contains all possible properties and values from [bool], [float64], [string], // [[]any]. // @@ -2464,7 +3933,7 @@ func (r *ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResult) Un // // If the underlying value is not a json object, one of the following properties // will be valid: OfBool OfFloat OfString OfAnyArray] -type ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion struct { +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. @@ -2482,37 +3951,37 @@ type ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttribut } `json:"-"` } -func (u ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion) AsBool() (v bool) { +func (u ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResultAttributeUnion) AsBool() (v bool) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion) AsFloat() (v float64) { +func (u ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResultAttributeUnion) AsFloat() (v float64) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion) AsString() (v string) { +func (u ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResultAttributeUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion) AsAnyArray() (v []any) { +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 ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion) RawJSON() string { +func (u ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResultAttributeUnion) RawJSON() string { return u.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemFileSearchCallResultAttributeUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResultAttributeUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Function tool call output message for OpenAI responses. -type ResponseObjectStreamResponseOutputItemAddedItemFunctionCall struct { +type ResponseObjectStreamResponseOutputItemDoneItemFunctionCall struct { // JSON string containing the function arguments Arguments string `json:"arguments,required"` // Unique identifier for the function call @@ -2539,15 +4008,15 @@ type ResponseObjectStreamResponseOutputItemAddedItemFunctionCall struct { } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemAddedItemFunctionCall) RawJSON() string { +func (r ResponseObjectStreamResponseOutputItemDoneItemFunctionCall) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemFunctionCall) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemDoneItemFunctionCall) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Model Context Protocol (MCP) call output message for OpenAI responses. -type ResponseObjectStreamResponseOutputItemAddedItemMcpCall struct { +type ResponseObjectStreamResponseOutputItemDoneItemMcpCall struct { // Unique identifier for this MCP call ID string `json:"id,required"` // JSON string containing the MCP call arguments @@ -2577,19 +4046,19 @@ type ResponseObjectStreamResponseOutputItemAddedItemMcpCall struct { } // 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 ResponseObjectStreamResponseOutputItemDoneItemMcpCall) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseOutputItemDoneItemMcpCall) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // MCP list tools output message containing available tools from an MCP server. -type ResponseObjectStreamResponseOutputItemAddedItemMcpListTools struct { +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 []ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTool `json:"tools,required"` + Tools []ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsTool `json:"tools,required"` // Tool call type identifier, always "mcp_list_tools" Type constant.McpListTools `json:"type,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. @@ -2604,17 +4073,17 @@ type ResponseObjectStreamResponseOutputItemAddedItemMcpListTools struct { } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemAddedItemMcpListTools) RawJSON() string { +func (r ResponseObjectStreamResponseOutputItemDoneItemMcpListTools) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemMcpListTools) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemDoneItemMcpListTools) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Tool definition returned by MCP list tools operation. -type ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTool struct { +type ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsTool struct { // JSON schema defining the tool's input parameters - InputSchema map[string]ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSchemaUnion `json:"input_schema,required"` + InputSchema map[string]ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion `json:"input_schema,required"` // Name of the tool Name string `json:"name,required"` // (Optional) Description of what the tool does @@ -2630,14 +4099,14 @@ type ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTool struct { } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTool) RawJSON() string { +func (r ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsTool) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTool) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsTool) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSchemaUnion +// ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion // contains all possible properties and values from [bool], [float64], [string], // [[]any]. // @@ -2645,7 +4114,7 @@ func (r *ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsTool) Unmars // // If the underlying value is not a json object, one of the following properties // will be valid: OfBool OfFloat OfString OfAnyArray] -type ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSchemaUnion struct { +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. @@ -2663,61 +4132,260 @@ type ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSchemaU } `json:"-"` } -func (u ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSchemaUnion) AsBool() (v bool) { +func (u ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion) AsBool() (v bool) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSchemaUnion) AsFloat() (v float64) { +func (u ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion) AsFloat() (v float64) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSchemaUnion) AsString() (v string) { +func (u ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSchemaUnion) AsAnyArray() (v []any) { +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 ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSchemaUnion) RawJSON() string { +func (u ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion) RawJSON() string { return u.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSchemaUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ResponseObjectStreamResponseOutputItemAddedItemRole string +// 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"` + // 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 ResponseObjectStreamResponseOutputItemDoneItemMcpApprovalRequest) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseOutputItemDoneItemMcpApprovalRequest) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type ResponseObjectStreamResponseOutputItemDoneItemRole string const ( - ResponseObjectStreamResponseOutputItemAddedItemRoleSystem ResponseObjectStreamResponseOutputItemAddedItemRole = "system" - ResponseObjectStreamResponseOutputItemAddedItemRoleDeveloper ResponseObjectStreamResponseOutputItemAddedItemRole = "developer" - ResponseObjectStreamResponseOutputItemAddedItemRoleUser ResponseObjectStreamResponseOutputItemAddedItemRole = "user" - ResponseObjectStreamResponseOutputItemAddedItemRoleAssistant ResponseObjectStreamResponseOutputItemAddedItemRole = "assistant" + ResponseObjectStreamResponseOutputItemDoneItemRoleSystem ResponseObjectStreamResponseOutputItemDoneItemRole = "system" + ResponseObjectStreamResponseOutputItemDoneItemRoleDeveloper ResponseObjectStreamResponseOutputItemDoneItemRole = "developer" + ResponseObjectStreamResponseOutputItemDoneItemRoleUser ResponseObjectStreamResponseOutputItemDoneItemRole = "user" + ResponseObjectStreamResponseOutputItemDoneItemRoleAssistant ResponseObjectStreamResponseOutputItemDoneItemRole = "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 +// 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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ContentIndex respjson.Field + Delta respjson.Field + ItemID respjson.Field + OutputIndex 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 ResponseObjectStreamResponseOutputTextDelta) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseOutputTextDelta) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ContentIndex respjson.Field + ItemID respjson.Field + OutputIndex respjson.Field + SequenceNumber respjson.Field + Text respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseOutputTextDone) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseOutputTextDone) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Delta respjson.Field + ItemID respjson.Field + OutputIndex 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 ResponseObjectStreamResponseFunctionCallArgumentsDelta) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseFunctionCallArgumentsDelta) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Arguments respjson.Field + ItemID respjson.Field + OutputIndex 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 ResponseObjectStreamResponseFunctionCallArgumentsDone) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseFunctionCallArgumentsDone) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ItemID respjson.Field + OutputIndex 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 ResponseObjectStreamResponseWebSearchCallInProgress) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseWebSearchCallInProgress) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ItemID respjson.Field + OutputIndex 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 ResponseObjectStreamResponseWebSearchCallSearching) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseWebSearchCallSearching) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` - // 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"` + // Event type identifier, always "response.web_search_call.completed" + Type constant.ResponseWebSearchCallCompleted `json:"type,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Item respjson.Field + ItemID respjson.Field OutputIndex respjson.Field - ResponseID respjson.Field SequenceNumber respjson.Field Type respjson.Field ExtraFields map[string]respjson.Field @@ -2726,430 +4394,351 @@ type ResponseObjectStreamResponseOutputItemDone struct { } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemDone) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemDone) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseWebSearchCallCompleted) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseWebSearchCallCompleted) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamResponseOutputItemDoneItemUnion contains all possible -// properties and values from -// [ResponseObjectStreamResponseOutputItemDoneItemMessage], -// [ResponseObjectStreamResponseOutputItemDoneItemWebSearchCall], -// [ResponseObjectStreamResponseOutputItemDoneItemFileSearchCall], -// [ResponseObjectStreamResponseOutputItemDoneItemFunctionCall], -// [ResponseObjectStreamResponseOutputItemDoneItemMcpCall], -// [ResponseObjectStreamResponseOutputItemDoneItemMcpListTools]. -// -// Use the [ResponseObjectStreamResponseOutputItemDoneItemUnion.AsAny] method to -// switch on the variant. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -type ResponseObjectStreamResponseOutputItemDoneItemUnion struct { - // This field is from variant - // [ResponseObjectStreamResponseOutputItemDoneItemMessage]. - 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". - Type string `json:"type"` - ID string `json:"id"` - Status string `json:"status"` - // This field is from variant - // [ResponseObjectStreamResponseOutputItemDoneItemFileSearchCall]. - Queries []string `json:"queries"` - // This field is from variant - // [ResponseObjectStreamResponseOutputItemDoneItemFileSearchCall]. - Results []ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResult `json:"results"` - Arguments string `json:"arguments"` - // This field is from variant - // [ResponseObjectStreamResponseOutputItemDoneItemFunctionCall]. - CallID string `json:"call_id"` - Name string `json:"name"` - ServerLabel string `json:"server_label"` - // This field is from variant - // [ResponseObjectStreamResponseOutputItemDoneItemMcpCall]. - Error string `json:"error"` - // This field is from variant - // [ResponseObjectStreamResponseOutputItemDoneItemMcpCall]. - Output string `json:"output"` - // This field is from variant - // [ResponseObjectStreamResponseOutputItemDoneItemMcpListTools]. - Tools []ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsTool `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 - ServerLabel respjson.Field - Error respjson.Field - Output respjson.Field - Tools respjson.Field - raw string +type ResponseObjectStreamResponseMcpListToolsInProgress struct { + SequenceNumber int64 `json:"sequence_number,required"` + Type constant.ResponseMcpListToolsInProgress `json:"type,required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + SequenceNumber respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } -// anyResponseObjectStreamResponseOutputItemDoneItem is implemented by each variant -// of [ResponseObjectStreamResponseOutputItemDoneItemUnion] to add type safety for -// the return type of [ResponseObjectStreamResponseOutputItemDoneItemUnion.AsAny] -type anyResponseObjectStreamResponseOutputItemDoneItem interface { - implResponseObjectStreamResponseOutputItemDoneItemUnion() +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseMcpListToolsInProgress) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseMcpListToolsInProgress) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (ResponseObjectStreamResponseOutputItemDoneItemMessage) implResponseObjectStreamResponseOutputItemDoneItemUnion() { -} -func (ResponseObjectStreamResponseOutputItemDoneItemWebSearchCall) implResponseObjectStreamResponseOutputItemDoneItemUnion() { -} -func (ResponseObjectStreamResponseOutputItemDoneItemFileSearchCall) implResponseObjectStreamResponseOutputItemDoneItemUnion() { +type ResponseObjectStreamResponseMcpListToolsFailed struct { + SequenceNumber int64 `json:"sequence_number,required"` + Type constant.ResponseMcpListToolsFailed `json:"type,required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + SequenceNumber respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } -func (ResponseObjectStreamResponseOutputItemDoneItemFunctionCall) implResponseObjectStreamResponseOutputItemDoneItemUnion() { + +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseMcpListToolsFailed) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseMcpListToolsFailed) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (ResponseObjectStreamResponseOutputItemDoneItemMcpCall) implResponseObjectStreamResponseOutputItemDoneItemUnion() { + +type ResponseObjectStreamResponseMcpListToolsCompleted struct { + SequenceNumber int64 `json:"sequence_number,required"` + Type constant.ResponseMcpListToolsCompleted `json:"type,required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + SequenceNumber respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } -func (ResponseObjectStreamResponseOutputItemDoneItemMcpListTools) implResponseObjectStreamResponseOutputItemDoneItemUnion() { + +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseMcpListToolsCompleted) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseMcpListToolsCompleted) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -// Use the following switch statement to find the correct variant -// -// switch variant := ResponseObjectStreamResponseOutputItemDoneItemUnion.AsAny().(type) { -// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMessage: -// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemWebSearchCall: -// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemFileSearchCall: -// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemFunctionCall: -// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMcpCall: -// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMcpListTools: -// default: -// fmt.Errorf("no variant present") -// } -func (u ResponseObjectStreamResponseOutputItemDoneItemUnion) AsAny() anyResponseObjectStreamResponseOutputItemDoneItem { - 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 "mcp_call": - return u.AsMcpCall() - case "mcp_list_tools": - return u.AsMcpListTools() - } - return nil +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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Delta respjson.Field + ItemID respjson.Field + OutputIndex respjson.Field + SequenceNumber respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } -func (u ResponseObjectStreamResponseOutputItemDoneItemUnion) AsMessage() (v ResponseObjectStreamResponseOutputItemDoneItemMessage) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseMcpCallArgumentsDelta) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseMcpCallArgumentsDelta) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ResponseObjectStreamResponseOutputItemDoneItemUnion) AsWebSearchCall() (v ResponseObjectStreamResponseOutputItemDoneItemWebSearchCall) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Arguments respjson.Field + ItemID respjson.Field + OutputIndex respjson.Field + SequenceNumber respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } -func (u ResponseObjectStreamResponseOutputItemDoneItemUnion) AsFileSearchCall() (v ResponseObjectStreamResponseOutputItemDoneItemFileSearchCall) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseMcpCallArgumentsDone) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseMcpCallArgumentsDone) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ResponseObjectStreamResponseOutputItemDoneItemUnion) AsFunctionCall() (v ResponseObjectStreamResponseOutputItemDoneItemFunctionCall) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// 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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ItemID respjson.Field + OutputIndex respjson.Field + SequenceNumber respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } -func (u ResponseObjectStreamResponseOutputItemDoneItemUnion) AsMcpCall() (v ResponseObjectStreamResponseOutputItemDoneItemMcpCall) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseMcpCallInProgress) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseMcpCallInProgress) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ResponseObjectStreamResponseOutputItemDoneItemUnion) AsMcpListTools() (v ResponseObjectStreamResponseOutputItemDoneItemMcpListTools) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// 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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + SequenceNumber respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } // Returns the unmodified JSON received from the API -func (u ResponseObjectStreamResponseOutputItemDoneItemUnion) RawJSON() string { return u.JSON.raw } - -func (r *ResponseObjectStreamResponseOutputItemDoneItemUnion) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseMcpCallFailed) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseMcpCallFailed) 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 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"` +// 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"` // 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 - ExtraFields map[string]respjson.Field - raw string + SequenceNumber respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemDoneItemMessage) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemDoneItemMessage) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseMcpCallCompleted) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseMcpCallCompleted) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion contains all -// possible properties and values from [string], -// [[]ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion], -// [[]ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItem]. -// -// 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 -// OfResponseObjectStreamResponseOutputItemDoneItemMessageContentArray OfVariant2] -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] - // instead of an object. - OfResponseObjectStreamResponseOutputItemDoneItemMessageContentArray []ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion `json:",inline"` - // This field will be present if the value is a - // [[]ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItem] - // instead of an object. - OfVariant2 []ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfResponseObjectStreamResponseOutputItemDoneItemMessageContentArray respjson.Field - OfVariant2 respjson.Field - raw string +// 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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ContentIndex respjson.Field + ItemID respjson.Field + OutputIndex respjson.Field + Part respjson.Field + ResponseID respjson.Field + SequenceNumber respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } -func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion) AsResponseObjectStreamResponseOutputItemDoneItemMessageContentArray() (v []ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion) AsVariant2() (v []ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItem) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - // Returns the unmodified JSON received from the API -func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion) RawJSON() string { - return u.JSON.raw -} - -func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentUnion) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseContentPartAdded) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseContentPartAdded) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion -// contains all possible properties and values from -// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputText], -// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage]. +// ResponseObjectStreamResponseContentPartAddedPartUnion contains all possible +// properties and values from +// [ResponseObjectStreamResponseContentPartAddedPartOutputText], +// [ResponseObjectStreamResponseContentPartAddedPartRefusal], +// [ResponseObjectStreamResponseContentPartAddedPartReasoningText]. // -// Use the -// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion.AsAny] -// method to switch on the variant. +// Use the [ResponseObjectStreamResponseContentPartAddedPartUnion.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 ResponseObjectStreamResponseContentPartAddedPartUnion struct { // This field is from variant - // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputText]. - Text string `json:"text"` - // Any of "input_text", "input_image". + // [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 - // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage]. - Detail ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetail `json:"detail"` + // [ResponseObjectStreamResponseContentPartAddedPartOutputText]. + Logprobs []map[string]ResponseObjectStreamResponseContentPartAddedPartOutputTextLogprobUnion `json:"logprobs"` // This field is from variant - // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage]. - ImageURL string `json:"image_url"` - JSON struct { - Text respjson.Field - Type respjson.Field - Detail respjson.Field - ImageURL respjson.Field - raw string + // [ResponseObjectStreamResponseContentPartAddedPartRefusal]. + Refusal string `json:"refusal"` + JSON struct { + Annotations respjson.Field + Text respjson.Field + Type respjson.Field + Logprobs respjson.Field + Refusal respjson.Field + raw string } `json:"-"` } -// anyResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItem is -// implemented by each variant of -// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion] to -// add type safety for the return type of -// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion.AsAny] -type anyResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItem interface { - implResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion() +// anyResponseObjectStreamResponseContentPartAddedPart is implemented by each +// variant of [ResponseObjectStreamResponseContentPartAddedPartUnion] to add type +// safety for the return type of +// [ResponseObjectStreamResponseContentPartAddedPartUnion.AsAny] +type anyResponseObjectStreamResponseContentPartAddedPart interface { + implResponseObjectStreamResponseContentPartAddedPartUnion() } -func (ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputText) implResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion() { +func (ResponseObjectStreamResponseContentPartAddedPartOutputText) implResponseObjectStreamResponseContentPartAddedPartUnion() { } -func (ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage) implResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion() { +func (ResponseObjectStreamResponseContentPartAddedPartRefusal) implResponseObjectStreamResponseContentPartAddedPartUnion() { +} +func (ResponseObjectStreamResponseContentPartAddedPartReasoningText) implResponseObjectStreamResponseContentPartAddedPartUnion() { } // Use the following switch statement to find the correct variant // -// switch variant := ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion.AsAny().(type) { -// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputText: -// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage: +// switch variant := ResponseObjectStreamResponseContentPartAddedPartUnion.AsAny().(type) { +// case llamastackclient.ResponseObjectStreamResponseContentPartAddedPartOutputText: +// case llamastackclient.ResponseObjectStreamResponseContentPartAddedPartRefusal: +// case llamastackclient.ResponseObjectStreamResponseContentPartAddedPartReasoningText: // default: // fmt.Errorf("no variant present") // } -func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion) AsAny() anyResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItem { +func (u ResponseObjectStreamResponseContentPartAddedPartUnion) AsAny() anyResponseObjectStreamResponseContentPartAddedPart { switch u.Type { - case "input_text": - return u.AsInputText() - case "input_image": - return u.AsInputImage() + case "output_text": + return u.AsOutputText() + case "refusal": + return u.AsRefusal() + case "reasoning_text": + return u.AsReasoningText() } return nil } -func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion) AsInputText() (v ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputText) { +func (u ResponseObjectStreamResponseContentPartAddedPartUnion) AsOutputText() (v ResponseObjectStreamResponseContentPartAddedPartOutputText) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion) AsInputImage() (v ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage) { +func (u ResponseObjectStreamResponseContentPartAddedPartUnion) AsRefusal() (v ResponseObjectStreamResponseContentPartAddedPartRefusal) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -// Returns the unmodified JSON received from the API -func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion) RawJSON() string { - return u.JSON.raw -} - -func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemUnion) 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 - Text string `json:"text,required"` - // Content type identifier, always "input_text" - Type constant.InputText `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:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputText) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputText) 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" - // - // Any of "low", "high", "auto". - Detail ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetail `json:"detail,required"` - // Content type identifier, always "input_image" - Type constant.InputImage `json:"type,required"` - // (Optional) URL of the image content - ImageURL string `json:"image_url"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Detail respjson.Field - Type respjson.Field - ImageURL respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImage) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) +func (u ResponseObjectStreamResponseContentPartAddedPartUnion) AsReasoningText() (v ResponseObjectStreamResponseContentPartAddedPartReasoningText) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return } -// Level of detail for image processing, can be "low", "high", or "auto" -type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetail string - -const ( - ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetailLow ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetail = "low" - ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetailHigh ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetail = "high" - ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetailAuto ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemInputImageDetail = "auto" -) - -// 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 ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItem struct { - Annotations []ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationUnion `json:"annotations,required"` - Text string `json:"text,required"` - Type constant.OutputText `json:"type,required"` +// Returns the unmodified JSON received from the API +func (u ResponseObjectStreamResponseContentPartAddedPartUnion) RawJSON() string { return u.JSON.raw } + +func (r *ResponseObjectStreamResponseContentPartAddedPartUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Annotations respjson.Field Text respjson.Field Type respjson.Field + Logprobs respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItem) RawJSON() string { +func (r ResponseObjectStreamResponseContentPartAddedPartOutputText) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseContentPartAddedPartOutputText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationUnion +// ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion // contains all possible properties and values from -// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationFileCitation], -// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationURLCitation], -// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationContainerFileCitation], -// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationFilePath]. +// [ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationFileCitation], +// [ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationURLCitation], +// [ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationContainerFileCitation], +// [ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationFilePath]. // // Use the -// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationUnion.AsAny] +// [ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion.AsAny] // method to switch on the variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationUnion struct { +type ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion struct { FileID string `json:"file_id"` Filename string `json:"filename"` Index int64 `json:"index"` @@ -3158,13 +4747,13 @@ type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnota EndIndex int64 `json:"end_index"` StartIndex int64 `json:"start_index"` // This field is from variant - // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationURLCitation]. + // [ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationURLCitation]. Title string `json:"title"` // This field is from variant - // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationURLCitation]. + // [ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationURLCitation]. URL string `json:"url"` // This field is from variant - // [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationContainerFileCitation]. + // [ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationContainerFileCitation]. ContainerID string `json:"container_id"` JSON struct { FileID respjson.Field @@ -3180,35 +4769,35 @@ type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnota } `json:"-"` } -// anyResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotation -// is implemented by each variant of -// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationUnion] -// to add type safety for the return type of -// [ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationUnion.AsAny] -type anyResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotation interface { - implResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationUnion() +// anyResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotation is +// implemented by each variant of +// [ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion] to +// add type safety for the return type of +// [ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion.AsAny] +type anyResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotation interface { + implResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion() } -func (ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationFileCitation) implResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationUnion() { +func (ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationFileCitation) implResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion() { } -func (ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationURLCitation) implResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationUnion() { +func (ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationURLCitation) implResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion() { } -func (ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationContainerFileCitation) implResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationUnion() { +func (ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationContainerFileCitation) implResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion() { } -func (ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationFilePath) implResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationUnion() { +func (ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationFilePath) implResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion() { } // Use the following switch statement to find the correct variant // -// switch variant := ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationUnion.AsAny().(type) { -// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationFileCitation: -// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationURLCitation: -// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationContainerFileCitation: -// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationFilePath: +// switch variant := ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion.AsAny().(type) { +// case llamastackclient.ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationFileCitation: +// case llamastackclient.ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationURLCitation: +// case llamastackclient.ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationContainerFileCitation: +// case llamastackclient.ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationFilePath: // default: // fmt.Errorf("no variant present") // } -func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationUnion) AsAny() anyResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotation { +func (u ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion) AsAny() anyResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotation { switch u.Type { case "file_citation": return u.AsFileCitation() @@ -3222,37 +4811,37 @@ func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnn return nil } -func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationUnion) AsFileCitation() (v ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationFileCitation) { +func (u ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion) AsFileCitation() (v ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationFileCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationUnion) AsURLCitation() (v ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationURLCitation) { +func (u ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion) AsURLCitation() (v ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationURLCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationUnion) AsContainerFileCitation() (v ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationContainerFileCitation) { +func (u ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion) AsContainerFileCitation() (v ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationContainerFileCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationUnion) AsFilePath() (v ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationFilePath) { +func (u ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion) AsFilePath() (v ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationFilePath) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationUnion) RawJSON() string { +func (u ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion) RawJSON() string { return u.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // File citation annotation for referencing specific files in response content. -type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationFileCitation struct { +type ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationFileCitation struct { // Unique identifier of the referenced file FileID string `json:"file_id,required"` // Name of the referenced file @@ -3273,15 +4862,15 @@ type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnota } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationFileCitation) RawJSON() string { +func (r ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationFileCitation) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationFileCitation) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationFileCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // URL citation annotation for referencing external web resources. -type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationURLCitation struct { +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 @@ -3305,14 +4894,14 @@ type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnota } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationURLCitation) RawJSON() string { +func (r ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationURLCitation) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationURLCitation) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationURLCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationContainerFileCitation struct { +type ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationContainerFileCitation struct { ContainerID string `json:"container_id,required"` EndIndex int64 `json:"end_index,required"` FileID string `json:"file_id,required"` @@ -3333,14 +4922,14 @@ type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnota } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationContainerFileCitation) RawJSON() string { +func (r ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationContainerFileCitation) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationFilePath struct { +type ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationFilePath struct { FileID string `json:"file_id,required"` Index int64 `json:"index,required"` Type constant.FilePath `json:"type,required"` @@ -3355,34 +4944,76 @@ type ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnota } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationFilePath) RawJSON() string { +func (r ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationFilePath) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemDoneItemMessageContentArrayItemAnnotationFilePath) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseContentPartAddedPartOutputTextAnnotationFilePath) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ResponseObjectStreamResponseOutputItemDoneItemMessageRole string +// 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:"-"` +} -const ( - ResponseObjectStreamResponseOutputItemDoneItemMessageRoleSystem ResponseObjectStreamResponseOutputItemDoneItemMessageRole = "system" - ResponseObjectStreamResponseOutputItemDoneItemMessageRoleDeveloper ResponseObjectStreamResponseOutputItemDoneItemMessageRole = "developer" - ResponseObjectStreamResponseOutputItemDoneItemMessageRoleUser ResponseObjectStreamResponseOutputItemDoneItemMessageRole = "user" - ResponseObjectStreamResponseOutputItemDoneItemMessageRoleAssistant ResponseObjectStreamResponseOutputItemDoneItemMessageRole = "assistant" -) +func (u ResponseObjectStreamResponseContentPartAddedPartOutputTextLogprobUnion) AsBool() (v bool) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} -// 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 - Status string `json:"status,required"` - // Tool call type identifier, always "web_search_call" - Type constant.WebSearchCall `json:"type,required"` +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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - ID respjson.Field - Status respjson.Field + Refusal respjson.Field Type respjson.Field ExtraFields map[string]respjson.Field raw string @@ -3390,218 +5021,379 @@ type ResponseObjectStreamResponseOutputItemDoneItemWebSearchCall struct { } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemDoneItemWebSearchCall) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseObjectStreamResponseOutputItemDoneItemWebSearchCall) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseContentPartAddedPartRefusal) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseContentPartAddedPartRefusal) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// 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"` +// 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"` // 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 Type respjson.Field - Results respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemDoneItemFileSearchCall) RawJSON() string { +func (r ResponseObjectStreamResponseContentPartAddedPartReasoningText) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemDoneItemFileSearchCall) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseContentPartAddedPartReasoningText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// 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 +// 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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ContentIndex respjson.Field + ItemID respjson.Field + OutputIndex respjson.Field + Part 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 ResponseObjectStreamResponseContentPartDone) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseContentPartDone) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ResponseObjectStreamResponseContentPartDonePartUnion contains all possible +// properties and values from +// [ResponseObjectStreamResponseContentPartDonePartOutputText], +// [ResponseObjectStreamResponseContentPartDonePartRefusal], +// [ResponseObjectStreamResponseContentPartDonePartReasoningText]. +// +// Use the [ResponseObjectStreamResponseContentPartDonePartUnion.AsAny] method to +// switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ResponseObjectStreamResponseContentPartDonePartUnion struct { + // 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"` + // This field is from variant + // [ResponseObjectStreamResponseContentPartDonePartRefusal]. + Refusal string `json:"refusal"` + JSON struct { + Annotations respjson.Field + Text respjson.Field + Type respjson.Field + Logprobs respjson.Field + Refusal respjson.Field + raw string + } `json:"-"` +} + +// anyResponseObjectStreamResponseContentPartDonePart is implemented by each +// variant of [ResponseObjectStreamResponseContentPartDonePartUnion] to add type +// safety for the return type of +// [ResponseObjectStreamResponseContentPartDonePartUnion.AsAny] +type anyResponseObjectStreamResponseContentPartDonePart interface { + implResponseObjectStreamResponseContentPartDonePartUnion() +} + +func (ResponseObjectStreamResponseContentPartDonePartOutputText) implResponseObjectStreamResponseContentPartDonePartUnion() { +} +func (ResponseObjectStreamResponseContentPartDonePartRefusal) implResponseObjectStreamResponseContentPartDonePartUnion() { +} +func (ResponseObjectStreamResponseContentPartDonePartReasoningText) implResponseObjectStreamResponseContentPartDonePartUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := ResponseObjectStreamResponseContentPartDonePartUnion.AsAny().(type) { +// case llamastackclient.ResponseObjectStreamResponseContentPartDonePartOutputText: +// case llamastackclient.ResponseObjectStreamResponseContentPartDonePartRefusal: +// case llamastackclient.ResponseObjectStreamResponseContentPartDonePartReasoningText: +// default: +// fmt.Errorf("no variant present") +// } +func (u ResponseObjectStreamResponseContentPartDonePartUnion) AsAny() anyResponseObjectStreamResponseContentPartDonePart { + switch u.Type { + case "output_text": + return u.AsOutputText() + case "refusal": + return u.AsRefusal() + case "reasoning_text": + return u.AsReasoningText() + } + return nil +} + +func (u ResponseObjectStreamResponseContentPartDonePartUnion) AsOutputText() (v ResponseObjectStreamResponseContentPartDonePartOutputText) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseContentPartDonePartUnion) AsRefusal() (v ResponseObjectStreamResponseContentPartDonePartRefusal) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseContentPartDonePartUnion) AsReasoningText() (v ResponseObjectStreamResponseContentPartDonePartReasoningText) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ResponseObjectStreamResponseContentPartDonePartUnion) RawJSON() string { return u.JSON.raw } + +func (r *ResponseObjectStreamResponseContentPartDonePartUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Attributes respjson.Field + Annotations respjson.Field + Text respjson.Field + Type respjson.Field + Logprobs respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseContentPartDonePartOutputText) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseContentPartDonePartOutputText) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion +// contains all possible properties and values from +// [ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationFileCitation], +// [ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationURLCitation], +// [ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationContainerFileCitation], +// [ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationFilePath]. +// +// Use the +// [ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion.AsAny] +// method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +type ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion 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 + // [ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationURLCitation]. + Title string `json:"title"` + // This field is from variant + // [ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationURLCitation]. + URL string `json:"url"` + // This field is from variant + // [ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationContainerFileCitation]. + 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 ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResult) RawJSON() string { - return r.JSON.raw +// anyResponseObjectStreamResponseContentPartDonePartOutputTextAnnotation is +// implemented by each variant of +// [ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion] to +// add type safety for the return type of +// [ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion.AsAny] +type anyResponseObjectStreamResponseContentPartDonePartOutputTextAnnotation interface { + implResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion() } -func (r *ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResult) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) + +func (ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationFileCitation) implResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion() { +} +func (ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationURLCitation) implResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion() { +} +func (ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationContainerFileCitation) implResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion() { +} +func (ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationFilePath) implResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion() { } -// 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. +// 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 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:"-"` +// switch variant := ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion.AsAny().(type) { +// case llamastackclient.ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationFileCitation: +// case llamastackclient.ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationURLCitation: +// case llamastackclient.ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationContainerFileCitation: +// case llamastackclient.ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationFilePath: +// default: +// fmt.Errorf("no variant present") +// } +func (u ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion) AsAny() anyResponseObjectStreamResponseContentPartDonePartOutputTextAnnotation { + 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 ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResultAttributeUnion) AsBool() (v bool) { +func (u ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion) AsFileCitation() (v ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationFileCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResultAttributeUnion) AsFloat() (v float64) { +func (u ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion) AsURLCitation() (v ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationURLCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResultAttributeUnion) AsString() (v string) { +func (u ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion) AsContainerFileCitation() (v ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationContainerFileCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResultAttributeUnion) AsAnyArray() (v []any) { +func (u ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion) AsFilePath() (v ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationFilePath) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResultAttributeUnion) RawJSON() string { +func (u ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion) RawJSON() string { return u.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemDoneItemFileSearchCallResultAttributeUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationUnion) 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"` +// 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 + 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"` // 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 ResponseObjectStreamResponseOutputItemDoneItemFunctionCall) RawJSON() string { +func (r ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationFileCitation) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemDoneItemFunctionCall) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationFileCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// 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 - 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 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"` // 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 Type respjson.Field - Error respjson.Field - Output respjson.Field + URL respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemDoneItemMcpCall) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemDoneItemMcpCall) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationURLCitation) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationURLCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// 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"` +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"` // 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 @@ -3609,48 +5401,43 @@ type ResponseObjectStreamResponseOutputItemDoneItemMcpListTools struct { } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputItemDoneItemMcpListTools) RawJSON() string { +func (r ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationContainerFileCitation) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemDoneItemMcpListTools) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// 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"` +type ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationFilePath struct { + FileID string `json:"file_id,required"` + Index int64 `json:"index,required"` + Type constant.FilePath `json:"type,required"` // 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 ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsTool) RawJSON() string { +func (r ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationFilePath) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsTool) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseContentPartDonePartOutputTextAnnotationFilePath) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion -// contains all possible properties and values from [bool], [float64], [string], -// [[]any]. +// 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 ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion struct { +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. @@ -3668,124 +5455,96 @@ type ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUn } `json:"-"` } -func (u ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion) AsBool() (v bool) { +func (u ResponseObjectStreamResponseContentPartDonePartOutputTextLogprobUnion) AsBool() (v bool) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion) AsFloat() (v float64) { +func (u ResponseObjectStreamResponseContentPartDonePartOutputTextLogprobUnion) AsFloat() (v float64) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion) AsString() (v string) { +func (u ResponseObjectStreamResponseContentPartDonePartOutputTextLogprobUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion) AsAnyArray() (v []any) { +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 ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion) RawJSON() string { +func (u ResponseObjectStreamResponseContentPartDonePartOutputTextLogprobUnion) RawJSON() string { return u.JSON.raw } -func (r *ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSchemaUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseContentPartDonePartOutputTextLogprobUnion) UnmarshalJSON(data []byte) error { 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"` +// 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - ContentIndex respjson.Field - Delta respjson.Field - ItemID respjson.Field - OutputIndex respjson.Field - SequenceNumber respjson.Field - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string + Refusal respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputTextDelta) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputTextDelta) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseContentPartDonePartRefusal) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseContentPartDonePartRefusal) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// 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 +// Reasoning text emitted as part of a streamed response. +type ResponseObjectStreamResponseContentPartDonePartReasoningText struct { + // Reasoning text supplied by the model Text string `json:"text,required"` - // Event type identifier, always "response.output_text.done" - Type constant.ResponseOutputTextDone `json:"type,required"` + // Content part type identifier, always "reasoning_text" + Type constant.ReasoningText `json:"type,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - ContentIndex respjson.Field - ItemID respjson.Field - OutputIndex respjson.Field - SequenceNumber respjson.Field - Text respjson.Field - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string + Text respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseOutputTextDone) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseOutputTextDone) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseContentPartDonePartReasoningText) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseContentPartDonePartReasoningText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Streaming event for incremental function call argument updates. -type ResponseObjectStreamResponseFunctionCallArgumentsDelta struct { - // Incremental function call arguments being added +// 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 function call being updated + // 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.function_call_arguments.delta" - Type constant.ResponseFunctionCallArgumentsDelta `json:"type,required"` + // Event type identifier, always "response.reasoning_text.delta" + Type constant.ResponseReasoningTextDelta `json:"type,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { + ContentIndex respjson.Field Delta respjson.Field ItemID respjson.Field OutputIndex respjson.Field @@ -3797,29 +5556,32 @@ type ResponseObjectStreamResponseFunctionCallArgumentsDelta struct { } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseFunctionCallArgumentsDelta) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseFunctionCallArgumentsDelta) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseReasoningTextDelta) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseReasoningTextDelta) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// 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 +// 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"` - // Event type identifier, always "response.function_call_arguments.done" - Type constant.ResponseFunctionCallArgumentsDone `json:"type,required"` + // Final complete reasoning text + Text string `json:"text,required"` + // Event type identifier, always "response.reasoning_text.done" + Type constant.ResponseReasoningTextDone `json:"type,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Arguments respjson.Field + ContentIndex respjson.Field ItemID respjson.Field OutputIndex respjson.Field SequenceNumber respjson.Field + Text respjson.Field Type respjson.Field ExtraFields map[string]respjson.Field raw string @@ -3827,26 +5589,32 @@ type ResponseObjectStreamResponseFunctionCallArgumentsDone struct { } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseFunctionCallArgumentsDone) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseFunctionCallArgumentsDone) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseReasoningTextDone) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseReasoningTextDone) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Streaming event for web search calls in progress. -type ResponseObjectStreamResponseWebSearchCallInProgress struct { - // Unique identifier of the web search call +// 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 item in the output list + // 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"` - // Event type identifier, always "response.web_search_call.in_progress" - Type constant.ResponseWebSearchCallInProgress `json:"type,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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ItemID respjson.Field OutputIndex respjson.Field + Part respjson.Field SequenceNumber respjson.Field + SummaryIndex respjson.Field Type respjson.Field ExtraFields map[string]respjson.Field raw string @@ -3854,48 +5622,55 @@ type ResponseObjectStreamResponseWebSearchCallInProgress struct { } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseWebSearchCallInProgress) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseWebSearchCallInProgress) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseReasoningSummaryPartAdded) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseReasoningSummaryPartAdded) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -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"` +// The summary part that was added +type ResponseObjectStreamResponseReasoningSummaryPartAddedPart struct { + // Summary text + Text string `json:"text,required"` + // Content part type identifier, always "summary_text" + Type constant.SummaryText `json:"type,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - ItemID respjson.Field - OutputIndex respjson.Field - SequenceNumber respjson.Field - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string + Text respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseWebSearchCallSearching) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseWebSearchCallSearching) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseReasoningSummaryPartAddedPart) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseReasoningSummaryPartAddedPart) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Streaming event for completed web search calls. -type ResponseObjectStreamResponseWebSearchCallCompleted struct { - // Unique identifier of the completed web search call +// 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 item in the output list + // 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"` - // Event type identifier, always "response.web_search_call.completed" - Type constant.ResponseWebSearchCallCompleted `json:"type,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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ItemID respjson.Field OutputIndex respjson.Field + Part respjson.Field SequenceNumber respjson.Field + SummaryIndex respjson.Field Type respjson.Field ExtraFields map[string]respjson.Field raw string @@ -3903,77 +5678,53 @@ type ResponseObjectStreamResponseWebSearchCallCompleted struct { } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseWebSearchCallCompleted) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseWebSearchCallCompleted) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type ResponseObjectStreamResponseMcpListToolsInProgress struct { - SequenceNumber int64 `json:"sequence_number,required"` - Type constant.ResponseMcpListToolsInProgress `json:"type,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - SequenceNumber respjson.Field - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseMcpListToolsInProgress) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseMcpListToolsInProgress) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type ResponseObjectStreamResponseMcpListToolsFailed struct { - SequenceNumber int64 `json:"sequence_number,required"` - Type constant.ResponseMcpListToolsFailed `json:"type,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - SequenceNumber respjson.Field - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseMcpListToolsFailed) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseMcpListToolsFailed) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseReasoningSummaryPartDone) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseReasoningSummaryPartDone) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ResponseObjectStreamResponseMcpListToolsCompleted struct { - SequenceNumber int64 `json:"sequence_number,required"` - Type constant.ResponseMcpListToolsCompleted `json:"type,required"` +// The completed summary part +type ResponseObjectStreamResponseReasoningSummaryPartDonePart struct { + // Summary text + Text string `json:"text,required"` + // Content part type identifier, always "summary_text" + Type constant.SummaryText `json:"type,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - SequenceNumber respjson.Field - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string + Text respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseMcpListToolsCompleted) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseMcpListToolsCompleted) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseReasoningSummaryPartDonePart) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseReasoningSummaryPartDonePart) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -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"` +// 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Delta respjson.Field ItemID respjson.Field OutputIndex respjson.Field SequenceNumber respjson.Field + SummaryIndex respjson.Field Type respjson.Field ExtraFields map[string]respjson.Field raw string @@ -3981,23 +5732,32 @@ type ResponseObjectStreamResponseMcpCallArgumentsDelta struct { } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseMcpCallArgumentsDelta) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseMcpCallArgumentsDelta) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseReasoningSummaryTextDelta) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseReasoningSummaryTextDelta) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -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"` +// 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Arguments respjson.Field ItemID respjson.Field OutputIndex respjson.Field SequenceNumber respjson.Field + SummaryIndex respjson.Field + Text respjson.Field Type respjson.Field ExtraFields map[string]respjson.Field raw string @@ -4005,23 +5765,29 @@ type ResponseObjectStreamResponseMcpCallArgumentsDone struct { } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseMcpCallArgumentsDone) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseMcpCallArgumentsDone) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseReasoningSummaryTextDone) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseReasoningSummaryTextDone) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Streaming event for MCP calls in progress. -type ResponseObjectStreamResponseMcpCallInProgress struct { - // Unique identifier of the MCP call +// 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.mcp_call.in_progress" - Type constant.ResponseMcpCallInProgress `json:"type,required"` + // Event type identifier, always "response.refusal.delta" + Type constant.ResponseRefusalDelta `json:"type,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { + ContentIndex respjson.Field + Delta respjson.Field ItemID respjson.Field OutputIndex respjson.Field SequenceNumber respjson.Field @@ -4032,40 +5798,31 @@ type ResponseObjectStreamResponseMcpCallInProgress struct { } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseMcpCallInProgress) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseMcpCallInProgress) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// 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"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - SequenceNumber respjson.Field - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseMcpCallFailed) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseMcpCallFailed) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseRefusalDelta) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseRefusalDelta) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Streaming event for completed MCP calls. -type ResponseObjectStreamResponseMcpCallCompleted struct { +// 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.mcp_call.completed" - Type constant.ResponseMcpCallCompleted `json:"type,required"` + // Event type identifier, always "response.refusal.done" + Type constant.ResponseRefusalDone `json:"type,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { + ContentIndex respjson.Field + ItemID respjson.Field + OutputIndex respjson.Field + Refusal respjson.Field SequenceNumber respjson.Field Type respjson.Field ExtraFields map[string]respjson.Field @@ -4074,121 +5831,176 @@ type ResponseObjectStreamResponseMcpCallCompleted struct { } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseMcpCallCompleted) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseMcpCallCompleted) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseRefusalDone) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseRefusalDone) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Streaming event for when a new content part is added to a response item. -type ResponseObjectStreamResponseContentPartAdded struct { - // Unique identifier of the output item containing this content part +// 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"` - // 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"` + // 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.content_part.added" - Type constant.ResponseContentPartAdded `json:"type,required"` + // Event type identifier, always "response.output_text.annotation.added" + Type constant.ResponseOutputTextAnnotationAdded `json:"type,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - ItemID respjson.Field - Part respjson.Field - ResponseID respjson.Field - SequenceNumber respjson.Field - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string + Annotation respjson.Field + AnnotationIndex respjson.Field + ContentIndex respjson.Field + ItemID respjson.Field + OutputIndex 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 ResponseObjectStreamResponseContentPartAdded) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseContentPartAdded) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseOutputTextAnnotationAdded) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseOutputTextAnnotationAdded) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamResponseContentPartAddedPartUnion contains all possible -// properties and values from -// [ResponseObjectStreamResponseContentPartAddedPartOutputText], -// [ResponseObjectStreamResponseContentPartAddedPartRefusal]. +// ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationUnion contains +// all possible properties and values from +// [ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationFileCitation], +// [ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationURLCitation], +// [ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationContainerFileCitation], +// [ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationFilePath]. // -// Use the [ResponseObjectStreamResponseContentPartAddedPartUnion.AsAny] method to -// switch on the variant. +// Use the +// [ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationUnion.AsAny] +// method to switch on the variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type ResponseObjectStreamResponseContentPartAddedPartUnion struct { +type ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationUnion 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 - // [ResponseObjectStreamResponseContentPartAddedPartOutputText]. - Text string `json:"text"` - // Any of "output_text", "refusal". - Type string `json:"type"` + // [ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationURLCitation]. + Title string `json:"title"` // This field is from variant - // [ResponseObjectStreamResponseContentPartAddedPartRefusal]. - Refusal string `json:"refusal"` - JSON struct { - Text respjson.Field - Type respjson.Field - Refusal respjson.Field - raw string + // [ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationURLCitation]. + URL string `json:"url"` + // This field is from variant + // [ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationContainerFileCitation]. + 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:"-"` } -// anyResponseObjectStreamResponseContentPartAddedPart is implemented by each -// variant of [ResponseObjectStreamResponseContentPartAddedPartUnion] to add type -// safety for the return type of -// [ResponseObjectStreamResponseContentPartAddedPartUnion.AsAny] -type anyResponseObjectStreamResponseContentPartAddedPart interface { - implResponseObjectStreamResponseContentPartAddedPartUnion() +// anyResponseObjectStreamResponseOutputTextAnnotationAddedAnnotation is +// implemented by each variant of +// [ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationUnion] to add +// type safety for the return type of +// [ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationUnion.AsAny] +type anyResponseObjectStreamResponseOutputTextAnnotationAddedAnnotation interface { + implResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationUnion() } -func (ResponseObjectStreamResponseContentPartAddedPartOutputText) implResponseObjectStreamResponseContentPartAddedPartUnion() { +func (ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationFileCitation) implResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationUnion() { } -func (ResponseObjectStreamResponseContentPartAddedPartRefusal) implResponseObjectStreamResponseContentPartAddedPartUnion() { +func (ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationURLCitation) implResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationUnion() { +} +func (ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationContainerFileCitation) implResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationUnion() { +} +func (ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationFilePath) implResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationUnion() { } // Use the following switch statement to find the correct variant // -// switch variant := ResponseObjectStreamResponseContentPartAddedPartUnion.AsAny().(type) { -// case llamastackclient.ResponseObjectStreamResponseContentPartAddedPartOutputText: -// case llamastackclient.ResponseObjectStreamResponseContentPartAddedPartRefusal: +// switch variant := ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationUnion.AsAny().(type) { +// case llamastackclient.ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationFileCitation: +// case llamastackclient.ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationURLCitation: +// case llamastackclient.ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationContainerFileCitation: +// case llamastackclient.ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationFilePath: // default: // fmt.Errorf("no variant present") // } -func (u ResponseObjectStreamResponseContentPartAddedPartUnion) AsAny() anyResponseObjectStreamResponseContentPartAddedPart { +func (u ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationUnion) AsAny() anyResponseObjectStreamResponseOutputTextAnnotationAddedAnnotation { switch u.Type { - case "output_text": - return u.AsOutputText() - case "refusal": - return u.AsRefusal() + 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 ResponseObjectStreamResponseContentPartAddedPartUnion) AsOutputText() (v ResponseObjectStreamResponseContentPartAddedPartOutputText) { +func (u ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationUnion) AsFileCitation() (v ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationFileCitation) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseObjectStreamResponseContentPartAddedPartUnion) AsRefusal() (v ResponseObjectStreamResponseContentPartAddedPartRefusal) { +func (u ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationUnion) AsURLCitation() (v ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationURLCitation) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationUnion) AsContainerFileCitation() (v ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationContainerFileCitation) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationUnion) AsFilePath() (v ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationFilePath) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ResponseObjectStreamResponseContentPartAddedPartUnion) RawJSON() string { return u.JSON.raw } +func (u ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationUnion) RawJSON() string { + return u.JSON.raw +} -func (r *ResponseObjectStreamResponseContentPartAddedPartUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ResponseObjectStreamResponseContentPartAddedPartOutputText struct { - Text string `json:"text,required"` - Type constant.OutputText `json:"type,required"` +// 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 + 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"` // 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 @@ -4196,48 +6008,109 @@ type ResponseObjectStreamResponseContentPartAddedPartOutputText struct { } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseContentPartAddedPartOutputText) RawJSON() string { +func (r ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationFileCitation) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseContentPartAddedPartOutputText) UnmarshalJSON(data []byte) error { +func (r *ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationFileCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ResponseObjectStreamResponseContentPartAddedPartRefusal struct { - Refusal string `json:"refusal,required"` - Type constant.Refusal `json:"type,required"` +// 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Refusal respjson.Field + EndIndex respjson.Field + StartIndex respjson.Field + Title respjson.Field Type respjson.Field + URL respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseContentPartAddedPartRefusal) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseContentPartAddedPartRefusal) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationURLCitation) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationURLCitation) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Streaming event for when a content part is completed. -type ResponseObjectStreamResponseContentPartDone struct { - // Unique identifier of the output item containing this content part +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"` + // 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 ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationContainerFileCitation) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationFilePath struct { + FileID string `json:"file_id,required"` + Index int64 `json:"index,required"` + Type constant.FilePath `json:"type,required"` + // 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 ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationFilePath) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseObjectStreamResponseOutputTextAnnotationAddedAnnotationFilePath) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Streaming event for file search calls in progress. +type ResponseObjectStreamResponseFileSearchCallInProgress struct { + // Unique identifier of the file search call ItemID string `json:"item_id,required"` - // The completed content part - Part ResponseObjectStreamResponseContentPartDonePartUnion `json:"part,required"` - // Unique identifier of the response containing this content - ResponseID string `json:"response_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.content_part.done" - Type constant.ResponseContentPartDone `json:"type,required"` + // Event type identifier, always "response.file_search_call.in_progress" + Type constant.ResponseFileSearchCallInProgress `json:"type,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ItemID respjson.Field - Part respjson.Field - ResponseID respjson.Field + OutputIndex respjson.Field SequenceNumber respjson.Field Type respjson.Field ExtraFields map[string]respjson.Field @@ -4246,126 +6119,116 @@ type ResponseObjectStreamResponseContentPartDone struct { } // Returns the unmodified JSON received from the API -func (r ResponseObjectStreamResponseContentPartDone) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseContentPartDone) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseFileSearchCallInProgress) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseFileSearchCallInProgress) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseObjectStreamResponseContentPartDonePartUnion contains all possible -// properties and values from -// [ResponseObjectStreamResponseContentPartDonePartOutputText], -// [ResponseObjectStreamResponseContentPartDonePartRefusal]. -// -// Use the [ResponseObjectStreamResponseContentPartDonePartUnion.AsAny] method to -// switch on the variant. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -type ResponseObjectStreamResponseContentPartDonePartUnion struct { - // This field is from variant - // [ResponseObjectStreamResponseContentPartDonePartOutputText]. - Text string `json:"text"` - // Any of "output_text", "refusal". - Type string `json:"type"` - // This field is from variant - // [ResponseObjectStreamResponseContentPartDonePartRefusal]. - Refusal string `json:"refusal"` - JSON struct { - Text respjson.Field - Type respjson.Field - Refusal respjson.Field - raw string +// 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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ItemID respjson.Field + OutputIndex respjson.Field + SequenceNumber respjson.Field + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } -// anyResponseObjectStreamResponseContentPartDonePart is implemented by each -// variant of [ResponseObjectStreamResponseContentPartDonePartUnion] to add type -// safety for the return type of -// [ResponseObjectStreamResponseContentPartDonePartUnion.AsAny] -type anyResponseObjectStreamResponseContentPartDonePart interface { - implResponseObjectStreamResponseContentPartDonePartUnion() -} - -func (ResponseObjectStreamResponseContentPartDonePartOutputText) implResponseObjectStreamResponseContentPartDonePartUnion() { -} -func (ResponseObjectStreamResponseContentPartDonePartRefusal) implResponseObjectStreamResponseContentPartDonePartUnion() { -} - -// Use the following switch statement to find the correct variant -// -// switch variant := ResponseObjectStreamResponseContentPartDonePartUnion.AsAny().(type) { -// case llamastackclient.ResponseObjectStreamResponseContentPartDonePartOutputText: -// case llamastackclient.ResponseObjectStreamResponseContentPartDonePartRefusal: -// default: -// fmt.Errorf("no variant present") -// } -func (u ResponseObjectStreamResponseContentPartDonePartUnion) AsAny() anyResponseObjectStreamResponseContentPartDonePart { - switch u.Type { - case "output_text": - return u.AsOutputText() - case "refusal": - return u.AsRefusal() - } - return nil -} - -func (u ResponseObjectStreamResponseContentPartDonePartUnion) AsOutputText() (v ResponseObjectStreamResponseContentPartDonePartOutputText) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Returns the unmodified JSON received from the API +func (r ResponseObjectStreamResponseFileSearchCallSearching) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseFileSearchCallSearching) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ResponseObjectStreamResponseContentPartDonePartUnion) AsRefusal() (v ResponseObjectStreamResponseContentPartDonePartRefusal) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// 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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ItemID respjson.Field + OutputIndex 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 (u ResponseObjectStreamResponseContentPartDonePartUnion) RawJSON() string { return u.JSON.raw } - -func (r *ResponseObjectStreamResponseContentPartDonePartUnion) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseFileSearchCallCompleted) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseFileSearchCallCompleted) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ResponseObjectStreamResponseContentPartDonePartOutputText struct { - Text string `json:"text,required"` - Type constant.OutputText `json:"type,required"` +// 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"` // 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 + Response 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 ResponseObjectStreamResponseContentPartDonePartOutputText) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseObjectStreamResponseContentPartDonePartOutputText) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseIncomplete) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseIncomplete) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ResponseObjectStreamResponseContentPartDonePartRefusal struct { - Refusal string `json:"refusal,required"` - Type constant.Refusal `json:"type,required"` +// 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"` // 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 + Response 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 ResponseObjectStreamResponseContentPartDonePartRefusal) RawJSON() string { return r.JSON.raw } -func (r *ResponseObjectStreamResponseContentPartDonePartRefusal) UnmarshalJSON(data []byte) error { +func (r ResponseObjectStreamResponseFailed) RawJSON() string { return r.JSON.raw } +func (r *ResponseObjectStreamResponseFailed) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Streaming event indicating a response has been completed. type ResponseObjectStreamResponseCompleted struct { - // The completed response object + // Completed response object Response ResponseObject `json:"response,required"` // Event type identifier, always "response.completed" Type constant.ResponseCompleted `json:"type,required"` @@ -4406,16 +6269,25 @@ type ResponseListResponse struct { 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) User identifier associated with the request - User string `json:"user"` + // (Optional) Token usage information for the response + Usage ResponseListResponseUsage `json:"usage"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { ID respjson.Field @@ -4428,11 +6300,15 @@ type ResponseListResponse struct { Status respjson.Field Text respjson.Field Error respjson.Field + Instructions respjson.Field + MaxToolCalls respjson.Field PreviousResponseID respjson.Field + Prompt respjson.Field Temperature respjson.Field + Tools respjson.Field TopP respjson.Field Truncation respjson.Field - User respjson.Field + Usage respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -4445,85 +6321,426 @@ func (r *ResponseListResponse) UnmarshalJSON(data []byte) error { } // ResponseListResponseInputUnion contains all possible properties and values from +// [ResponseListResponseInputOpenAIResponseMessage], // [ResponseListResponseInputOpenAIResponseOutputMessageWebSearchToolCall], // [ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCall], // [ResponseListResponseInputOpenAIResponseOutputMessageFunctionToolCall], +// [ResponseListResponseInputOpenAIResponseOutputMessageMcpCall], +// [ResponseListResponseInputOpenAIResponseOutputMessageMcpListTools], +// [ResponseListResponseInputOpenAIResponseMcpApprovalRequest], // [ResponseListResponseInputOpenAIResponseInputFunctionToolCallOutput], +// [ResponseListResponseInputOpenAIResponseMcpApprovalResponse], // [ResponseListResponseInputOpenAIResponseMessage]. // // Use the methods beginning with 'As' to cast the union to one of its variants. type ResponseListResponseInputUnion struct { - ID string `json:"id"` - Status string `json:"status"` - Type string `json:"type"` + // 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 // [ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCall]. Queries []string `json:"queries"` // This field is from variant // [ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCall]. - Results []ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResult `json:"results"` + Results []ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResult `json:"results"` + Arguments string `json:"arguments"` + CallID string `json:"call_id"` + Name string `json:"name"` + ServerLabel string `json:"server_label"` + // This field is from variant + // [ResponseListResponseInputOpenAIResponseOutputMessageMcpCall]. + Error string `json:"error"` + Output string `json:"output"` // This field is from variant - // [ResponseListResponseInputOpenAIResponseOutputMessageFunctionToolCall]. - Arguments string `json:"arguments"` - CallID string `json:"call_id"` + // [ResponseListResponseInputOpenAIResponseOutputMessageMcpListTools]. + Tools []ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsTool `json:"tools"` // This field is from variant - // [ResponseListResponseInputOpenAIResponseOutputMessageFunctionToolCall]. - Name string `json:"name"` + // [ResponseListResponseInputOpenAIResponseMcpApprovalResponse]. + ApprovalRequestID string `json:"approval_request_id"` // This field is from variant - // [ResponseListResponseInputOpenAIResponseInputFunctionToolCallOutput]. - Output string `json:"output"` - // This field is from variant [ResponseListResponseInputOpenAIResponseMessage]. - Content ResponseListResponseInputOpenAIResponseMessageContentUnion `json:"content"` - // This field is from variant [ResponseListResponseInputOpenAIResponseMessage]. - Role ResponseListResponseInputOpenAIResponseMessageRole `json:"role"` + // [ResponseListResponseInputOpenAIResponseMcpApprovalResponse]. + Approve bool `json:"approve"` + // This field is from variant + // [ResponseListResponseInputOpenAIResponseMcpApprovalResponse]. + Reason string `json:"reason"` + 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 + ServerLabel respjson.Field + Error respjson.Field + Output respjson.Field + Tools respjson.Field + ApprovalRequestID respjson.Field + Approve respjson.Field + Reason respjson.Field + raw string + } `json:"-"` +} + +func (u ResponseListResponseInputUnion) AsOpenAIResponseMessage() (v ResponseListResponseInputOpenAIResponseMessage) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseInputUnion) AsOpenAIResponseOutputMessageWebSearchToolCall() (v ResponseListResponseInputOpenAIResponseOutputMessageWebSearchToolCall) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseInputUnion) AsOpenAIResponseOutputMessageFileSearchToolCall() (v ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCall) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseInputUnion) AsOpenAIResponseOutputMessageFunctionToolCall() (v ResponseListResponseInputOpenAIResponseOutputMessageFunctionToolCall) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseInputUnion) AsOpenAIResponseOutputMessageMcpCall() (v ResponseListResponseInputOpenAIResponseOutputMessageMcpCall) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseInputUnion) AsOpenAIResponseOutputMessageMcpListTools() (v ResponseListResponseInputOpenAIResponseOutputMessageMcpListTools) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseInputUnion) AsOpenAIResponseMcpApprovalRequest() (v ResponseListResponseInputOpenAIResponseMcpApprovalRequest) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseInputUnion) AsOpenAIResponseInputFunctionToolCallOutput() (v ResponseListResponseInputOpenAIResponseInputFunctionToolCallOutput) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseInputUnion) AsOpenAIResponseMcpApprovalResponse() (v ResponseListResponseInputOpenAIResponseMcpApprovalResponse) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseInputUnion) AsResponseListResponseInputOpenAIResponseMessage() (v ResponseListResponseInputOpenAIResponseMessage) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ResponseListResponseInputUnion) RawJSON() string { return u.JSON.raw } + +func (r *ResponseListResponseInputUnion) 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 ResponseListResponseInputOpenAIResponseMessage struct { + Content ResponseListResponseInputOpenAIResponseMessageContentUnion `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"` + // 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 + 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 { + return apijson.UnmarshalRoot(data, r) +} + +// ResponseListResponseInputOpenAIResponseMessageContentUnion contains all possible +// properties and values from [string], +// [[]ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion], +// [[]ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion]. +// +// 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 { + // 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 + } `json:"-"` +} + +func (u ResponseListResponseInputOpenAIResponseMessageContentUnion) AsString() (v string) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseInputOpenAIResponseMessageContentUnion) AsResponseListResponseInputOpenAIResponseMessageContentArray() (v []ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseInputOpenAIResponseMessageContentUnion) AsVariant2() (v []ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ResponseListResponseInputOpenAIResponseMessageContentUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *ResponseListResponseInputOpenAIResponseMessageContentUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion contains all +// possible properties and values from +// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText], +// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage], +// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputFile]. +// +// Use the +// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion.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"` + // This field is from variant + // [ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputFile]. + FileData string `json:"file_data"` + // This field is from variant + // [ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputFile]. + FileURL string `json:"file_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 + } `json:"-"` +} + +// anyResponseListResponseInputOpenAIResponseMessageContentArrayItem is implemented +// by each variant of +// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion] to add +// type safety for the return type of +// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion.AsAny] +type anyResponseListResponseInputOpenAIResponseMessageContentArrayItem interface { + implResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion() +} + +func (ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText) implResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion() { +} +func (ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage) implResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion() { +} +func (ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputFile) implResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion() { +} + +// Use the following switch statement to find the correct variant +// +// switch variant := ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion.AsAny().(type) { +// case llamastackclient.ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText: +// case llamastackclient.ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage: +// case llamastackclient.ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputFile: +// default: +// fmt.Errorf("no variant present") +// } +func (u ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion) AsAny() anyResponseListResponseInputOpenAIResponseMessageContentArrayItem { + 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 ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion) AsInputText() (v ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion) AsInputImage() (v ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion) AsInputFile() (v ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputFile) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion) RawJSON() string { + return u.JSON.raw +} + +func (r *ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion) 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"` + // 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 ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText) 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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - ID respjson.Field - Status respjson.Field - Type respjson.Field - Queries respjson.Field - Results respjson.Field - Arguments respjson.Field - CallID respjson.Field - Name respjson.Field - Output respjson.Field - Content respjson.Field - Role respjson.Field - raw string + Detail respjson.Field + Type respjson.Field + FileID respjson.Field + ImageURL respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } -func (u ResponseListResponseInputUnion) AsOpenAIResponseOutputMessageWebSearchToolCall() (v ResponseListResponseInputOpenAIResponseOutputMessageWebSearchToolCall) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Returns the unmodified JSON received from the API +func (r ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage) RawJSON() string { + return r.JSON.raw } - -func (u ResponseListResponseInputUnion) AsOpenAIResponseOutputMessageFileSearchToolCall() (v ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCall) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +func (r *ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ResponseListResponseInputUnion) AsOpenAIResponseOutputMessageFunctionToolCall() (v ResponseListResponseInputOpenAIResponseOutputMessageFunctionToolCall) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} +// Level of detail for image processing, can be "low", "high", or "auto" +type ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImageDetail string -func (u ResponseListResponseInputUnion) AsOpenAIResponseInputFunctionToolCallOutput() (v ResponseListResponseInputOpenAIResponseInputFunctionToolCallOutput) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} +const ( + ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImageDetailLow ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImageDetail = "low" + ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImageDetailHigh ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImageDetail = "high" + ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImageDetailAuto ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImageDetail = "auto" +) -func (u ResponseListResponseInputUnion) AsOpenAIResponseMessage() (v ResponseListResponseInputOpenAIResponseMessage) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// 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"` + // 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 + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } // Returns the unmodified JSON received from the API -func (u ResponseListResponseInputUnion) RawJSON() string { return u.JSON.raw } - -func (r *ResponseListResponseInputUnion) UnmarshalJSON(data []byte) error { +func (r ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputFile) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +// Level of detail for image processing, can be "low", "high", or "auto" +type ResponseListResponseInputOpenAIResponseMessageContentArrayItemDetail string + +const ( + ResponseListResponseInputOpenAIResponseMessageContentArrayItemDetailLow ResponseListResponseInputOpenAIResponseMessageContentArrayItemDetail = "low" + ResponseListResponseInputOpenAIResponseMessageContentArrayItemDetailHigh ResponseListResponseInputOpenAIResponseMessageContentArrayItemDetail = "high" + ResponseListResponseInputOpenAIResponseMessageContentArrayItemDetailAuto ResponseListResponseInputOpenAIResponseMessageContentArrayItemDetail = "auto" +) + +type ResponseListResponseInputOpenAIResponseMessageRole string + +const ( + ResponseListResponseInputOpenAIResponseMessageRoleSystem ResponseListResponseInputOpenAIResponseMessageRole = "system" + ResponseListResponseInputOpenAIResponseMessageRoleDeveloper ResponseListResponseInputOpenAIResponseMessageRole = "developer" + ResponseListResponseInputOpenAIResponseMessageRoleUser ResponseListResponseInputOpenAIResponseMessageRole = "user" + ResponseListResponseInputOpenAIResponseMessageRoleAssistant ResponseListResponseInputOpenAIResponseMessageRole = "assistant" +) + // Web search tool call output message for OpenAI responses. type ResponseListResponseInputOpenAIResponseOutputMessageWebSearchToolCall struct { // Unique identifier for this tool call @@ -4610,11 +6827,194 @@ type ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResul func (r ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResult) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResult) UnmarshalJSON(data []byte) error { +func (r *ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResult) UnmarshalJSON(data []byte) error { + 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"` + // 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 + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseListResponseInputOpenAIResponseOutputMessageFunctionToolCall) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseListResponseInputOpenAIResponseOutputMessageFunctionToolCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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 + 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"` + // 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 + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseListResponseInputOpenAIResponseOutputMessageMcpCall) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseListResponseInputOpenAIResponseOutputMessageMcpCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` + // 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 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) } -// ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion +// ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion // contains all possible properties and values from [bool], [float64], [string], // [[]any]. // @@ -4622,7 +7022,7 @@ func (r *ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallR // // If the underlying value is not a json object, one of the following properties // will be valid: OfBool OfFloat OfString OfAnyArray] -type ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion struct { +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. @@ -4640,67 +7040,59 @@ type ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResul } `json:"-"` } -func (u ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) AsBool() (v bool) { +func (u ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) AsBool() (v bool) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) AsFloat() (v float64) { +func (u ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) AsFloat() (v float64) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) AsString() (v string) { +func (u ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) AsAnyArray() (v []any) { +func (u ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) 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 { +func (u ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) RawJSON() string { return u.JSON.raw } -func (r *ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseListResponseInputOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) 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"` +// 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { + ID respjson.Field Arguments respjson.Field - CallID respjson.Field Name respjson.Field + ServerLabel 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 ResponseListResponseInputOpenAIResponseOutputMessageFunctionToolCall) RawJSON() string { +func (r ResponseListResponseInputOpenAIResponseMcpApprovalRequest) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseInputOpenAIResponseOutputMessageFunctionToolCall) UnmarshalJSON(data []byte) error { +func (r *ResponseListResponseInputOpenAIResponseMcpApprovalRequest) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } @@ -4732,16 +7124,196 @@ func (r *ResponseListResponseInputOpenAIResponseInputFunctionToolCallOutput) Unm return apijson.UnmarshalRoot(data, r) } +// 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"` + // 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:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseListResponseInputOpenAIResponseMcpApprovalResponse) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseListResponseInputOpenAIResponseMcpApprovalResponse) UnmarshalJSON(data []byte) error { + 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], +// [ResponseListResponseOutputFunctionCall], [ResponseListResponseOutputMcpCall], +// [ResponseListResponseOutputMcpListTools], +// [ResponseListResponseOutputMcpApprovalRequest]. +// +// Use the [ResponseListResponseOutputUnion.AsAny] method to switch on the variant. +// +// Use the methods beginning with 'As' to cast the union to one of its variants. +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"` + ID string `json:"id"` + Status string `json:"status"` + // This field is from variant [ResponseListResponseOutputFileSearchCall]. + Queries []string `json:"queries"` + // This field is from variant [ResponseListResponseOutputFileSearchCall]. + Results []ResponseListResponseOutputFileSearchCallResult `json:"results"` + Arguments string `json:"arguments"` + // This field is from variant [ResponseListResponseOutputFunctionCall]. + CallID string `json:"call_id"` + Name string `json:"name"` + ServerLabel string `json:"server_label"` + // This field is from variant [ResponseListResponseOutputMcpCall]. + Error string `json:"error"` + // This field is from variant [ResponseListResponseOutputMcpCall]. + Output string `json:"output"` + // This field is from variant [ResponseListResponseOutputMcpListTools]. + Tools []ResponseListResponseOutputMcpListToolsTool `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 + ServerLabel respjson.Field + Error respjson.Field + Output respjson.Field + Tools respjson.Field + raw string + } `json:"-"` +} + +// anyResponseListResponseOutput is implemented by each variant of +// [ResponseListResponseOutputUnion] to add type safety for the return type of +// [ResponseListResponseOutputUnion.AsAny] +type anyResponseListResponseOutput interface { + implResponseListResponseOutputUnion() +} + +func (ResponseListResponseOutputMessage) implResponseListResponseOutputUnion() {} +func (ResponseListResponseOutputWebSearchCall) implResponseListResponseOutputUnion() {} +func (ResponseListResponseOutputFileSearchCall) implResponseListResponseOutputUnion() {} +func (ResponseListResponseOutputFunctionCall) implResponseListResponseOutputUnion() {} +func (ResponseListResponseOutputMcpCall) implResponseListResponseOutputUnion() {} +func (ResponseListResponseOutputMcpListTools) implResponseListResponseOutputUnion() {} +func (ResponseListResponseOutputMcpApprovalRequest) implResponseListResponseOutputUnion() {} + +// Use the following switch statement to find the correct variant +// +// switch variant := ResponseListResponseOutputUnion.AsAny().(type) { +// case llamastackclient.ResponseListResponseOutputMessage: +// case llamastackclient.ResponseListResponseOutputWebSearchCall: +// case llamastackclient.ResponseListResponseOutputFileSearchCall: +// case llamastackclient.ResponseListResponseOutputFunctionCall: +// case llamastackclient.ResponseListResponseOutputMcpCall: +// case llamastackclient.ResponseListResponseOutputMcpListTools: +// case llamastackclient.ResponseListResponseOutputMcpApprovalRequest: +// default: +// fmt.Errorf("no variant present") +// } +func (u ResponseListResponseOutputUnion) AsAny() anyResponseListResponseOutput { + 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 "mcp_call": + return u.AsMcpCall() + case "mcp_list_tools": + return u.AsMcpListTools() + case "mcp_approval_request": + return u.AsMcpApprovalRequest() + } + return nil +} + +func (u ResponseListResponseOutputUnion) AsMessage() (v ResponseListResponseOutputMessage) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseOutputUnion) AsWebSearchCall() (v ResponseListResponseOutputWebSearchCall) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseOutputUnion) AsFileSearchCall() (v ResponseListResponseOutputFileSearchCall) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseOutputUnion) AsFunctionCall() (v ResponseListResponseOutputFunctionCall) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseOutputUnion) AsMcpCall() (v ResponseListResponseOutputMcpCall) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseOutputUnion) AsMcpListTools() (v ResponseListResponseOutputMcpListTools) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ResponseListResponseOutputUnion) AsMcpApprovalRequest() (v ResponseListResponseOutputMcpApprovalRequest) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ResponseListResponseOutputUnion) RawJSON() string { return u.JSON.raw } + +func (r *ResponseListResponseOutputUnion) 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 ResponseListResponseInputOpenAIResponseMessage struct { - Content ResponseListResponseInputOpenAIResponseMessageContentUnion `json:"content,required"` +type ResponseListResponseOutputMessage struct { + Content ResponseListResponseOutputMessageContentUnion `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 ResponseListResponseOutputMessageRole `json:"role,required"` + Type constant.Message `json:"type,required"` + ID string `json:"id"` + Status string `json:"status"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Content respjson.Field @@ -4755,148 +7327,160 @@ type ResponseListResponseInputOpenAIResponseMessage struct { } // 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 ResponseListResponseOutputMessage) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponseOutputMessage) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseListResponseInputOpenAIResponseMessageContentUnion contains all possible -// properties and values from [string], -// [[]ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion], -// [[]ResponseListResponseInputOpenAIResponseMessageContentArrayItem]. +// ResponseListResponseOutputMessageContentUnion contains all possible properties +// and values from [string], +// [[]ResponseListResponseOutputMessageContentArrayItemUnion], +// [[]ResponseListResponseOutputMessageContentArrayItemUnion]. // // 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 -// OfResponseListResponseInputOpenAIResponseMessageContentArray OfVariant2] -type ResponseListResponseInputOpenAIResponseMessageContentUnion struct { +// will be valid: OfString OfVariant2] +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 - // [[]ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion] instead - // of an object. - OfResponseListResponseInputOpenAIResponseMessageContentArray []ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion `json:",inline"` - // This field will be present if the value is a - // [[]ResponseListResponseInputOpenAIResponseMessageContentArrayItem] instead of an - // object. - OfVariant2 []ResponseListResponseInputOpenAIResponseMessageContentArrayItem `json:",inline"` + // [[]ResponseListResponseOutputMessageContentArrayItemUnion] instead of an object. + OfVariant2 []ResponseListResponseOutputMessageContentArrayItemUnion `json:",inline"` JSON struct { - OfString respjson.Field - OfResponseListResponseInputOpenAIResponseMessageContentArray respjson.Field - OfVariant2 respjson.Field - raw string + OfString respjson.Field + OfVariant2 respjson.Field + raw string } `json:"-"` } -func (u ResponseListResponseInputOpenAIResponseMessageContentUnion) AsString() (v string) { +func (u ResponseListResponseOutputMessageContentUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseInputOpenAIResponseMessageContentUnion) AsResponseListResponseInputOpenAIResponseMessageContentArray() (v []ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion) { +func (u ResponseListResponseOutputMessageContentUnion) AsResponseListResponseOutputMessageContentArray() (v []ResponseListResponseOutputMessageContentArrayItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseInputOpenAIResponseMessageContentUnion) AsVariant2() (v []ResponseListResponseInputOpenAIResponseMessageContentArrayItem) { +func (u ResponseListResponseOutputMessageContentUnion) AsVariant2() (v []ResponseListResponseOutputMessageContentArrayItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ResponseListResponseInputOpenAIResponseMessageContentUnion) RawJSON() string { - return u.JSON.raw -} +func (u ResponseListResponseOutputMessageContentUnion) RawJSON() string { return u.JSON.raw } -func (r *ResponseListResponseInputOpenAIResponseMessageContentUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseListResponseOutputMessageContentUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion contains all -// possible properties and values from -// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText], -// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage]. +// ResponseListResponseOutputMessageContentArrayItemUnion contains all possible +// properties and values from +// [ResponseListResponseOutputMessageContentArrayItemInputText], +// [ResponseListResponseOutputMessageContentArrayItemInputImage], +// [ResponseListResponseOutputMessageContentArrayItemInputFile]. // -// Use the -// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion.AsAny] -// method to switch on the variant. +// Use the [ResponseListResponseOutputMessageContentArrayItemUnion.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 { +type ResponseListResponseOutputMessageContentArrayItemUnion struct { // This field is from variant - // [ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText]. + // [ResponseListResponseOutputMessageContentArrayItemInputText]. Text string `json:"text"` - // Any of "input_text", "input_image". + // Any of "input_text", "input_image", "input_file". Type string `json:"type"` // This field is from variant - // [ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage]. - Detail ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImageDetail `json:"detail"` + // [ResponseListResponseOutputMessageContentArrayItemInputImage]. + Detail ResponseListResponseOutputMessageContentArrayItemInputImageDetail `json:"detail"` + FileID string `json:"file_id"` // This field is from variant - // [ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage]. + // [ResponseListResponseOutputMessageContentArrayItemInputImage]. ImageURL string `json:"image_url"` + // This field is from variant + // [ResponseListResponseOutputMessageContentArrayItemInputFile]. + FileData string `json:"file_data"` + // This field is from variant + // [ResponseListResponseOutputMessageContentArrayItemInputFile]. + FileURL string `json:"file_url"` + // This field is from variant + // [ResponseListResponseOutputMessageContentArrayItemInputFile]. + 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:"-"` } -// anyResponseListResponseInputOpenAIResponseMessageContentArrayItem is implemented -// by each variant of -// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion] to add -// type safety for the return type of -// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion.AsAny] -type anyResponseListResponseInputOpenAIResponseMessageContentArrayItem interface { - implResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion() +// anyResponseListResponseOutputMessageContentArrayItem is implemented by each +// variant of [ResponseListResponseOutputMessageContentArrayItemUnion] to add type +// safety for the return type of +// [ResponseListResponseOutputMessageContentArrayItemUnion.AsAny] +type anyResponseListResponseOutputMessageContentArrayItem interface { + implResponseListResponseOutputMessageContentArrayItemUnion() } -func (ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText) implResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion() { +func (ResponseListResponseOutputMessageContentArrayItemInputText) implResponseListResponseOutputMessageContentArrayItemUnion() { } -func (ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage) implResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion() { +func (ResponseListResponseOutputMessageContentArrayItemInputImage) implResponseListResponseOutputMessageContentArrayItemUnion() { +} +func (ResponseListResponseOutputMessageContentArrayItemInputFile) implResponseListResponseOutputMessageContentArrayItemUnion() { } // Use the following switch statement to find the correct variant // -// switch variant := ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion.AsAny().(type) { -// case llamastackclient.ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText: -// case llamastackclient.ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage: +// switch variant := ResponseListResponseOutputMessageContentArrayItemUnion.AsAny().(type) { +// case llamastackclient.ResponseListResponseOutputMessageContentArrayItemInputText: +// case llamastackclient.ResponseListResponseOutputMessageContentArrayItemInputImage: +// case llamastackclient.ResponseListResponseOutputMessageContentArrayItemInputFile: // default: // fmt.Errorf("no variant present") // } -func (u ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion) AsAny() anyResponseListResponseInputOpenAIResponseMessageContentArrayItem { +func (u ResponseListResponseOutputMessageContentArrayItemUnion) AsAny() anyResponseListResponseOutputMessageContentArrayItem { 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 ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion) AsInputText() (v ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText) { +func (u ResponseListResponseOutputMessageContentArrayItemUnion) AsInputText() (v ResponseListResponseOutputMessageContentArrayItemInputText) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion) AsInputImage() (v ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage) { +func (u ResponseListResponseOutputMessageContentArrayItemUnion) AsInputImage() (v ResponseListResponseOutputMessageContentArrayItemInputImage) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -// Returns the unmodified JSON received from the API -func (u ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion) RawJSON() string { - return u.JSON.raw +func (u ResponseListResponseOutputMessageContentArrayItemUnion) AsInputFile() (v ResponseListResponseOutputMessageContentArrayItemInputFile) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return } -func (r *ResponseListResponseInputOpenAIResponseMessageContentArrayItemUnion) UnmarshalJSON(data []byte) error { +// Returns the unmodified JSON received from the API +func (u ResponseListResponseOutputMessageContentArrayItemUnion) RawJSON() string { return u.JSON.raw } + +func (r *ResponseListResponseOutputMessageContentArrayItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Text content for input messages in OpenAI response format. -type ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText struct { +type ResponseListResponseOutputMessageContentArrayItemInputText struct { // The text content of the input message Text string `json:"text,required"` // Content type identifier, always "input_text" @@ -4911,27 +7495,30 @@ type ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText str } // Returns the unmodified JSON received from the API -func (r ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText) RawJSON() string { +func (r ResponseListResponseOutputMessageContentArrayItemInputText) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputText) UnmarshalJSON(data []byte) error { +func (r *ResponseListResponseOutputMessageContentArrayItemInputText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Image content for input messages in OpenAI response format. -type ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage struct { +type ResponseListResponseOutputMessageContentArrayItemInputImage struct { // Level of detail for image processing, can be "low", "high", or "auto" // // Any of "low", "high", "auto". - Detail ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImageDetail `json:"detail,required"` + 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"` // 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 ExtraFields map[string]respjson.Field raw string @@ -4939,264 +7526,294 @@ type ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage st } // Returns the unmodified JSON received from the API -func (r ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage) RawJSON() string { +func (r ResponseListResponseOutputMessageContentArrayItemInputImage) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseInputOpenAIResponseMessageContentArrayItemInputImage) UnmarshalJSON(data []byte) error { +func (r *ResponseListResponseOutputMessageContentArrayItemInputImage) 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" -) - -// Level of detail for image processing, can be "low", "high", or "auto" -type ResponseListResponseInputOpenAIResponseMessageContentArrayItemDetail string +type ResponseListResponseOutputMessageContentArrayItemInputImageDetail string const ( - ResponseListResponseInputOpenAIResponseMessageContentArrayItemDetailLow ResponseListResponseInputOpenAIResponseMessageContentArrayItemDetail = "low" - ResponseListResponseInputOpenAIResponseMessageContentArrayItemDetailHigh ResponseListResponseInputOpenAIResponseMessageContentArrayItemDetail = "high" - ResponseListResponseInputOpenAIResponseMessageContentArrayItemDetailAuto ResponseListResponseInputOpenAIResponseMessageContentArrayItemDetail = "auto" + ResponseListResponseOutputMessageContentArrayItemInputImageDetailLow ResponseListResponseOutputMessageContentArrayItemInputImageDetail = "low" + ResponseListResponseOutputMessageContentArrayItemInputImageDetailHigh ResponseListResponseOutputMessageContentArrayItemInputImageDetail = "high" + ResponseListResponseOutputMessageContentArrayItemInputImageDetailAuto ResponseListResponseOutputMessageContentArrayItemInputImageDetail = "auto" ) -type ResponseListResponseInputOpenAIResponseMessageContentArrayItem struct { - Annotations []ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationUnion `json:"annotations,required"` - Text string `json:"text,required"` - Type constant.OutputText `json:"type,required"` +// 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Annotations respjson.Field - Text 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 ResponseListResponseInputOpenAIResponseMessageContentArrayItem) RawJSON() string { +func (r ResponseListResponseOutputMessageContentArrayItemInputFile) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseInputOpenAIResponseMessageContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ResponseListResponseOutputMessageContentArrayItemInputFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationUnion -// contains all possible properties and values from -// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationFileCitation], -// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationURLCitation], -// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationContainerFileCitation], -// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationFilePath]. -// -// Use the -// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationUnion.AsAny] -// method to switch on the variant. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -type ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationUnion 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 - // [ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationURLCitation]. - Title string `json:"title"` - // This field is from variant - // [ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationURLCitation]. - URL string `json:"url"` - // This field is from variant - // [ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationContainerFileCitation]. - ContainerID string `json:"container_id"` - JSON struct { - FileID respjson.Field - Filename respjson.Field - Index respjson.Field +// Level of detail for image processing, can be "low", "high", or "auto" +type ResponseListResponseOutputMessageContentArrayItemDetail string + +const ( + ResponseListResponseOutputMessageContentArrayItemDetailLow ResponseListResponseOutputMessageContentArrayItemDetail = "low" + ResponseListResponseOutputMessageContentArrayItemDetailHigh ResponseListResponseOutputMessageContentArrayItemDetail = "high" + ResponseListResponseOutputMessageContentArrayItemDetailAuto ResponseListResponseOutputMessageContentArrayItemDetail = "auto" +) + +type ResponseListResponseOutputMessageRole string + +const ( + ResponseListResponseOutputMessageRoleSystem ResponseListResponseOutputMessageRole = "system" + ResponseListResponseOutputMessageRoleDeveloper ResponseListResponseOutputMessageRole = "developer" + ResponseListResponseOutputMessageRoleUser ResponseListResponseOutputMessageRole = "user" + ResponseListResponseOutputMessageRoleAssistant ResponseListResponseOutputMessageRole = "assistant" +) + +// 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 + 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 - EndIndex respjson.Field - StartIndex respjson.Field - Title respjson.Field - URL respjson.Field - ContainerID respjson.Field + ExtraFields map[string]respjson.Field raw string } `json:"-"` } -// anyResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotation is -// implemented by each variant of -// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationUnion] -// to add type safety for the return type of -// [ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationUnion.AsAny] -type anyResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotation interface { - implResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationUnion() +// Returns the unmodified JSON received from the API +func (r ResponseListResponseOutputWebSearchCall) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponseOutputWebSearchCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationFileCitation) implResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationUnion() { -} -func (ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationURLCitation) implResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationUnion() { -} -func (ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationContainerFileCitation) implResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationUnion() { +// 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"` + // 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 (ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationFilePath) implResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationUnion() { + +// Returns the unmodified JSON received from the API +func (r ResponseListResponseOutputFileSearchCall) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponseOutputFileSearchCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -// Use the following switch statement to find the correct variant -// -// switch variant := ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationUnion.AsAny().(type) { -// case llamastackclient.ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationFileCitation: -// case llamastackclient.ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationURLCitation: -// case llamastackclient.ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationContainerFileCitation: -// case llamastackclient.ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationFilePath: -// default: -// fmt.Errorf("no variant present") -// } -func (u ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationUnion) AsAny() anyResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotation { - 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 +// 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"` + // 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:"-"` } -func (u ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationUnion) AsFileCitation() (v ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationFileCitation) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Returns the unmodified JSON received from the API +func (r ResponseListResponseOutputFileSearchCallResult) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponseOutputFileSearchCallResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationUnion) AsURLCitation() (v ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationURLCitation) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// 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 ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationUnion) AsContainerFileCitation() (v ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationContainerFileCitation) { +func (u ResponseListResponseOutputFileSearchCallResultAttributeUnion) AsBool() (v bool) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationUnion) AsFilePath() (v ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationFilePath) { +func (u ResponseListResponseOutputFileSearchCallResultAttributeUnion) AsFloat() (v float64) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -// Returns the unmodified JSON received from the API -func (u ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationUnion) RawJSON() string { - return u.JSON.raw -} - -func (r *ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// File citation annotation for referencing specific files in response content. -type ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationFileCitation struct { - // Unique identifier of the referenced file - FileID string `json:"file_id,required"` - // Name of the referenced file - 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"` - // 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:"-"` +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 (r ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationFileCitation) RawJSON() string { - return r.JSON.raw +func (u ResponseListResponseOutputFileSearchCallResultAttributeUnion) RawJSON() string { + return u.JSON.raw } -func (r *ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationFileCitation) UnmarshalJSON(data []byte) error { + +func (r *ResponseListResponseOutputFileSearchCallResultAttributeUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// URL citation annotation for referencing external web resources. -type ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationURLCitation 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"` +// 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - EndIndex respjson.Field - StartIndex respjson.Field - Title respjson.Field + Arguments respjson.Field + CallID respjson.Field + Name respjson.Field Type respjson.Field - URL 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 ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationURLCitation) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationURLCitation) UnmarshalJSON(data []byte) error { +func (r ResponseListResponseOutputFunctionCall) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponseOutputFunctionCall) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationContainerFileCitation 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"` +// 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 + 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"` // 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 + ID respjson.Field + Arguments respjson.Field + Name respjson.Field + ServerLabel 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 ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationContainerFileCitation) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error { +func (r ResponseListResponseOutputMcpCall) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponseOutputMcpCall) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationFilePath struct { - FileID string `json:"file_id,required"` - Index int64 `json:"index,required"` - Type constant.FilePath `json:"type,required"` +// 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - FileID respjson.Field - Index respjson.Field + ID respjson.Field + ServerLabel respjson.Field + Tools respjson.Field Type respjson.Field ExtraFields map[string]respjson.Field raw string @@ -5204,537 +7821,384 @@ type ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationFil } // Returns the unmodified JSON received from the API -func (r ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationFilePath) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseListResponseInputOpenAIResponseMessageContentArrayItemAnnotationFilePath) UnmarshalJSON(data []byte) error { +func (r ResponseListResponseOutputMcpListTools) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponseOutputMcpListTools) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ResponseListResponseInputOpenAIResponseMessageRole string - -const ( - ResponseListResponseInputOpenAIResponseMessageRoleSystem ResponseListResponseInputOpenAIResponseMessageRole = "system" - ResponseListResponseInputOpenAIResponseMessageRoleDeveloper ResponseListResponseInputOpenAIResponseMessageRole = "developer" - ResponseListResponseInputOpenAIResponseMessageRoleUser ResponseListResponseInputOpenAIResponseMessageRole = "user" - ResponseListResponseInputOpenAIResponseMessageRoleAssistant ResponseListResponseInputOpenAIResponseMessageRole = "assistant" -) - -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], -// [ResponseListResponseOutputFunctionCall], [ResponseListResponseOutputMcpCall], -// [ResponseListResponseOutputMcpListTools]. -// -// Use the [ResponseListResponseOutputUnion.AsAny] method to switch on the variant. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -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". - Type string `json:"type"` - ID string `json:"id"` - Status string `json:"status"` - // This field is from variant [ResponseListResponseOutputFileSearchCall]. - Queries []string `json:"queries"` - // This field is from variant [ResponseListResponseOutputFileSearchCall]. - Results []ResponseListResponseOutputFileSearchCallResult `json:"results"` - Arguments string `json:"arguments"` - // This field is from variant [ResponseListResponseOutputFunctionCall]. - CallID string `json:"call_id"` - Name string `json:"name"` - ServerLabel string `json:"server_label"` - // This field is from variant [ResponseListResponseOutputMcpCall]. - Error string `json:"error"` - // This field is from variant [ResponseListResponseOutputMcpCall]. - Output string `json:"output"` - // This field is from variant [ResponseListResponseOutputMcpListTools]. - Tools []ResponseListResponseOutputMcpListToolsTool `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 +// 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 - ServerLabel respjson.Field - Error respjson.Field - Output respjson.Field - Tools respjson.Field + Description respjson.Field + ExtraFields map[string]respjson.Field raw string } `json:"-"` } -// anyResponseListResponseOutput is implemented by each variant of -// [ResponseListResponseOutputUnion] to add type safety for the return type of -// [ResponseListResponseOutputUnion.AsAny] -type anyResponseListResponseOutput interface { - implResponseListResponseOutputUnion() +// 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) } -func (ResponseListResponseOutputMessage) implResponseListResponseOutputUnion() {} -func (ResponseListResponseOutputWebSearchCall) implResponseListResponseOutputUnion() {} -func (ResponseListResponseOutputFileSearchCall) implResponseListResponseOutputUnion() {} -func (ResponseListResponseOutputFunctionCall) implResponseListResponseOutputUnion() {} -func (ResponseListResponseOutputMcpCall) implResponseListResponseOutputUnion() {} -func (ResponseListResponseOutputMcpListTools) implResponseListResponseOutputUnion() {} - -// Use the following switch statement to find the correct variant +// ResponseListResponseOutputMcpListToolsToolInputSchemaUnion contains all possible +// properties and values from [bool], [float64], [string], [[]any]. // -// switch variant := ResponseListResponseOutputUnion.AsAny().(type) { -// case llamastackclient.ResponseListResponseOutputMessage: -// case llamastackclient.ResponseListResponseOutputWebSearchCall: -// case llamastackclient.ResponseListResponseOutputFileSearchCall: -// case llamastackclient.ResponseListResponseOutputFunctionCall: -// case llamastackclient.ResponseListResponseOutputMcpCall: -// case llamastackclient.ResponseListResponseOutputMcpListTools: -// default: -// fmt.Errorf("no variant present") -// } -func (u ResponseListResponseOutputUnion) AsAny() anyResponseListResponseOutput { - 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 "mcp_call": - return u.AsMcpCall() - case "mcp_list_tools": - return u.AsMcpListTools() - } - return nil -} - -func (u ResponseListResponseOutputUnion) AsMessage() (v ResponseListResponseOutputMessage) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseListResponseOutputUnion) AsWebSearchCall() (v ResponseListResponseOutputWebSearchCall) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// 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 ResponseListResponseOutputUnion) AsFileSearchCall() (v ResponseListResponseOutputFileSearchCall) { +func (u ResponseListResponseOutputMcpListToolsToolInputSchemaUnion) AsBool() (v bool) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseOutputUnion) AsFunctionCall() (v ResponseListResponseOutputFunctionCall) { +func (u ResponseListResponseOutputMcpListToolsToolInputSchemaUnion) AsFloat() (v float64) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseOutputUnion) AsMcpCall() (v ResponseListResponseOutputMcpCall) { +func (u ResponseListResponseOutputMcpListToolsToolInputSchemaUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseOutputUnion) AsMcpListTools() (v ResponseListResponseOutputMcpListTools) { +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 ResponseListResponseOutputUnion) RawJSON() string { return u.JSON.raw } +func (u ResponseListResponseOutputMcpListToolsToolInputSchemaUnion) RawJSON() string { + return u.JSON.raw +} -func (r *ResponseListResponseOutputUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseListResponseOutputMcpListToolsToolInputSchemaUnion) 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 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"` +// 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 { - Content respjson.Field - Role respjson.Field - Type respjson.Field ID respjson.Field - Status 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 ResponseListResponseOutputMessage) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseOutputMessage) 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) } -// ResponseListResponseOutputMessageContentUnion contains all possible properties -// and values from [string], -// [[]ResponseListResponseOutputMessageContentArrayItemUnion], -// [[]ResponseListResponseOutputMessageContentArrayItem]. -// -// 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 OfResponseListResponseOutputMessageContentArray -// OfVariant2] -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. - OfResponseListResponseOutputMessageContentArray []ResponseListResponseOutputMessageContentArrayItemUnion `json:",inline"` - // This field will be present if the value is a - // [[]ResponseListResponseOutputMessageContentArrayItem] instead of an object. - OfVariant2 []ResponseListResponseOutputMessageContentArrayItem `json:",inline"` - JSON struct { - OfString respjson.Field - OfResponseListResponseOutputMessageContentArray respjson.Field - OfVariant2 respjson.Field - raw string - } `json:"-"` -} - -func (u ResponseListResponseOutputMessageContentUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} +type ResponseListResponseOutputRole string -func (u ResponseListResponseOutputMessageContentUnion) AsResponseListResponseOutputMessageContentArray() (v []ResponseListResponseOutputMessageContentArrayItemUnion) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} +const ( + ResponseListResponseOutputRoleSystem ResponseListResponseOutputRole = "system" + ResponseListResponseOutputRoleDeveloper ResponseListResponseOutputRole = "developer" + ResponseListResponseOutputRoleUser ResponseListResponseOutputRole = "user" + ResponseListResponseOutputRoleAssistant ResponseListResponseOutputRole = "assistant" +) -func (u ResponseListResponseOutputMessageContentUnion) AsVariant2() (v []ResponseListResponseOutputMessageContentArrayItem) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// 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 (u ResponseListResponseOutputMessageContentUnion) RawJSON() string { return u.JSON.raw } - -func (r *ResponseListResponseOutputMessageContentUnion) UnmarshalJSON(data []byte) error { +func (r ResponseListResponseText) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponseText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseListResponseOutputMessageContentArrayItemUnion contains all possible -// properties and values from -// [ResponseListResponseOutputMessageContentArrayItemInputText], -// [ResponseListResponseOutputMessageContentArrayItemInputImage]. -// -// Use the [ResponseListResponseOutputMessageContentArrayItemUnion.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 { - // This field is from variant - // [ResponseListResponseOutputMessageContentArrayItemInputText]. - Text string `json:"text"` - // Any of "input_text", "input_image". - Type string `json:"type"` - // This field is from variant - // [ResponseListResponseOutputMessageContentArrayItemInputImage]. - Detail ResponseListResponseOutputMessageContentArrayItemInputImageDetail `json:"detail"` - // This field is from variant - // [ResponseListResponseOutputMessageContentArrayItemInputImage]. - ImageURL string `json:"image_url"` - JSON struct { - Text respjson.Field - Type respjson.Field - Detail respjson.Field - ImageURL respjson.Field - raw string +// (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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Type respjson.Field + Description respjson.Field + Name respjson.Field + Schema respjson.Field + Strict respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } -// anyResponseListResponseOutputMessageContentArrayItem is implemented by each -// variant of [ResponseListResponseOutputMessageContentArrayItemUnion] to add type -// safety for the return type of -// [ResponseListResponseOutputMessageContentArrayItemUnion.AsAny] -type anyResponseListResponseOutputMessageContentArrayItem interface { - implResponseListResponseOutputMessageContentArrayItemUnion() +// 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) } -func (ResponseListResponseOutputMessageContentArrayItemInputText) implResponseListResponseOutputMessageContentArrayItemUnion() { -} -func (ResponseListResponseOutputMessageContentArrayItemInputImage) implResponseListResponseOutputMessageContentArrayItemUnion() { -} +// Must be "text", "json_schema", or "json_object" to identify the format type +type ResponseListResponseTextFormatType string -// Use the following switch statement to find the correct variant +const ( + ResponseListResponseTextFormatTypeText ResponseListResponseTextFormatType = "text" + ResponseListResponseTextFormatTypeJsonSchema ResponseListResponseTextFormatType = "json_schema" + ResponseListResponseTextFormatTypeJsonObject ResponseListResponseTextFormatType = "json_object" +) + +// ResponseListResponseTextFormatSchemaUnion contains all possible properties and +// values from [bool], [float64], [string], [[]any]. // -// switch variant := ResponseListResponseOutputMessageContentArrayItemUnion.AsAny().(type) { -// case llamastackclient.ResponseListResponseOutputMessageContentArrayItemInputText: -// case llamastackclient.ResponseListResponseOutputMessageContentArrayItemInputImage: -// default: -// fmt.Errorf("no variant present") -// } -func (u ResponseListResponseOutputMessageContentArrayItemUnion) AsAny() anyResponseListResponseOutputMessageContentArrayItem { - switch u.Type { - case "input_text": - return u.AsInputText() - case "input_image": - return u.AsInputImage() - } - return nil +// 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 + } `json:"-"` } -func (u ResponseListResponseOutputMessageContentArrayItemUnion) AsInputText() (v ResponseListResponseOutputMessageContentArrayItemInputText) { +func (u ResponseListResponseTextFormatSchemaUnion) AsBool() (v bool) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseOutputMessageContentArrayItemUnion) AsInputImage() (v ResponseListResponseOutputMessageContentArrayItemInputImage) { +func (u ResponseListResponseTextFormatSchemaUnion) AsFloat() (v float64) { 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 (r *ResponseListResponseOutputMessageContentArrayItemUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) +func (u ResponseListResponseTextFormatSchemaUnion) AsString() (v string) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return } -// 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"` - // 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 (u ResponseListResponseTextFormatSchemaUnion) AsAnyArray() (v []any) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return } // Returns the unmodified JSON received from the API -func (r ResponseListResponseOutputMessageContentArrayItemInputText) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseListResponseOutputMessageContentArrayItemInputText) UnmarshalJSON(data []byte) error { +func (u ResponseListResponseTextFormatSchemaUnion) RawJSON() string { return u.JSON.raw } + +func (r *ResponseListResponseTextFormatSchemaUnion) 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) URL of the image content - ImageURL string `json:"image_url"` +// (Optional) Error details if the response generation failed +type ResponseListResponseError struct { + // Error code identifying the type of failure + Code string `json:"code,required"` + // Human-readable error message describing the failure + Message string `json:"message,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Detail respjson.Field - Type respjson.Field - ImageURL respjson.Field + Code respjson.Field + Message respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } -// Returns the unmodified JSON received from the API -func (r ResponseListResponseOutputMessageContentArrayItemInputImage) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseListResponseOutputMessageContentArrayItemInputImage) 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" -) - -// Level of detail for image processing, can be "low", "high", or "auto" -type ResponseListResponseOutputMessageContentArrayItemDetail string - -const ( - ResponseListResponseOutputMessageContentArrayItemDetailLow ResponseListResponseOutputMessageContentArrayItemDetail = "low" - ResponseListResponseOutputMessageContentArrayItemDetailHigh ResponseListResponseOutputMessageContentArrayItemDetail = "high" - ResponseListResponseOutputMessageContentArrayItemDetailAuto ResponseListResponseOutputMessageContentArrayItemDetail = "auto" -) +// Returns the unmodified JSON received from the API +func (r ResponseListResponseError) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponseError) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} -type ResponseListResponseOutputMessageContentArrayItem struct { - Annotations []ResponseListResponseOutputMessageContentArrayItemAnnotationUnion `json:"annotations,required"` - Text string `json:"text,required"` - Type constant.OutputText `json:"type,required"` +// (Optional) Reference to a prompt template and its variables. +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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Annotations respjson.Field - Text respjson.Field - Type respjson.Field + ID respjson.Field + Variables respjson.Field + Version respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseListResponseOutputMessageContentArrayItem) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseOutputMessageContentArrayItem) UnmarshalJSON(data []byte) error { +func (r ResponseListResponsePrompt) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponsePrompt) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseListResponseOutputMessageContentArrayItemAnnotationUnion contains all -// possible properties and values from -// [ResponseListResponseOutputMessageContentArrayItemAnnotationFileCitation], -// [ResponseListResponseOutputMessageContentArrayItemAnnotationURLCitation], -// [ResponseListResponseOutputMessageContentArrayItemAnnotationContainerFileCitation], -// [ResponseListResponseOutputMessageContentArrayItemAnnotationFilePath]. +// ResponseListResponsePromptVariableUnion contains all possible properties and +// values from [ResponseListResponsePromptVariableInputText], +// [ResponseListResponsePromptVariableInputImage], +// [ResponseListResponsePromptVariableInputFile]. // -// Use the [ResponseListResponseOutputMessageContentArrayItemAnnotationUnion.AsAny] -// method to switch on the variant. +// Use the [ResponseListResponsePromptVariableUnion.AsAny] method to switch on the +// variant. // // Use the methods beginning with 'As' to cast the union to one of its variants. -type ResponseListResponseOutputMessageContentArrayItemAnnotationUnion struct { - FileID string `json:"file_id"` +type ResponseListResponsePromptVariableUnion struct { + // This field is from variant [ResponseListResponsePromptVariableInputText]. + Text string `json:"text"` + // 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"` + // This field is from variant [ResponseListResponsePromptVariableInputImage]. + ImageURL string `json:"image_url"` + // This field is from variant [ResponseListResponsePromptVariableInputFile]. + FileData string `json:"file_data"` + // This field is from variant [ResponseListResponsePromptVariableInputFile]. + FileURL string `json:"file_url"` + // This field is from variant [ResponseListResponsePromptVariableInputFile]. 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 - // [ResponseListResponseOutputMessageContentArrayItemAnnotationURLCitation]. - Title string `json:"title"` - // This field is from variant - // [ResponseListResponseOutputMessageContentArrayItemAnnotationURLCitation]. - URL string `json:"url"` - // This field is from variant - // [ResponseListResponseOutputMessageContentArrayItemAnnotationContainerFileCitation]. - 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 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:"-"` } -// anyResponseListResponseOutputMessageContentArrayItemAnnotation is implemented by -// each variant of -// [ResponseListResponseOutputMessageContentArrayItemAnnotationUnion] to add type -// safety for the return type of -// [ResponseListResponseOutputMessageContentArrayItemAnnotationUnion.AsAny] -type anyResponseListResponseOutputMessageContentArrayItemAnnotation interface { - implResponseListResponseOutputMessageContentArrayItemAnnotationUnion() +// anyResponseListResponsePromptVariable is implemented by each variant of +// [ResponseListResponsePromptVariableUnion] to add type safety for the return type +// of [ResponseListResponsePromptVariableUnion.AsAny] +type anyResponseListResponsePromptVariable interface { + implResponseListResponsePromptVariableUnion() } -func (ResponseListResponseOutputMessageContentArrayItemAnnotationFileCitation) implResponseListResponseOutputMessageContentArrayItemAnnotationUnion() { -} -func (ResponseListResponseOutputMessageContentArrayItemAnnotationURLCitation) implResponseListResponseOutputMessageContentArrayItemAnnotationUnion() { -} -func (ResponseListResponseOutputMessageContentArrayItemAnnotationContainerFileCitation) implResponseListResponseOutputMessageContentArrayItemAnnotationUnion() { -} -func (ResponseListResponseOutputMessageContentArrayItemAnnotationFilePath) implResponseListResponseOutputMessageContentArrayItemAnnotationUnion() { -} +func (ResponseListResponsePromptVariableInputText) implResponseListResponsePromptVariableUnion() {} +func (ResponseListResponsePromptVariableInputImage) implResponseListResponsePromptVariableUnion() {} +func (ResponseListResponsePromptVariableInputFile) implResponseListResponsePromptVariableUnion() {} // Use the following switch statement to find the correct variant // -// switch variant := ResponseListResponseOutputMessageContentArrayItemAnnotationUnion.AsAny().(type) { -// case llamastackclient.ResponseListResponseOutputMessageContentArrayItemAnnotationFileCitation: -// case llamastackclient.ResponseListResponseOutputMessageContentArrayItemAnnotationURLCitation: -// case llamastackclient.ResponseListResponseOutputMessageContentArrayItemAnnotationContainerFileCitation: -// case llamastackclient.ResponseListResponseOutputMessageContentArrayItemAnnotationFilePath: +// switch variant := ResponseListResponsePromptVariableUnion.AsAny().(type) { +// case llamastackclient.ResponseListResponsePromptVariableInputText: +// case llamastackclient.ResponseListResponsePromptVariableInputImage: +// case llamastackclient.ResponseListResponsePromptVariableInputFile: // default: // fmt.Errorf("no variant present") // } -func (u ResponseListResponseOutputMessageContentArrayItemAnnotationUnion) AsAny() anyResponseListResponseOutputMessageContentArrayItemAnnotation { +func (u ResponseListResponsePromptVariableUnion) AsAny() anyResponseListResponsePromptVariable { 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() + case "input_text": + return u.AsInputText() + case "input_image": + return u.AsInputImage() + case "input_file": + return u.AsInputFile() } return nil } -func (u ResponseListResponseOutputMessageContentArrayItemAnnotationUnion) AsFileCitation() (v ResponseListResponseOutputMessageContentArrayItemAnnotationFileCitation) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseListResponseOutputMessageContentArrayItemAnnotationUnion) AsURLCitation() (v ResponseListResponseOutputMessageContentArrayItemAnnotationURLCitation) { +func (u ResponseListResponsePromptVariableUnion) AsInputText() (v ResponseListResponsePromptVariableInputText) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseOutputMessageContentArrayItemAnnotationUnion) AsContainerFileCitation() (v ResponseListResponseOutputMessageContentArrayItemAnnotationContainerFileCitation) { +func (u ResponseListResponsePromptVariableUnion) AsInputImage() (v ResponseListResponsePromptVariableInputImage) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseOutputMessageContentArrayItemAnnotationUnion) AsFilePath() (v ResponseListResponseOutputMessageContentArrayItemAnnotationFilePath) { +func (u ResponseListResponsePromptVariableUnion) AsInputFile() (v ResponseListResponsePromptVariableInputFile) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u ResponseListResponseOutputMessageContentArrayItemAnnotationUnion) RawJSON() string { - return u.JSON.raw -} +func (u ResponseListResponsePromptVariableUnion) RawJSON() string { return u.JSON.raw } -func (r *ResponseListResponseOutputMessageContentArrayItemAnnotationUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseListResponsePromptVariableUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// File citation annotation for referencing specific files in response content. -type ResponseListResponseOutputMessageContentArrayItemAnnotationFileCitation struct { - // Unique identifier of the referenced file - FileID string `json:"file_id,required"` - // Name of the referenced file - 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"` +// 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - FileID respjson.Field - Filename respjson.Field - Index respjson.Field + Text respjson.Field Type respjson.Field ExtraFields map[string]respjson.Field raw string @@ -5742,196 +8206,238 @@ type ResponseListResponseOutputMessageContentArrayItemAnnotationFileCitation str } // Returns the unmodified JSON received from the API -func (r ResponseListResponseOutputMessageContentArrayItemAnnotationFileCitation) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseListResponseOutputMessageContentArrayItemAnnotationFileCitation) UnmarshalJSON(data []byte) error { +func (r ResponseListResponsePromptVariableInputText) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponsePromptVariableInputText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// URL citation annotation for referencing external web resources. -type ResponseListResponseOutputMessageContentArrayItemAnnotationURLCitation 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"` +// 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - EndIndex respjson.Field - StartIndex respjson.Field - Title respjson.Field + Detail respjson.Field Type respjson.Field - URL 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 ResponseListResponseOutputMessageContentArrayItemAnnotationURLCitation) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseListResponseOutputMessageContentArrayItemAnnotationURLCitation) UnmarshalJSON(data []byte) error { +func (r ResponseListResponsePromptVariableInputImage) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponsePromptVariableInputImage) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ResponseListResponseOutputMessageContentArrayItemAnnotationContainerFileCitation 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"` +// 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - ContainerID respjson.Field - EndIndex respjson.Field + Type respjson.Field + FileData 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 ResponseListResponseOutputMessageContentArrayItemAnnotationContainerFileCitation) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseListResponseOutputMessageContentArrayItemAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error { +func (r ResponseListResponsePromptVariableInputFile) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponsePromptVariableInputFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ResponseListResponseOutputMessageContentArrayItemAnnotationFilePath struct { - FileID string `json:"file_id,required"` - Index int64 `json:"index,required"` - Type constant.FilePath `json:"type,required"` - // 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 +// Level of detail for image processing, can be "low", "high", or "auto" +type ResponseListResponsePromptVariableDetail string + +const ( + ResponseListResponsePromptVariableDetailLow ResponseListResponsePromptVariableDetail = "low" + ResponseListResponsePromptVariableDetailHigh ResponseListResponsePromptVariableDetail = "high" + ResponseListResponsePromptVariableDetailAuto ResponseListResponsePromptVariableDetail = "auto" +) + +// ResponseListResponseToolUnion contains all possible properties and values from +// [ResponseListResponseToolOpenAIResponseInputToolWebSearch], +// [ResponseListResponseToolFileSearch], [ResponseListResponseToolFunction], +// [ResponseListResponseToolMcp]. +// +// Use the [ResponseListResponseToolUnion.AsAny] method to switch on the variant. +// +// 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"` + // This field is from variant [ResponseListResponseToolFileSearch]. + VectorStoreIDs []string `json:"vector_store_ids"` + // This field is from variant [ResponseListResponseToolFileSearch]. + Filters map[string]ResponseListResponseToolFileSearchFilterUnion `json:"filters"` + // This field is from variant [ResponseListResponseToolFileSearch]. + MaxNumResults int64 `json:"max_num_results"` + // This field is from variant [ResponseListResponseToolFileSearch]. + RankingOptions ResponseListResponseToolFileSearchRankingOptions `json:"ranking_options"` + // This field is from variant [ResponseListResponseToolFunction]. + Name string `json:"name"` + // This field is from variant [ResponseListResponseToolFunction]. + Description string `json:"description"` + // This field is from variant [ResponseListResponseToolFunction]. + Parameters map[string]ResponseListResponseToolFunctionParameterUnion `json:"parameters"` + // This field is from variant [ResponseListResponseToolFunction]. + Strict bool `json:"strict"` + // This field is from variant [ResponseListResponseToolMcp]. + ServerLabel string `json:"server_label"` + // This field is from variant [ResponseListResponseToolMcp]. + AllowedTools ResponseListResponseToolMcpAllowedToolsUnion `json:"allowed_tools"` + JSON struct { + Type respjson.Field + SearchContextSize respjson.Field + VectorStoreIDs respjson.Field + Filters respjson.Field + MaxNumResults respjson.Field + RankingOptions respjson.Field + Name respjson.Field + Description respjson.Field + Parameters respjson.Field + Strict respjson.Field + ServerLabel respjson.Field + AllowedTools respjson.Field + raw string } `json:"-"` } -// Returns the unmodified JSON received from the API -func (r ResponseListResponseOutputMessageContentArrayItemAnnotationFilePath) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseListResponseOutputMessageContentArrayItemAnnotationFilePath) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) +func (u ResponseListResponseToolUnion) AsOpenAIResponseInputToolWebSearch() (v ResponseListResponseToolOpenAIResponseInputToolWebSearch) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return } -type ResponseListResponseOutputMessageRole string +func (u ResponseListResponseToolUnion) AsFileSearch() (v ResponseListResponseToolFileSearch) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} -const ( - ResponseListResponseOutputMessageRoleSystem ResponseListResponseOutputMessageRole = "system" - ResponseListResponseOutputMessageRoleDeveloper ResponseListResponseOutputMessageRole = "developer" - ResponseListResponseOutputMessageRoleUser ResponseListResponseOutputMessageRole = "user" - ResponseListResponseOutputMessageRoleAssistant ResponseListResponseOutputMessageRole = "assistant" -) +func (u ResponseListResponseToolUnion) AsFunction() (v ResponseListResponseToolFunction) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} -// 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 - 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 ResponseListResponseToolUnion) AsMcp() (v ResponseListResponseToolMcp) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return } // Returns the unmodified JSON received from the API -func (r ResponseListResponseOutputWebSearchCall) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseOutputWebSearchCall) UnmarshalJSON(data []byte) error { +func (u ResponseListResponseToolUnion) RawJSON() string { return u.JSON.raw } + +func (r *ResponseListResponseToolUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// 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"` +// Web search tool configuration for OpenAI response inputs. +type ResponseListResponseToolOpenAIResponseInputToolWebSearch struct { + // Web search tool type variant to use + // + // 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"` // 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 + Type respjson.Field + SearchContextSize respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } -// Returns the unmodified JSON received from the API -func (r ResponseListResponseOutputFileSearchCall) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseOutputFileSearchCall) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// 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"` +// Returns the unmodified JSON received from the API +func (r ResponseListResponseToolOpenAIResponseInputToolWebSearch) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponseToolOpenAIResponseInputToolWebSearch) UnmarshalJSON(data []byte) error { + 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"` // 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 + Type respjson.Field + VectorStoreIDs respjson.Field + Filters respjson.Field + MaxNumResults respjson.Field + RankingOptions respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseListResponseOutputFileSearchCallResult) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseOutputFileSearchCallResult) UnmarshalJSON(data []byte) error { +func (r ResponseListResponseToolFileSearch) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponseToolFileSearch) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseListResponseOutputFileSearchCallResultAttributeUnion contains all -// possible properties and values from [bool], [float64], [string], [[]any]. +// 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 ResponseListResponseOutputFileSearchCallResultAttributeUnion struct { +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. @@ -5949,163 +8455,92 @@ type ResponseListResponseOutputFileSearchCallResultAttributeUnion struct { } `json:"-"` } -func (u ResponseListResponseOutputFileSearchCallResultAttributeUnion) AsBool() (v bool) { +func (u ResponseListResponseToolFileSearchFilterUnion) AsBool() (v bool) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseOutputFileSearchCallResultAttributeUnion) AsFloat() (v float64) { +func (u ResponseListResponseToolFileSearchFilterUnion) AsFloat() (v float64) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseOutputFileSearchCallResultAttributeUnion) AsString() (v string) { +func (u ResponseListResponseToolFileSearchFilterUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseOutputFileSearchCallResultAttributeUnion) AsAnyArray() (v []any) { +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 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"` - // 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 - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ResponseListResponseOutputFunctionCall) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseOutputFunctionCall) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// 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 - 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"` - // 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 - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} +func (u ResponseListResponseToolFileSearchFilterUnion) RawJSON() string { return u.JSON.raw } -// Returns the unmodified JSON received from the API -func (r ResponseListResponseOutputMcpCall) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseOutputMcpCall) UnmarshalJSON(data []byte) error { +func (r *ResponseListResponseToolFileSearchFilterUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// 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"` +// (Optional) Options for ranking and scoring 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"` // 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 + Ranker respjson.Field + ScoreThreshold respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseListResponseOutputMcpListTools) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseOutputMcpListTools) UnmarshalJSON(data []byte) error { +func (r ResponseListResponseToolFileSearchRankingOptions) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponseToolFileSearchRankingOptions) UnmarshalJSON(data []byte) error { 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 +// Function tool configuration for OpenAI response inputs. +type ResponseListResponseToolFunction struct { + // Name of the function that can be called Name string `json:"name,required"` - // (Optional) Description of what the tool does + // 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - InputSchema respjson.Field Name respjson.Field + Type respjson.Field Description respjson.Field + Parameters respjson.Field + Strict 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 { +func (r ResponseListResponseToolFunction) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponseToolFunction) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseListResponseOutputMcpListToolsToolInputSchemaUnion contains all possible -// properties and values from [bool], [float64], [string], [[]any]. +// 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 ResponseListResponseOutputMcpListToolsToolInputSchemaUnion struct { +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. @@ -6123,175 +8558,215 @@ type ResponseListResponseOutputMcpListToolsToolInputSchemaUnion struct { } `json:"-"` } -func (u ResponseListResponseOutputMcpListToolsToolInputSchemaUnion) AsBool() (v bool) { +func (u ResponseListResponseToolFunctionParameterUnion) AsBool() (v bool) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseOutputMcpListToolsToolInputSchemaUnion) AsFloat() (v float64) { +func (u ResponseListResponseToolFunctionParameterUnion) AsFloat() (v float64) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseOutputMcpListToolsToolInputSchemaUnion) AsString() (v string) { +func (u ResponseListResponseToolFunctionParameterUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseListResponseOutputMcpListToolsToolInputSchemaUnion) AsAnyArray() (v []any) { +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 ResponseListResponseOutputMcpListToolsToolInputSchemaUnion) RawJSON() string { - return u.JSON.raw -} +func (u ResponseListResponseToolFunctionParameterUnion) RawJSON() string { return u.JSON.raw } -func (r *ResponseListResponseOutputMcpListToolsToolInputSchemaUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseListResponseToolFunctionParameterUnion) 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"` +// 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Format respjson.Field - ExtraFields map[string]respjson.Field - raw string + ServerLabel respjson.Field + Type respjson.Field + AllowedTools 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 { +func (r ResponseListResponseToolMcp) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponseToolMcp) 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"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Type respjson.Field - Description respjson.Field - Name respjson.Field - Schema respjson.Field - Strict respjson.Field - ExtraFields map[string]respjson.Field - raw string +// ResponseListResponseToolMcpAllowedToolsUnion contains all possible properties +// and values from [[]string], +// [ResponseListResponseToolMcpAllowedToolsAllowedToolsFilter]. +// +// 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] +type ResponseListResponseToolMcpAllowedToolsUnion struct { + // This field will be present if the value is a [[]string] instead of an object. + OfStringArray []string `json:",inline"` + // This field is from variant + // [ResponseListResponseToolMcpAllowedToolsAllowedToolsFilter]. + ToolNames []string `json:"tool_names"` + JSON struct { + OfStringArray respjson.Field + ToolNames 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) +func (u ResponseListResponseToolMcpAllowedToolsUnion) AsStringArray() (v []string) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return } -// Must be "text", "json_schema", or "json_object" to identify the format type -type ResponseListResponseTextFormatType string +func (u ResponseListResponseToolMcpAllowedToolsUnion) AsAllowedToolsFilter() (v ResponseListResponseToolMcpAllowedToolsAllowedToolsFilter) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} -const ( - ResponseListResponseTextFormatTypeText ResponseListResponseTextFormatType = "text" - ResponseListResponseTextFormatTypeJsonSchema ResponseListResponseTextFormatType = "json_schema" - ResponseListResponseTextFormatTypeJsonObject ResponseListResponseTextFormatType = "json_object" -) +// Returns the unmodified JSON received from the API +func (u ResponseListResponseToolMcpAllowedToolsUnion) RawJSON() string { return u.JSON.raw } -// 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 +func (r *ResponseListResponseToolMcpAllowedToolsUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ToolNames 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 +// Returns the unmodified JSON received from the API +func (r ResponseListResponseToolMcpAllowedToolsAllowedToolsFilter) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseListResponseToolMcpAllowedToolsAllowedToolsFilter) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ResponseListResponseTextFormatSchemaUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// 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 +type ResponseListResponseUsage struct { + // Number of tokens in the input + InputTokens int64 `json:"input_tokens,required"` + // Number of tokens in the output + 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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + InputTokens respjson.Field + OutputTokens respjson.Field + TotalTokens respjson.Field + InputTokensDetails respjson.Field + OutputTokensDetails respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` } -func (u ResponseListResponseTextFormatSchemaUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Returns the unmodified JSON received from the API +func (r ResponseListResponseUsage) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponseUsage) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (u ResponseListResponseTextFormatSchemaUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return +// Detailed breakdown of input token usage +type ResponseListResponseUsageInputTokensDetails struct { + // Number of tokens retrieved from cache + CachedTokens int64 `json:"cached_tokens"` + // 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 (u ResponseListResponseTextFormatSchemaUnion) RawJSON() string { return u.JSON.raw } +func (r ResponseListResponseUsageInputTokensDetails) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponseUsageInputTokensDetails) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} -func (r *ResponseListResponseTextFormatSchemaUnion) UnmarshalJSON(data []byte) error { +// Detailed breakdown of output token usage +type ResponseListResponseUsageOutputTokensDetails struct { + // Number of tokens used for reasoning (o1/o3 models) + ReasoningTokens int64 `json:"reasoning_tokens"` + // 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 ResponseListResponseUsageOutputTokensDetails) RawJSON() string { return r.JSON.raw } +func (r *ResponseListResponseUsageOutputTokensDetails) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// (Optional) Error details if the response generation failed -type ResponseListResponseError struct { - // Error code identifying the type of failure - Code string `json:"code,required"` - // Human-readable error message describing the failure - Message string `json:"message,required"` +// 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Code respjson.Field - Message respjson.Field + ID respjson.Field + Deleted respjson.Field + Object respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` } // Returns the unmodified JSON received from the API -func (r ResponseListResponseError) RawJSON() string { return r.JSON.raw } -func (r *ResponseListResponseError) UnmarshalJSON(data []byte) error { +func (r ResponseDeleteResponse) RawJSON() string { return r.JSON.raw } +func (r *ResponseDeleteResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } @@ -6299,9 +8774,16 @@ 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"` + 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. @@ -6310,6 +8792,8 @@ type ResponseNewParams struct { 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. + Prompt ResponseNewParamsPrompt `json:"prompt,omitzero"` // Text response configuration for OpenAI responses. Text ResponseNewParamsText `json:"text,omitzero"` Tools []ResponseNewParamsToolUnion `json:"tools,omitzero"` @@ -6353,36 +8837,56 @@ func (u *ResponseNewParamsInputUnion) asAny() any { // // Use [param.IsOmitted] to confirm if a field is set. type ResponseNewParamsInputArrayItemUnion struct { - OfOpenAIResponseOutputMessageWebSearchToolCall *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageWebSearchToolCall `json:",omitzero,inline"` - OfOpenAIResponseOutputMessageFileSearchToolCall *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCall `json:",omitzero,inline"` - OfOpenAIResponseOutputMessageFunctionToolCall *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFunctionToolCall `json:",omitzero,inline"` - OfOpenAIResponseInputFunctionToolCallOutput *ResponseNewParamsInputArrayItemOpenAIResponseInputFunctionToolCallOutput `json:",omitzero,inline"` - OfOpenAIResponseMessage *ResponseNewParamsInputArrayItemOpenAIResponseMessage `json:",omitzero,inline"` + 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"` paramUnion } func (u ResponseNewParamsInputArrayItemUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfOpenAIResponseOutputMessageWebSearchToolCall, + return param.MarshalUnion(u, u.OfOpenAIResponseMessage, + u.OfOpenAIResponseOutputMessageWebSearchToolCall, u.OfOpenAIResponseOutputMessageFileSearchToolCall, u.OfOpenAIResponseOutputMessageFunctionToolCall, + u.OfOpenAIResponseOutputMessageMcpCall, + u.OfOpenAIResponseOutputMessageMcpListTools, + u.OfOpenAIResponseMcpApprovalRequest, u.OfOpenAIResponseInputFunctionToolCallOutput, - u.OfOpenAIResponseMessage) + u.OfOpenAIResponseMcpApprovalResponse, + u.OfResponseNewsInputArrayItemOpenAIResponseMessage) } func (u *ResponseNewParamsInputArrayItemUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } func (u *ResponseNewParamsInputArrayItemUnion) asAny() any { - if !param.IsOmitted(u.OfOpenAIResponseOutputMessageWebSearchToolCall) { + if !param.IsOmitted(u.OfOpenAIResponseMessage) { + return u.OfOpenAIResponseMessage + } else if !param.IsOmitted(u.OfOpenAIResponseOutputMessageWebSearchToolCall) { return u.OfOpenAIResponseOutputMessageWebSearchToolCall } else if !param.IsOmitted(u.OfOpenAIResponseOutputMessageFileSearchToolCall) { return u.OfOpenAIResponseOutputMessageFileSearchToolCall } else if !param.IsOmitted(u.OfOpenAIResponseOutputMessageFunctionToolCall) { return u.OfOpenAIResponseOutputMessageFunctionToolCall + } else if !param.IsOmitted(u.OfOpenAIResponseOutputMessageMcpCall) { + return u.OfOpenAIResponseOutputMessageMcpCall + } else if !param.IsOmitted(u.OfOpenAIResponseOutputMessageMcpListTools) { + return u.OfOpenAIResponseOutputMessageMcpListTools + } else if !param.IsOmitted(u.OfOpenAIResponseMcpApprovalRequest) { + return u.OfOpenAIResponseMcpApprovalRequest } else if !param.IsOmitted(u.OfOpenAIResponseInputFunctionToolCallOutput) { return u.OfOpenAIResponseInputFunctionToolCallOutput - } else if !param.IsOmitted(u.OfOpenAIResponseMessage) { - return u.OfOpenAIResponseMessage + } else if !param.IsOmitted(u.OfOpenAIResponseMcpApprovalResponse) { + return u.OfOpenAIResponseMcpApprovalResponse + } else if !param.IsOmitted(u.OfResponseNewsInputArrayItemOpenAIResponseMessage) { + return u.OfResponseNewsInputArrayItemOpenAIResponseMessage } return nil } @@ -6403,104 +8907,444 @@ func (u ResponseNewParamsInputArrayItemUnion) GetResults() []ResponseNewParamsIn return nil } +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputArrayItemUnion) GetError() *string { + if vt := u.OfOpenAIResponseOutputMessageMcpCall; vt != nil && vt.Error.Valid() { + return &vt.Error.Value + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputArrayItemUnion) GetTools() []ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListToolsTool { + if vt := u.OfOpenAIResponseOutputMessageMcpListTools; vt != nil { + return vt.Tools + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputArrayItemUnion) GetApprovalRequestID() *string { + if vt := u.OfOpenAIResponseMcpApprovalResponse; vt != nil { + return &vt.ApprovalRequestID + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputArrayItemUnion) GetApprove() *bool { + if vt := u.OfOpenAIResponseMcpApprovalResponse; vt != nil { + return &vt.Approve + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputArrayItemUnion) GetReason() *string { + if vt := u.OfOpenAIResponseMcpApprovalResponse; vt != nil && vt.Reason.Valid() { + return &vt.Reason.Value + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputArrayItemUnion) GetRole() *string { + if vt := u.OfOpenAIResponseMessage; vt != nil { + return (*string)(&vt.Role) + } else if vt := u.OfResponseNewsInputArrayItemOpenAIResponseMessage; 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() { + return &vt.ID.Value + } else if vt := u.OfOpenAIResponseOutputMessageWebSearchToolCall; vt != nil { + return (*string)(&vt.ID) + } else if vt := u.OfOpenAIResponseOutputMessageFileSearchToolCall; vt != nil { + return (*string)(&vt.ID) + } else if vt := u.OfOpenAIResponseOutputMessageFunctionToolCall; vt != nil && vt.ID.Valid() { + return &vt.ID.Value + } else if vt := u.OfOpenAIResponseOutputMessageMcpCall; vt != nil { + return (*string)(&vt.ID) + } else if vt := u.OfOpenAIResponseOutputMessageMcpListTools; vt != nil { + return (*string)(&vt.ID) + } else if vt := u.OfOpenAIResponseMcpApprovalRequest; vt != nil { + return (*string)(&vt.ID) + } else if vt := u.OfOpenAIResponseInputFunctionToolCallOutput; vt != nil && vt.ID.Valid() { + 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() { + 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() { + return &vt.Status.Value + } else if vt := u.OfOpenAIResponseOutputMessageWebSearchToolCall; vt != nil { + return (*string)(&vt.Status) + } else if vt := u.OfOpenAIResponseOutputMessageFileSearchToolCall; vt != nil { + return (*string)(&vt.Status) + } else if vt := u.OfOpenAIResponseOutputMessageFunctionToolCall; vt != nil && vt.Status.Valid() { + 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() { + return &vt.Status.Value + } + return nil +} + // Returns a pointer to the underlying variant's property, if present. func (u ResponseNewParamsInputArrayItemUnion) GetArguments() *string { if vt := u.OfOpenAIResponseOutputMessageFunctionToolCall; vt != nil { - return &vt.Arguments + return (*string)(&vt.Arguments) + } else if vt := u.OfOpenAIResponseOutputMessageMcpCall; vt != nil { + return (*string)(&vt.Arguments) + } else if vt := u.OfOpenAIResponseMcpApprovalRequest; vt != nil { + return (*string)(&vt.Arguments) + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputArrayItemUnion) GetCallID() *string { + if vt := u.OfOpenAIResponseOutputMessageFunctionToolCall; vt != nil { + return (*string)(&vt.CallID) + } else if vt := u.OfOpenAIResponseInputFunctionToolCallOutput; vt != nil { + return (*string)(&vt.CallID) + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputArrayItemUnion) GetName() *string { + if vt := u.OfOpenAIResponseOutputMessageFunctionToolCall; vt != nil { + return (*string)(&vt.Name) + } else if vt := u.OfOpenAIResponseOutputMessageMcpCall; vt != nil { + return (*string)(&vt.Name) + } else if vt := u.OfOpenAIResponseMcpApprovalRequest; vt != nil { + return (*string)(&vt.Name) + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputArrayItemUnion) GetServerLabel() *string { + if vt := u.OfOpenAIResponseOutputMessageMcpCall; vt != nil { + return (*string)(&vt.ServerLabel) + } else if vt := u.OfOpenAIResponseOutputMessageMcpListTools; vt != nil { + return (*string)(&vt.ServerLabel) + } else if vt := u.OfOpenAIResponseMcpApprovalRequest; vt != nil { + return (*string)(&vt.ServerLabel) + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsInputArrayItemUnion) GetOutput() *string { + if vt := u.OfOpenAIResponseOutputMessageMcpCall; vt != nil && vt.Output.Valid() { + return &vt.Output.Value + } else if vt := u.OfOpenAIResponseInputFunctionToolCallOutput; vt != nil { + return (*string)(&vt.Output) + } + return nil +} + +// Returns a pointer to the underlying variant's Content property, if present. +func (u ResponseNewParamsInputArrayItemUnion) GetContent() *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentUnion { + if vt := u.OfOpenAIResponseMessage; vt != nil { + return &vt.Content + } else if vt := u.OfResponseNewsInputArrayItemOpenAIResponseMessage; vt != nil { + return &vt.Content + } + return nil +} + +// 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 ResponseNewParamsInputArrayItemOpenAIResponseMessage struct { + Content ResponseNewParamsInputArrayItemOpenAIResponseMessageContentUnion `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"` + paramObj +} + +func (r ResponseNewParamsInputArrayItemOpenAIResponseMessage) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputArrayItemOpenAIResponseMessage + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ResponseNewParamsInputArrayItemOpenAIResponseMessage) 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 ResponseNewParamsInputArrayItemOpenAIResponseMessageContentUnion struct { + OfString param.Opt[string] `json:",omitzero,inline"` + OfResponseNewsInputArrayItemOpenAIResponseMessageContentArray []ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion `json:",omitzero,inline"` + OfVariant2 []ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion `json:",omitzero,inline"` + paramUnion +} + +func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfString, u.OfResponseNewsInputArrayItemOpenAIResponseMessageContentArray, u.OfVariant2) +} +func (u *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentUnion) 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 + } + return nil +} + +// 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"` + paramUnion +} + +func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfInputText, u.OfInputImage, u.OfInputFile) +} +func (u *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) 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 ResponseNewParamsInputArrayItemUnion) GetName() *string { - if vt := u.OfOpenAIResponseOutputMessageFunctionToolCall; vt != nil { - return &vt.Name +func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) 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 ResponseNewParamsInputArrayItemUnion) GetOutput() *string { - if vt := u.OfOpenAIResponseInputFunctionToolCallOutput; vt != nil { - return &vt.Output +func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) GetDetail() *string { + if vt := u.OfInputImage; vt != nil { + return (*string)(&vt.Detail) } return nil } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemUnion) GetContent() *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentUnion { - if vt := u.OfOpenAIResponseMessage; vt != nil { - return &vt.Content +func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) 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 ResponseNewParamsInputArrayItemUnion) GetRole() *string { - if vt := u.OfOpenAIResponseMessage; vt != nil { - return (*string)(&vt.Role) +func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) 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 ResponseNewParamsInputArrayItemUnion) GetID() *string { - if vt := u.OfOpenAIResponseOutputMessageWebSearchToolCall; vt != nil { - return (*string)(&vt.ID) - } else if vt := u.OfOpenAIResponseOutputMessageFileSearchToolCall; vt != nil { - return (*string)(&vt.ID) - } else if vt := u.OfOpenAIResponseOutputMessageFunctionToolCall; vt != nil && vt.ID.Valid() { - return &vt.ID.Value - } else if vt := u.OfOpenAIResponseInputFunctionToolCallOutput; vt != nil && vt.ID.Valid() { - return &vt.ID.Value - } else if vt := u.OfOpenAIResponseMessage; vt != nil && vt.ID.Valid() { - return &vt.ID.Value +func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) 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 ResponseNewParamsInputArrayItemUnion) GetStatus() *string { - if vt := u.OfOpenAIResponseOutputMessageWebSearchToolCall; vt != nil { - return (*string)(&vt.Status) - } else if vt := u.OfOpenAIResponseOutputMessageFileSearchToolCall; vt != nil { - return (*string)(&vt.Status) - } else if vt := u.OfOpenAIResponseOutputMessageFunctionToolCall; vt != nil && vt.Status.Valid() { - return &vt.Status.Value - } else if vt := u.OfOpenAIResponseInputFunctionToolCallOutput; vt != nil && vt.Status.Valid() { - return &vt.Status.Value - } else if vt := u.OfOpenAIResponseMessage; vt != nil && vt.Status.Valid() { - return &vt.Status.Value +func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) 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 ResponseNewParamsInputArrayItemUnion) GetType() *string { - 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 { +func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) GetType() *string { + if vt := u.OfInputText; vt != nil { return (*string)(&vt.Type) - } else if vt := u.OfOpenAIResponseInputFunctionToolCallOutput; vt != nil { + } else if vt := u.OfInputImage; vt != nil { return (*string)(&vt.Type) - } else if vt := u.OfOpenAIResponseMessage; vt != nil { + } 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 ResponseNewParamsInputArrayItemUnion) GetCallID() *string { - if vt := u.OfOpenAIResponseOutputMessageFunctionToolCall; vt != nil { - return (*string)(&vt.CallID) - } else if vt := u.OfOpenAIResponseInputFunctionToolCallOutput; vt != nil { - return (*string)(&vt.CallID) +func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) 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[ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion]( + "type", + apijson.Discriminator[ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputText]("input_text"), + apijson.Discriminator[ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImage]("input_image"), + apijson.Discriminator[ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputFile]("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 + 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"` + paramObj +} + +func (r ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputText) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputText + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputText) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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 + 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"` + paramObj +} + +func (r ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImage) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImage + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImage) 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" +) + +// 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. + 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"` + paramObj +} + +func (r ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputFile) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputFile + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputFile) 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" +) + // Web search tool call output message for OpenAI responses. // // The properties ID, Status, Type are required. @@ -6572,14 +9416,151 @@ func (r ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchTool type shadow ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCallResult return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCallResult) UnmarshalJSON(data []byte) error { +func (r *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCallResult) 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 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 +} + +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 (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 +} + +// 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"` + paramObj +} + +func (r ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFunctionToolCall) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFunctionToolCall + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFunctionToolCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` + paramObj +} + +func (r ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpCall) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpCall + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` + paramObj +} + +func (r ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListTools) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListTools + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListTools) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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 + Description param.Opt[string] `json:"description,omitzero"` + paramObj +} + +func (r ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListToolsTool) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListToolsTool + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListToolsTool) 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 ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion struct { +type ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion struct { OfBool param.Opt[bool] `json:",omitzero,inline"` OfFloat param.Opt[float64] `json:",omitzero,inline"` OfString param.Opt[string] `json:",omitzero,inline"` @@ -6587,14 +9568,14 @@ type ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCal paramUnion } -func (u ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) MarshalJSON() ([]byte, error) { +func (u ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) MarshalJSON() ([]byte, error) { return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) } -func (u *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) UnmarshalJSON(data []byte) error { +func (u *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) asAny() any { +func (u *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageMcpListToolsToolInputSchemaUnion) asAny() any { if !param.IsOmitted(u.OfBool) { return &u.OfBool.Value } else if !param.IsOmitted(u.OfFloat) { @@ -6607,32 +9588,25 @@ func (u *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToo return nil } -// Function tool call output message for OpenAI responses. +// A request for human approval of a tool invocation. // -// 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 ID, Arguments, Name, ServerLabel, Type are required. +type ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalRequest 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"` paramObj } -func (r ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFunctionToolCall) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFunctionToolCall +func (r ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalRequest) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalRequest return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFunctionToolCall) UnmarshalJSON(data []byte) error { +func (r *ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalRequest) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } @@ -6659,85 +9633,81 @@ func (r *ResponseNewParamsInputArrayItemOpenAIResponseInputFunctionToolCallOutpu 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. +// A response to an MCP approval request. // -// The properties Content, Role, Type are required. -type ResponseNewParamsInputArrayItemOpenAIResponseMessage struct { - Content ResponseNewParamsInputArrayItemOpenAIResponseMessageContentUnion `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"` +// The properties ApprovalRequestID, Approve, Type are required. +type ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalResponse 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"` paramObj } -func (r ResponseNewParamsInputArrayItemOpenAIResponseMessage) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsInputArrayItemOpenAIResponseMessage +func (r ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalResponse) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalResponse return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ResponseNewParamsInputArrayItemOpenAIResponseMessage) UnmarshalJSON(data []byte) error { +func (r *ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Only one field can be non-zero. +// (Optional) Prompt object with ID, version, and variables. // -// 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 []ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItem `json:",omitzero,inline"` - paramUnion +// 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. + Variables map[string]ResponseNewParamsPromptVariableUnion `json:"variables,omitzero"` + paramObj } -func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfResponseNewsInputArrayItemOpenAIResponseMessageContentArray, u.OfVariant2) -} -func (u *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) +func (r ResponseNewParamsPrompt) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsPrompt + return param.MarshalObject(r, (*shadow)(&r)) } - -func (u *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentUnion) 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 - } - return nil +func (r *ResponseNewParamsPrompt) 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 ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion struct { - OfInputText *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputText `json:",omitzero,inline"` - OfInputImage *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImage `json:",omitzero,inline"` +type ResponseNewParamsPromptVariableUnion struct { + OfInputText *ResponseNewParamsPromptVariableInputText `json:",omitzero,inline"` + OfInputImage *ResponseNewParamsPromptVariableInputImage `json:",omitzero,inline"` + OfInputFile *ResponseNewParamsPromptVariableInputFile `json:",omitzero,inline"` paramUnion } -func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfInputText, u.OfInputImage) +func (u ResponseNewParamsPromptVariableUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfInputText, u.OfInputImage, u.OfInputFile) } -func (u *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) UnmarshalJSON(data []byte) error { +func (u *ResponseNewParamsPromptVariableUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } -func (u *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) asAny() any { +func (u *ResponseNewParamsPromptVariableUnion) 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 ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) GetText() *string { +func (u ResponseNewParamsPromptVariableUnion) GetText() *string { if vt := u.OfInputText; vt != nil { return &vt.Text } @@ -6745,7 +9715,7 @@ func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnio } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) GetDetail() *string { +func (u ResponseNewParamsPromptVariableUnion) GetDetail() *string { if vt := u.OfInputImage; vt != nil { return (*string)(&vt.Detail) } @@ -6753,7 +9723,7 @@ func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnio } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) GetImageURL() *string { +func (u ResponseNewParamsPromptVariableUnion) GetImageURL() *string { if vt := u.OfInputImage; vt != nil && vt.ImageURL.Valid() { return &vt.ImageURL.Value } @@ -6761,27 +9731,64 @@ func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnio } // Returns a pointer to the underlying variant's property, if present. -func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion) GetType() *string { +func (u ResponseNewParamsPromptVariableUnion) 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 ResponseNewParamsPromptVariableUnion) 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 ResponseNewParamsPromptVariableUnion) 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 ResponseNewParamsPromptVariableUnion) 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 ResponseNewParamsPromptVariableUnion) 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[ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemUnion]( + apijson.RegisterUnion[ResponseNewParamsPromptVariableUnion]( "type", - apijson.Discriminator[ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputText]("input_text"), - apijson.Discriminator[ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImage]("input_image"), + apijson.Discriminator[ResponseNewParamsPromptVariableInputText]("input_text"), + apijson.Discriminator[ResponseNewParamsPromptVariableInputImage]("input_image"), + apijson.Discriminator[ResponseNewParamsPromptVariableInputFile]("input_file"), ) } // Text content for input messages in OpenAI response format. // // The properties Text, Type are required. -type ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputText struct { +type ResponseNewParamsPromptVariableInputText struct { // The text content of the input message Text string `json:"text,required"` // Content type identifier, always "input_text" @@ -6791,22 +9798,24 @@ type ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputTe paramObj } -func (r ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputText) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputText +func (r ResponseNewParamsPromptVariableInputText) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsPromptVariableInputText return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputText) UnmarshalJSON(data []byte) error { +func (r *ResponseNewParamsPromptVariableInputText) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Image content for input messages in OpenAI response format. // // The properties Detail, Type are required. -type ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImage struct { +type ResponseNewParamsPromptVariableInputImage struct { // Level of detail for image processing, can be "low", "high", or "auto" // // Any of "low", "high", "auto". - Detail ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImageDetail `json:"detail,omitzero,required"` + 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 ImageURL param.Opt[string] `json:"image_url,omitzero"` // Content type identifier, always "input_image" @@ -6816,271 +9825,50 @@ type ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputIm paramObj } -func (r ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImage) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImage +func (r ResponseNewParamsPromptVariableInputImage) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsPromptVariableInputImage return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImage) UnmarshalJSON(data []byte) error { +func (r *ResponseNewParamsPromptVariableInputImage) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } // Level of detail for image processing, can be "low", "high", or "auto" -type ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImageDetail string +type ResponseNewParamsPromptVariableInputImageDetail string const ( - ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImageDetailLow ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImageDetail = "low" - ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImageDetailHigh ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImageDetail = "high" - ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImageDetailAuto ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemInputImageDetail = "auto" + ResponseNewParamsPromptVariableInputImageDetailLow ResponseNewParamsPromptVariableInputImageDetail = "low" + ResponseNewParamsPromptVariableInputImageDetailHigh ResponseNewParamsPromptVariableInputImageDetail = "high" + ResponseNewParamsPromptVariableInputImageDetailAuto ResponseNewParamsPromptVariableInputImageDetail = "auto" ) -// The properties Annotations, Text, Type are required. -type ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItem struct { - Annotations []ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationUnion `json:"annotations,omitzero,required"` - Text string `json:"text,required"` - // This field can be elided, and will marshal its zero value as "output_text". - Type constant.OutputText `json:"type,required"` - paramObj -} - -func (r ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItem) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItem - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItem) 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 ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationUnion struct { - OfFileCitation *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationFileCitation `json:",omitzero,inline"` - OfURLCitation *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationURLCitation `json:",omitzero,inline"` - OfContainerFileCitation *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationContainerFileCitation `json:",omitzero,inline"` - OfFilePath *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationFilePath `json:",omitzero,inline"` - paramUnion -} - -func (u ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfFileCitation, u.OfURLCitation, u.OfContainerFileCitation, u.OfFilePath) -} -func (u *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationUnion) 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 ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationUnion) 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 ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationUnion) 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 ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationUnion) 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 ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationUnion) 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 ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationUnion) 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 ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationUnion) 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 ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationUnion) 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 ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationUnion) 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 ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationUnion) 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[ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationUnion]( - "type", - apijson.Discriminator[ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationFileCitation]("file_citation"), - apijson.Discriminator[ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationURLCitation]("url_citation"), - apijson.Discriminator[ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationContainerFileCitation]("container_file_citation"), - apijson.Discriminator[ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationFilePath]("file_path"), - ) -} - -// File citation annotation for referencing specific files in response content. -// -// The properties FileID, Filename, Index, Type are required. -type ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationFileCitation struct { - // Unique identifier of the referenced file - FileID string `json:"file_id,required"` - // Name of the referenced file - Filename string `json:"filename,required"` - // Position index of the citation within the content - Index int64 `json:"index,required"` - // Annotation type identifier, always "file_citation" - // - // This field can be elided, and will marshal its zero value as "file_citation". - Type constant.FileCitation `json:"type,required"` - paramObj -} - -func (r ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationFileCitation) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationFileCitation - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationFileCitation) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// URL citation annotation for referencing external web resources. +// File content for input messages in OpenAI response format. // -// The properties EndIndex, StartIndex, Title, Type, URL are required. -type ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationURLCitation 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"` - // URL of the referenced web resource - URL string `json:"url,required"` - // Annotation type identifier, always "url_citation" +// 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. + 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 "url_citation". - Type constant.URLCitation `json:"type,required"` + // This field can be elided, and will marshal its zero value as "input_file". + Type constant.InputFile `json:"type,required"` paramObj } -func (r ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationURLCitation) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationURLCitation +func (r ResponseNewParamsPromptVariableInputFile) MarshalJSON() (data []byte, err error) { + type shadow ResponseNewParamsPromptVariableInputFile return param.MarshalObject(r, (*shadow)(&r)) } -func (r *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationURLCitation) UnmarshalJSON(data []byte) error { +func (r *ResponseNewParamsPromptVariableInputFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// The properties ContainerID, EndIndex, FileID, Filename, StartIndex, Type are -// required. -type ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationContainerFileCitation 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"` - // This field can be elided, and will marshal its zero value as - // "container_file_citation". - Type constant.ContainerFileCitation `json:"type,required"` - paramObj -} - -func (r ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationContainerFileCitation) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationContainerFileCitation - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// The properties FileID, Index, Type are required. -type ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationFilePath struct { - FileID string `json:"file_id,required"` - Index int64 `json:"index,required"` - // This field can be elided, and will marshal its zero value as "file_path". - Type constant.FilePath `json:"type,required"` - paramObj -} - -func (r ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationFilePath) MarshalJSON() (data []byte, err error) { - type shadow ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationFilePath - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *ResponseNewParamsInputArrayItemOpenAIResponseMessageContentArrayItemAnnotationFilePath) 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" -) - // Text response configuration for OpenAI responses. type ResponseNewParamsText struct { // (Optional) Text format configuration specifying output format requirements @@ -7300,6 +10088,14 @@ func (u ResponseNewParamsToolUnion) GetAllowedTools() *ResponseNewParamsToolMcpA return nil } +// Returns a pointer to the underlying variant's property, if present. +func (u ResponseNewParamsToolUnion) GetAuthorization() *string { + if vt := u.OfMcp; vt != nil && vt.Authorization.Valid() { + return &vt.Authorization.Value + } + return nil +} + // Returns a pointer to the underlying variant's property, if present. func (u ResponseNewParamsToolUnion) GetHeaders() map[string]ResponseNewParamsToolMcpHeaderUnion { if vt := u.OfMcp; vt != nil { @@ -7328,6 +10124,7 @@ func init() { apijson.Discriminator[ResponseNewParamsToolOpenAIResponseInputToolWebSearch]("web_search"), apijson.Discriminator[ResponseNewParamsToolOpenAIResponseInputToolWebSearch]("web_search_preview"), apijson.Discriminator[ResponseNewParamsToolOpenAIResponseInputToolWebSearch]("web_search_preview_2025_03_11"), + apijson.Discriminator[ResponseNewParamsToolOpenAIResponseInputToolWebSearch]("web_search_2025_08_26"), apijson.Discriminator[ResponseNewParamsToolFileSearch]("file_search"), apijson.Discriminator[ResponseNewParamsToolFunction]("function"), apijson.Discriminator[ResponseNewParamsToolMcp]("mcp"), @@ -7340,7 +10137,8 @@ func init() { type ResponseNewParamsToolOpenAIResponseInputToolWebSearch struct { // Web search tool type variant to use // - // Any of "web_search", "web_search_preview", "web_search_preview_2025_03_11". + // 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"` @@ -7362,6 +10160,7 @@ 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" ) // File search tool configuration for OpenAI response inputs. @@ -7507,6 +10306,8 @@ type ResponseNewParamsToolMcp struct { 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 diff --git a/response_test.go b/response_test.go index ea61345..d4206af 100644 --- a/response_test.go +++ b/response_test.go @@ -1,3 +1,9 @@ +// 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 @@ -29,12 +35,25 @@ func TestResponseNewWithOptionalParams(t *testing.T) { OfString: llamastackclient.String("string"), }, Model: "model", + Conversation: llamastackclient.String("conversation"), Include: []string{"string"}, Instructions: llamastackclient.String("instructions"), MaxInferIters: llamastackclient.Int(0), + MaxToolCalls: llamastackclient.Int(0), PreviousResponseID: llamastackclient.String("previous_response_id"), - Store: llamastackclient.Bool(true), - Temperature: llamastackclient.Float(0), + Prompt: llamastackclient.ResponseNewParamsPrompt{ + ID: "id", + Variables: map[string]llamastackclient.ResponseNewParamsPromptVariableUnion{ + "foo": { + OfInputText: &llamastackclient.ResponseNewParamsPromptVariableInputText{ + Text: "text", + }, + }, + }, + Version: llamastackclient.String("version"), + }, + Store: llamastackclient.Bool(true), + Temperature: llamastackclient.Float(0), Text: llamastackclient.ResponseNewParamsText{ Format: llamastackclient.ResponseNewParamsTextFormat{ Type: llamastackclient.ResponseNewParamsTextFormatTypeText, @@ -110,3 +129,24 @@ func TestResponseListWithOptionalParams(t *testing.T) { t.Fatalf("err should be nil: %s", err.Error()) } } + +func TestResponseDelete(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.Responses.Delete(context.TODO(), "response_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/responseinputitem.go b/responseinputitem.go index 76f004c..2a41410 100644 --- a/responseinputitem.go +++ b/responseinputitem.go @@ -1,3 +1,9 @@ +// 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 @@ -9,6 +15,7 @@ import ( "fmt" "net/http" "net/url" + "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" "github.com/llamastack/llama-stack-client-go/internal/apiquery" @@ -38,14 +45,14 @@ func NewResponseInputItemService(opts ...option.RequestOption) (r ResponseInputI return } -// List input items for a given OpenAI response. +// List input items. func (r *ResponseInputItemService) List(ctx context.Context, responseID string, query ResponseInputItemListParams, opts ...option.RequestOption) (res *ResponseInputItemListResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if responseID == "" { err = errors.New("missing required response_id parameter") return } - path := fmt.Sprintf("v1/openai/v1/responses/%s/input_items", responseID) + path := fmt.Sprintf("v1/responses/%s/input_items", responseID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) return } @@ -72,56 +79,81 @@ func (r *ResponseInputItemListResponse) UnmarshalJSON(data []byte) error { } // ResponseInputItemListResponseDataUnion contains all possible properties and -// values from +// values from [ResponseInputItemListResponseDataOpenAIResponseMessage], // [ResponseInputItemListResponseDataOpenAIResponseOutputMessageWebSearchToolCall], // [ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCall], // [ResponseInputItemListResponseDataOpenAIResponseOutputMessageFunctionToolCall], +// [ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpCall], +// [ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpListTools], +// [ResponseInputItemListResponseDataOpenAIResponseMcpApprovalRequest], // [ResponseInputItemListResponseDataOpenAIResponseInputFunctionToolCallOutput], +// [ResponseInputItemListResponseDataOpenAIResponseMcpApprovalResponse], // [ResponseInputItemListResponseDataOpenAIResponseMessage]. // // Use the methods beginning with 'As' to cast the union to one of its variants. type ResponseInputItemListResponseDataUnion struct { - ID string `json:"id"` - Status string `json:"status"` - Type string `json:"type"` + // This field is from variant + // [ResponseInputItemListResponseDataOpenAIResponseMessage]. + Content ResponseInputItemListResponseDataOpenAIResponseMessageContentUnion `json:"content"` + // This field is from variant + // [ResponseInputItemListResponseDataOpenAIResponseMessage]. + Role ResponseInputItemListResponseDataOpenAIResponseMessageRole `json:"role"` + Type string `json:"type"` + ID string `json:"id"` + Status string `json:"status"` // This field is from variant // [ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCall]. Queries []string `json:"queries"` // This field is from variant // [ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCall]. - Results []ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResult `json:"results"` + Results []ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResult `json:"results"` + Arguments string `json:"arguments"` + CallID string `json:"call_id"` + Name string `json:"name"` + ServerLabel string `json:"server_label"` // This field is from variant - // [ResponseInputItemListResponseDataOpenAIResponseOutputMessageFunctionToolCall]. - Arguments string `json:"arguments"` - CallID string `json:"call_id"` + // [ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpCall]. + Error string `json:"error"` + Output string `json:"output"` // This field is from variant - // [ResponseInputItemListResponseDataOpenAIResponseOutputMessageFunctionToolCall]. - Name string `json:"name"` + // [ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpListTools]. + Tools []ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpListToolsTool `json:"tools"` // This field is from variant - // [ResponseInputItemListResponseDataOpenAIResponseInputFunctionToolCallOutput]. - Output string `json:"output"` + // [ResponseInputItemListResponseDataOpenAIResponseMcpApprovalResponse]. + ApprovalRequestID string `json:"approval_request_id"` // This field is from variant - // [ResponseInputItemListResponseDataOpenAIResponseMessage]. - Content ResponseInputItemListResponseDataOpenAIResponseMessageContentUnion `json:"content"` + // [ResponseInputItemListResponseDataOpenAIResponseMcpApprovalResponse]. + Approve bool `json:"approve"` // This field is from variant - // [ResponseInputItemListResponseDataOpenAIResponseMessage]. - Role ResponseInputItemListResponseDataOpenAIResponseMessageRole `json:"role"` - JSON struct { - ID respjson.Field - Status respjson.Field - Type respjson.Field - Queries respjson.Field - Results respjson.Field - Arguments respjson.Field - CallID respjson.Field - Name respjson.Field - Output respjson.Field - Content respjson.Field - Role respjson.Field - raw string + // [ResponseInputItemListResponseDataOpenAIResponseMcpApprovalResponse]. + Reason string `json:"reason"` + 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 + ServerLabel respjson.Field + Error respjson.Field + Output respjson.Field + Tools respjson.Field + ApprovalRequestID respjson.Field + Approve respjson.Field + Reason respjson.Field + raw string } `json:"-"` } +func (u ResponseInputItemListResponseDataUnion) AsOpenAIResponseMessage() (v ResponseInputItemListResponseDataOpenAIResponseMessage) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + func (u ResponseInputItemListResponseDataUnion) AsOpenAIResponseOutputMessageWebSearchToolCall() (v ResponseInputItemListResponseDataOpenAIResponseOutputMessageWebSearchToolCall) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return @@ -137,228 +169,40 @@ func (u ResponseInputItemListResponseDataUnion) AsOpenAIResponseOutputMessageFun return } -func (u ResponseInputItemListResponseDataUnion) AsOpenAIResponseInputFunctionToolCallOutput() (v ResponseInputItemListResponseDataOpenAIResponseInputFunctionToolCallOutput) { +func (u ResponseInputItemListResponseDataUnion) AsOpenAIResponseOutputMessageMcpCall() (v ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpCall) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseInputItemListResponseDataUnion) AsOpenAIResponseMessage() (v ResponseInputItemListResponseDataOpenAIResponseMessage) { +func (u ResponseInputItemListResponseDataUnion) AsOpenAIResponseOutputMessageMcpListTools() (v ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpListTools) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -// Returns the unmodified JSON received from the API -func (u ResponseInputItemListResponseDataUnion) RawJSON() string { return u.JSON.raw } - -func (r *ResponseInputItemListResponseDataUnion) 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 - 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:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ResponseInputItemListResponseDataOpenAIResponseOutputMessageWebSearchToolCall) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseInputItemListResponseDataOpenAIResponseOutputMessageWebSearchToolCall) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// 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"` - // 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:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCall) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCall) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// 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"` - // 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 ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResult) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResult) UnmarshalJSON(data []byte) error { - 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) { +func (u ResponseInputItemListResponseDataUnion) AsOpenAIResponseMcpApprovalRequest() (v ResponseInputItemListResponseDataOpenAIResponseMcpApprovalRequest) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) AsFloat() (v float64) { +func (u ResponseInputItemListResponseDataUnion) AsOpenAIResponseInputFunctionToolCallOutput() (v ResponseInputItemListResponseDataOpenAIResponseInputFunctionToolCallOutput) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) AsString() (v string) { +func (u ResponseInputItemListResponseDataUnion) AsOpenAIResponseMcpApprovalResponse() (v ResponseInputItemListResponseDataOpenAIResponseMcpApprovalResponse) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) AsAnyArray() (v []any) { +func (u ResponseInputItemListResponseDataUnion) AsResponseInputItemListResponseDataOpenAIResponseMessage() (v ResponseInputItemListResponseDataOpenAIResponseMessage) { 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"` - // 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 - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ResponseInputItemListResponseDataOpenAIResponseOutputMessageFunctionToolCall) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseInputItemListResponseDataOpenAIResponseOutputMessageFunctionToolCall) 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 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"` - // 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 (u ResponseInputItemListResponseDataUnion) RawJSON() string { return u.JSON.raw } -// Returns the unmodified JSON received from the API -func (r ResponseInputItemListResponseDataOpenAIResponseInputFunctionToolCallOutput) RawJSON() string { - return r.JSON.raw -} -func (r *ResponseInputItemListResponseDataOpenAIResponseInputFunctionToolCallOutput) UnmarshalJSON(data []byte) error { +func (r *ResponseInputItemListResponseDataUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } @@ -393,29 +237,23 @@ func (r *ResponseInputItemListResponseDataOpenAIResponseMessage) UnmarshalJSON(d // ResponseInputItemListResponseDataOpenAIResponseMessageContentUnion contains all // possible properties and values from [string], // [[]ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion], -// [[]ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItem]. +// [[]ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion]. // // 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 -// OfResponseInputItemListResponseDataOpenAIResponseMessageContentArray OfVariant2] +// will be valid: OfString OfVariant2] type ResponseInputItemListResponseDataOpenAIResponseMessageContentUnion 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] // instead of an object. - OfResponseInputItemListResponseDataOpenAIResponseMessageContentArray []ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion `json:",inline"` - // This field will be present if the value is a - // [[]ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItem] - // instead of an object. - OfVariant2 []ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItem `json:",inline"` + OfVariant2 []ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion `json:",inline"` JSON struct { - OfString respjson.Field - OfResponseInputItemListResponseDataOpenAIResponseMessageContentArray respjson.Field - OfVariant2 respjson.Field - raw string + OfString respjson.Field + OfVariant2 respjson.Field + raw string } `json:"-"` } @@ -429,7 +267,7 @@ func (u ResponseInputItemListResponseDataOpenAIResponseMessageContentUnion) AsRe return } -func (u ResponseInputItemListResponseDataOpenAIResponseMessageContentUnion) AsVariant2() (v []ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItem) { +func (u ResponseInputItemListResponseDataOpenAIResponseMessageContentUnion) AsVariant2() (v []ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } @@ -446,7 +284,8 @@ func (r *ResponseInputItemListResponseDataOpenAIResponseMessageContentUnion) Unm // ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion // contains all possible properties and values from // [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputText], -// [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImage]. +// [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImage], +// [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputFile]. // // Use the // [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion.AsAny] @@ -457,19 +296,33 @@ type ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion // This field is from variant // [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputText]. Text string `json:"text"` - // Any of "input_text", "input_image". + // 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"` // This field is from variant // [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImage]. ImageURL string `json:"image_url"` + // This field is from variant + // [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputFile]. + FileData string `json:"file_data"` + // This field is from variant + // [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputFile]. + FileURL string `json:"file_url"` + // This field is from variant + // [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputFile]. + 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:"-"` } @@ -487,12 +340,15 @@ func (ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInpu } func (ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImage) implResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion() { } +func (ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputFile) implResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion() { +} // Use the following switch statement to find the correct variant // // switch variant := ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion.AsAny().(type) { // case llamastackclient.ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputText: // case llamastackclient.ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImage: +// case llamastackclient.ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputFile: // default: // fmt.Errorf("no variant present") // } @@ -502,6 +358,8 @@ func (u ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUn return u.AsInputText() case "input_image": return u.AsInputImage() + case "input_file": + return u.AsInputFile() } return nil } @@ -516,6 +374,11 @@ func (u ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUn return } +func (u ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion) AsInputFile() (v ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputFile) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + // Returns the unmodified JSON received from the API func (u ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemUnion) RawJSON() string { return u.JSON.raw @@ -556,12 +419,15 @@ type ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInput 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"` // 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 ExtraFields map[string]respjson.Field raw string @@ -585,226 +451,289 @@ const ( ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImageDetailAuto ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputImageDetail = "auto" ) -// Level of detail for image processing, can be "low", "high", or "auto" -type ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemDetail string - -const ( - ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemDetailLow ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemDetail = "low" - ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemDetailHigh ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemDetail = "high" - ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemDetailAuto ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemDetail = "auto" -) - -type ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItem struct { - Annotations []ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationUnion `json:"annotations,required"` - Text string `json:"text,required"` - Type constant.OutputText `json:"type,required"` +// 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. + Filename string `json:"filename"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Annotations respjson.Field - Text 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 ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItem) RawJSON() string { +func (r ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputFile) RawJSON() string { return r.JSON.raw } -func (r *ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItem) UnmarshalJSON(data []byte) error { +func (r *ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemInputFile) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationUnion -// contains all possible properties and values from -// [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationFileCitation], -// [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationURLCitation], -// [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationContainerFileCitation], -// [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationFilePath]. -// -// Use the -// [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationUnion.AsAny] -// method to switch on the variant. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -type ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationUnion 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 - // [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationURLCitation]. - Title string `json:"title"` - // This field is from variant - // [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationURLCitation]. - URL string `json:"url"` - // This field is from variant - // [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationContainerFileCitation]. - ContainerID string `json:"container_id"` - JSON struct { - FileID respjson.Field - Filename respjson.Field - Index respjson.Field +// Level of detail for image processing, can be "low", "high", or "auto" +type ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemDetail string + +const ( + ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemDetailLow ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemDetail = "low" + ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemDetailHigh ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemDetail = "high" + ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemDetailAuto ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemDetail = "auto" +) + +type ResponseInputItemListResponseDataOpenAIResponseMessageRole string + +const ( + ResponseInputItemListResponseDataOpenAIResponseMessageRoleSystem ResponseInputItemListResponseDataOpenAIResponseMessageRole = "system" + ResponseInputItemListResponseDataOpenAIResponseMessageRoleDeveloper ResponseInputItemListResponseDataOpenAIResponseMessageRole = "developer" + ResponseInputItemListResponseDataOpenAIResponseMessageRoleUser ResponseInputItemListResponseDataOpenAIResponseMessageRole = "user" + ResponseInputItemListResponseDataOpenAIResponseMessageRoleAssistant ResponseInputItemListResponseDataOpenAIResponseMessageRole = "assistant" +) + +// 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 + 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 - EndIndex respjson.Field - StartIndex respjson.Field - Title respjson.Field - URL respjson.Field - ContainerID respjson.Field + ExtraFields map[string]respjson.Field raw string } `json:"-"` } -// anyResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotation -// is implemented by each variant of -// [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationUnion] -// to add type safety for the return type of -// [ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationUnion.AsAny] -type anyResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotation interface { - implResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationUnion() +// Returns the unmodified JSON received from the API +func (r ResponseInputItemListResponseDataOpenAIResponseOutputMessageWebSearchToolCall) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseInputItemListResponseDataOpenAIResponseOutputMessageWebSearchToolCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationFileCitation) implResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationUnion() { +// 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"` + // 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:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCall) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -func (ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationURLCitation) implResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationUnion() { + +// 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"` + // 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:"-"` } -func (ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationContainerFileCitation) implResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationUnion() { + +// Returns the unmodified JSON received from the API +func (r ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResult) RawJSON() string { + return r.JSON.raw } -func (ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationFilePath) implResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationUnion() { +func (r *ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResult) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) } -// Use the following switch statement to find the correct variant +// ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion +// contains all possible properties and values from [bool], [float64], [string], +// [[]any]. // -// switch variant := ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationUnion.AsAny().(type) { -// case llamastackclient.ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationFileCitation: -// case llamastackclient.ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationURLCitation: -// case llamastackclient.ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationContainerFileCitation: -// case llamastackclient.ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationFilePath: -// default: -// fmt.Errorf("no variant present") -// } -func (u ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationUnion) AsAny() anyResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotation { - 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 +// 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 ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationUnion) AsFileCitation() (v ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationFileCitation) { +func (u ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) AsBool() (v bool) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationUnion) AsURLCitation() (v ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationURLCitation) { +func (u ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) AsFloat() (v float64) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationUnion) AsContainerFileCitation() (v ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationContainerFileCitation) { +func (u ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationUnion) AsFilePath() (v ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationFilePath) { +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 ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationUnion) RawJSON() string { +func (u ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) RawJSON() string { return u.JSON.raw } -func (r *ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationUnion) UnmarshalJSON(data []byte) error { +func (r *ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResultAttributeUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// File citation annotation for referencing specific files in response content. -type ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationFileCitation struct { - // Unique identifier of the referenced file - FileID string `json:"file_id,required"` - // Name of the referenced file - 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"` +// 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - FileID respjson.Field - Filename respjson.Field - Index respjson.Field + Arguments respjson.Field + CallID respjson.Field + Name 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 ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationFileCitation) RawJSON() string { +func (r ResponseInputItemListResponseDataOpenAIResponseOutputMessageFunctionToolCall) RawJSON() string { return r.JSON.raw } -func (r *ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationFileCitation) UnmarshalJSON(data []byte) error { +func (r *ResponseInputItemListResponseDataOpenAIResponseOutputMessageFunctionToolCall) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// URL citation annotation for referencing external web resources. -type ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationURLCitation 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"` +// 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 + 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - EndIndex respjson.Field - StartIndex respjson.Field - Title respjson.Field + ID respjson.Field + Arguments respjson.Field + Name respjson.Field + ServerLabel respjson.Field Type respjson.Field - URL 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 ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationURLCitation) RawJSON() string { +func (r ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpCall) RawJSON() string { return r.JSON.raw } -func (r *ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationURLCitation) UnmarshalJSON(data []byte) error { +func (r *ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpCall) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationContainerFileCitation 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"` +// 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"` // 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 + ID respjson.Field + ServerLabel respjson.Field + Tools respjson.Field Type respjson.Field ExtraFields map[string]respjson.Field raw string @@ -812,21 +741,107 @@ type ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnot } // Returns the unmodified JSON received from the API -func (r ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationContainerFileCitation) RawJSON() string { +func (r ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpListTools) RawJSON() string { return r.JSON.raw } -func (r *ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationContainerFileCitation) UnmarshalJSON(data []byte) error { +func (r *ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpListTools) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationFilePath struct { - FileID string `json:"file_id,required"` - Index int64 `json:"index,required"` - Type constant.FilePath `json:"type,required"` +// 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - FileID respjson.Field - Index respjson.Field + 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 ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpListToolsTool) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseInputItemListResponseDataOpenAIResponseOutputMessageMcpListToolsTool) UnmarshalJSON(data []byte) error { + 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"` + // 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 @@ -834,21 +849,67 @@ type ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnot } // Returns the unmodified JSON received from the API -func (r ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationFilePath) RawJSON() string { +func (r ResponseInputItemListResponseDataOpenAIResponseMcpApprovalRequest) RawJSON() string { return r.JSON.raw } -func (r *ResponseInputItemListResponseDataOpenAIResponseMessageContentArrayItemAnnotationFilePath) UnmarshalJSON(data []byte) error { +func (r *ResponseInputItemListResponseDataOpenAIResponseMcpApprovalRequest) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -type ResponseInputItemListResponseDataOpenAIResponseMessageRole string +// 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"` + // 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:"-"` +} -const ( - ResponseInputItemListResponseDataOpenAIResponseMessageRoleSystem ResponseInputItemListResponseDataOpenAIResponseMessageRole = "system" - ResponseInputItemListResponseDataOpenAIResponseMessageRoleDeveloper ResponseInputItemListResponseDataOpenAIResponseMessageRole = "developer" - ResponseInputItemListResponseDataOpenAIResponseMessageRoleUser ResponseInputItemListResponseDataOpenAIResponseMessageRole = "user" - ResponseInputItemListResponseDataOpenAIResponseMessageRoleAssistant ResponseInputItemListResponseDataOpenAIResponseMessageRole = "assistant" -) +// Returns the unmodified JSON received from the API +func (r ResponseInputItemListResponseDataOpenAIResponseInputFunctionToolCallOutput) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseInputItemListResponseDataOpenAIResponseInputFunctionToolCallOutput) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` + // 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:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ResponseInputItemListResponseDataOpenAIResponseMcpApprovalResponse) RawJSON() string { + return r.JSON.raw +} +func (r *ResponseInputItemListResponseDataOpenAIResponseMcpApprovalResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} type ResponseInputItemListResponseDataRole string diff --git a/responseinputitem_test.go b/responseinputitem_test.go index 82a007b..b64a77d 100644 --- a/responseinputitem_test.go +++ b/responseinputitem_test.go @@ -1,3 +1,9 @@ +// 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 diff --git a/route.go b/route.go index 9ab5dfb..d3cc821 100644 --- a/route.go +++ b/route.go @@ -1,3 +1,9 @@ +// 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 @@ -5,8 +11,11 @@ package llamastackclient import ( "context" "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/respjson" @@ -31,12 +40,13 @@ func NewRouteService(opts ...option.RequestOption) (r RouteService) { return } -// List all available API routes with their methods and implementing providers. -func (r *RouteService) List(ctx context.Context, opts ...option.RequestOption) (res *[]RouteInfo, err error) { +// 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 = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v1/inspect/routes" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) if err != nil { return } @@ -61,3 +71,35 @@ func (r ListRoutesResponse) RawJSON() string { return r.JSON.raw } func (r *ListRoutesResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } + +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 +} + +// URLQuery serializes [RouteListParams]'s query parameters as `url.Values`. +func (r RouteListParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// 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 ( + RouteListParamsAPIFilterV1 RouteListParamsAPIFilter = "v1" + RouteListParamsAPIFilterV1alpha RouteListParamsAPIFilter = "v1alpha" + RouteListParamsAPIFilterV1beta RouteListParamsAPIFilter = "v1beta" + RouteListParamsAPIFilterDeprecated RouteListParamsAPIFilter = "deprecated" +) diff --git a/route_test.go b/route_test.go index 115f2f7..b5b823a 100644 --- a/route_test.go +++ b/route_test.go @@ -1,3 +1,9 @@ +// 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 @@ -13,7 +19,7 @@ import ( "github.com/llamastack/llama-stack-client-go/option" ) -func TestRouteList(t *testing.T) { +func TestRouteListWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -24,7 +30,9 @@ func TestRouteList(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.Routes.List(context.TODO()) + _, err := client.Routes.List(context.TODO(), llamastackclient.RouteListParams{ + APIFilter: llamastackclient.RouteListParamsAPIFilterV1, + }) if err != nil { var apierr *llamastackclient.Error if errors.As(err, &apierr) { diff --git a/safety.go b/safety.go index 1c01cfe..32d79d8 100644 --- a/safety.go +++ b/safety.go @@ -1,3 +1,9 @@ +// 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 @@ -5,13 +11,14 @@ package llamastackclient import ( "context" "net/http" + "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" "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" + "github.com/llamastack/llama-stack-client-go/shared/constant" ) // SafetyService contains methods and other services that help with interacting @@ -33,9 +40,9 @@ func NewSafetyService(opts ...option.RequestOption) (r SafetyService) { return } -// 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 = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v1/safety/run-shield" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -44,7 +51,7 @@ 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 shared.SafetyViolation `json:"violation"` + Violation SafetyViolation `json:"violation"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Violation respjson.Field @@ -61,7 +68,7 @@ func (r *RunShieldResponse) UnmarshalJSON(data []byte) error { type SafetyRunShieldParams struct { // The messages to run the shield on. - Messages []shared.MessageUnionParam `json:"messages,omitzero,required"` + 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. @@ -77,6 +84,678 @@ func (r *SafetyRunShieldParams) 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 SafetyRunShieldParamsMessageUnion struct { + OfUser *SafetyRunShieldParamsMessageUser `json:",omitzero,inline"` + OfSystem *SafetyRunShieldParamsMessageSystem `json:",omitzero,inline"` + OfAssistant *SafetyRunShieldParamsMessageAssistant `json:",omitzero,inline"` + OfTool *SafetyRunShieldParamsMessageTool `json:",omitzero,inline"` + OfDeveloper *SafetyRunShieldParamsMessageDeveloper `json:",omitzero,inline"` + paramUnion +} + +func (u SafetyRunShieldParamsMessageUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfUser, + u.OfSystem, + u.OfAssistant, + u.OfTool, + u.OfDeveloper) +} +func (u *SafetyRunShieldParamsMessageUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *SafetyRunShieldParamsMessageUnion) asAny() any { + if !param.IsOmitted(u.OfUser) { + return u.OfUser + } else if !param.IsOmitted(u.OfSystem) { + return u.OfSystem + } else if !param.IsOmitted(u.OfAssistant) { + return u.OfAssistant + } else if !param.IsOmitted(u.OfTool) { + return u.OfTool + } else if !param.IsOmitted(u.OfDeveloper) { + return u.OfDeveloper + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u SafetyRunShieldParamsMessageUnion) GetToolCalls() []SafetyRunShieldParamsMessageAssistantToolCall { + if vt := u.OfAssistant; vt != nil { + return vt.ToolCalls + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u SafetyRunShieldParamsMessageUnion) GetToolCallID() *string { + if vt := u.OfTool; vt != nil { + return &vt.ToolCallID + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u SafetyRunShieldParamsMessageUnion) GetRole() *string { + if vt := u.OfUser; vt != nil { + return (*string)(&vt.Role) + } else if vt := u.OfSystem; vt != nil { + return (*string)(&vt.Role) + } else if vt := u.OfAssistant; vt != nil { + return (*string)(&vt.Role) + } else if vt := u.OfTool; vt != nil { + return (*string)(&vt.Role) + } else if vt := u.OfDeveloper; vt != nil { + return (*string)(&vt.Role) + } + 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 +func (u SafetyRunShieldParamsMessageUnion) GetContent() (res safetyRunShieldParamsMessageUnionContent) { + if vt := u.OfUser; vt != nil { + res.any = vt.Content.asAny() + } else if vt := u.OfSystem; vt != nil { + res.any = vt.Content.asAny() + } else if vt := u.OfAssistant; vt != nil { + res.any = vt.Content.asAny() + } else if vt := u.OfTool; vt != nil { + res.any = vt.Content.asAny() + } else if vt := u.OfDeveloper; vt != nil { + res.any = vt.Content.asAny() + } + return +} + +// Can have the runtime types [*string], +// [_[]SafetyRunShieldParamsMessageUserContentArrayItemUnion], +// [_[]SafetyRunShieldParamsMessageSystemContentArrayItem], +// [_[]SafetyRunShieldParamsMessageAssistantContentArrayItem], +// [_[]SafetyRunShieldParamsMessageToolContentArrayItem], +// [\*[]SafetyRunShieldParamsMessageDeveloperContentArrayItem] +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: +// default: +// fmt.Errorf("not present") +// } +func (u safetyRunShieldParamsMessageUnionContent) AsAny() any { return u.any } + +func init() { + apijson.RegisterUnion[SafetyRunShieldParamsMessageUnion]( + "role", + apijson.Discriminator[SafetyRunShieldParamsMessageUser]("user"), + apijson.Discriminator[SafetyRunShieldParamsMessageSystem]("system"), + apijson.Discriminator[SafetyRunShieldParamsMessageAssistant]("assistant"), + apijson.Discriminator[SafetyRunShieldParamsMessageTool]("tool"), + apijson.Discriminator[SafetyRunShieldParamsMessageDeveloper]("developer"), + ) +} + +// A message from the user in an OpenAI-compatible chat completion request. +// +// The properties Content, Role are 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"` + paramObj +} + +func (r SafetyRunShieldParamsMessageUser) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageUser + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *SafetyRunShieldParamsMessageUser) 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 SafetyRunShieldParamsMessageUserContentUnion struct { + OfString param.Opt[string] `json:",omitzero,inline"` + OfSafetyRunShieldsMessageUserContentArray []SafetyRunShieldParamsMessageUserContentArrayItemUnion `json:",omitzero,inline"` + paramUnion +} + +func (u SafetyRunShieldParamsMessageUserContentUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfString, u.OfSafetyRunShieldsMessageUserContentArray) +} +func (u *SafetyRunShieldParamsMessageUserContentUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *SafetyRunShieldParamsMessageUserContentUnion) asAny() any { + if !param.IsOmitted(u.OfString) { + return &u.OfString.Value + } else if !param.IsOmitted(u.OfSafetyRunShieldsMessageUserContentArray) { + return &u.OfSafetyRunShieldsMessageUserContentArray + } + return nil +} + +// 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"` + paramUnion +} + +func (u SafetyRunShieldParamsMessageUserContentArrayItemUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfText, u.OfImageURL, u.OfFile) +} +func (u *SafetyRunShieldParamsMessageUserContentArrayItemUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *SafetyRunShieldParamsMessageUserContentArrayItemUnion) asAny() any { + if !param.IsOmitted(u.OfText) { + return u.OfText + } else if !param.IsOmitted(u.OfImageURL) { + return u.OfImageURL + } else if !param.IsOmitted(u.OfFile) { + return u.OfFile + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u SafetyRunShieldParamsMessageUserContentArrayItemUnion) 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 SafetyRunShieldParamsMessageUserContentArrayItemUnion) GetImageURL() *SafetyRunShieldParamsMessageUserContentArrayItemImageURLImageURL { + if vt := u.OfImageURL; vt != nil { + return &vt.ImageURL + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u SafetyRunShieldParamsMessageUserContentArrayItemUnion) GetFile() *SafetyRunShieldParamsMessageUserContentArrayItemFileFile { + if vt := u.OfFile; vt != nil { + return &vt.File + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u SafetyRunShieldParamsMessageUserContentArrayItemUnion) GetType() *string { + if vt := u.OfText; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfImageURL; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfFile; vt != nil { + return (*string)(&vt.Type) + } + return nil +} + +func init() { + apijson.RegisterUnion[SafetyRunShieldParamsMessageUserContentArrayItemUnion]( + "type", + apijson.Discriminator[SafetyRunShieldParamsMessageUserContentArrayItemText]("text"), + apijson.Discriminator[SafetyRunShieldParamsMessageUserContentArrayItemImageURL]("image_url"), + apijson.Discriminator[SafetyRunShieldParamsMessageUserContentArrayItemFile]("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 + 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"` + paramObj +} + +func (r SafetyRunShieldParamsMessageUserContentArrayItemText) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageUserContentArrayItemText + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *SafetyRunShieldParamsMessageUserContentArrayItemText) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` + paramObj +} + +func (r SafetyRunShieldParamsMessageUserContentArrayItemImageURL) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageUserContentArrayItemImageURL + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *SafetyRunShieldParamsMessageUserContentArrayItemImageURL) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Image URL specification and processing details +// +// 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" + Detail param.Opt[string] `json:"detail,omitzero"` + paramObj +} + +func (r SafetyRunShieldParamsMessageUserContentArrayItemImageURLImageURL) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageUserContentArrayItemImageURLImageURL + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *SafetyRunShieldParamsMessageUserContentArrayItemImageURLImageURL) 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"` + paramObj +} + +func (r SafetyRunShieldParamsMessageUserContentArrayItemFile) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageUserContentArrayItemFile + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *SafetyRunShieldParamsMessageUserContentArrayItemFile) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type SafetyRunShieldParamsMessageUserContentArrayItemFileFile 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 + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *SafetyRunShieldParamsMessageUserContentArrayItemFileFile) 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 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"` + paramObj +} + +func (r SafetyRunShieldParamsMessageSystem) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageSystem + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *SafetyRunShieldParamsMessageSystem) 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 SafetyRunShieldParamsMessageSystemContentUnion struct { + OfString param.Opt[string] `json:",omitzero,inline"` + OfSafetyRunShieldsMessageSystemContentArray []SafetyRunShieldParamsMessageSystemContentArrayItem `json:",omitzero,inline"` + paramUnion +} + +func (u SafetyRunShieldParamsMessageSystemContentUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfString, u.OfSafetyRunShieldsMessageSystemContentArray) +} +func (u *SafetyRunShieldParamsMessageSystemContentUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *SafetyRunShieldParamsMessageSystemContentUnion) asAny() any { + if !param.IsOmitted(u.OfString) { + return &u.OfString.Value + } else if !param.IsOmitted(u.OfSafetyRunShieldsMessageSystemContentArray) { + return &u.OfSafetyRunShieldsMessageSystemContentArray + } + 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 + 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"` + paramObj +} + +func (r SafetyRunShieldParamsMessageSystemContentArrayItem) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageSystemContentArrayItem + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *SafetyRunShieldParamsMessageSystemContentArrayItem) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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"` + paramObj +} + +func (r SafetyRunShieldParamsMessageAssistant) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageAssistant + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *SafetyRunShieldParamsMessageAssistant) 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 SafetyRunShieldParamsMessageAssistantContentUnion struct { + OfString param.Opt[string] `json:",omitzero,inline"` + OfSafetyRunShieldsMessageAssistantContentArray []SafetyRunShieldParamsMessageAssistantContentArrayItem `json:",omitzero,inline"` + paramUnion +} + +func (u SafetyRunShieldParamsMessageAssistantContentUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfString, u.OfSafetyRunShieldsMessageAssistantContentArray) +} +func (u *SafetyRunShieldParamsMessageAssistantContentUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *SafetyRunShieldParamsMessageAssistantContentUnion) asAny() any { + if !param.IsOmitted(u.OfString) { + return &u.OfString.Value + } else if !param.IsOmitted(u.OfSafetyRunShieldsMessageAssistantContentArray) { + return &u.OfSafetyRunShieldsMessageAssistantContentArray + } + 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 + 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"` + paramObj +} + +func (r SafetyRunShieldParamsMessageAssistantContentArrayItem) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageAssistantContentArrayItem + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *SafetyRunShieldParamsMessageAssistantContentArrayItem) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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 + 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"` + paramObj +} + +func (r SafetyRunShieldParamsMessageAssistantToolCall) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageAssistantToolCall + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *SafetyRunShieldParamsMessageAssistantToolCall) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// (Optional) Function call details +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"` + paramObj +} + +func (r SafetyRunShieldParamsMessageAssistantToolCallFunction) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageAssistantToolCallFunction + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *SafetyRunShieldParamsMessageAssistantToolCallFunction) 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. +// +// The properties Content, Role, 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"` + paramObj +} + +func (r SafetyRunShieldParamsMessageTool) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageTool + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *SafetyRunShieldParamsMessageTool) 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 SafetyRunShieldParamsMessageToolContentUnion struct { + OfString param.Opt[string] `json:",omitzero,inline"` + OfSafetyRunShieldsMessageToolContentArray []SafetyRunShieldParamsMessageToolContentArrayItem `json:",omitzero,inline"` + paramUnion +} + +func (u SafetyRunShieldParamsMessageToolContentUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfString, u.OfSafetyRunShieldsMessageToolContentArray) +} +func (u *SafetyRunShieldParamsMessageToolContentUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *SafetyRunShieldParamsMessageToolContentUnion) asAny() any { + if !param.IsOmitted(u.OfString) { + return &u.OfString.Value + } else if !param.IsOmitted(u.OfSafetyRunShieldsMessageToolContentArray) { + return &u.OfSafetyRunShieldsMessageToolContentArray + } + 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 + 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"` + paramObj +} + +func (r SafetyRunShieldParamsMessageToolContentArrayItem) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageToolContentArrayItem + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *SafetyRunShieldParamsMessageToolContentArrayItem) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// A message from the developer in an OpenAI-compatible chat completion request. +// +// The properties Content, Role are 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"` + paramObj +} + +func (r SafetyRunShieldParamsMessageDeveloper) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageDeveloper + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *SafetyRunShieldParamsMessageDeveloper) 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 SafetyRunShieldParamsMessageDeveloperContentUnion struct { + OfString param.Opt[string] `json:",omitzero,inline"` + OfSafetyRunShieldsMessageDeveloperContentArray []SafetyRunShieldParamsMessageDeveloperContentArrayItem `json:",omitzero,inline"` + paramUnion +} + +func (u SafetyRunShieldParamsMessageDeveloperContentUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfString, u.OfSafetyRunShieldsMessageDeveloperContentArray) +} +func (u *SafetyRunShieldParamsMessageDeveloperContentUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *SafetyRunShieldParamsMessageDeveloperContentUnion) asAny() any { + if !param.IsOmitted(u.OfString) { + return &u.OfString.Value + } else if !param.IsOmitted(u.OfSafetyRunShieldsMessageDeveloperContentArray) { + return &u.OfSafetyRunShieldsMessageDeveloperContentArray + } + 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 + 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"` + paramObj +} + +func (r SafetyRunShieldParamsMessageDeveloperContentArrayItem) MarshalJSON() (data []byte, err error) { + type shadow SafetyRunShieldParamsMessageDeveloperContentArrayItem + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *SafetyRunShieldParamsMessageDeveloperContentArrayItem) 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. diff --git a/safety_test.go b/safety_test.go index 012daef..db56629 100644 --- a/safety_test.go +++ b/safety_test.go @@ -1,3 +1,9 @@ +// 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 @@ -11,7 +17,6 @@ import ( "github.com/llamastack/llama-stack-client-go" "github.com/llamastack/llama-stack-client-go/internal/testutil" "github.com/llamastack/llama-stack-client-go/option" - "github.com/llamastack/llama-stack-client-go/shared" ) func TestSafetyRunShield(t *testing.T) { @@ -26,14 +31,12 @@ func TestSafetyRunShield(t *testing.T) { option.WithBaseURL(baseURL), ) _, err := client.Safety.RunShield(context.TODO(), llamastackclient.SafetyRunShieldParams{ - Messages: []shared.MessageUnionParam{{ - OfUser: &shared.UserMessageParam{ - Content: shared.InterleavedContentUnionParam{ - OfString: llamastackclient.String("string"), - }, - Context: shared.InterleavedContentUnionParam{ + Messages: []llamastackclient.SafetyRunShieldParamsMessageUnion{{ + OfUser: &llamastackclient.SafetyRunShieldParamsMessageUser{ + Content: llamastackclient.SafetyRunShieldParamsMessageUserContentUnion{ OfString: llamastackclient.String("string"), }, + Name: llamastackclient.String("name"), }, }}, Params: map[string]llamastackclient.SafetyRunShieldParamsParamUnion{ diff --git a/scoring.go b/scoring.go index 19b5c06..953dedf 100644 --- a/scoring.go +++ b/scoring.go @@ -1,3 +1,9 @@ +// 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 @@ -5,13 +11,13 @@ package llamastackclient import ( "context" "net/http" + "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" "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" ) // ScoringService contains methods and other services that help with interacting @@ -35,7 +41,7 @@ func NewScoringService(opts ...option.RequestOption) (r ScoringService) { // Score a list of rows. func (r *ScoringService) Score(ctx context.Context, body ScoringScoreParams, opts ...option.RequestOption) (res *ScoringScoreResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v1/scoring/score" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -43,7 +49,7 @@ func (r *ScoringService) Score(ctx context.Context, body ScoringScoreParams, opt // Score a batch of rows. func (r *ScoringService) ScoreBatch(ctx context.Context, body ScoringScoreBatchParams, opts ...option.RequestOption) (res *ScoringScoreBatchResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v1/scoring/score-batch" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -52,7 +58,7 @@ 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]shared.ScoringResult `json:"results,required"` + Results map[string]ScoringResult `json:"results,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Results respjson.Field @@ -70,7 +76,7 @@ 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]shared.ScoringResult `json:"results,required"` + Results map[string]ScoringResult `json:"results,required"` // (Optional) The identifier of the dataset that was scored DatasetID string `json:"dataset_id"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. diff --git a/scoring_test.go b/scoring_test.go index e42e129..f7b2001 100644 --- a/scoring_test.go +++ b/scoring_test.go @@ -1,3 +1,9 @@ +// 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 diff --git a/scoringfunction.go b/scoringfunction.go index 898bca7..1f28d7a 100644 --- a/scoringfunction.go +++ b/scoringfunction.go @@ -1,3 +1,9 @@ +// 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 @@ -8,13 +14,13 @@ import ( "errors" "fmt" "net/http" + "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" "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" "github.com/llamastack/llama-stack-client-go/shared/constant" ) @@ -39,7 +45,7 @@ func NewScoringFunctionService(opts ...option.RequestOption) (r ScoringFunctionS // Get a scoring function by its ID. func (r *ScoringFunctionService) Get(ctx context.Context, scoringFnID string, opts ...option.RequestOption) (res *ScoringFn, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if scoringFnID == "" { err = errors.New("missing required scoring_fn_id parameter") return @@ -52,7 +58,7 @@ func (r *ScoringFunctionService) Get(ctx context.Context, scoringFnID string, op // List all scoring functions. func (r *ScoringFunctionService) List(ctx context.Context, opts ...option.RequestOption) (res *[]ScoringFn, err error) { var env ListScoringFunctionsResponse - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v1/scoring-functions" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) if err != nil { @@ -63,8 +69,10 @@ func (r *ScoringFunctionService) List(ctx context.Context, opts ...option.Reques } // Register a scoring function. +// +// Deprecated: deprecated func (r *ScoringFunctionService) Register(ctx context.Context, body ScoringFunctionRegisterParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) path := "v1/scoring-functions" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...) @@ -92,7 +100,7 @@ type ScoringFn struct { Identifier string `json:"identifier,required"` Metadata map[string]ScoringFnMetadataUnion `json:"metadata,required"` ProviderID string `json:"provider_id,required"` - ReturnType shared.ReturnType `json:"return_type,required"` + ReturnType ScoringFnReturnType `json:"return_type,required"` // The resource type, always scoring_function Type constant.ScoringFunction `json:"type,required"` Description string `json:"description"` @@ -172,6 +180,24 @@ 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". + Type string `json:"type,required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Type respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ScoringFnReturnType) RawJSON() string { return r.JSON.raw } +func (r *ScoringFnReturnType) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + // ScoringFnParamsUnionResp contains all possible properties and values from // [ScoringFnParamsLlmAsJudgeResp], [ScoringFnParamsRegexParserResp], // [ScoringFnParamsBasicResp]. @@ -541,8 +567,8 @@ func (r *ScoringFnParamsBasic) UnmarshalJSON(data []byte) error { type ScoringFunctionRegisterParams struct { // The description of the scoring function. - Description string `json:"description,required"` - ReturnType shared.ReturnTypeParam `json:"return_type,omitzero,required"` + 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. @@ -562,3 +588,25 @@ 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 3ba1c2e..f661c97 100644 --- a/scoringfunction_test.go +++ b/scoringfunction_test.go @@ -1,3 +1,9 @@ +// 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 @@ -11,7 +17,6 @@ import ( "github.com/llamastack/llama-stack-client-go" "github.com/llamastack/llama-stack-client-go/internal/testutil" "github.com/llamastack/llama-stack-client-go/option" - "github.com/llamastack/llama-stack-client-go/shared" ) func TestScoringFunctionGet(t *testing.T) { @@ -69,8 +74,8 @@ func TestScoringFunctionRegisterWithOptionalParams(t *testing.T) { ) err := client.ScoringFunctions.Register(context.TODO(), llamastackclient.ScoringFunctionRegisterParams{ Description: "description", - ReturnType: shared.ReturnTypeParam{ - Type: shared.ReturnTypeTypeString, + ReturnType: llamastackclient.ScoringFunctionRegisterParamsReturnType{ + Type: "string", }, ScoringFnID: "scoring_fn_id", Params: llamastackclient.ScoringFnParamsUnion{ diff --git a/scripts/bootstrap b/scripts/bootstrap index d6ac165..5ab3066 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -4,10 +4,18 @@ set -e cd "$(dirname "$0")/.." -if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ]; then +if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then brew bundle check >/dev/null 2>&1 || { - echo "==> Installing Homebrew dependencies…" - brew bundle + echo -n "==> Install Homebrew dependencies? (y/N): " + read -r response + case "$response" in + [yY][eE][sS]|[yY]) + brew bundle + ;; + *) + ;; + esac + echo } fi diff --git a/shared.go b/shared.go new file mode 100644 index 0000000..6f5db9e --- /dev/null +++ b/shared.go @@ -0,0 +1,1028 @@ +// 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 ( + "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 +} + +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 } + +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"` + // 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 InterleavedContentImageContentItem) RawJSON() string { return r.JSON.raw } +func (r *InterleavedContentImageContentItem) 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) +} + +// 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:"-"` +} + +// 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) +} + +// 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:"-"` +} + +// Returns the unmodified JSON received from the API +func (r InterleavedContentTextContentItem) RawJSON() string { return r.JSON.raw } +func (r *InterleavedContentTextContentItem) 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"` + paramUnion +} + +func (u InterleavedContentUnionParam) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfString, u.OfImageContentItem, u.OfTextContentItem, u.OfInterleavedContentItemArray) +} +func (u *InterleavedContentUnionParam) 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 + } + 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 + } + 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 + } + 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) + } + 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 +} + +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) +} + +// 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"` + paramObj +} + +func (r InterleavedContentImageContentItemImageParam) MarshalJSON() (data []byte, err error) { + type shadow InterleavedContentImageContentItemImageParam + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *InterleavedContentImageContentItemImageParam) 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) +} + +// A text content item +// +// 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"` + paramObj +} + +func (r InterleavedContentTextContentItemParam) MarshalJSON() (data []byte, err error) { + type shadow InterleavedContentTextContentItemParam + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *InterleavedContentTextContentItemParam) 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() +} + +// Use the following switch statement to find the correct variant +// +// 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 +} + +func (u InterleavedContentItemUnion) AsText() (v InterleavedContentItemText) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u InterleavedContentItemUnion) RawJSON() string { return u.JSON.raw } + +func (r *InterleavedContentItemUnion) 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 (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"` + // 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 InterleavedContentItemImageImage) RawJSON() string { return r.JSON.raw } +func (r *InterleavedContentItemImageImage) 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 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:"-"` +} + +// Returns the unmodified JSON received from the API +func (r InterleavedContentItemText) RawJSON() string { return r.JSON.raw } +func (r *InterleavedContentItemText) 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"` + paramUnion +} + +func (u InterleavedContentItemUnionParam) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfImage, u.OfText) +} +func (u *InterleavedContentItemUnionParam) 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 + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u InterleavedContentItemUnionParam) GetImage() *InterleavedContentItemImageImageParam { + if vt := u.OfImage; 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 { + 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 { + return (*string)(&vt.Type) + } else if vt := u.OfText; 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"` + paramObj +} + +func (r InterleavedContentItemImageParam) MarshalJSON() (data []byte, err error) { + type shadow InterleavedContentItemImageParam + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *InterleavedContentItemImageParam) 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 + 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"` + paramObj +} + +func (r InterleavedContentItemImageImageParam) MarshalJSON() (data []byte, err error) { + type shadow InterleavedContentItemImageImageParam + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *InterleavedContentItemImageImageParam) 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 InterleavedContentItemImageImageURLParam struct { + // The URL string pointing to the resource + Uri string `json:"uri,required"` + paramObj +} + +func (r InterleavedContentItemImageImageURLParam) MarshalJSON() (data []byte, err error) { + type shadow InterleavedContentItemImageImageURLParam + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *InterleavedContentItemImageImageURLParam) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// A text content item +// +// The properties Text, Type are required. +type InterleavedContentItemTextParam 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"` + paramObj +} + +func (r InterleavedContentItemTextParam) MarshalJSON() (data []byte, err error) { + type shadow InterleavedContentItemTextParam + 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 { + 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) +} + +// 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"` + paramUnion +} + +func (u SamplingParamsStrategyUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfGreedy, u.OfTopP, u.OfTopK) +} +func (u *SamplingParamsStrategyUnion) 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 + } + 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 + } + 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 + } + 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 { + return (*string)(&vt.Type) + } else if vt := u.OfTopK; vt != nil { + return (*string)(&vt.Type) + } + return nil +} + +func init() { + apijson.RegisterUnion[SamplingParamsStrategyUnion]( + "type", + apijson.Discriminator[SamplingParamsStrategyGreedy]("greedy"), + apijson.Discriminator[SamplingParamsStrategyTopP]("top_p"), + apijson.Discriminator[SamplingParamsStrategyTopK]("top_k"), + ) +} + +func NewSamplingParamsStrategyGreedy() SamplingParamsStrategyGreedy { + return SamplingParamsStrategyGreedy{ + Type: "greedy", + } +} + +// Greedy sampling strategy that selects the highest probability token at each +// step. +// +// 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"` + paramObj +} + +func (r SamplingParamsStrategyGreedy) MarshalJSON() (data []byte, err error) { + type shadow SamplingParamsStrategyGreedy + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *SamplingParamsStrategyGreedy) 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"` + paramObj +} + +func (r SamplingParamsStrategyTopP) MarshalJSON() (data []byte, err error) { + type shadow SamplingParamsStrategyTopP + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *SamplingParamsStrategyTopP) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Top-k sampling strategy that restricts sampling to the k most likely tokens. +// +// 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"` + paramObj +} + +func (r SamplingParamsStrategyTopK) MarshalJSON() (data []byte, err error) { + type shadow SamplingParamsStrategyTopK + 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 { + 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. +// +// 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 +} + +func (u ScoringResultAggregatedResultUnion) AsAnyArray() (v []any) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ScoringResultAggregatedResultUnion) RawJSON() string { return u.JSON.raw } + +func (r *ScoringResultAggregatedResultUnion) 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 +} + +// Returns the unmodified JSON received from the API +func (u ScoringResultScoreRowUnion) RawJSON() string { return u.JSON.raw } + +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) +} diff --git a/shared/constant/constants.go b/shared/constant/constants.go index 9a0304b..0fd3fb1 100644 --- a/shared/constant/constants.go +++ b/shared/constant/constants.go @@ -1,3 +1,9 @@ +// 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 constant @@ -18,8 +24,6 @@ func ValueOf[T Constant[T]]() T { return t.Default() } -type Agent string // Always "agent" -type AgentTurnInput string // Always "agent_turn_input" type Array string // Always "array" type Assistant string // Always "assistant" type Auto string // Always "auto" @@ -31,8 +35,9 @@ 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 Default string // Always "default" type Developer string // Always "developer" type Embedding string // Always "embedding" type File string // Always "file" @@ -43,31 +48,30 @@ 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 Grammar string // Always "grammar" type Greedy string // Always "greedy" type Image string // Always "image" type ImageURL string // Always "image_url" -type Inference string // Always "inference" +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 Llm string // Always "llm" 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 MemoryRetrieval string // Always "memory_retrieval" type Message string // Always "message" -type Metric string // Always "metric" 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" @@ -75,8 +79,14 @@ 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" @@ -87,47 +97,40 @@ type ResponseMcpListToolsFailed string // Always "response.mcp_list_tool 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 Rrf string // Always "rrf" type ScoringFunction string // Always "scoring_function" type Shield string // Always "shield" -type ShieldCall string // Always "shield_call" -type SpanEnd string // Always "span_end" -type SpanStart string // Always "span_start" type Static string // Always "static" -type StepComplete string // Always "step_complete" -type StepProgress string // Always "step_progress" -type StepStart string // Always "step_start" type String string // Always "string" -type StructuredLog string // Always "structured_log" +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 ToolCall string // Always "tool_call" -type ToolExecution string // Always "tool_execution" type ToolGroup string // Always "tool_group" type TopK string // Always "top_k" type TopP string // Always "top_p" -type TurnAwaitingInput string // Always "turn_awaiting_input" -type TurnComplete string // Always "turn_complete" -type TurnStart string // Always "turn_start" type Union string // Always "union" -type UnstructuredLog string // Always "unstructured_log" type Uri string // Always "uri" type URLCitation string // Always "url_citation" type User string // Always "user" -type VectorDB string // Always "vector_db" +type VectorStoreFileContentPage string // Always "vector_store.file_content.page" type WebSearchCall string // Always "web_search_call" -type Weighted string // Always "weighted" -func (c Agent) Default() Agent { return "agent" } -func (c AgentTurnInput) Default() AgentTurnInput { return "agent_turn_input" } func (c Array) Default() Array { return "array" } func (c Assistant) Default() Assistant { return "assistant" } func (c Auto) Default() Auto { return "auto" } @@ -139,8 +142,9 @@ func (c ChatCompletion) Default() ChatCompletion { return "chat.co 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 Default) Default() Default { return "default" } func (c Developer) Default() Developer { return "developer" } func (c Embedding) Default() Embedding { return "embedding" } func (c File) Default() File { return "file" } @@ -151,31 +155,30 @@ func (c FileSearchCall) Default() FileSearchCall { return "file_se 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 Grammar) Default() Grammar { return "grammar" } func (c Greedy) Default() Greedy { return "greedy" } func (c Image) Default() Image { return "image" } func (c ImageURL) Default() ImageURL { return "image_url" } -func (c Inference) Default() Inference { return "inference" } +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 Llm) Default() Llm { return "llm" } 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 MemoryRetrieval) Default() MemoryRetrieval { return "memory_retrieval" } func (c Message) Default() Message { return "message" } -func (c Metric) Default() Metric { return "metric" } 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" } @@ -187,12 +190,24 @@ 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" } @@ -219,10 +234,33 @@ 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" } @@ -232,42 +270,28 @@ func (c ResponseWebSearchCallInProgress) Default() ResponseWebSearchCallInProgre func (c ResponseWebSearchCallSearching) Default() ResponseWebSearchCallSearching { return "response.web_search_call.searching" } -func (c Rows) Default() Rows { return "rows" } -func (c Rrf) Default() Rrf { return "rrf" } -func (c ScoringFunction) Default() ScoringFunction { return "scoring_function" } -func (c Shield) Default() Shield { return "shield" } -func (c ShieldCall) Default() ShieldCall { return "shield_call" } -func (c SpanEnd) Default() SpanEnd { return "span_end" } -func (c SpanStart) Default() SpanStart { return "span_start" } -func (c Static) Default() Static { return "static" } -func (c StepComplete) Default() StepComplete { return "step_complete" } -func (c StepProgress) Default() StepProgress { return "step_progress" } -func (c StepStart) Default() StepStart { return "step_start" } -func (c String) Default() String { return "string" } -func (c StructuredLog) Default() StructuredLog { return "structured_log" } -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 ToolCall) Default() ToolCall { return "tool_call" } -func (c ToolExecution) Default() ToolExecution { return "tool_execution" } -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 TurnAwaitingInput) Default() TurnAwaitingInput { return "turn_awaiting_input" } -func (c TurnComplete) Default() TurnComplete { return "turn_complete" } -func (c TurnStart) Default() TurnStart { return "turn_start" } -func (c Union) Default() Union { return "union" } -func (c UnstructuredLog) Default() UnstructuredLog { return "unstructured_log" } -func (c Uri) Default() Uri { return "uri" } -func (c URLCitation) Default() URLCitation { return "url_citation" } -func (c User) Default() User { return "user" } -func (c VectorDB) Default() VectorDB { return "vector_db" } -func (c WebSearchCall) Default() WebSearchCall { return "web_search_call" } -func (c Weighted) Default() Weighted { return "weighted" } +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 Agent) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c AgentTurnInput) MarshalJSON() ([]byte, error) { return marshalString(c) } 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) } @@ -279,8 +303,9 @@ func (c ChatCompletion) MarshalJSON() ([]byte, error) { retu 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 Default) 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) } @@ -291,31 +316,30 @@ func (c FileSearchCall) MarshalJSON() ([]byte, error) { retu 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 Grammar) 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 Inference) 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 Llm) 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 MemoryRetrieval) MarshalJSON() ([]byte, error) { return marshalString(c) } func (c Message) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Metric) 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) } @@ -323,8 +347,14 @@ func (c ResponseCompleted) MarshalJSON() ([]byte, error) { retu 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) } @@ -335,44 +365,39 @@ func (c ResponseMcpListToolsFailed) MarshalJSON() ([]byte, error) { retu 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 Rrf) 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 ShieldCall) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c SpanEnd) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c SpanStart) MarshalJSON() ([]byte, error) { return marshalString(c) } func (c Static) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c StepComplete) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c StepProgress) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c StepStart) MarshalJSON() ([]byte, error) { return marshalString(c) } func (c String) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c StructuredLog) 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 ToolCall) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c ToolExecution) 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 TurnAwaitingInput) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c TurnComplete) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c TurnStart) MarshalJSON() ([]byte, error) { return marshalString(c) } func (c Union) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c UnstructuredLog) 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 VectorDB) MarshalJSON() ([]byte, error) { return marshalString(c) } +func (c VectorStoreFileContentPage) MarshalJSON() ([]byte, error) { return marshalString(c) } func (c WebSearchCall) MarshalJSON() ([]byte, error) { return marshalString(c) } -func (c Weighted) MarshalJSON() ([]byte, error) { return marshalString(c) } type constant[T any] interface { Constant[T] diff --git a/shared/shared.go b/shared/shared.go deleted file mode 100644 index 23bf070..0000000 --- a/shared/shared.go +++ /dev/null @@ -1,4063 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package shared - -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" -) - -// aliased to make [param.APIUnion] private when embedding -type paramUnion = param.APIUnion - -// aliased to make [param.APIObject] private when embedding -type paramObj = param.APIObject - -// Configuration for an agent. -type AgentConfig struct { - // The system instructions for the agent - Instructions string `json:"instructions,required"` - // The model identifier to use for the agent - Model string `json:"model,required"` - ClientTools []SharedToolDef `json:"client_tools"` - // Optional flag indicating whether session data has to be persisted - EnableSessionPersistence bool `json:"enable_session_persistence"` - InputShields []string `json:"input_shields"` - MaxInferIters int64 `json:"max_infer_iters"` - // Optional name for the agent, used in telemetry and identification - Name string `json:"name"` - OutputShields []string `json:"output_shields"` - // Optional response format configuration - ResponseFormat ResponseFormatUnion `json:"response_format"` - // Sampling parameters. - SamplingParams SamplingParamsResp `json:"sampling_params"` - // Whether tool use is required or automatic. This is a hint to the model which may - // not be followed. It depends on the Instruction Following capabilities of the - // model. - // - // Any of "auto", "required", "none". - // - // Deprecated: deprecated - ToolChoice AgentConfigToolChoice `json:"tool_choice"` - // Configuration for tool use. - ToolConfig AgentConfigToolConfig `json:"tool_config"` - // Prompt format for calling custom / zero shot tools. - // - // Any of "json", "function_tag", "python_list". - // - // Deprecated: deprecated - ToolPromptFormat AgentConfigToolPromptFormat `json:"tool_prompt_format"` - Toolgroups []AgentConfigToolgroupUnion `json:"toolgroups"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Instructions respjson.Field - Model respjson.Field - ClientTools respjson.Field - EnableSessionPersistence respjson.Field - InputShields respjson.Field - MaxInferIters respjson.Field - Name respjson.Field - OutputShields respjson.Field - ResponseFormat respjson.Field - SamplingParams respjson.Field - ToolChoice respjson.Field - ToolConfig respjson.Field - ToolPromptFormat respjson.Field - Toolgroups respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r AgentConfig) RawJSON() string { return r.JSON.raw } -func (r *AgentConfig) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ToParam converts this AgentConfig to a AgentConfigParam. -// -// 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 -// AgentConfigParam.Overrides() -func (r AgentConfig) ToParam() AgentConfigParam { - return param.Override[AgentConfigParam](json.RawMessage(r.RawJSON())) -} - -// Whether tool use is required or automatic. This is a hint to the model which may -// not be followed. It depends on the Instruction Following capabilities of the -// model. -type AgentConfigToolChoice string - -const ( - AgentConfigToolChoiceAuto AgentConfigToolChoice = "auto" - AgentConfigToolChoiceRequired AgentConfigToolChoice = "required" - AgentConfigToolChoiceNone AgentConfigToolChoice = "none" -) - -// Configuration for tool use. -type AgentConfigToolConfig struct { - // (Optional) Config for how to override the default system prompt. - - // `SystemMessageBehavior.append`: Appends the provided system message to the - // default system prompt. - `SystemMessageBehavior.replace`: Replaces the default - // system prompt with the provided system message. The system message can include - // the string '{{function_definitions}}' to indicate where the function definitions - // should be inserted. - // - // Any of "append", "replace". - SystemMessageBehavior string `json:"system_message_behavior"` - // (Optional) Whether tool use is automatic, required, or none. Can also specify a - // tool name to use a specific tool. Defaults to ToolChoice.auto. - ToolChoice string `json:"tool_choice"` - // (Optional) Instructs the model how to format tool calls. By default, Llama Stack - // will attempt to use a format that is best adapted to the model. - - // `ToolPromptFormat.json`: The tool calls are formatted as a JSON object. - - // `ToolPromptFormat.function_tag`: The tool calls are enclosed in a - // tag. - `ToolPromptFormat.python_list`: The tool calls - // are output as Python syntax -- a list of function calls. - // - // Any of "json", "function_tag", "python_list". - ToolPromptFormat string `json:"tool_prompt_format"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - SystemMessageBehavior respjson.Field - ToolChoice respjson.Field - ToolPromptFormat respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r AgentConfigToolConfig) RawJSON() string { return r.JSON.raw } -func (r *AgentConfigToolConfig) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Prompt format for calling custom / zero shot tools. -type AgentConfigToolPromptFormat string - -const ( - AgentConfigToolPromptFormatJson AgentConfigToolPromptFormat = "json" - AgentConfigToolPromptFormatFunctionTag AgentConfigToolPromptFormat = "function_tag" - AgentConfigToolPromptFormatPythonList AgentConfigToolPromptFormat = "python_list" -) - -// AgentConfigToolgroupUnion contains all possible properties and values from -// [string], [AgentConfigToolgroupAgentToolGroupWithArgs]. -// -// 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] -type AgentConfigToolgroupUnion struct { - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field is from variant [AgentConfigToolgroupAgentToolGroupWithArgs]. - Args map[string]AgentConfigToolgroupAgentToolGroupWithArgsArgUnion `json:"args"` - // This field is from variant [AgentConfigToolgroupAgentToolGroupWithArgs]. - Name string `json:"name"` - JSON struct { - OfString respjson.Field - Args respjson.Field - Name respjson.Field - raw string - } `json:"-"` -} - -func (u AgentConfigToolgroupUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u AgentConfigToolgroupUnion) AsAgentToolGroupWithArgs() (v AgentConfigToolgroupAgentToolGroupWithArgs) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u AgentConfigToolgroupUnion) RawJSON() string { return u.JSON.raw } - -func (r *AgentConfigToolgroupUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type AgentConfigToolgroupAgentToolGroupWithArgs struct { - Args map[string]AgentConfigToolgroupAgentToolGroupWithArgsArgUnion `json:"args,required"` - Name string `json:"name,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Args respjson.Field - Name respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r AgentConfigToolgroupAgentToolGroupWithArgs) RawJSON() string { return r.JSON.raw } -func (r *AgentConfigToolgroupAgentToolGroupWithArgs) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// AgentConfigToolgroupAgentToolGroupWithArgsArgUnion 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 AgentConfigToolgroupAgentToolGroupWithArgsArgUnion 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 AgentConfigToolgroupAgentToolGroupWithArgsArgUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u AgentConfigToolgroupAgentToolGroupWithArgsArgUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u AgentConfigToolgroupAgentToolGroupWithArgsArgUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u AgentConfigToolgroupAgentToolGroupWithArgsArgUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u AgentConfigToolgroupAgentToolGroupWithArgsArgUnion) RawJSON() string { return u.JSON.raw } - -func (r *AgentConfigToolgroupAgentToolGroupWithArgsArgUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Configuration for an agent. -// -// The properties Instructions, Model are required. -type AgentConfigParam struct { - // The system instructions for the agent - Instructions string `json:"instructions,required"` - // The model identifier to use for the agent - Model string `json:"model,required"` - // Optional flag indicating whether session data has to be persisted - EnableSessionPersistence param.Opt[bool] `json:"enable_session_persistence,omitzero"` - MaxInferIters param.Opt[int64] `json:"max_infer_iters,omitzero"` - // Optional name for the agent, used in telemetry and identification - Name param.Opt[string] `json:"name,omitzero"` - ClientTools []SharedToolDefParam `json:"client_tools,omitzero"` - InputShields []string `json:"input_shields,omitzero"` - OutputShields []string `json:"output_shields,omitzero"` - // Optional response format configuration - ResponseFormat ResponseFormatUnionParam `json:"response_format,omitzero"` - // Sampling parameters. - SamplingParams SamplingParams `json:"sampling_params,omitzero"` - // Whether tool use is required or automatic. This is a hint to the model which may - // not be followed. It depends on the Instruction Following capabilities of the - // model. - // - // Any of "auto", "required", "none". - // - // Deprecated: deprecated - ToolChoice AgentConfigToolChoice `json:"tool_choice,omitzero"` - // Configuration for tool use. - ToolConfig AgentConfigToolConfigParam `json:"tool_config,omitzero"` - // Prompt format for calling custom / zero shot tools. - // - // Any of "json", "function_tag", "python_list". - // - // Deprecated: deprecated - ToolPromptFormat AgentConfigToolPromptFormat `json:"tool_prompt_format,omitzero"` - Toolgroups []AgentConfigToolgroupUnionParam `json:"toolgroups,omitzero"` - paramObj -} - -func (r AgentConfigParam) MarshalJSON() (data []byte, err error) { - type shadow AgentConfigParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *AgentConfigParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Configuration for tool use. -type AgentConfigToolConfigParam struct { - // (Optional) Config for how to override the default system prompt. - - // `SystemMessageBehavior.append`: Appends the provided system message to the - // default system prompt. - `SystemMessageBehavior.replace`: Replaces the default - // system prompt with the provided system message. The system message can include - // the string '{{function_definitions}}' to indicate where the function definitions - // should be inserted. - // - // Any of "append", "replace". - SystemMessageBehavior string `json:"system_message_behavior,omitzero"` - // (Optional) Whether tool use is automatic, required, or none. Can also specify a - // tool name to use a specific tool. Defaults to ToolChoice.auto. - ToolChoice string `json:"tool_choice,omitzero"` - // (Optional) Instructs the model how to format tool calls. By default, Llama Stack - // will attempt to use a format that is best adapted to the model. - - // `ToolPromptFormat.json`: The tool calls are formatted as a JSON object. - - // `ToolPromptFormat.function_tag`: The tool calls are enclosed in a - // tag. - `ToolPromptFormat.python_list`: The tool calls - // are output as Python syntax -- a list of function calls. - // - // Any of "json", "function_tag", "python_list". - ToolPromptFormat string `json:"tool_prompt_format,omitzero"` - paramObj -} - -func (r AgentConfigToolConfigParam) MarshalJSON() (data []byte, err error) { - type shadow AgentConfigToolConfigParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *AgentConfigToolConfigParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -func init() { - apijson.RegisterFieldValidator[AgentConfigToolConfigParam]( - "system_message_behavior", "append", "replace", - ) - apijson.RegisterFieldValidator[AgentConfigToolConfigParam]( - "tool_prompt_format", "json", "function_tag", "python_list", - ) -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type AgentConfigToolgroupUnionParam struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfAgentToolGroupWithArgs *AgentConfigToolgroupAgentToolGroupWithArgsParam `json:",omitzero,inline"` - paramUnion -} - -func (u AgentConfigToolgroupUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfAgentToolGroupWithArgs) -} -func (u *AgentConfigToolgroupUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *AgentConfigToolgroupUnionParam) asAny() any { - if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfAgentToolGroupWithArgs) { - return u.OfAgentToolGroupWithArgs - } - return nil -} - -// The properties Args, Name are required. -type AgentConfigToolgroupAgentToolGroupWithArgsParam struct { - Args map[string]AgentConfigToolgroupAgentToolGroupWithArgsArgUnionParam `json:"args,omitzero,required"` - Name string `json:"name,required"` - paramObj -} - -func (r AgentConfigToolgroupAgentToolGroupWithArgsParam) MarshalJSON() (data []byte, err error) { - type shadow AgentConfigToolgroupAgentToolGroupWithArgsParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *AgentConfigToolgroupAgentToolGroupWithArgsParam) 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 AgentConfigToolgroupAgentToolGroupWithArgsArgUnionParam 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 AgentConfigToolgroupAgentToolGroupWithArgsArgUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *AgentConfigToolgroupAgentToolGroupWithArgsArgUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *AgentConfigToolgroupAgentToolGroupWithArgsArgUnionParam) 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 -} - -// Response from a batch completion request. -type BatchCompletion struct { - // List of completion responses, one for each input in the batch - Batch []SharedCompletionResponse `json:"batch,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Batch respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r BatchCompletion) RawJSON() string { return r.JSON.raw } -func (r *BatchCompletion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Response from a chat completion request. -type ChatCompletionResponse struct { - // The complete response message - CompletionMessage CompletionMessage `json:"completion_message,required"` - // Optional log probabilities for generated tokens - Logprobs []ChatCompletionResponseLogprob `json:"logprobs"` - // (Optional) List of metrics associated with the API response - Metrics []ChatCompletionResponseMetric `json:"metrics"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - CompletionMessage respjson.Field - Logprobs respjson.Field - Metrics respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ChatCompletionResponse) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionResponse) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Log probabilities for generated tokens. -type ChatCompletionResponseLogprob struct { - // Dictionary mapping tokens to their log probabilities - LogprobsByToken map[string]float64 `json:"logprobs_by_token,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - LogprobsByToken respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ChatCompletionResponseLogprob) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionResponseLogprob) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A metric value included in API responses. -type ChatCompletionResponseMetric struct { - // The name of the metric - Metric string `json:"metric,required"` - // The numeric value of the metric - Value float64 `json:"value,required"` - // (Optional) The unit of measurement for the metric value - Unit string `json:"unit"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Metric respjson.Field - Value respjson.Field - Unit respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ChatCompletionResponseMetric) RawJSON() string { return r.JSON.raw } -func (r *ChatCompletionResponseMetric) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A message containing the model's (assistant) response in a chat conversation. -type CompletionMessage struct { - // The content of the model's response - Content InterleavedContentUnion `json:"content,required"` - // Must be "assistant" to identify this as the model's response - Role constant.Assistant `json:"role,required"` - // Reason why the model stopped generating. Options are: - - // `StopReason.end_of_turn`: The model finished generating the entire response. - - // `StopReason.end_of_message`: The model finished generating but generated a - // partial response -- usually, a tool call. The user may call the tool and - // continue the conversation with the tool's response. - - // `StopReason.out_of_tokens`: The model ran out of token budget. - // - // Any of "end_of_turn", "end_of_message", "out_of_tokens". - StopReason CompletionMessageStopReason `json:"stop_reason,required"` - // List of tool calls. Each tool call is a ToolCall object. - ToolCalls []ToolCall `json:"tool_calls"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Content respjson.Field - Role respjson.Field - StopReason respjson.Field - ToolCalls respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r CompletionMessage) RawJSON() string { return r.JSON.raw } -func (r *CompletionMessage) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ToParam converts this CompletionMessage to a CompletionMessageParam. -// -// 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 -// CompletionMessageParam.Overrides() -func (r CompletionMessage) ToParam() CompletionMessageParam { - return param.Override[CompletionMessageParam](json.RawMessage(r.RawJSON())) -} - -// Reason why the model stopped generating. Options are: - -// `StopReason.end_of_turn`: The model finished generating the entire response. - -// `StopReason.end_of_message`: The model finished generating but generated a -// partial response -- usually, a tool call. The user may call the tool and -// continue the conversation with the tool's response. - -// `StopReason.out_of_tokens`: The model ran out of token budget. -type CompletionMessageStopReason string - -const ( - CompletionMessageStopReasonEndOfTurn CompletionMessageStopReason = "end_of_turn" - CompletionMessageStopReasonEndOfMessage CompletionMessageStopReason = "end_of_message" - CompletionMessageStopReasonOutOfTokens CompletionMessageStopReason = "out_of_tokens" -) - -// A message containing the model's (assistant) response in a chat conversation. -// -// The properties Content, Role, StopReason are required. -type CompletionMessageParam struct { - // The content of the model's response - Content InterleavedContentUnionParam `json:"content,omitzero,required"` - // Reason why the model stopped generating. Options are: - - // `StopReason.end_of_turn`: The model finished generating the entire response. - - // `StopReason.end_of_message`: The model finished generating but generated a - // partial response -- usually, a tool call. The user may call the tool and - // continue the conversation with the tool's response. - - // `StopReason.out_of_tokens`: The model ran out of token budget. - // - // Any of "end_of_turn", "end_of_message", "out_of_tokens". - StopReason CompletionMessageStopReason `json:"stop_reason,omitzero,required"` - // List of tool calls. Each tool call is a ToolCall object. - ToolCalls []ToolCallParam `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"` - paramObj -} - -func (r CompletionMessageParam) MarshalJSON() (data []byte, err error) { - type shadow CompletionMessageParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *CompletionMessageParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ContentDeltaUnion contains all possible properties and values from -// [ContentDeltaText], [ContentDeltaImage], [ContentDeltaToolCall]. -// -// Use the [ContentDeltaUnion.AsAny] method to switch on the variant. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -type ContentDeltaUnion struct { - // This field is from variant [ContentDeltaText]. - Text string `json:"text"` - // Any of "text", "image", "tool_call". - Type string `json:"type"` - // This field is from variant [ContentDeltaImage]. - Image string `json:"image"` - // This field is from variant [ContentDeltaToolCall]. - ParseStatus string `json:"parse_status"` - // This field is from variant [ContentDeltaToolCall]. - ToolCall ToolCallOrStringUnion `json:"tool_call"` - JSON struct { - Text respjson.Field - Type respjson.Field - Image respjson.Field - ParseStatus respjson.Field - ToolCall respjson.Field - raw string - } `json:"-"` -} - -// anyContentDelta is implemented by each variant of [ContentDeltaUnion] to add -// type safety for the return type of [ContentDeltaUnion.AsAny] -type anyContentDelta interface { - implContentDeltaUnion() -} - -// Use the following switch statement to find the correct variant -// -// switch variant := ContentDeltaUnion.AsAny().(type) { -// case shared.ContentDeltaText: -// case shared.ContentDeltaImage: -// case shared.ContentDeltaToolCall: -// default: -// fmt.Errorf("no variant present") -// } -func (u ContentDeltaUnion) AsAny() anyContentDelta { - switch u.Type { - case "text": - return u.AsText() - case "image": - return u.AsImage() - case "tool_call": - return u.AsToolCall() - } - return nil -} - -func (u ContentDeltaUnion) AsText() (v ContentDeltaText) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ContentDeltaUnion) AsImage() (v ContentDeltaImage) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ContentDeltaUnion) AsToolCall() (v ContentDeltaToolCall) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ContentDeltaUnion) RawJSON() string { return u.JSON.raw } - -func (r *ContentDeltaUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A text content delta for streaming responses. -type ContentDeltaText struct { - // The incremental text content - Text string `json:"text,required"` - // Discriminator type of the delta. 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:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ContentDeltaText) RawJSON() string { return r.JSON.raw } -func (r *ContentDeltaText) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -func (ContentDeltaText) implContentDeltaUnion() {} - -// An image content delta for streaming responses. -type ContentDeltaImage struct { - // The incremental image data as bytes - Image string `json:"image,required"` - // Discriminator type of the delta. 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 ContentDeltaImage) RawJSON() string { return r.JSON.raw } -func (r *ContentDeltaImage) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -func (ContentDeltaImage) implContentDeltaUnion() {} - -// A tool call content delta for streaming responses. -type ContentDeltaToolCall struct { - // Current parsing status of the tool call - // - // Any of "started", "in_progress", "failed", "succeeded". - ParseStatus string `json:"parse_status,required"` - // Either an in-progress tool call string or the final parsed tool call - ToolCall ToolCallOrStringUnion `json:"tool_call,required"` - // Discriminator type of the delta. Always "tool_call" - Type constant.ToolCall `json:"type,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - ParseStatus respjson.Field - ToolCall respjson.Field - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ContentDeltaToolCall) RawJSON() string { return r.JSON.raw } -func (r *ContentDeltaToolCall) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -func (ContentDeltaToolCall) implContentDeltaUnion() {} - -// A document to be used for document ingestion in the RAG Tool. -// -// The properties Content, DocumentID, Metadata are required. -type DocumentParam struct { - // The content of the document. - Content DocumentContentUnionParam `json:"content,omitzero,required"` - // The unique identifier for the document. - DocumentID string `json:"document_id,required"` - // Additional metadata for the document. - Metadata map[string]DocumentMetadataUnionParam `json:"metadata,omitzero,required"` - // The MIME type of the document. - MimeType param.Opt[string] `json:"mime_type,omitzero"` - paramObj -} - -func (r DocumentParam) MarshalJSON() (data []byte, err error) { - type shadow DocumentParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *DocumentParam) 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 DocumentContentUnionParam struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfImageContentItem *DocumentContentImageContentItemParam `json:",omitzero,inline"` - OfTextContentItem *DocumentContentTextContentItemParam `json:",omitzero,inline"` - OfInterleavedContentItemArray []InterleavedContentItemUnionParam `json:",omitzero,inline"` - OfURL *DocumentContentURLParam `json:",omitzero,inline"` - paramUnion -} - -func (u DocumentContentUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, - u.OfImageContentItem, - u.OfTextContentItem, - u.OfInterleavedContentItemArray, - u.OfURL) -} -func (u *DocumentContentUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *DocumentContentUnionParam) 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 - } else if !param.IsOmitted(u.OfURL) { - return u.OfURL - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u DocumentContentUnionParam) GetImage() *DocumentContentImageContentItemImageParam { - if vt := u.OfImageContentItem; vt != nil { - return &vt.Image - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u DocumentContentUnionParam) 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 DocumentContentUnionParam) GetUri() *string { - if vt := u.OfURL; vt != nil { - return &vt.Uri - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u DocumentContentUnionParam) GetType() *string { - if vt := u.OfImageContentItem; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfTextContentItem; vt != nil { - return (*string)(&vt.Type) - } - return nil -} - -// A image content item -// -// The properties Image, Type are required. -type DocumentContentImageContentItemParam struct { - // Image as a base64 encoded string or an URL - Image DocumentContentImageContentItemImageParam `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 -} - -func (r DocumentContentImageContentItemParam) MarshalJSON() (data []byte, err error) { - type shadow DocumentContentImageContentItemParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *DocumentContentImageContentItemParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Image as a base64 encoded string or an URL -type DocumentContentImageContentItemImageParam 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 DocumentContentImageContentItemImageURLParam `json:"url,omitzero"` - paramObj -} - -func (r DocumentContentImageContentItemImageParam) MarshalJSON() (data []byte, err error) { - type shadow DocumentContentImageContentItemImageParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *DocumentContentImageContentItemImageParam) 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 DocumentContentImageContentItemImageURLParam struct { - // The URL string pointing to the resource - Uri string `json:"uri,required"` - paramObj -} - -func (r DocumentContentImageContentItemImageURLParam) MarshalJSON() (data []byte, err error) { - type shadow DocumentContentImageContentItemImageURLParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *DocumentContentImageContentItemImageURLParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A text content item -// -// The properties Text, Type are required. -type DocumentContentTextContentItemParam 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"` - paramObj -} - -func (r DocumentContentTextContentItemParam) MarshalJSON() (data []byte, err error) { - type shadow DocumentContentTextContentItemParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *DocumentContentTextContentItemParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A URL reference to external content. -// -// The property Uri is required. -type DocumentContentURLParam struct { - // The URL string pointing to the resource - Uri string `json:"uri,required"` - paramObj -} - -func (r DocumentContentURLParam) MarshalJSON() (data []byte, err error) { - type shadow DocumentContentURLParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *DocumentContentURLParam) 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 DocumentMetadataUnionParam 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 DocumentMetadataUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *DocumentMetadataUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *DocumentMetadataUnionParam) 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 -} - -// 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 -} - -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 } - -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"` - // 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 InterleavedContentImageContentItem) RawJSON() string { return r.JSON.raw } -func (r *InterleavedContentImageContentItem) 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) -} - -// 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:"-"` -} - -// 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) -} - -// 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:"-"` -} - -// Returns the unmodified JSON received from the API -func (r InterleavedContentTextContentItem) RawJSON() string { return r.JSON.raw } -func (r *InterleavedContentTextContentItem) 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"` - paramUnion -} - -func (u InterleavedContentUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfImageContentItem, u.OfTextContentItem, u.OfInterleavedContentItemArray) -} -func (u *InterleavedContentUnionParam) 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 - } - 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 - } - 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 - } - 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) - } - 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 -} - -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) -} - -// 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"` - paramObj -} - -func (r InterleavedContentImageContentItemImageParam) MarshalJSON() (data []byte, err error) { - type shadow InterleavedContentImageContentItemImageParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *InterleavedContentImageContentItemImageParam) 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) -} - -// A text content item -// -// 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"` - paramObj -} - -func (r InterleavedContentTextContentItemParam) MarshalJSON() (data []byte, err error) { - type shadow InterleavedContentTextContentItemParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *InterleavedContentTextContentItemParam) 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() -} - -// Use the following switch statement to find the correct variant -// -// switch variant := InterleavedContentItemUnion.AsAny().(type) { -// case shared.InterleavedContentItemImage: -// case shared.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 -} - -func (u InterleavedContentItemUnion) AsText() (v InterleavedContentItemText) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u InterleavedContentItemUnion) RawJSON() string { return u.JSON.raw } - -func (r *InterleavedContentItemUnion) 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 (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"` - // 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 InterleavedContentItemImageImage) RawJSON() string { return r.JSON.raw } -func (r *InterleavedContentItemImageImage) 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 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:"-"` -} - -// Returns the unmodified JSON received from the API -func (r InterleavedContentItemText) RawJSON() string { return r.JSON.raw } -func (r *InterleavedContentItemText) 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"` - paramUnion -} - -func (u InterleavedContentItemUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfImage, u.OfText) -} -func (u *InterleavedContentItemUnionParam) 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 - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u InterleavedContentItemUnionParam) GetImage() *InterleavedContentItemImageImageParam { - if vt := u.OfImage; 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 { - 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 { - return (*string)(&vt.Type) - } else if vt := u.OfText; 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"` - paramObj -} - -func (r InterleavedContentItemImageParam) MarshalJSON() (data []byte, err error) { - type shadow InterleavedContentItemImageParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *InterleavedContentItemImageParam) 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 - 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"` - paramObj -} - -func (r InterleavedContentItemImageImageParam) MarshalJSON() (data []byte, err error) { - type shadow InterleavedContentItemImageImageParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *InterleavedContentItemImageImageParam) 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 InterleavedContentItemImageImageURLParam struct { - // The URL string pointing to the resource - Uri string `json:"uri,required"` - paramObj -} - -func (r InterleavedContentItemImageImageURLParam) MarshalJSON() (data []byte, err error) { - type shadow InterleavedContentItemImageImageURLParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *InterleavedContentItemImageImageURLParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A text content item -// -// The properties Text, Type are required. -type InterleavedContentItemTextParam 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"` - paramObj -} - -func (r InterleavedContentItemTextParam) MarshalJSON() (data []byte, err error) { - type shadow InterleavedContentItemTextParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *InterleavedContentItemTextParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -func MessageParamOfUser[ - T string | InterleavedContentImageContentItemParam | InterleavedContentTextContentItemParam | []InterleavedContentItemUnionParam, -](content T) MessageUnionParam { - var user UserMessageParam - switch v := any(content).(type) { - case string: - user.Content.OfString = param.NewOpt(v) - case InterleavedContentImageContentItemParam: - user.Content.OfImageContentItem = &v - case InterleavedContentTextContentItemParam: - user.Content.OfTextContentItem = &v - case []InterleavedContentItemUnionParam: - user.Content.OfInterleavedContentItemArray = v - } - return MessageUnionParam{OfUser: &user} -} - -func MessageParamOfSystem[ - T string | InterleavedContentImageContentItemParam | InterleavedContentTextContentItemParam | []InterleavedContentItemUnionParam, -](content T) MessageUnionParam { - var system SystemMessageParam - switch v := any(content).(type) { - case string: - system.Content.OfString = param.NewOpt(v) - case InterleavedContentImageContentItemParam: - system.Content.OfImageContentItem = &v - case InterleavedContentTextContentItemParam: - system.Content.OfTextContentItem = &v - case []InterleavedContentItemUnionParam: - system.Content.OfInterleavedContentItemArray = v - } - return MessageUnionParam{OfSystem: &system} -} - -func MessageParamOfTool[ - T string | InterleavedContentImageContentItemParam | InterleavedContentTextContentItemParam | []InterleavedContentItemUnionParam, -](callID string, content T) MessageUnionParam { - var tool ToolResponseMessageParam - tool.CallID = callID - switch v := any(content).(type) { - case string: - tool.Content.OfString = param.NewOpt(v) - case InterleavedContentImageContentItemParam: - tool.Content.OfImageContentItem = &v - case InterleavedContentTextContentItemParam: - tool.Content.OfTextContentItem = &v - case []InterleavedContentItemUnionParam: - tool.Content.OfInterleavedContentItemArray = v - } - return MessageUnionParam{OfTool: &tool} -} - -func MessageParamOfAssistant[ - T string | InterleavedContentImageContentItemParam | InterleavedContentTextContentItemParam | []InterleavedContentItemUnionParam, -](content T, stopReason CompletionMessageStopReason) MessageUnionParam { - var assistant CompletionMessageParam - switch v := any(content).(type) { - case string: - assistant.Content.OfString = param.NewOpt(v) - case InterleavedContentImageContentItemParam: - assistant.Content.OfImageContentItem = &v - case InterleavedContentTextContentItemParam: - assistant.Content.OfTextContentItem = &v - case []InterleavedContentItemUnionParam: - assistant.Content.OfInterleavedContentItemArray = v - } - assistant.StopReason = stopReason - return MessageUnionParam{OfAssistant: &assistant} -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type MessageUnionParam struct { - OfUser *UserMessageParam `json:",omitzero,inline"` - OfSystem *SystemMessageParam `json:",omitzero,inline"` - OfTool *ToolResponseMessageParam `json:",omitzero,inline"` - OfAssistant *CompletionMessageParam `json:",omitzero,inline"` - paramUnion -} - -func (u MessageUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfUser, u.OfSystem, u.OfTool, u.OfAssistant) -} -func (u *MessageUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *MessageUnionParam) asAny() any { - if !param.IsOmitted(u.OfUser) { - return u.OfUser - } else if !param.IsOmitted(u.OfSystem) { - return u.OfSystem - } else if !param.IsOmitted(u.OfTool) { - return u.OfTool - } else if !param.IsOmitted(u.OfAssistant) { - return u.OfAssistant - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u MessageUnionParam) GetContext() *InterleavedContentUnionParam { - if vt := u.OfUser; vt != nil { - return &vt.Context - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u MessageUnionParam) GetCallID() *string { - if vt := u.OfTool; vt != nil { - return &vt.CallID - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u MessageUnionParam) GetStopReason() *string { - if vt := u.OfAssistant; vt != nil { - return (*string)(&vt.StopReason) - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u MessageUnionParam) GetToolCalls() []ToolCallParam { - if vt := u.OfAssistant; vt != nil { - return vt.ToolCalls - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u MessageUnionParam) GetRole() *string { - if vt := u.OfUser; vt != nil { - return (*string)(&vt.Role) - } else if vt := u.OfSystem; vt != nil { - return (*string)(&vt.Role) - } else if vt := u.OfTool; vt != nil { - return (*string)(&vt.Role) - } else if vt := u.OfAssistant; vt != nil { - return (*string)(&vt.Role) - } - return nil -} - -// Returns a pointer to the underlying variant's Content property, if present. -func (u MessageUnionParam) GetContent() *InterleavedContentUnionParam { - if vt := u.OfUser; vt != nil { - return &vt.Content - } else if vt := u.OfSystem; vt != nil { - return &vt.Content - } else if vt := u.OfTool; vt != nil { - return &vt.Content - } else if vt := u.OfAssistant; vt != nil { - return &vt.Content - } - return nil -} - -func init() { - apijson.RegisterUnion[MessageUnionParam]( - "role", - apijson.Discriminator[UserMessageParam]("user"), - apijson.Discriminator[SystemMessageParam]("system"), - apijson.Discriminator[ToolResponseMessageParam]("tool"), - apijson.Discriminator[CompletionMessageParam]("assistant"), - ) -} - -// Configuration for the RAG query generation. -// -// The properties ChunkTemplate, MaxChunks, MaxTokensInContext, -// QueryGeneratorConfig are required. -type QueryConfigParam struct { - // Template for formatting each retrieved chunk in the context. Available - // placeholders: {index} (1-based chunk ordinal), {chunk.content} (chunk content - // string), {metadata} (chunk metadata dict). Default: "Result {index}\nContent: - // {chunk.content}\nMetadata: {metadata}\n" - ChunkTemplate string `json:"chunk_template,required"` - // Maximum number of chunks to retrieve. - MaxChunks int64 `json:"max_chunks,required"` - // Maximum number of tokens in the context. - MaxTokensInContext int64 `json:"max_tokens_in_context,required"` - // Configuration for the query generator. - QueryGeneratorConfig QueryGeneratorConfigUnionParam `json:"query_generator_config,omitzero,required"` - // Search mode for retrieval—either "vector", "keyword", or "hybrid". Default - // "vector". - // - // Any of "vector", "keyword", "hybrid". - Mode QueryConfigMode `json:"mode,omitzero"` - // Configuration for the ranker to use in hybrid search. Defaults to RRF ranker. - Ranker QueryConfigRankerUnionParam `json:"ranker,omitzero"` - paramObj -} - -func (r QueryConfigParam) MarshalJSON() (data []byte, err error) { - type shadow QueryConfigParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *QueryConfigParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Search mode for retrieval—either "vector", "keyword", or "hybrid". Default -// "vector". -type QueryConfigMode string - -const ( - QueryConfigModeVector QueryConfigMode = "vector" - QueryConfigModeKeyword QueryConfigMode = "keyword" - QueryConfigModeHybrid QueryConfigMode = "hybrid" -) - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type QueryConfigRankerUnionParam struct { - OfRrf *QueryConfigRankerRrfParam `json:",omitzero,inline"` - OfWeighted *QueryConfigRankerWeightedParam `json:",omitzero,inline"` - paramUnion -} - -func (u QueryConfigRankerUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfRrf, u.OfWeighted) -} -func (u *QueryConfigRankerUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *QueryConfigRankerUnionParam) asAny() any { - if !param.IsOmitted(u.OfRrf) { - return u.OfRrf - } else if !param.IsOmitted(u.OfWeighted) { - return u.OfWeighted - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u QueryConfigRankerUnionParam) GetImpactFactor() *float64 { - if vt := u.OfRrf; vt != nil { - return &vt.ImpactFactor - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u QueryConfigRankerUnionParam) GetAlpha() *float64 { - if vt := u.OfWeighted; vt != nil { - return &vt.Alpha - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u QueryConfigRankerUnionParam) GetType() *string { - if vt := u.OfRrf; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfWeighted; vt != nil { - return (*string)(&vt.Type) - } - return nil -} - -func init() { - apijson.RegisterUnion[QueryConfigRankerUnionParam]( - "type", - apijson.Discriminator[QueryConfigRankerRrfParam]("rrf"), - apijson.Discriminator[QueryConfigRankerWeightedParam]("weighted"), - ) -} - -// Reciprocal Rank Fusion (RRF) ranker configuration. -// -// The properties ImpactFactor, Type are required. -type QueryConfigRankerRrfParam struct { - // The impact factor for RRF scoring. Higher values give more weight to - // higher-ranked results. Must be greater than 0 - ImpactFactor float64 `json:"impact_factor,required"` - // The type of ranker, always "rrf" - // - // This field can be elided, and will marshal its zero value as "rrf". - Type constant.Rrf `json:"type,required"` - paramObj -} - -func (r QueryConfigRankerRrfParam) MarshalJSON() (data []byte, err error) { - type shadow QueryConfigRankerRrfParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *QueryConfigRankerRrfParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Weighted ranker configuration that combines vector and keyword scores. -// -// The properties Alpha, Type are required. -type QueryConfigRankerWeightedParam struct { - // Weight factor between 0 and 1. 0 means only use keyword scores, 1 means only use - // vector scores, values in between blend both scores. - Alpha float64 `json:"alpha,required"` - // The type of ranker, always "weighted" - // - // This field can be elided, and will marshal its zero value as "weighted". - Type constant.Weighted `json:"type,required"` - paramObj -} - -func (r QueryConfigRankerWeightedParam) MarshalJSON() (data []byte, err error) { - type shadow QueryConfigRankerWeightedParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *QueryConfigRankerWeightedParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -func QueryGeneratorConfigParamOfDefault(separator string) QueryGeneratorConfigUnionParam { - var default_ QueryGeneratorConfigDefaultParam - default_.Separator = separator - return QueryGeneratorConfigUnionParam{OfDefault: &default_} -} - -func QueryGeneratorConfigParamOfLlm(model string, template string) QueryGeneratorConfigUnionParam { - var llm QueryGeneratorConfigLlmParam - llm.Model = model - llm.Template = template - return QueryGeneratorConfigUnionParam{OfLlm: &llm} -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type QueryGeneratorConfigUnionParam struct { - OfDefault *QueryGeneratorConfigDefaultParam `json:",omitzero,inline"` - OfLlm *QueryGeneratorConfigLlmParam `json:",omitzero,inline"` - paramUnion -} - -func (u QueryGeneratorConfigUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfDefault, u.OfLlm) -} -func (u *QueryGeneratorConfigUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *QueryGeneratorConfigUnionParam) asAny() any { - if !param.IsOmitted(u.OfDefault) { - return u.OfDefault - } else if !param.IsOmitted(u.OfLlm) { - return u.OfLlm - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u QueryGeneratorConfigUnionParam) GetSeparator() *string { - if vt := u.OfDefault; vt != nil { - return &vt.Separator - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u QueryGeneratorConfigUnionParam) GetModel() *string { - if vt := u.OfLlm; vt != nil { - return &vt.Model - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u QueryGeneratorConfigUnionParam) GetTemplate() *string { - if vt := u.OfLlm; vt != nil { - return &vt.Template - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u QueryGeneratorConfigUnionParam) GetType() *string { - if vt := u.OfDefault; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfLlm; vt != nil { - return (*string)(&vt.Type) - } - return nil -} - -func init() { - apijson.RegisterUnion[QueryGeneratorConfigUnionParam]( - "type", - apijson.Discriminator[QueryGeneratorConfigDefaultParam]("default"), - apijson.Discriminator[QueryGeneratorConfigLlmParam]("llm"), - ) -} - -// Configuration for the default RAG query generator. -// -// The properties Separator, Type are required. -type QueryGeneratorConfigDefaultParam struct { - // String separator used to join query terms - Separator string `json:"separator,required"` - // Type of query generator, always 'default' - // - // This field can be elided, and will marshal its zero value as "default". - Type constant.Default `json:"type,required"` - paramObj -} - -func (r QueryGeneratorConfigDefaultParam) MarshalJSON() (data []byte, err error) { - type shadow QueryGeneratorConfigDefaultParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *QueryGeneratorConfigDefaultParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Configuration for the LLM-based RAG query generator. -// -// The properties Model, Template, Type are required. -type QueryGeneratorConfigLlmParam struct { - // Name of the language model to use for query generation - Model string `json:"model,required"` - // Template string for formatting the query generation prompt - Template string `json:"template,required"` - // Type of query generator, always 'llm' - // - // This field can be elided, and will marshal its zero value as "llm". - Type constant.Llm `json:"type,required"` - paramObj -} - -func (r QueryGeneratorConfigLlmParam) MarshalJSON() (data []byte, err error) { - type shadow QueryGeneratorConfigLlmParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *QueryGeneratorConfigLlmParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Result of a RAG query containing retrieved content and metadata. -type QueryResult struct { - // Additional metadata about the query result - Metadata map[string]QueryResultMetadataUnion `json:"metadata,required"` - // (Optional) The retrieved content from the query - Content InterleavedContentUnion `json:"content"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Metadata respjson.Field - Content respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r QueryResult) RawJSON() string { return r.JSON.raw } -func (r *QueryResult) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// QueryResultMetadataUnion 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 QueryResultMetadataUnion 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 QueryResultMetadataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u QueryResultMetadataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u QueryResultMetadataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u QueryResultMetadataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u QueryResultMetadataUnion) RawJSON() string { return u.JSON.raw } - -func (r *QueryResultMetadataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ResponseFormatUnion contains all possible properties and values from -// [ResponseFormatJsonSchema], [ResponseFormatGrammar]. -// -// Use the [ResponseFormatUnion.AsAny] method to switch on the variant. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -type ResponseFormatUnion struct { - // This field is from variant [ResponseFormatJsonSchema]. - JsonSchema map[string]ResponseFormatJsonSchemaJsonSchemaUnion `json:"json_schema"` - // Any of "json_schema", "grammar". - Type string `json:"type"` - // This field is from variant [ResponseFormatGrammar]. - Bnf map[string]ResponseFormatGrammarBnfUnion `json:"bnf"` - JSON struct { - JsonSchema respjson.Field - Type respjson.Field - Bnf respjson.Field - raw string - } `json:"-"` -} - -// anyResponseFormat is implemented by each variant of [ResponseFormatUnion] to add -// type safety for the return type of [ResponseFormatUnion.AsAny] -type anyResponseFormat interface { - implResponseFormatUnion() -} - -// Use the following switch statement to find the correct variant -// -// switch variant := ResponseFormatUnion.AsAny().(type) { -// case shared.ResponseFormatJsonSchema: -// case shared.ResponseFormatGrammar: -// default: -// fmt.Errorf("no variant present") -// } -func (u ResponseFormatUnion) AsAny() anyResponseFormat { - switch u.Type { - case "json_schema": - return u.AsJsonSchema() - case "grammar": - return u.AsGrammar() - } - return nil -} - -func (u ResponseFormatUnion) AsJsonSchema() (v ResponseFormatJsonSchema) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseFormatUnion) AsGrammar() (v ResponseFormatGrammar) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ResponseFormatUnion) RawJSON() string { return u.JSON.raw } - -func (r *ResponseFormatUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ToParam converts this ResponseFormatUnion to a ResponseFormatUnionParam. -// -// 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 -// ResponseFormatUnionParam.Overrides() -func (r ResponseFormatUnion) ToParam() ResponseFormatUnionParam { - return param.Override[ResponseFormatUnionParam](json.RawMessage(r.RawJSON())) -} - -// Configuration for JSON schema-guided response generation. -type ResponseFormatJsonSchema struct { - // The JSON schema the response should conform to. In a Python SDK, this is often a - // `pydantic` model. - JsonSchema map[string]ResponseFormatJsonSchemaJsonSchemaUnion `json:"json_schema,required"` - // Must be "json_schema" to identify this format type - Type constant.JsonSchema `json:"type,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - JsonSchema respjson.Field - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ResponseFormatJsonSchema) RawJSON() string { return r.JSON.raw } -func (r *ResponseFormatJsonSchema) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -func (ResponseFormatJsonSchema) implResponseFormatUnion() {} - -// ResponseFormatJsonSchemaJsonSchemaUnion 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 ResponseFormatJsonSchemaJsonSchemaUnion 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 ResponseFormatJsonSchemaJsonSchemaUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseFormatJsonSchemaJsonSchemaUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseFormatJsonSchemaJsonSchemaUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseFormatJsonSchemaJsonSchemaUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ResponseFormatJsonSchemaJsonSchemaUnion) RawJSON() string { return u.JSON.raw } - -func (r *ResponseFormatJsonSchemaJsonSchemaUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Configuration for grammar-guided response generation. -type ResponseFormatGrammar struct { - // The BNF grammar specification the response should conform to - Bnf map[string]ResponseFormatGrammarBnfUnion `json:"bnf,required"` - // Must be "grammar" to identify this format type - Type constant.Grammar `json:"type,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Bnf respjson.Field - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ResponseFormatGrammar) RawJSON() string { return r.JSON.raw } -func (r *ResponseFormatGrammar) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -func (ResponseFormatGrammar) implResponseFormatUnion() {} - -// ResponseFormatGrammarBnfUnion 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 ResponseFormatGrammarBnfUnion 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 ResponseFormatGrammarBnfUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseFormatGrammarBnfUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseFormatGrammarBnfUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ResponseFormatGrammarBnfUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ResponseFormatGrammarBnfUnion) RawJSON() string { return u.JSON.raw } - -func (r *ResponseFormatGrammarBnfUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -func ResponseFormatParamOfJsonSchema(jsonSchema map[string]ResponseFormatJsonSchemaJsonSchemaUnionParam) ResponseFormatUnionParam { - var variant ResponseFormatJsonSchemaParam - variant.JsonSchema = jsonSchema - return ResponseFormatUnionParam{OfJsonSchema: &variant} -} - -func ResponseFormatParamOfGrammar(bnf map[string]ResponseFormatGrammarBnfUnionParam) ResponseFormatUnionParam { - var grammar ResponseFormatGrammarParam - grammar.Bnf = bnf - return ResponseFormatUnionParam{OfGrammar: &grammar} -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ResponseFormatUnionParam struct { - OfJsonSchema *ResponseFormatJsonSchemaParam `json:",omitzero,inline"` - OfGrammar *ResponseFormatGrammarParam `json:",omitzero,inline"` - paramUnion -} - -func (u ResponseFormatUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfJsonSchema, u.OfGrammar) -} -func (u *ResponseFormatUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ResponseFormatUnionParam) asAny() any { - if !param.IsOmitted(u.OfJsonSchema) { - return u.OfJsonSchema - } else if !param.IsOmitted(u.OfGrammar) { - return u.OfGrammar - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u ResponseFormatUnionParam) GetJsonSchema() map[string]ResponseFormatJsonSchemaJsonSchemaUnionParam { - if vt := u.OfJsonSchema; vt != nil { - return vt.JsonSchema - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u ResponseFormatUnionParam) GetBnf() map[string]ResponseFormatGrammarBnfUnionParam { - if vt := u.OfGrammar; vt != nil { - return vt.Bnf - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u ResponseFormatUnionParam) GetType() *string { - if vt := u.OfJsonSchema; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfGrammar; vt != nil { - return (*string)(&vt.Type) - } - return nil -} - -func init() { - apijson.RegisterUnion[ResponseFormatUnionParam]( - "type", - apijson.Discriminator[ResponseFormatJsonSchemaParam]("json_schema"), - apijson.Discriminator[ResponseFormatGrammarParam]("grammar"), - ) -} - -// Configuration for JSON schema-guided response generation. -// -// The properties JsonSchema, Type are required. -type ResponseFormatJsonSchemaParam struct { - // The JSON schema the response should conform to. In a Python SDK, this is often a - // `pydantic` model. - JsonSchema map[string]ResponseFormatJsonSchemaJsonSchemaUnionParam `json:"json_schema,omitzero,required"` - // Must be "json_schema" to identify this format type - // - // This field can be elided, and will marshal its zero value as "json_schema". - Type constant.JsonSchema `json:"type,required"` - paramObj -} - -func (r ResponseFormatJsonSchemaParam) MarshalJSON() (data []byte, err error) { - type shadow ResponseFormatJsonSchemaParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *ResponseFormatJsonSchemaParam) 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 ResponseFormatJsonSchemaJsonSchemaUnionParam 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 ResponseFormatJsonSchemaJsonSchemaUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *ResponseFormatJsonSchemaJsonSchemaUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ResponseFormatJsonSchemaJsonSchemaUnionParam) 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 -} - -// Configuration for grammar-guided response generation. -// -// The properties Bnf, Type are required. -type ResponseFormatGrammarParam struct { - // The BNF grammar specification the response should conform to - Bnf map[string]ResponseFormatGrammarBnfUnionParam `json:"bnf,omitzero,required"` - // Must be "grammar" to identify this format type - // - // This field can be elided, and will marshal its zero value as "grammar". - Type constant.Grammar `json:"type,required"` - paramObj -} - -func (r ResponseFormatGrammarParam) MarshalJSON() (data []byte, err error) { - type shadow ResponseFormatGrammarParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *ResponseFormatGrammarParam) 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 ResponseFormatGrammarBnfUnionParam 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 ResponseFormatGrammarBnfUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *ResponseFormatGrammarBnfUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ResponseFormatGrammarBnfUnionParam) 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 ReturnType struct { - // Any of "string", "number", "boolean", "array", "object", "json", "union", - // "chat_completion_input", "completion_input", "agent_turn_input". - Type ReturnTypeType `json:"type,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ReturnType) RawJSON() string { return r.JSON.raw } -func (r *ReturnType) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ToParam converts this ReturnType to a ReturnTypeParam. -// -// 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 -// ReturnTypeParam.Overrides() -func (r ReturnType) ToParam() ReturnTypeParam { - return param.Override[ReturnTypeParam](json.RawMessage(r.RawJSON())) -} - -type ReturnTypeType string - -const ( - ReturnTypeTypeString ReturnTypeType = "string" - ReturnTypeTypeNumber ReturnTypeType = "number" - ReturnTypeTypeBoolean ReturnTypeType = "boolean" - ReturnTypeTypeArray ReturnTypeType = "array" - ReturnTypeTypeObject ReturnTypeType = "object" - ReturnTypeTypeJson ReturnTypeType = "json" - ReturnTypeTypeUnion ReturnTypeType = "union" - ReturnTypeTypeChatCompletionInput ReturnTypeType = "chat_completion_input" - ReturnTypeTypeCompletionInput ReturnTypeType = "completion_input" - ReturnTypeTypeAgentTurnInput ReturnTypeType = "agent_turn_input" -) - -// The property Type is required. -type ReturnTypeParam struct { - // Any of "string", "number", "boolean", "array", "object", "json", "union", - // "chat_completion_input", "completion_input", "agent_turn_input". - Type ReturnTypeType `json:"type,omitzero,required"` - paramObj -} - -func (r ReturnTypeParam) MarshalJSON() (data []byte, err error) { - type shadow ReturnTypeParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *ReturnTypeParam) 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 { - 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. -type SamplingParamsResp struct { - // The sampling strategy. - Strategy SamplingParamsStrategyUnionResp `json:"strategy,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 int64 `json:"max_tokens"` - // 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 float64 `json:"repetition_penalty"` - // 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"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Strategy respjson.Field - MaxTokens respjson.Field - RepetitionPenalty respjson.Field - Stop respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r SamplingParamsResp) RawJSON() string { return r.JSON.raw } -func (r *SamplingParamsResp) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ToParam converts this SamplingParamsResp to a SamplingParams. -// -// 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 -// SamplingParams.Overrides() -func (r SamplingParamsResp) ToParam() SamplingParams { - return param.Override[SamplingParams](json.RawMessage(r.RawJSON())) -} - -// SamplingParamsStrategyUnionResp contains all possible properties and values from -// [SamplingParamsStrategyGreedyResp], [SamplingParamsStrategyTopPResp], -// [SamplingParamsStrategyTopKResp]. -// -// Use the [SamplingParamsStrategyUnionResp.AsAny] method to switch on the variant. -// -// Use the methods beginning with 'As' to cast the union to one of its variants. -type SamplingParamsStrategyUnionResp struct { - // Any of "greedy", "top_p", "top_k". - Type string `json:"type"` - // This field is from variant [SamplingParamsStrategyTopPResp]. - Temperature float64 `json:"temperature"` - // This field is from variant [SamplingParamsStrategyTopPResp]. - TopP float64 `json:"top_p"` - // This field is from variant [SamplingParamsStrategyTopKResp]. - TopK int64 `json:"top_k"` - JSON struct { - Type respjson.Field - Temperature respjson.Field - TopP respjson.Field - TopK respjson.Field - raw string - } `json:"-"` -} - -// anySamplingParamsStrategyResp is implemented by each variant of -// [SamplingParamsStrategyUnionResp] to add type safety for the return type of -// [SamplingParamsStrategyUnionResp.AsAny] -type anySamplingParamsStrategyResp interface { - implSamplingParamsStrategyUnionResp() -} - -// Use the following switch statement to find the correct variant -// -// switch variant := SamplingParamsStrategyUnionResp.AsAny().(type) { -// case shared.SamplingParamsStrategyGreedyResp: -// case shared.SamplingParamsStrategyTopPResp: -// case shared.SamplingParamsStrategyTopKResp: -// default: -// fmt.Errorf("no variant present") -// } -func (u SamplingParamsStrategyUnionResp) AsAny() anySamplingParamsStrategyResp { - switch u.Type { - case "greedy": - return u.AsGreedy() - case "top_p": - return u.AsTopP() - case "top_k": - return u.AsTopK() - } - return nil -} - -func (u SamplingParamsStrategyUnionResp) AsGreedy() (v SamplingParamsStrategyGreedyResp) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u SamplingParamsStrategyUnionResp) AsTopP() (v SamplingParamsStrategyTopPResp) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u SamplingParamsStrategyUnionResp) AsTopK() (v SamplingParamsStrategyTopKResp) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u SamplingParamsStrategyUnionResp) RawJSON() string { return u.JSON.raw } - -func (r *SamplingParamsStrategyUnionResp) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Greedy sampling strategy that selects the highest probability token at each -// step. -type SamplingParamsStrategyGreedyResp struct { - // Must be "greedy" to identify this sampling strategy - Type constant.Greedy `json:"type,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r SamplingParamsStrategyGreedyResp) RawJSON() string { return r.JSON.raw } -func (r *SamplingParamsStrategyGreedyResp) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -func (SamplingParamsStrategyGreedyResp) implSamplingParamsStrategyUnionResp() {} - -// Top-p (nucleus) sampling strategy that samples from the smallest set of tokens -// with cumulative probability >= p. -type SamplingParamsStrategyTopPResp struct { - // Must be "top_p" to identify this sampling strategy - Type constant.TopP `json:"type,required"` - // Controls randomness in sampling. Higher values increase randomness - Temperature float64 `json:"temperature"` - // Cumulative probability threshold for nucleus sampling. Defaults to 0.95 - TopP float64 `json:"top_p"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Type respjson.Field - Temperature respjson.Field - TopP respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r SamplingParamsStrategyTopPResp) RawJSON() string { return r.JSON.raw } -func (r *SamplingParamsStrategyTopPResp) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -func (SamplingParamsStrategyTopPResp) implSamplingParamsStrategyUnionResp() {} - -// Top-k sampling strategy that restricts sampling to the k most likely tokens. -type SamplingParamsStrategyTopKResp 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 - Type constant.TopK `json:"type,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - TopK respjson.Field - Type respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r SamplingParamsStrategyTopKResp) RawJSON() string { return r.JSON.raw } -func (r *SamplingParamsStrategyTopKResp) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -func (SamplingParamsStrategyTopKResp) implSamplingParamsStrategyUnionResp() {} - -// 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) -} - -// 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"` - paramUnion -} - -func (u SamplingParamsStrategyUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfGreedy, u.OfTopP, u.OfTopK) -} -func (u *SamplingParamsStrategyUnion) 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 - } - 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 - } - 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 - } - 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 { - return (*string)(&vt.Type) - } else if vt := u.OfTopK; vt != nil { - return (*string)(&vt.Type) - } - return nil -} - -func init() { - apijson.RegisterUnion[SamplingParamsStrategyUnion]( - "type", - apijson.Discriminator[SamplingParamsStrategyGreedy]("greedy"), - apijson.Discriminator[SamplingParamsStrategyTopP]("top_p"), - apijson.Discriminator[SamplingParamsStrategyTopK]("top_k"), - ) -} - -func NewSamplingParamsStrategyGreedy() SamplingParamsStrategyGreedy { - return SamplingParamsStrategyGreedy{ - Type: "greedy", - } -} - -// Greedy sampling strategy that selects the highest probability token at each -// step. -// -// 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"` - paramObj -} - -func (r SamplingParamsStrategyGreedy) MarshalJSON() (data []byte, err error) { - type shadow SamplingParamsStrategyGreedy - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *SamplingParamsStrategyGreedy) 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"` - paramObj -} - -func (r SamplingParamsStrategyTopP) MarshalJSON() (data []byte, err error) { - type shadow SamplingParamsStrategyTopP - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *SamplingParamsStrategyTopP) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Top-k sampling strategy that restricts sampling to the k most likely tokens. -// -// 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"` - paramObj -} - -func (r SamplingParamsStrategyTopK) MarshalJSON() (data []byte, err error) { - type shadow SamplingParamsStrategyTopK - 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 { - 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. -// -// 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 -} - -func (u ScoringResultAggregatedResultUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ScoringResultAggregatedResultUnion) RawJSON() string { return u.JSON.raw } - -func (r *ScoringResultAggregatedResultUnion) 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 -} - -// Returns the unmodified JSON received from the API -func (u ScoringResultScoreRowUnion) RawJSON() string { return u.JSON.raw } - -func (r *ScoringResultScoreRowUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Response from a completion request. -type SharedCompletionResponse struct { - // The generated completion text - Content string `json:"content,required"` - // Reason why generation stopped - // - // Any of "end_of_turn", "end_of_message", "out_of_tokens". - StopReason SharedCompletionResponseStopReason `json:"stop_reason,required"` - // Optional log probabilities for generated tokens - Logprobs []SharedCompletionResponseLogprob `json:"logprobs"` - // (Optional) List of metrics associated with the API response - Metrics []SharedCompletionResponseMetric `json:"metrics"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Content respjson.Field - StopReason respjson.Field - Logprobs respjson.Field - Metrics respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r SharedCompletionResponse) RawJSON() string { return r.JSON.raw } -func (r *SharedCompletionResponse) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Reason why generation stopped -type SharedCompletionResponseStopReason string - -const ( - SharedCompletionResponseStopReasonEndOfTurn SharedCompletionResponseStopReason = "end_of_turn" - SharedCompletionResponseStopReasonEndOfMessage SharedCompletionResponseStopReason = "end_of_message" - SharedCompletionResponseStopReasonOutOfTokens SharedCompletionResponseStopReason = "out_of_tokens" -) - -// Log probabilities for generated tokens. -type SharedCompletionResponseLogprob struct { - // Dictionary mapping tokens to their log probabilities - LogprobsByToken map[string]float64 `json:"logprobs_by_token,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - LogprobsByToken respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r SharedCompletionResponseLogprob) RawJSON() string { return r.JSON.raw } -func (r *SharedCompletionResponseLogprob) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A metric value included in API responses. -type SharedCompletionResponseMetric struct { - // The name of the metric - Metric string `json:"metric,required"` - // The numeric value of the metric - Value float64 `json:"value,required"` - // (Optional) The unit of measurement for the metric value - Unit string `json:"unit"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Metric respjson.Field - Value respjson.Field - Unit respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r SharedCompletionResponseMetric) RawJSON() string { return r.JSON.raw } -func (r *SharedCompletionResponseMetric) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Tool definition used in runtime contexts. -type SharedToolDef struct { - // Name of the tool - Name string `json:"name,required"` - // (Optional) Human-readable description of what the tool does - Description string `json:"description"` - // (Optional) Additional metadata about the tool - Metadata map[string]SharedToolDefMetadataUnion `json:"metadata"` - // (Optional) List of parameters this tool accepts - Parameters []SharedToolDefParameter `json:"parameters"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Name respjson.Field - Description respjson.Field - Metadata respjson.Field - Parameters respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r SharedToolDef) RawJSON() string { return r.JSON.raw } -func (r *SharedToolDef) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ToParam converts this SharedToolDef to a SharedToolDefParam. -// -// 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 -// SharedToolDefParam.Overrides() -func (r SharedToolDef) ToParam() SharedToolDefParam { - return param.Override[SharedToolDefParam](json.RawMessage(r.RawJSON())) -} - -// SharedToolDefMetadataUnion 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 SharedToolDefMetadataUnion 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 SharedToolDefMetadataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u SharedToolDefMetadataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u SharedToolDefMetadataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u SharedToolDefMetadataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u SharedToolDefMetadataUnion) RawJSON() string { return u.JSON.raw } - -func (r *SharedToolDefMetadataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Parameter definition for a tool. -type SharedToolDefParameter struct { - // Human-readable description of what the parameter does - Description string `json:"description,required"` - // Name of the parameter - Name string `json:"name,required"` - // Type of the parameter (e.g., string, integer) - ParameterType string `json:"parameter_type,required"` - // Whether this parameter is required for tool invocation - Required bool `json:"required,required"` - // (Optional) Default value for the parameter if not provided - Default SharedToolDefParameterDefaultUnion `json:"default,nullable"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Description respjson.Field - Name respjson.Field - ParameterType respjson.Field - Required respjson.Field - Default respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r SharedToolDefParameter) RawJSON() string { return r.JSON.raw } -func (r *SharedToolDefParameter) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// SharedToolDefParameterDefaultUnion 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 SharedToolDefParameterDefaultUnion 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 SharedToolDefParameterDefaultUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u SharedToolDefParameterDefaultUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u SharedToolDefParameterDefaultUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u SharedToolDefParameterDefaultUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u SharedToolDefParameterDefaultUnion) RawJSON() string { return u.JSON.raw } - -func (r *SharedToolDefParameterDefaultUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Tool definition used in runtime contexts. -// -// The property Name is required. -type SharedToolDefParam struct { - // Name of the tool - Name string `json:"name,required"` - // (Optional) Human-readable description of what the tool does - Description param.Opt[string] `json:"description,omitzero"` - // (Optional) Additional metadata about the tool - Metadata map[string]SharedToolDefMetadataUnionParam `json:"metadata,omitzero"` - // (Optional) List of parameters this tool accepts - Parameters []SharedToolDefParameterParam `json:"parameters,omitzero"` - paramObj -} - -func (r SharedToolDefParam) MarshalJSON() (data []byte, err error) { - type shadow SharedToolDefParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *SharedToolDefParam) 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 SharedToolDefMetadataUnionParam 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 SharedToolDefMetadataUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *SharedToolDefMetadataUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *SharedToolDefMetadataUnionParam) 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 -} - -// Parameter definition for a tool. -// -// The properties Description, Name, ParameterType, Required are required. -type SharedToolDefParameterParam struct { - // Human-readable description of what the parameter does - Description string `json:"description,required"` - // Name of the parameter - Name string `json:"name,required"` - // Type of the parameter (e.g., string, integer) - ParameterType string `json:"parameter_type,required"` - // Whether this parameter is required for tool invocation - Required bool `json:"required,required"` - // (Optional) Default value for the parameter if not provided - Default SharedToolDefParameterDefaultUnionParam `json:"default,omitzero"` - paramObj -} - -func (r SharedToolDefParameterParam) MarshalJSON() (data []byte, err error) { - type shadow SharedToolDefParameterParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *SharedToolDefParameterParam) 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 SharedToolDefParameterDefaultUnionParam 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 SharedToolDefParameterDefaultUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *SharedToolDefParameterDefaultUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *SharedToolDefParameterDefaultUnionParam) 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 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) -} - -type ToolCall struct { - Arguments ToolCallArgumentsUnion `json:"arguments,required"` - CallID string `json:"call_id,required"` - ToolName ToolCallToolName `json:"tool_name,required"` - ArgumentsJson string `json:"arguments_json"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Arguments respjson.Field - CallID respjson.Field - ToolName respjson.Field - ArgumentsJson respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ToolCall) RawJSON() string { return r.JSON.raw } -func (r *ToolCall) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ToParam converts this ToolCall to a ToolCallParam. -// -// 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 -// ToolCallParam.Overrides() -func (r ToolCall) ToParam() ToolCallParam { - return param.Override[ToolCallParam](json.RawMessage(r.RawJSON())) -} - -// ToolCallArgumentsUnion contains all possible properties and values from -// [string], [map[string]ToolCallArgumentsMapItemUnion]. -// -// 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 OfToolCallArgumentsMapItemArray] -type ToolCallArgumentsUnion 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"` - // This field will be present if the value is a - // [[]ToolCallArgumentsMapItemArrayItemUnion] instead of an object. - OfToolCallArgumentsMapItemArray []ToolCallArgumentsMapItemArrayItemUnion `json:",inline"` - JSON struct { - OfString respjson.Field - OfFloat respjson.Field - OfBool respjson.Field - OfToolCallArgumentsMapItemArray respjson.Field - raw string - } `json:"-"` -} - -func (u ToolCallArgumentsUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ToolCallArgumentsUnion) AsToolCallArgumentsMapMap() (v map[string]ToolCallArgumentsMapItemUnion) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ToolCallArgumentsUnion) RawJSON() string { return u.JSON.raw } - -func (r *ToolCallArgumentsUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ToolCallArgumentsMapItemUnion contains all possible properties and values from -// [string], [float64], [bool], [[]ToolCallArgumentsMapItemArrayItemUnion], -// [map[string]ToolCallArgumentsMapItemMapItemUnion]. -// -// 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 OfToolCallArgumentsMapItemArray] -type ToolCallArgumentsMapItemUnion 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"` - // This field will be present if the value is a - // [[]ToolCallArgumentsMapItemArrayItemUnion] instead of an object. - OfToolCallArgumentsMapItemArray []ToolCallArgumentsMapItemArrayItemUnion `json:",inline"` - JSON struct { - OfString respjson.Field - OfFloat respjson.Field - OfBool respjson.Field - OfToolCallArgumentsMapItemArray respjson.Field - raw string - } `json:"-"` -} - -func (u ToolCallArgumentsMapItemUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ToolCallArgumentsMapItemUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ToolCallArgumentsMapItemUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ToolCallArgumentsMapItemUnion) AsToolCallArgumentsMapItemArray() (v []ToolCallArgumentsMapItemArrayItemUnion) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ToolCallArgumentsMapItemUnion) AsToolCallArgumentsMapItemMapMap() (v map[string]ToolCallArgumentsMapItemMapItemUnion) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ToolCallArgumentsMapItemUnion) RawJSON() string { return u.JSON.raw } - -func (r *ToolCallArgumentsMapItemUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ToolCallArgumentsMapItemArrayItemUnion 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 ToolCallArgumentsMapItemArrayItemUnion 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 ToolCallArgumentsMapItemArrayItemUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ToolCallArgumentsMapItemArrayItemUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ToolCallArgumentsMapItemArrayItemUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ToolCallArgumentsMapItemArrayItemUnion) RawJSON() string { return u.JSON.raw } - -func (r *ToolCallArgumentsMapItemArrayItemUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ToolCallArgumentsMapItemMapItemUnion 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 ToolCallArgumentsMapItemMapItemUnion 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 ToolCallArgumentsMapItemMapItemUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ToolCallArgumentsMapItemMapItemUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ToolCallArgumentsMapItemMapItemUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ToolCallArgumentsMapItemMapItemUnion) RawJSON() string { return u.JSON.raw } - -func (r *ToolCallArgumentsMapItemMapItemUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type ToolCallToolName string - -const ( - ToolCallToolNameBraveSearch ToolCallToolName = "brave_search" - ToolCallToolNameWolframAlpha ToolCallToolName = "wolfram_alpha" - ToolCallToolNamePhotogen ToolCallToolName = "photogen" - ToolCallToolNameCodeInterpreter ToolCallToolName = "code_interpreter" -) - -// The properties Arguments, CallID, ToolName are required. -type ToolCallParam struct { - Arguments ToolCallArgumentsUnionParam `json:"arguments,omitzero,required"` - CallID string `json:"call_id,required"` - ToolName ToolCallToolName `json:"tool_name,omitzero,required"` - ArgumentsJson param.Opt[string] `json:"arguments_json,omitzero"` - paramObj -} - -func (r ToolCallParam) MarshalJSON() (data []byte, err error) { - type shadow ToolCallParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *ToolCallParam) 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 ToolCallArgumentsUnionParam struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfToolCallArgumentsMapMap map[string]ToolCallArgumentsMapItemUnionParam `json:",omitzero,inline"` - paramUnion -} - -func (u ToolCallArgumentsUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfToolCallArgumentsMapMap) -} -func (u *ToolCallArgumentsUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ToolCallArgumentsUnionParam) asAny() any { - if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfToolCallArgumentsMapMap) { - return &u.OfToolCallArgumentsMapMap - } - return nil -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ToolCallArgumentsMapItemUnionParam struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfBool param.Opt[bool] `json:",omitzero,inline"` - OfToolCallArgumentsMapItemArray []ToolCallArgumentsMapItemArrayItemUnionParam `json:",omitzero,inline"` - OfToolCallArgumentsMapItemMapMap map[string]ToolCallArgumentsMapItemMapItemUnionParam `json:",omitzero,inline"` - paramUnion -} - -func (u ToolCallArgumentsMapItemUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, - u.OfFloat, - u.OfBool, - u.OfToolCallArgumentsMapItemArray, - u.OfToolCallArgumentsMapItemMapMap) -} -func (u *ToolCallArgumentsMapItemUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ToolCallArgumentsMapItemUnionParam) asAny() any { - if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } else if !param.IsOmitted(u.OfToolCallArgumentsMapItemArray) { - return &u.OfToolCallArgumentsMapItemArray - } else if !param.IsOmitted(u.OfToolCallArgumentsMapItemMapMap) { - return &u.OfToolCallArgumentsMapItemMapMap - } - return nil -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ToolCallArgumentsMapItemArrayItemUnionParam struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfBool param.Opt[bool] `json:",omitzero,inline"` - paramUnion -} - -func (u ToolCallArgumentsMapItemArrayItemUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfFloat, u.OfBool) -} -func (u *ToolCallArgumentsMapItemArrayItemUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ToolCallArgumentsMapItemArrayItemUnionParam) asAny() any { - if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } - return nil -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type ToolCallArgumentsMapItemMapItemUnionParam struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfBool param.Opt[bool] `json:",omitzero,inline"` - paramUnion -} - -func (u ToolCallArgumentsMapItemMapItemUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfFloat, u.OfBool) -} -func (u *ToolCallArgumentsMapItemMapItemUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ToolCallArgumentsMapItemMapItemUnionParam) asAny() any { - if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } - return nil -} - -// ToolCallOrStringUnion contains all possible properties and values from [string], -// [ToolCall]. -// -// 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] -type ToolCallOrStringUnion struct { - // This field will be present if the value is a [string] instead of an object. - OfString string `json:",inline"` - // This field is from variant [ToolCall]. - Arguments ToolCallArgumentsUnion `json:"arguments"` - // This field is from variant [ToolCall]. - CallID string `json:"call_id"` - // This field is from variant [ToolCall]. - ToolName ToolCallToolName `json:"tool_name"` - // This field is from variant [ToolCall]. - ArgumentsJson string `json:"arguments_json"` - JSON struct { - OfString respjson.Field - Arguments respjson.Field - CallID respjson.Field - ToolName respjson.Field - ArgumentsJson respjson.Field - raw string - } `json:"-"` -} - -func (u ToolCallOrStringUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ToolCallOrStringUnion) AsToolCall() (v ToolCall) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ToolCallOrStringUnion) RawJSON() string { return u.JSON.raw } - -func (r *ToolCallOrStringUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// The property ParamType is required. -type ToolParamDefinition struct { - ParamType string `json:"param_type,required"` - Description param.Opt[string] `json:"description,omitzero"` - Required param.Opt[bool] `json:"required,omitzero"` - Default ToolParamDefinitionDefaultUnion `json:"default,omitzero"` - paramObj -} - -func (r ToolParamDefinition) MarshalJSON() (data []byte, err error) { - type shadow ToolParamDefinition - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *ToolParamDefinition) 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 ToolParamDefinitionDefaultUnion 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 ToolParamDefinitionDefaultUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *ToolParamDefinitionDefaultUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *ToolParamDefinitionDefaultUnion) 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 message representing the result of a tool invocation. -type ToolResponseMessage struct { - // Unique identifier for the tool call this response is for - CallID string `json:"call_id,required"` - // The response content from the tool - Content InterleavedContentUnion `json:"content,required"` - // Must be "tool" to identify this as a tool response - Role constant.Tool `json:"role,required"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - CallID respjson.Field - Content respjson.Field - Role respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ToolResponseMessage) RawJSON() string { return r.JSON.raw } -func (r *ToolResponseMessage) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ToParam converts this ToolResponseMessage to a ToolResponseMessageParam. -// -// 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 -// ToolResponseMessageParam.Overrides() -func (r ToolResponseMessage) ToParam() ToolResponseMessageParam { - return param.Override[ToolResponseMessageParam](json.RawMessage(r.RawJSON())) -} - -// A message representing the result of a tool invocation. -// -// The properties CallID, Content, Role are required. -type ToolResponseMessageParam struct { - // Unique identifier for the tool call this response is for - CallID string `json:"call_id,required"` - // The response content from the tool - Content InterleavedContentUnionParam `json:"content,omitzero,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"` - paramObj -} - -func (r ToolResponseMessageParam) MarshalJSON() (data []byte, err error) { - type shadow ToolResponseMessageParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *ToolResponseMessageParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A message from the user in a chat conversation. -type UserMessage struct { - // The content of the message, which can include text and other media - Content InterleavedContentUnion `json:"content,required"` - // Must be "user" to identify this as a user message - Role constant.User `json:"role,required"` - // (Optional) This field is used internally by Llama Stack to pass RAG context. - // This field may be removed in the API in the future. - Context InterleavedContentUnion `json:"context"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Content respjson.Field - Role respjson.Field - Context respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r UserMessage) RawJSON() string { return r.JSON.raw } -func (r *UserMessage) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ToParam converts this UserMessage to a UserMessageParam. -// -// 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 -// UserMessageParam.Overrides() -func (r UserMessage) ToParam() UserMessageParam { - return param.Override[UserMessageParam](json.RawMessage(r.RawJSON())) -} - -// A message from the user in a chat conversation. -// -// The properties Content, Role are required. -type UserMessageParam struct { - // The content of the message, which can include text and other media - Content InterleavedContentUnionParam `json:"content,omitzero,required"` - // (Optional) This field is used internally by Llama Stack to pass RAG context. - // This field may be removed in the API in the future. - Context InterleavedContentUnionParam `json:"context,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"` - paramObj -} - -func (r UserMessageParam) MarshalJSON() (data []byte, err error) { - type shadow UserMessageParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *UserMessageParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} diff --git a/shield.go b/shield.go index 575f942..d604ece 100644 --- a/shield.go +++ b/shield.go @@ -1,3 +1,9 @@ +// 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 @@ -8,6 +14,7 @@ import ( "errors" "fmt" "net/http" + "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" "github.com/llamastack/llama-stack-client-go/internal/requestconfig" @@ -38,7 +45,7 @@ func NewShieldService(opts ...option.RequestOption) (r ShieldService) { // Get a shield by its identifier. func (r *ShieldService) Get(ctx context.Context, identifier string, opts ...option.RequestOption) (res *Shield, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if identifier == "" { err = errors.New("missing required identifier parameter") return @@ -51,7 +58,7 @@ func (r *ShieldService) Get(ctx context.Context, identifier string, opts ...opti // List all shields. func (r *ShieldService) List(ctx context.Context, opts ...option.RequestOption) (res *[]Shield, err error) { var env ListShieldsResponse - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v1/shields" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) if err != nil { @@ -61,9 +68,26 @@ func (r *ShieldService) List(ctx context.Context, opts ...option.RequestOption) return } +// Unregister a shield. +// +// 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...) + if identifier == "" { + err = errors.New("missing required identifier parameter") + return + } + path := fmt.Sprintf("v1/shields/%s", identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...) + return +} + // Register a shield. +// +// Deprecated: deprecated func (r *ShieldService) Register(ctx context.Context, body ShieldRegisterParams, opts ...option.RequestOption) (res *Shield, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v1/shields" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return diff --git a/shield_test.go b/shield_test.go index 1201b74..eca9cf2 100644 --- a/shield_test.go +++ b/shield_test.go @@ -1,3 +1,9 @@ +// 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 @@ -55,6 +61,27 @@ func TestShieldList(t *testing.T) { } } +func TestShieldDelete(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.Shields.Delete(context.TODO(), "identifier") + 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 TestShieldRegisterWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { diff --git a/syntheticdatageneration.go b/syntheticdatageneration.go deleted file mode 100644 index 91f49ad..0000000 --- a/syntheticdatageneration.go +++ /dev/null @@ -1,203 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package llamastackclient - -import ( - "context" - "encoding/json" - "net/http" - - "github.com/llamastack/llama-stack-client-go/internal/apijson" - "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" -) - -// SyntheticDataGenerationService 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 [NewSyntheticDataGenerationService] method instead. -type SyntheticDataGenerationService struct { - Options []option.RequestOption -} - -// NewSyntheticDataGenerationService 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 NewSyntheticDataGenerationService(opts ...option.RequestOption) (r SyntheticDataGenerationService) { - r = SyntheticDataGenerationService{} - r.Options = opts - return -} - -// Generate synthetic data based on input dialogs and apply filtering. -func (r *SyntheticDataGenerationService) Generate(ctx context.Context, body SyntheticDataGenerationGenerateParams, opts ...option.RequestOption) (res *SyntheticDataGenerationResponse, err error) { - opts = append(r.Options[:], opts...) - path := "v1/synthetic-data-generation/generate" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) - return -} - -// Response from the synthetic data generation. Batch of (prompt, response, score) -// tuples that pass the threshold. -type SyntheticDataGenerationResponse struct { - // List of generated synthetic data samples that passed the filtering criteria - SyntheticData []map[string]SyntheticDataGenerationResponseSyntheticDataUnion `json:"synthetic_data,required"` - // (Optional) Statistical information about the generation process and filtering - // results - Statistics map[string]SyntheticDataGenerationResponseStatisticUnion `json:"statistics"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - SyntheticData respjson.Field - Statistics respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r SyntheticDataGenerationResponse) RawJSON() string { return r.JSON.raw } -func (r *SyntheticDataGenerationResponse) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// SyntheticDataGenerationResponseSyntheticDataUnion 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 SyntheticDataGenerationResponseSyntheticDataUnion 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 SyntheticDataGenerationResponseSyntheticDataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u SyntheticDataGenerationResponseSyntheticDataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u SyntheticDataGenerationResponseSyntheticDataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u SyntheticDataGenerationResponseSyntheticDataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u SyntheticDataGenerationResponseSyntheticDataUnion) RawJSON() string { return u.JSON.raw } - -func (r *SyntheticDataGenerationResponseSyntheticDataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// SyntheticDataGenerationResponseStatisticUnion 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 SyntheticDataGenerationResponseStatisticUnion 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 SyntheticDataGenerationResponseStatisticUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u SyntheticDataGenerationResponseStatisticUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u SyntheticDataGenerationResponseStatisticUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u SyntheticDataGenerationResponseStatisticUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u SyntheticDataGenerationResponseStatisticUnion) RawJSON() string { return u.JSON.raw } - -func (r *SyntheticDataGenerationResponseStatisticUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type SyntheticDataGenerationGenerateParams struct { - // List of conversation messages to use as input for synthetic data generation - Dialogs []shared.MessageUnionParam `json:"dialogs,omitzero,required"` - // Type of filtering to apply to generated synthetic data samples - // - // Any of "none", "random", "top_k", "top_p", "top_k_top_p", "sigmoid". - FilteringFunction SyntheticDataGenerationGenerateParamsFilteringFunction `json:"filtering_function,omitzero,required"` - // (Optional) The identifier of the model to use. The model must be registered with - // Llama Stack and available via the /models endpoint - Model param.Opt[string] `json:"model,omitzero"` - paramObj -} - -func (r SyntheticDataGenerationGenerateParams) MarshalJSON() (data []byte, err error) { - type shadow SyntheticDataGenerationGenerateParams - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *SyntheticDataGenerationGenerateParams) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Type of filtering to apply to generated synthetic data samples -type SyntheticDataGenerationGenerateParamsFilteringFunction string - -const ( - SyntheticDataGenerationGenerateParamsFilteringFunctionNone SyntheticDataGenerationGenerateParamsFilteringFunction = "none" - SyntheticDataGenerationGenerateParamsFilteringFunctionRandom SyntheticDataGenerationGenerateParamsFilteringFunction = "random" - SyntheticDataGenerationGenerateParamsFilteringFunctionTopK SyntheticDataGenerationGenerateParamsFilteringFunction = "top_k" - SyntheticDataGenerationGenerateParamsFilteringFunctionTopP SyntheticDataGenerationGenerateParamsFilteringFunction = "top_p" - SyntheticDataGenerationGenerateParamsFilteringFunctionTopKTopP SyntheticDataGenerationGenerateParamsFilteringFunction = "top_k_top_p" - SyntheticDataGenerationGenerateParamsFilteringFunctionSigmoid SyntheticDataGenerationGenerateParamsFilteringFunction = "sigmoid" -) diff --git a/telemetry.go b/telemetry.go deleted file mode 100644 index 5349bd8..0000000 --- a/telemetry.go +++ /dev/null @@ -1,1116 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package llamastackclient - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "net/http" - "time" - - "github.com/llamastack/llama-stack-client-go/internal/apijson" - "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" -) - -// TelemetryService 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 [NewTelemetryService] method instead. -type TelemetryService struct { - Options []option.RequestOption -} - -// NewTelemetryService 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 NewTelemetryService(opts ...option.RequestOption) (r TelemetryService) { - r = TelemetryService{} - r.Options = opts - return -} - -// Get a span by its ID. -func (r *TelemetryService) GetSpan(ctx context.Context, spanID string, query TelemetryGetSpanParams, opts ...option.RequestOption) (res *TelemetryGetSpanResponse, err error) { - opts = append(r.Options[:], opts...) - if query.TraceID == "" { - err = errors.New("missing required trace_id parameter") - return - } - if spanID == "" { - err = errors.New("missing required span_id parameter") - return - } - path := fmt.Sprintf("v1/telemetry/traces/%s/spans/%s", query.TraceID, spanID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) - return -} - -// Get a span tree by its ID. -func (r *TelemetryService) GetSpanTree(ctx context.Context, spanID string, body TelemetryGetSpanTreeParams, opts ...option.RequestOption) (res *TelemetryGetSpanTreeResponse, err error) { - var env TelemetryGetSpanTreeResponseEnvelope - opts = append(r.Options[:], opts...) - if spanID == "" { - err = errors.New("missing required span_id parameter") - return - } - path := fmt.Sprintf("v1/telemetry/spans/%s/tree", spanID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Data - return -} - -// Get a trace by its ID. -func (r *TelemetryService) GetTrace(ctx context.Context, traceID string, opts ...option.RequestOption) (res *Trace, err error) { - opts = append(r.Options[:], opts...) - if traceID == "" { - err = errors.New("missing required trace_id parameter") - return - } - path := fmt.Sprintf("v1/telemetry/traces/%s", traceID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) - return -} - -// Log an event. -func (r *TelemetryService) LogEvent(ctx context.Context, body TelemetryLogEventParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - path := "v1/telemetry/events" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...) - return -} - -// Query spans. -func (r *TelemetryService) QuerySpans(ctx context.Context, body TelemetryQuerySpansParams, opts ...option.RequestOption) (res *[]QuerySpansResponseData, err error) { - var env QuerySpansResponse - opts = append(r.Options[:], opts...) - path := "v1/telemetry/spans" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Data - return -} - -// Query traces. -func (r *TelemetryService) QueryTraces(ctx context.Context, body TelemetryQueryTracesParams, opts ...option.RequestOption) (res *[]Trace, err error) { - var env TelemetryQueryTracesResponseEnvelope - opts = append(r.Options[:], opts...) - path := "v1/telemetry/traces" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Data - return -} - -// Save spans to a dataset. -func (r *TelemetryService) SaveSpansToDataset(ctx context.Context, body TelemetrySaveSpansToDatasetParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - path := "v1/telemetry/spans/export" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...) - return -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type EventUnionParam struct { - OfUnstructuredLog *EventUnstructuredLogParam `json:",omitzero,inline"` - OfMetric *EventMetricParam `json:",omitzero,inline"` - OfStructuredLog *EventStructuredLogParam `json:",omitzero,inline"` - paramUnion -} - -func (u EventUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfUnstructuredLog, u.OfMetric, u.OfStructuredLog) -} -func (u *EventUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *EventUnionParam) asAny() any { - if !param.IsOmitted(u.OfUnstructuredLog) { - return u.OfUnstructuredLog - } else if !param.IsOmitted(u.OfMetric) { - return u.OfMetric - } else if !param.IsOmitted(u.OfStructuredLog) { - return u.OfStructuredLog - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u EventUnionParam) GetMessage() *string { - if vt := u.OfUnstructuredLog; vt != nil { - return &vt.Message - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u EventUnionParam) GetSeverity() *string { - if vt := u.OfUnstructuredLog; vt != nil { - return &vt.Severity - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u EventUnionParam) GetMetric() *string { - if vt := u.OfMetric; vt != nil { - return &vt.Metric - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u EventUnionParam) GetUnit() *string { - if vt := u.OfMetric; vt != nil { - return &vt.Unit - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u EventUnionParam) GetValue() *float64 { - if vt := u.OfMetric; vt != nil { - return &vt.Value - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u EventUnionParam) GetPayload() *EventStructuredLogPayloadUnionParam { - if vt := u.OfStructuredLog; vt != nil { - return &vt.Payload - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u EventUnionParam) GetSpanID() *string { - if vt := u.OfUnstructuredLog; vt != nil { - return (*string)(&vt.SpanID) - } else if vt := u.OfMetric; vt != nil { - return (*string)(&vt.SpanID) - } else if vt := u.OfStructuredLog; vt != nil { - return (*string)(&vt.SpanID) - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u EventUnionParam) GetTraceID() *string { - if vt := u.OfUnstructuredLog; vt != nil { - return (*string)(&vt.TraceID) - } else if vt := u.OfMetric; vt != nil { - return (*string)(&vt.TraceID) - } else if vt := u.OfStructuredLog; vt != nil { - return (*string)(&vt.TraceID) - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u EventUnionParam) GetType() *string { - if vt := u.OfUnstructuredLog; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfMetric; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfStructuredLog; vt != nil { - return (*string)(&vt.Type) - } - return nil -} - -// Returns a pointer to the underlying variant's Timestamp property, if present. -func (u EventUnionParam) GetTimestamp() *time.Time { - if vt := u.OfUnstructuredLog; vt != nil { - return &vt.Timestamp - } else if vt := u.OfMetric; vt != nil { - return &vt.Timestamp - } else if vt := u.OfStructuredLog; vt != nil { - return &vt.Timestamp - } - return nil -} - -// Returns a subunion which exports methods to access subproperties -// -// Or use AsAny() to get the underlying value -func (u EventUnionParam) GetAttributes() (res eventUnionParamAttributes) { - if vt := u.OfUnstructuredLog; vt != nil { - res.any = &vt.Attributes - } else if vt := u.OfMetric; vt != nil { - res.any = &vt.Attributes - } else if vt := u.OfStructuredLog; vt != nil { - res.any = &vt.Attributes - } - return -} - -// Can have the runtime types -// [*map[string]EventUnstructuredLogAttributeUnionParam], -// [*map[string]EventMetricAttributeUnionParam], -// [\*map[string]EventStructuredLogAttributeUnionParam] -type eventUnionParamAttributes struct{ any } - -// Use the following switch statement to get the type of the union: -// -// switch u.AsAny().(type) { -// case *map[string]llamastackclient.EventUnstructuredLogAttributeUnionParam: -// case *map[string]llamastackclient.EventMetricAttributeUnionParam: -// case *map[string]llamastackclient.EventStructuredLogAttributeUnionParam: -// default: -// fmt.Errorf("not present") -// } -func (u eventUnionParamAttributes) AsAny() any { return u.any } - -func init() { - apijson.RegisterUnion[EventUnionParam]( - "type", - apijson.Discriminator[EventUnstructuredLogParam]("unstructured_log"), - apijson.Discriminator[EventMetricParam]("metric"), - apijson.Discriminator[EventStructuredLogParam]("structured_log"), - ) -} - -// An unstructured log event containing a simple text message. -// -// The properties Message, Severity, SpanID, Timestamp, TraceID, Type are required. -type EventUnstructuredLogParam struct { - // The log message text - Message string `json:"message,required"` - // The severity level of the log message - // - // Any of "verbose", "debug", "info", "warn", "error", "critical". - Severity string `json:"severity,omitzero,required"` - // Unique identifier for the span this event belongs to - SpanID string `json:"span_id,required"` - // Timestamp when the event occurred - Timestamp time.Time `json:"timestamp,required" format:"date-time"` - // Unique identifier for the trace this event belongs to - TraceID string `json:"trace_id,required"` - // (Optional) Key-value pairs containing additional metadata about the event - Attributes map[string]EventUnstructuredLogAttributeUnionParam `json:"attributes,omitzero"` - // Event type identifier set to UNSTRUCTURED_LOG - // - // This field can be elided, and will marshal its zero value as "unstructured_log". - Type constant.UnstructuredLog `json:"type,required"` - paramObj -} - -func (r EventUnstructuredLogParam) MarshalJSON() (data []byte, err error) { - type shadow EventUnstructuredLogParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *EventUnstructuredLogParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -func init() { - apijson.RegisterFieldValidator[EventUnstructuredLogParam]( - "severity", "verbose", "debug", "info", "warn", "error", "critical", - ) -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type EventUnstructuredLogAttributeUnionParam struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfBool param.Opt[bool] `json:",omitzero,inline"` - paramUnion -} - -func (u EventUnstructuredLogAttributeUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfFloat, u.OfBool) -} -func (u *EventUnstructuredLogAttributeUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *EventUnstructuredLogAttributeUnionParam) asAny() any { - if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } - return nil -} - -// A metric event containing a measured value. -// -// The properties Metric, SpanID, Timestamp, TraceID, Type, Unit, Value are -// required. -type EventMetricParam struct { - // The name of the metric being measured - Metric string `json:"metric,required"` - // Unique identifier for the span this event belongs to - SpanID string `json:"span_id,required"` - // Timestamp when the event occurred - Timestamp time.Time `json:"timestamp,required" format:"date-time"` - // Unique identifier for the trace this event belongs to - TraceID string `json:"trace_id,required"` - // The unit of measurement for the metric value - Unit string `json:"unit,required"` - // The numeric value of the metric measurement - Value float64 `json:"value,required"` - // (Optional) Key-value pairs containing additional metadata about the event - Attributes map[string]EventMetricAttributeUnionParam `json:"attributes,omitzero"` - // Event type identifier set to METRIC - // - // This field can be elided, and will marshal its zero value as "metric". - Type constant.Metric `json:"type,required"` - paramObj -} - -func (r EventMetricParam) MarshalJSON() (data []byte, err error) { - type shadow EventMetricParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *EventMetricParam) 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 EventMetricAttributeUnionParam struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfBool param.Opt[bool] `json:",omitzero,inline"` - paramUnion -} - -func (u EventMetricAttributeUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfFloat, u.OfBool) -} -func (u *EventMetricAttributeUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *EventMetricAttributeUnionParam) asAny() any { - if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } - return nil -} - -// A structured log event containing typed payload data. -// -// The properties Payload, SpanID, Timestamp, TraceID, Type are required. -type EventStructuredLogParam struct { - // The structured payload data for the log event - Payload EventStructuredLogPayloadUnionParam `json:"payload,omitzero,required"` - // Unique identifier for the span this event belongs to - SpanID string `json:"span_id,required"` - // Timestamp when the event occurred - Timestamp time.Time `json:"timestamp,required" format:"date-time"` - // Unique identifier for the trace this event belongs to - TraceID string `json:"trace_id,required"` - // (Optional) Key-value pairs containing additional metadata about the event - Attributes map[string]EventStructuredLogAttributeUnionParam `json:"attributes,omitzero"` - // Event type identifier set to STRUCTURED_LOG - // - // This field can be elided, and will marshal its zero value as "structured_log". - Type constant.StructuredLog `json:"type,required"` - paramObj -} - -func (r EventStructuredLogParam) MarshalJSON() (data []byte, err error) { - type shadow EventStructuredLogParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *EventStructuredLogParam) 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 EventStructuredLogPayloadUnionParam struct { - OfSpanStart *EventStructuredLogPayloadSpanStartParam `json:",omitzero,inline"` - OfSpanEnd *EventStructuredLogPayloadSpanEndParam `json:",omitzero,inline"` - paramUnion -} - -func (u EventStructuredLogPayloadUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfSpanStart, u.OfSpanEnd) -} -func (u *EventStructuredLogPayloadUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *EventStructuredLogPayloadUnionParam) asAny() any { - if !param.IsOmitted(u.OfSpanStart) { - return u.OfSpanStart - } else if !param.IsOmitted(u.OfSpanEnd) { - return u.OfSpanEnd - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u EventStructuredLogPayloadUnionParam) GetName() *string { - if vt := u.OfSpanStart; vt != nil { - return &vt.Name - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u EventStructuredLogPayloadUnionParam) GetParentSpanID() *string { - if vt := u.OfSpanStart; vt != nil && vt.ParentSpanID.Valid() { - return &vt.ParentSpanID.Value - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u EventStructuredLogPayloadUnionParam) GetStatus() *string { - if vt := u.OfSpanEnd; vt != nil { - return &vt.Status - } - return nil -} - -// Returns a pointer to the underlying variant's property, if present. -func (u EventStructuredLogPayloadUnionParam) GetType() *string { - if vt := u.OfSpanStart; vt != nil { - return (*string)(&vt.Type) - } else if vt := u.OfSpanEnd; vt != nil { - return (*string)(&vt.Type) - } - return nil -} - -func init() { - apijson.RegisterUnion[EventStructuredLogPayloadUnionParam]( - "type", - apijson.Discriminator[EventStructuredLogPayloadSpanStartParam]("span_start"), - apijson.Discriminator[EventStructuredLogPayloadSpanEndParam]("span_end"), - ) -} - -// Payload for a span start event. -// -// The properties Name, Type are required. -type EventStructuredLogPayloadSpanStartParam struct { - // Human-readable name describing the operation this span represents - Name string `json:"name,required"` - // (Optional) Unique identifier for the parent span, if this is a child span - ParentSpanID param.Opt[string] `json:"parent_span_id,omitzero"` - // Payload type identifier set to SPAN_START - // - // This field can be elided, and will marshal its zero value as "span_start". - Type constant.SpanStart `json:"type,required"` - paramObj -} - -func (r EventStructuredLogPayloadSpanStartParam) MarshalJSON() (data []byte, err error) { - type shadow EventStructuredLogPayloadSpanStartParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *EventStructuredLogPayloadSpanStartParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Payload for a span end event. -// -// The properties Status, Type are required. -type EventStructuredLogPayloadSpanEndParam struct { - // The final status of the span indicating success or failure - // - // Any of "ok", "error". - Status string `json:"status,omitzero,required"` - // Payload type identifier set to SPAN_END - // - // This field can be elided, and will marshal its zero value as "span_end". - Type constant.SpanEnd `json:"type,required"` - paramObj -} - -func (r EventStructuredLogPayloadSpanEndParam) MarshalJSON() (data []byte, err error) { - type shadow EventStructuredLogPayloadSpanEndParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *EventStructuredLogPayloadSpanEndParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -func init() { - apijson.RegisterFieldValidator[EventStructuredLogPayloadSpanEndParam]( - "status", "ok", "error", - ) -} - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type EventStructuredLogAttributeUnionParam struct { - OfString param.Opt[string] `json:",omitzero,inline"` - OfFloat param.Opt[float64] `json:",omitzero,inline"` - OfBool param.Opt[bool] `json:",omitzero,inline"` - paramUnion -} - -func (u EventStructuredLogAttributeUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfString, u.OfFloat, u.OfBool) -} -func (u *EventStructuredLogAttributeUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *EventStructuredLogAttributeUnionParam) asAny() any { - if !param.IsOmitted(u.OfString) { - return &u.OfString.Value - } else if !param.IsOmitted(u.OfFloat) { - return &u.OfFloat.Value - } else if !param.IsOmitted(u.OfBool) { - return &u.OfBool.Value - } - return nil -} - -// A condition for filtering query results. -// -// The properties Key, Op, Value are required. -type QueryConditionParam struct { - // The value to compare against - Value QueryConditionValueUnionParam `json:"value,omitzero,required"` - // The attribute key to filter on - Key string `json:"key,required"` - // The comparison operator to apply - // - // Any of "eq", "ne", "gt", "lt". - Op QueryConditionOp `json:"op,omitzero,required"` - paramObj -} - -func (r QueryConditionParam) MarshalJSON() (data []byte, err error) { - type shadow QueryConditionParam - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *QueryConditionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// The comparison operator to apply -type QueryConditionOp string - -const ( - QueryConditionOpEq QueryConditionOp = "eq" - QueryConditionOpNe QueryConditionOp = "ne" - QueryConditionOpGt QueryConditionOp = "gt" - QueryConditionOpLt QueryConditionOp = "lt" -) - -// Only one field can be non-zero. -// -// Use [param.IsOmitted] to confirm if a field is set. -type QueryConditionValueUnionParam 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 QueryConditionValueUnionParam) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) -} -func (u *QueryConditionValueUnionParam) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, u) -} - -func (u *QueryConditionValueUnionParam) 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 -} - -// Response containing a list of spans. -type QuerySpansResponse struct { - // List of spans matching the query criteria - Data []QuerySpansResponseData `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:"-"` -} - -// Returns the unmodified JSON received from the API -func (r QuerySpansResponse) RawJSON() string { return r.JSON.raw } -func (r *QuerySpansResponse) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A span representing a single operation within a trace. -type QuerySpansResponseData struct { - // Human-readable name describing the operation this span represents - Name string `json:"name,required"` - // Unique identifier for the span - SpanID string `json:"span_id,required"` - // Timestamp when the operation began - StartTime time.Time `json:"start_time,required" format:"date-time"` - // Unique identifier for the trace this span belongs to - TraceID string `json:"trace_id,required"` - // (Optional) Key-value pairs containing additional metadata about the span - Attributes map[string]QuerySpansResponseDataAttributeUnion `json:"attributes"` - // (Optional) Timestamp when the operation finished, if completed - EndTime time.Time `json:"end_time" format:"date-time"` - // (Optional) Unique identifier for the parent span, if this is a child span - ParentSpanID string `json:"parent_span_id"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Name respjson.Field - SpanID respjson.Field - StartTime respjson.Field - TraceID respjson.Field - Attributes respjson.Field - EndTime respjson.Field - ParentSpanID respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r QuerySpansResponseData) RawJSON() string { return r.JSON.raw } -func (r *QuerySpansResponseData) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// QuerySpansResponseDataAttributeUnion 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 QuerySpansResponseDataAttributeUnion 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 QuerySpansResponseDataAttributeUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u QuerySpansResponseDataAttributeUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u QuerySpansResponseDataAttributeUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u QuerySpansResponseDataAttributeUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u QuerySpansResponseDataAttributeUnion) RawJSON() string { return u.JSON.raw } - -func (r *QuerySpansResponseDataAttributeUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A span that includes status information. -type SpanWithStatus struct { - // Human-readable name describing the operation this span represents - Name string `json:"name,required"` - // Unique identifier for the span - SpanID string `json:"span_id,required"` - // Timestamp when the operation began - StartTime time.Time `json:"start_time,required" format:"date-time"` - // Unique identifier for the trace this span belongs to - TraceID string `json:"trace_id,required"` - // (Optional) Key-value pairs containing additional metadata about the span - Attributes map[string]SpanWithStatusAttributeUnion `json:"attributes"` - // (Optional) Timestamp when the operation finished, if completed - EndTime time.Time `json:"end_time" format:"date-time"` - // (Optional) Unique identifier for the parent span, if this is a child span - ParentSpanID string `json:"parent_span_id"` - // (Optional) The current status of the span - // - // Any of "ok", "error". - Status SpanWithStatusStatus `json:"status"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Name respjson.Field - SpanID respjson.Field - StartTime respjson.Field - TraceID respjson.Field - Attributes respjson.Field - EndTime respjson.Field - ParentSpanID respjson.Field - Status respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r SpanWithStatus) RawJSON() string { return r.JSON.raw } -func (r *SpanWithStatus) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// SpanWithStatusAttributeUnion 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 SpanWithStatusAttributeUnion 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 SpanWithStatusAttributeUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u SpanWithStatusAttributeUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u SpanWithStatusAttributeUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u SpanWithStatusAttributeUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u SpanWithStatusAttributeUnion) RawJSON() string { return u.JSON.raw } - -func (r *SpanWithStatusAttributeUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// (Optional) The current status of the span -type SpanWithStatusStatus string - -const ( - SpanWithStatusStatusOk SpanWithStatusStatus = "ok" - SpanWithStatusStatusError SpanWithStatusStatus = "error" -) - -// A trace representing the complete execution path of a request across multiple -// operations. -type Trace struct { - // Unique identifier for the root span that started this trace - RootSpanID string `json:"root_span_id,required"` - // Timestamp when the trace began - StartTime time.Time `json:"start_time,required" format:"date-time"` - // Unique identifier for the trace - TraceID string `json:"trace_id,required"` - // (Optional) Timestamp when the trace finished, if completed - EndTime time.Time `json:"end_time" format:"date-time"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - RootSpanID respjson.Field - StartTime respjson.Field - TraceID respjson.Field - EndTime respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r Trace) RawJSON() string { return r.JSON.raw } -func (r *Trace) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A span representing a single operation within a trace. -type TelemetryGetSpanResponse struct { - // Human-readable name describing the operation this span represents - Name string `json:"name,required"` - // Unique identifier for the span - SpanID string `json:"span_id,required"` - // Timestamp when the operation began - StartTime time.Time `json:"start_time,required" format:"date-time"` - // Unique identifier for the trace this span belongs to - TraceID string `json:"trace_id,required"` - // (Optional) Key-value pairs containing additional metadata about the span - Attributes map[string]TelemetryGetSpanResponseAttributeUnion `json:"attributes"` - // (Optional) Timestamp when the operation finished, if completed - EndTime time.Time `json:"end_time" format:"date-time"` - // (Optional) Unique identifier for the parent span, if this is a child span - ParentSpanID string `json:"parent_span_id"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Name respjson.Field - SpanID respjson.Field - StartTime respjson.Field - TraceID respjson.Field - Attributes respjson.Field - EndTime respjson.Field - ParentSpanID respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r TelemetryGetSpanResponse) RawJSON() string { return r.JSON.raw } -func (r *TelemetryGetSpanResponse) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// TelemetryGetSpanResponseAttributeUnion 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 TelemetryGetSpanResponseAttributeUnion 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 TelemetryGetSpanResponseAttributeUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u TelemetryGetSpanResponseAttributeUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u TelemetryGetSpanResponseAttributeUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u TelemetryGetSpanResponseAttributeUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u TelemetryGetSpanResponseAttributeUnion) RawJSON() string { return u.JSON.raw } - -func (r *TelemetryGetSpanResponseAttributeUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type TelemetryGetSpanTreeResponse map[string]SpanWithStatus - -type TelemetryGetSpanParams struct { - TraceID string `path:"trace_id,required" json:"-"` - paramObj -} - -type TelemetryGetSpanTreeParams struct { - // The maximum depth of the tree. - MaxDepth param.Opt[int64] `json:"max_depth,omitzero"` - // The attributes to return in the tree. - AttributesToReturn []string `json:"attributes_to_return,omitzero"` - paramObj -} - -func (r TelemetryGetSpanTreeParams) MarshalJSON() (data []byte, err error) { - type shadow TelemetryGetSpanTreeParams - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *TelemetryGetSpanTreeParams) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Response containing a tree structure of spans. -type TelemetryGetSpanTreeResponseEnvelope struct { - // Dictionary mapping span IDs to spans with status information - Data TelemetryGetSpanTreeResponse `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:"-"` -} - -// Returns the unmodified JSON received from the API -func (r TelemetryGetSpanTreeResponseEnvelope) RawJSON() string { return r.JSON.raw } -func (r *TelemetryGetSpanTreeResponseEnvelope) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type TelemetryLogEventParams struct { - // The event to log. - Event EventUnionParam `json:"event,omitzero,required"` - // The time to live of the event. - TtlSeconds int64 `json:"ttl_seconds,required"` - paramObj -} - -func (r TelemetryLogEventParams) MarshalJSON() (data []byte, err error) { - type shadow TelemetryLogEventParams - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *TelemetryLogEventParams) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type TelemetryQuerySpansParams struct { - // The attribute filters to apply to the spans. - AttributeFilters []QueryConditionParam `json:"attribute_filters,omitzero,required"` - // The attributes to return in the spans. - AttributesToReturn []string `json:"attributes_to_return,omitzero,required"` - // The maximum depth of the tree. - MaxDepth param.Opt[int64] `json:"max_depth,omitzero"` - paramObj -} - -func (r TelemetryQuerySpansParams) MarshalJSON() (data []byte, err error) { - type shadow TelemetryQuerySpansParams - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *TelemetryQuerySpansParams) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type TelemetryQueryTracesParams struct { - // The limit of traces to return. - Limit param.Opt[int64] `json:"limit,omitzero"` - // The offset of the traces to return. - Offset param.Opt[int64] `json:"offset,omitzero"` - // The attribute filters to apply to the traces. - AttributeFilters []QueryConditionParam `json:"attribute_filters,omitzero"` - // The order by of the traces to return. - OrderBy []string `json:"order_by,omitzero"` - paramObj -} - -func (r TelemetryQueryTracesParams) MarshalJSON() (data []byte, err error) { - type shadow TelemetryQueryTracesParams - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *TelemetryQueryTracesParams) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Response containing a list of traces. -type TelemetryQueryTracesResponseEnvelope struct { - // List of traces matching the query criteria - Data []Trace `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:"-"` -} - -// Returns the unmodified JSON received from the API -func (r TelemetryQueryTracesResponseEnvelope) RawJSON() string { return r.JSON.raw } -func (r *TelemetryQueryTracesResponseEnvelope) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type TelemetrySaveSpansToDatasetParams struct { - // The attribute filters to apply to the spans. - AttributeFilters []QueryConditionParam `json:"attribute_filters,omitzero,required"` - // The attributes to save to the dataset. - AttributesToSave []string `json:"attributes_to_save,omitzero,required"` - // The ID of the dataset to save the spans to. - DatasetID string `json:"dataset_id,required"` - // The maximum depth of the tree. - MaxDepth param.Opt[int64] `json:"max_depth,omitzero"` - paramObj -} - -func (r TelemetrySaveSpansToDatasetParams) MarshalJSON() (data []byte, err error) { - type shadow TelemetrySaveSpansToDatasetParams - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *TelemetrySaveSpansToDatasetParams) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} diff --git a/telemetry_test.go b/telemetry_test.go deleted file mode 100644 index 924d900..0000000 --- a/telemetry_test.go +++ /dev/null @@ -1,225 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package llamastackclient_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "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 TestTelemetryGetSpan(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.Telemetry.GetSpan( - context.TODO(), - "span_id", - llamastackclient.TelemetryGetSpanParams{ - TraceID: "trace_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 TestTelemetryGetSpanTreeWithOptionalParams(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.Telemetry.GetSpanTree( - context.TODO(), - "span_id", - llamastackclient.TelemetryGetSpanTreeParams{ - AttributesToReturn: []string{"string"}, - MaxDepth: 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 TestTelemetryGetTrace(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.Telemetry.GetTrace(context.TODO(), "trace_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 TestTelemetryLogEventWithOptionalParams(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.Telemetry.LogEvent(context.TODO(), llamastackclient.TelemetryLogEventParams{ - Event: llamastackclient.EventUnionParam{ - OfUnstructuredLog: &llamastackclient.EventUnstructuredLogParam{ - Message: "message", - Severity: "verbose", - SpanID: "span_id", - Timestamp: time.Now(), - TraceID: "trace_id", - Attributes: map[string]llamastackclient.EventUnstructuredLogAttributeUnionParam{ - "foo": { - OfString: llamastackclient.String("string"), - }, - }, - }, - }, - TtlSeconds: 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 TestTelemetryQuerySpansWithOptionalParams(t *testing.T) { - t.Skip("unsupported query params in java / kotlin") - 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.Telemetry.QuerySpans(context.TODO(), llamastackclient.TelemetryQuerySpansParams{ - AttributeFilters: []llamastackclient.QueryConditionParam{{ - Key: "key", - Op: llamastackclient.QueryConditionOpEq, - Value: llamastackclient.QueryConditionValueUnionParam{ - OfBool: llamastackclient.Bool(true), - }, - }}, - AttributesToReturn: []string{"string"}, - MaxDepth: 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 TestTelemetryQueryTracesWithOptionalParams(t *testing.T) { - t.Skip("unsupported query params in java / kotlin") - 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.Telemetry.QueryTraces(context.TODO(), llamastackclient.TelemetryQueryTracesParams{ - AttributeFilters: []llamastackclient.QueryConditionParam{{ - Key: "key", - Op: llamastackclient.QueryConditionOpEq, - Value: llamastackclient.QueryConditionValueUnionParam{ - OfBool: llamastackclient.Bool(true), - }, - }}, - Limit: llamastackclient.Int(0), - Offset: llamastackclient.Int(0), - OrderBy: []string{"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 TestTelemetrySaveSpansToDatasetWithOptionalParams(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.Telemetry.SaveSpansToDataset(context.TODO(), llamastackclient.TelemetrySaveSpansToDatasetParams{ - AttributeFilters: []llamastackclient.QueryConditionParam{{ - Key: "key", - Op: llamastackclient.QueryConditionOpEq, - Value: llamastackclient.QueryConditionValueUnionParam{ - OfBool: llamastackclient.Bool(true), - }, - }}, - AttributesToSave: []string{"string"}, - DatasetID: "dataset_id", - MaxDepth: 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()) - } -} diff --git a/tool.go b/tool.go index 3518704..e659f56 100644 --- a/tool.go +++ b/tool.go @@ -1,14 +1,20 @@ +// 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" - "encoding/json" "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" @@ -16,7 +22,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" ) // ToolService contains methods and other services that help with interacting with @@ -39,9 +44,9 @@ func NewToolService(opts ...option.RequestOption) (r ToolService) { } // List tools with optional tool group. -func (r *ToolService) List(ctx context.Context, query ToolListParams, opts ...option.RequestOption) (res *[]Tool, err error) { - var env ListToolsResponse - opts = append(r.Options[:], opts...) +func (r *ToolService) List(ctx context.Context, query ToolListParams, opts ...option.RequestOption) (res *[]ToolDef, err error) { + var env ToolListResponseEnvelope + opts = slices.Concat(r.Options, opts) path := "v1/tools" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) if err != nil { @@ -52,8 +57,8 @@ func (r *ToolService) List(ctx context.Context, query ToolListParams, opts ...op } // Get a tool by its name. -func (r *ToolService) Get(ctx context.Context, toolName string, opts ...option.RequestOption) (res *Tool, err error) { - opts = append(r.Options[:], opts...) +func (r *ToolService) Get(ctx context.Context, toolName string, opts ...option.RequestOption) (res *ToolDef, err error) { + opts = slices.Concat(r.Options, opts) if toolName == "" { err = errors.New("missing required tool_name parameter") return @@ -63,194 +68,6 @@ func (r *ToolService) Get(ctx context.Context, toolName string, opts ...option.R return } -// Response containing a list of tools. -type ListToolsResponse struct { - // List of tools - Data []Tool `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:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ListToolsResponse) RawJSON() string { return r.JSON.raw } -func (r *ListToolsResponse) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// A tool that can be invoked by agents. -type Tool struct { - // Human-readable description of what the tool does - Description string `json:"description,required"` - Identifier string `json:"identifier,required"` - // List of parameters this tool accepts - Parameters []ToolParameter `json:"parameters,required"` - ProviderID string `json:"provider_id,required"` - // ID of the tool group this tool belongs to - ToolgroupID string `json:"toolgroup_id,required"` - // Type of resource, always 'tool' - Type constant.Tool `json:"type,required"` - // (Optional) Additional metadata about the tool - Metadata map[string]ToolMetadataUnion `json:"metadata"` - ProviderResourceID string `json:"provider_resource_id"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Description respjson.Field - Identifier respjson.Field - Parameters respjson.Field - ProviderID respjson.Field - ToolgroupID respjson.Field - Type respjson.Field - Metadata respjson.Field - ProviderResourceID respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r Tool) RawJSON() string { return r.JSON.raw } -func (r *Tool) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Parameter definition for a tool. -type ToolParameter struct { - // Human-readable description of what the parameter does - Description string `json:"description,required"` - // Name of the parameter - Name string `json:"name,required"` - // Type of the parameter (e.g., string, integer) - ParameterType string `json:"parameter_type,required"` - // Whether this parameter is required for tool invocation - Required bool `json:"required,required"` - // (Optional) Default value for the parameter if not provided - Default ToolParameterDefaultUnion `json:"default,nullable"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - Description respjson.Field - Name respjson.Field - ParameterType respjson.Field - Required respjson.Field - Default respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ToolParameter) RawJSON() string { return r.JSON.raw } -func (r *ToolParameter) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ToolParameterDefaultUnion 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 ToolParameterDefaultUnion 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 ToolParameterDefaultUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ToolParameterDefaultUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ToolParameterDefaultUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ToolParameterDefaultUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ToolParameterDefaultUnion) RawJSON() string { return u.JSON.raw } - -func (r *ToolParameterDefaultUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// ToolMetadataUnion 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 ToolMetadataUnion 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 ToolMetadataUnion) AsBool() (v bool) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ToolMetadataUnion) AsFloat() (v float64) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ToolMetadataUnion) AsString() (v string) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -func (u ToolMetadataUnion) AsAnyArray() (v []any) { - apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) - return -} - -// Returns the unmodified JSON received from the API -func (u ToolMetadataUnion) RawJSON() string { return u.JSON.raw } - -func (r *ToolMetadataUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - type ToolListParams struct { // The ID of the tool group to list tools for. ToolgroupID param.Opt[string] `query:"toolgroup_id,omitzero" json:"-"` @@ -264,3 +81,21 @@ func (r ToolListParams) URLQuery() (v url.Values, err error) { NestedFormat: apiquery.NestedQueryFormatBrackets, }) } + +// 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 { + Data respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ToolListResponseEnvelope) RawJSON() string { return r.JSON.raw } +func (r *ToolListResponseEnvelope) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} diff --git a/tool_test.go b/tool_test.go index fe5a58a..15e7780 100644 --- a/tool_test.go +++ b/tool_test.go @@ -1,3 +1,9 @@ +// 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 diff --git a/toolgroup.go b/toolgroup.go index bed1c74..934ab6d 100644 --- a/toolgroup.go +++ b/toolgroup.go @@ -1,3 +1,9 @@ +// 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 @@ -8,6 +14,7 @@ import ( "errors" "fmt" "net/http" + "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" "github.com/llamastack/llama-stack-client-go/internal/requestconfig" @@ -39,7 +46,7 @@ func NewToolgroupService(opts ...option.RequestOption) (r ToolgroupService) { // List tool groups with optional provider. func (r *ToolgroupService) List(ctx context.Context, opts ...option.RequestOption) (res *[]ToolGroup, err error) { var env ListToolGroupsResponse - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v1/toolgroups" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) if err != nil { @@ -51,7 +58,7 @@ func (r *ToolgroupService) List(ctx context.Context, opts ...option.RequestOptio // Get a tool group by its ID. func (r *ToolgroupService) Get(ctx context.Context, toolgroupID string, opts ...option.RequestOption) (res *ToolGroup, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if toolgroupID == "" { err = errors.New("missing required toolgroup_id parameter") return @@ -62,8 +69,10 @@ func (r *ToolgroupService) Get(ctx context.Context, toolgroupID string, opts ... } // Register a tool group. +// +// Deprecated: deprecated func (r *ToolgroupService) Register(ctx context.Context, body ToolgroupRegisterParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) path := "v1/toolgroups" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...) @@ -71,8 +80,10 @@ func (r *ToolgroupService) Register(ctx context.Context, body ToolgroupRegisterP } // Unregister a tool group. +// +// Deprecated: deprecated func (r *ToolgroupService) Unregister(ctx context.Context, toolgroupID string, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) if toolgroupID == "" { err = errors.New("missing required toolgroup_id parameter") diff --git a/toolgroup_test.go b/toolgroup_test.go index 8f9d0db..f705111 100644 --- a/toolgroup_test.go +++ b/toolgroup_test.go @@ -1,3 +1,9 @@ +// 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 diff --git a/toolruntime.go b/toolruntime.go index 59067b3..d51e0d8 100644 --- a/toolruntime.go +++ b/toolruntime.go @@ -1,3 +1,9 @@ +// 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 @@ -7,6 +13,7 @@ import ( "encoding/json" "net/http" "net/url" + "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" "github.com/llamastack/llama-stack-client-go/internal/apiquery" @@ -14,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" ) // ToolRuntimeService contains methods and other services that help with @@ -40,16 +46,16 @@ func NewToolRuntimeService(opts ...option.RequestOption) (r ToolRuntimeService) // Run a tool with the given arguments. func (r *ToolRuntimeService) InvokeTool(ctx context.Context, body ToolRuntimeInvokeToolParams, opts ...option.RequestOption) (res *ToolInvocationResult, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v1/tool-runtime/invoke" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return } // List all tools in the runtime. -func (r *ToolRuntimeService) ListTools(ctx context.Context, query ToolRuntimeListToolsParams, opts ...option.RequestOption) (res *[]shared.SharedToolDef, err error) { +func (r *ToolRuntimeService) ListTools(ctx context.Context, query ToolRuntimeListToolsParams, opts ...option.RequestOption) (res *[]ToolDef, err error) { var env ToolRuntimeListToolsResponseEnvelope - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v1/tool-runtime/list-tools" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) if err != nil { @@ -59,10 +65,199 @@ func (r *ToolRuntimeService) ListTools(ctx context.Context, query ToolRuntimeLis return } +// 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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Name respjson.Field + Description respjson.Field + InputSchema respjson.Field + Metadata respjson.Field + OutputSchema respjson.Field + ToolgroupID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ToolDef) RawJSON() string { return r.JSON.raw } +func (r *ToolDef) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ToolDefInputSchemaUnion 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 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"` + // 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 ToolDefInputSchemaUnion) AsBool() (v bool) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ToolDefInputSchemaUnion) AsFloat() (v float64) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ToolDefInputSchemaUnion) AsString() (v string) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ToolDefInputSchemaUnion) AsAnyArray() (v []any) { + 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 (r *ToolDefInputSchemaUnion) 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 + } `json:"-"` +} + +func (u ToolDefMetadataUnion) AsBool() (v bool) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ToolDefMetadataUnion) AsFloat() (v float64) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ToolDefMetadataUnion) AsString() (v string) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ToolDefMetadataUnion) AsAnyArray() (v []any) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +// Returns the unmodified JSON received from the API +func (u ToolDefMetadataUnion) RawJSON() string { return u.JSON.raw } + +func (r *ToolDefMetadataUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// ToolDefOutputSchemaUnion 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 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 + } `json:"-"` +} + +func (u ToolDefOutputSchemaUnion) AsBool() (v bool) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ToolDefOutputSchemaUnion) AsFloat() (v float64) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ToolDefOutputSchemaUnion) AsString() (v string) { + apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) + return +} + +func (u ToolDefOutputSchemaUnion) AsAnyArray() (v []any) { + 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 (r *ToolDefOutputSchemaUnion) 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 shared.InterleavedContentUnion `json:"content"` + 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 @@ -143,6 +338,8 @@ type ToolRuntimeInvokeToolParams struct { 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. + Authorization param.Opt[string] `json:"authorization,omitzero"` paramObj } @@ -186,6 +383,8 @@ func (u *ToolRuntimeInvokeToolParamsKwargUnion) asAny() any { } 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. @@ -223,7 +422,7 @@ func (r ToolRuntimeListToolsParamsMcpEndpoint) URLQuery() (v url.Values, err err // Response containing a list of tool definitions. type ToolRuntimeListToolsResponseEnvelope struct { // List of tool definitions - Data []shared.SharedToolDef `json:"data,required"` + Data []ToolDef `json:"data,required"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { Data respjson.Field diff --git a/toolruntime_test.go b/toolruntime_test.go index 10c4bc1..d183229 100644 --- a/toolruntime_test.go +++ b/toolruntime_test.go @@ -1,3 +1,9 @@ +// 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 @@ -13,7 +19,7 @@ import ( "github.com/llamastack/llama-stack-client-go/option" ) -func TestToolRuntimeInvokeTool(t *testing.T) { +func TestToolRuntimeInvokeToolWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -30,7 +36,8 @@ func TestToolRuntimeInvokeTool(t *testing.T) { OfBool: llamastackclient.Bool(true), }, }, - ToolName: "tool_name", + ToolName: "tool_name", + Authorization: llamastackclient.String("authorization"), }) if err != nil { var apierr *llamastackclient.Error @@ -42,7 +49,7 @@ func TestToolRuntimeInvokeTool(t *testing.T) { } func TestToolRuntimeListToolsWithOptionalParams(t *testing.T) { - t.Skip("invalid query params unsupported by prism") + t.Skip("TODO: investigate mock server 400 error") baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -54,6 +61,7 @@ func TestToolRuntimeListToolsWithOptionalParams(t *testing.T) { option.WithBaseURL(baseURL), ) _, err := client.ToolRuntime.ListTools(context.TODO(), llamastackclient.ToolRuntimeListToolsParams{ + Authorization: llamastackclient.String("authorization"), McpEndpoint: llamastackclient.ToolRuntimeListToolsParamsMcpEndpoint{ Uri: "uri", }, diff --git a/toolruntimeragtool.go b/toolruntimeragtool.go index 603e9cb..1834df2 100644 --- a/toolruntimeragtool.go +++ b/toolruntimeragtool.go @@ -1,16 +1,15 @@ +// 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" - "net/http" - - "github.com/llamastack/llama-stack-client-go/internal/apijson" - "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/shared" ) // ToolRuntimeRagToolService contains methods and other services that help with @@ -31,56 +30,3 @@ func NewToolRuntimeRagToolService(opts ...option.RequestOption) (r ToolRuntimeRa r.Options = opts return } - -// Index documents so they can be used by the RAG system. -func (r *ToolRuntimeRagToolService) Insert(ctx context.Context, body ToolRuntimeRagToolInsertParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - path := "v1/tool-runtime/rag-tool/insert" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...) - return -} - -// Query the RAG system for context; typically invoked by the agent. -func (r *ToolRuntimeRagToolService) Query(ctx context.Context, body ToolRuntimeRagToolQueryParams, opts ...option.RequestOption) (res *shared.QueryResult, err error) { - opts = append(r.Options[:], opts...) - path := "v1/tool-runtime/rag-tool/query" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) - return -} - -type ToolRuntimeRagToolInsertParams struct { - // (Optional) Size in tokens for document chunking during indexing - ChunkSizeInTokens int64 `json:"chunk_size_in_tokens,required"` - // List of documents to index in the RAG system - Documents []shared.DocumentParam `json:"documents,omitzero,required"` - // ID of the vector database to store the document embeddings - VectorDBID string `json:"vector_db_id,required"` - paramObj -} - -func (r ToolRuntimeRagToolInsertParams) MarshalJSON() (data []byte, err error) { - type shadow ToolRuntimeRagToolInsertParams - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *ToolRuntimeRagToolInsertParams) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type ToolRuntimeRagToolQueryParams struct { - // The query content to search for in the indexed documents - Content shared.InterleavedContentUnionParam `json:"content,omitzero,required"` - // List of vector database IDs to search within - VectorDBIDs []string `json:"vector_db_ids,omitzero,required"` - // (Optional) Configuration parameters for the query operation - QueryConfig shared.QueryConfigParam `json:"query_config,omitzero"` - paramObj -} - -func (r ToolRuntimeRagToolQueryParams) MarshalJSON() (data []byte, err error) { - type shadow ToolRuntimeRagToolQueryParams - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *ToolRuntimeRagToolQueryParams) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} diff --git a/toolruntimeragtool_test.go b/toolruntimeragtool_test.go deleted file mode 100644 index a2dcfb6..0000000 --- a/toolruntimeragtool_test.go +++ /dev/null @@ -1,93 +0,0 @@ -// 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" - "github.com/llamastack/llama-stack-client-go/shared" -) - -func TestToolRuntimeRagToolInsert(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.ToolRuntime.RagTool.Insert(context.TODO(), llamastackclient.ToolRuntimeRagToolInsertParams{ - ChunkSizeInTokens: 0, - Documents: []shared.DocumentParam{{ - Content: shared.DocumentContentUnionParam{ - OfString: llamastackclient.String("string"), - }, - DocumentID: "document_id", - Metadata: map[string]shared.DocumentMetadataUnionParam{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, - }, - MimeType: llamastackclient.String("mime_type"), - }}, - VectorDBID: "vector_db_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 TestToolRuntimeRagToolQueryWithOptionalParams(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.ToolRuntime.RagTool.Query(context.TODO(), llamastackclient.ToolRuntimeRagToolQueryParams{ - Content: shared.InterleavedContentUnionParam{ - OfString: llamastackclient.String("string"), - }, - VectorDBIDs: []string{"string"}, - QueryConfig: shared.QueryConfigParam{ - ChunkTemplate: "chunk_template", - MaxChunks: 0, - MaxTokensInContext: 0, - QueryGeneratorConfig: shared.QueryGeneratorConfigUnionParam{ - OfDefault: &shared.QueryGeneratorConfigDefaultParam{ - Separator: "separator", - }, - }, - Mode: shared.QueryConfigModeVector, - Ranker: shared.QueryConfigRankerUnionParam{ - OfRrf: &shared.QueryConfigRankerRrfParam{ - ImpactFactor: 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()) - } -} diff --git a/usage_test.go b/usage_test.go index f22a896..b4bd603 100644 --- a/usage_test.go +++ b/usage_test.go @@ -1,3 +1,9 @@ +// 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 @@ -23,11 +29,11 @@ func TestUsage(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - model, err := client.Models.Register(context.TODO(), llamastackclient.ModelRegisterParams{ + response, err := client.Models.Register(context.TODO(), llamastackclient.ModelRegisterParams{ ModelID: "model_id", }) if err != nil { t.Fatalf("err should be nil: %s", err.Error()) } - t.Logf("%+v\n", model.Identifier) + t.Logf("%+v\n", response.Identifier) } diff --git a/vectordb.go b/vectordb.go deleted file mode 100644 index 99547fa..0000000 --- a/vectordb.go +++ /dev/null @@ -1,220 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package llamastackclient - -import ( - "context" - "errors" - "fmt" - "net/http" - - "github.com/llamastack/llama-stack-client-go/internal/apijson" - "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" -) - -// VectorDBService 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 [NewVectorDBService] method instead. -type VectorDBService struct { - Options []option.RequestOption -} - -// NewVectorDBService 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 NewVectorDBService(opts ...option.RequestOption) (r VectorDBService) { - r = VectorDBService{} - r.Options = opts - return -} - -// Get a vector database by its identifier. -func (r *VectorDBService) Get(ctx context.Context, vectorDBID string, opts ...option.RequestOption) (res *VectorDBGetResponse, err error) { - opts = append(r.Options[:], opts...) - if vectorDBID == "" { - err = errors.New("missing required vector_db_id parameter") - return - } - path := fmt.Sprintf("v1/vector-dbs/%s", vectorDBID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) - return -} - -// List all vector databases. -func (r *VectorDBService) List(ctx context.Context, opts ...option.RequestOption) (res *[]ListVectorDBsResponseData, err error) { - var env ListVectorDBsResponse - opts = append(r.Options[:], opts...) - path := "v1/vector-dbs" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Data - return -} - -// Register a vector database. -func (r *VectorDBService) Register(ctx context.Context, body VectorDBRegisterParams, opts ...option.RequestOption) (res *VectorDBRegisterResponse, err error) { - opts = append(r.Options[:], opts...) - path := "v1/vector-dbs" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) - return -} - -// Unregister a vector database. -func (r *VectorDBService) Unregister(ctx context.Context, vectorDBID string, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - if vectorDBID == "" { - err = errors.New("missing required vector_db_id parameter") - return - } - path := fmt.Sprintf("v1/vector-dbs/%s", vectorDBID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...) - return -} - -// Response from listing vector databases. -type ListVectorDBsResponse struct { - // List of vector databases - Data []ListVectorDBsResponseData `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:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ListVectorDBsResponse) RawJSON() string { return r.JSON.raw } -func (r *ListVectorDBsResponse) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Vector database resource for storing and querying vector embeddings. -type ListVectorDBsResponseData struct { - // Dimension of the embedding vectors - EmbeddingDimension int64 `json:"embedding_dimension,required"` - // Name of the embedding model to use for vector generation - EmbeddingModel string `json:"embedding_model,required"` - Identifier string `json:"identifier,required"` - ProviderID string `json:"provider_id,required"` - // Type of resource, always 'vector_db' for vector databases - Type constant.VectorDB `json:"type,required"` - ProviderResourceID string `json:"provider_resource_id"` - VectorDBName string `json:"vector_db_name"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - EmbeddingDimension respjson.Field - EmbeddingModel respjson.Field - Identifier respjson.Field - ProviderID respjson.Field - Type respjson.Field - ProviderResourceID respjson.Field - VectorDBName respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r ListVectorDBsResponseData) RawJSON() string { return r.JSON.raw } -func (r *ListVectorDBsResponseData) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Vector database resource for storing and querying vector embeddings. -type VectorDBGetResponse struct { - // Dimension of the embedding vectors - EmbeddingDimension int64 `json:"embedding_dimension,required"` - // Name of the embedding model to use for vector generation - EmbeddingModel string `json:"embedding_model,required"` - Identifier string `json:"identifier,required"` - ProviderID string `json:"provider_id,required"` - // Type of resource, always 'vector_db' for vector databases - Type constant.VectorDB `json:"type,required"` - ProviderResourceID string `json:"provider_resource_id"` - VectorDBName string `json:"vector_db_name"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - EmbeddingDimension respjson.Field - EmbeddingModel respjson.Field - Identifier respjson.Field - ProviderID respjson.Field - Type respjson.Field - ProviderResourceID respjson.Field - VectorDBName respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r VectorDBGetResponse) RawJSON() string { return r.JSON.raw } -func (r *VectorDBGetResponse) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Vector database resource for storing and querying vector embeddings. -type VectorDBRegisterResponse struct { - // Dimension of the embedding vectors - EmbeddingDimension int64 `json:"embedding_dimension,required"` - // Name of the embedding model to use for vector generation - EmbeddingModel string `json:"embedding_model,required"` - Identifier string `json:"identifier,required"` - ProviderID string `json:"provider_id,required"` - // Type of resource, always 'vector_db' for vector databases - Type constant.VectorDB `json:"type,required"` - ProviderResourceID string `json:"provider_resource_id"` - VectorDBName string `json:"vector_db_name"` - // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. - JSON struct { - EmbeddingDimension respjson.Field - EmbeddingModel respjson.Field - Identifier respjson.Field - ProviderID respjson.Field - Type respjson.Field - ProviderResourceID respjson.Field - VectorDBName respjson.Field - ExtraFields map[string]respjson.Field - raw string - } `json:"-"` -} - -// Returns the unmodified JSON received from the API -func (r VectorDBRegisterResponse) RawJSON() string { return r.JSON.raw } -func (r *VectorDBRegisterResponse) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -type VectorDBRegisterParams struct { - // The embedding model to use. - EmbeddingModel string `json:"embedding_model,required"` - // The identifier of the vector database to register. - VectorDBID string `json:"vector_db_id,required"` - // The dimension of the embedding model. - EmbeddingDimension param.Opt[int64] `json:"embedding_dimension,omitzero"` - // The identifier of the provider. - ProviderID param.Opt[string] `json:"provider_id,omitzero"` - // The identifier of the vector database in the provider. - ProviderVectorDBID param.Opt[string] `json:"provider_vector_db_id,omitzero"` - // The name of the vector database. - VectorDBName param.Opt[string] `json:"vector_db_name,omitzero"` - paramObj -} - -func (r VectorDBRegisterParams) MarshalJSON() (data []byte, err error) { - type shadow VectorDBRegisterParams - return param.MarshalObject(r, (*shadow)(&r)) -} -func (r *VectorDBRegisterParams) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} diff --git a/vectorio.go b/vectorio.go index b830aed..5b271d1 100644 --- a/vectorio.go +++ b/vectorio.go @@ -1,3 +1,9 @@ +// 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 @@ -6,13 +12,13 @@ import ( "context" "encoding/json" "net/http" + "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" "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" ) // VectorIoService contains methods and other services that help with interacting @@ -36,7 +42,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 = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) path := "v1/vector-io/insert" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...) @@ -45,7 +51,7 @@ func (r *VectorIoService) Insert(ctx context.Context, body VectorIoInsertParams, // Query chunks from a vector database. func (r *VectorIoService) Query(ctx context.Context, body VectorIoQueryParams, opts ...option.RequestOption) (res *QueryChunksResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) path := "v1/vector-io/query" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return @@ -74,8 +80,10 @@ 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 shared.InterleavedContentUnion `json:"content,required"` + 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"` @@ -84,16 +92,13 @@ type QueryChunksResponseChunk struct { ChunkMetadata QueryChunksResponseChunkChunkMetadata `json:"chunk_metadata"` // Optional embedding for the chunk. If not provided, it will be computed later. Embedding []float64 `json:"embedding"` - // The chunk ID that is stored in the vector database. Used for backend - // functionality. - StoredChunkID string `json:"stored_chunk_id"` // 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 - StoredChunkID respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -215,7 +220,7 @@ type VectorIoInsertParams struct { // not provided, it will be computed later. Chunks []VectorIoInsertParamsChunk `json:"chunks,omitzero,required"` // The identifier of the vector database to insert the chunks into. - VectorDBID string `json:"vector_db_id,required"` + VectorStoreID string `json:"vector_store_id,required"` // The time to live of the chunks. TtlSeconds param.Opt[int64] `json:"ttl_seconds,omitzero"` paramObj @@ -231,16 +236,15 @@ func (r *VectorIoInsertParams) UnmarshalJSON(data []byte) error { // A chunk of content that can be inserted into a vector database. // -// The properties Content, Metadata are required. +// The properties ChunkID, Content, Metadata 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 shared.InterleavedContentUnionParam `json:"content,omitzero,required"` + 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"` - // The chunk ID that is stored in the vector database. Used for backend - // functionality. - StoredChunkID param.Opt[string] `json:"stored_chunk_id,omitzero"` // Metadata for the chunk that will NOT be used in the context during inference. // The `chunk_metadata` is required backend functionality. ChunkMetadata VectorIoInsertParamsChunkChunkMetadata `json:"chunk_metadata,omitzero"` @@ -327,9 +331,9 @@ func (r *VectorIoInsertParamsChunkChunkMetadata) UnmarshalJSON(data []byte) erro type VectorIoQueryParams struct { // The query to search for. - Query shared.InterleavedContentUnionParam `json:"query,omitzero,required"` + Query InterleavedContentUnionParam `json:"query,omitzero,required"` // The identifier of the vector database to query. - VectorDBID string `json:"vector_db_id,required"` + VectorStoreID string `json:"vector_store_id,required"` // The parameters of the query. Params map[string]VectorIoQueryParamsParamUnion `json:"params,omitzero"` paramObj diff --git a/vectorio_test.go b/vectorio_test.go index 73d696e..1c1973b 100644 --- a/vectorio_test.go +++ b/vectorio_test.go @@ -1,3 +1,9 @@ +// 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 @@ -11,7 +17,6 @@ import ( "github.com/llamastack/llama-stack-client-go" "github.com/llamastack/llama-stack-client-go/internal/testutil" "github.com/llamastack/llama-stack-client-go/option" - "github.com/llamastack/llama-stack-client-go/shared" ) func TestVectorIoInsertWithOptionalParams(t *testing.T) { @@ -27,7 +32,8 @@ func TestVectorIoInsertWithOptionalParams(t *testing.T) { ) err := client.VectorIo.Insert(context.TODO(), llamastackclient.VectorIoInsertParams{ Chunks: []llamastackclient.VectorIoInsertParamsChunk{{ - Content: shared.InterleavedContentUnionParam{ + ChunkID: "chunk_id", + Content: llamastackclient.InterleavedContentUnionParam{ OfString: llamastackclient.String("string"), }, Metadata: map[string]llamastackclient.VectorIoInsertParamsChunkMetadataUnion{ @@ -48,11 +54,10 @@ func TestVectorIoInsertWithOptionalParams(t *testing.T) { Source: llamastackclient.String("source"), UpdatedTimestamp: llamastackclient.Int(0), }, - Embedding: []float64{0}, - StoredChunkID: llamastackclient.String("stored_chunk_id"), + Embedding: []float64{0}, }}, - VectorDBID: "vector_db_id", - TtlSeconds: llamastackclient.Int(0), + VectorStoreID: "vector_store_id", + TtlSeconds: llamastackclient.Int(0), }) if err != nil { var apierr *llamastackclient.Error @@ -75,10 +80,10 @@ func TestVectorIoQueryWithOptionalParams(t *testing.T) { option.WithBaseURL(baseURL), ) _, err := client.VectorIo.Query(context.TODO(), llamastackclient.VectorIoQueryParams{ - Query: shared.InterleavedContentUnionParam{ + Query: llamastackclient.InterleavedContentUnionParam{ OfString: llamastackclient.String("string"), }, - VectorDBID: "vector_db_id", + VectorStoreID: "vector_store_id", Params: map[string]llamastackclient.VectorIoQueryParamsParamUnion{ "foo": { OfBool: llamastackclient.Bool(true), diff --git a/vectorstore.go b/vectorstore.go index 8a41fde..a621236 100644 --- a/vectorstore.go +++ b/vectorstore.go @@ -1,3 +1,9 @@ +// 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 @@ -9,6 +15,7 @@ import ( "fmt" "net/http" "net/url" + "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" "github.com/llamastack/llama-stack-client-go/internal/apiquery" @@ -27,8 +34,9 @@ import ( // automatically. You should not instantiate this service directly, and instead use // the [NewVectorStoreService] method instead. type VectorStoreService struct { - Options []option.RequestOption - Files VectorStoreFileService + Options []option.RequestOption + Files VectorStoreFileService + FileBatches VectorStoreFileBatchService } // NewVectorStoreService generates a new service that applies the given options to @@ -38,37 +46,39 @@ func NewVectorStoreService(opts ...option.RequestOption) (r VectorStoreService) r = VectorStoreService{} r.Options = opts r.Files = NewVectorStoreFileService(opts...) + r.FileBatches = NewVectorStoreFileBatchService(opts...) return } -// Creates a vector store. +// 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 = append(r.Options[:], opts...) - path := "v1/openai/v1/vector_stores" + opts = slices.Concat(r.Options, opts) + path := "v1/vector_stores" err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return } // Retrieves a vector store. func (r *VectorStoreService) Get(ctx context.Context, vectorStoreID string, opts ...option.RequestOption) (res *VectorStore, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if vectorStoreID == "" { err = errors.New("missing required vector_store_id parameter") return } - path := fmt.Sprintf("v1/openai/v1/vector_stores/%s", vectorStoreID) + path := fmt.Sprintf("v1/vector_stores/%s", vectorStoreID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return } // Updates a vector store. func (r *VectorStoreService) Update(ctx context.Context, vectorStoreID string, body VectorStoreUpdateParams, opts ...option.RequestOption) (res *VectorStore, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if vectorStoreID == "" { err = errors.New("missing required vector_store_id parameter") return } - path := fmt.Sprintf("v1/openai/v1/vector_stores/%s", vectorStoreID) + path := fmt.Sprintf("v1/vector_stores/%s", vectorStoreID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return } @@ -76,9 +86,9 @@ func (r *VectorStoreService) Update(ctx context.Context, vectorStoreID string, b // Returns a list of vector stores. func (r *VectorStoreService) List(ctx context.Context, query VectorStoreListParams, opts ...option.RequestOption) (res *pagination.OpenAICursorPage[VectorStore], err error) { var raw *http.Response - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := "v1/openai/v1/vector_stores" + path := "v1/vector_stores" cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) if err != nil { return nil, err @@ -98,12 +108,12 @@ func (r *VectorStoreService) ListAutoPaging(ctx context.Context, query VectorSto // Delete a vector store. func (r *VectorStoreService) Delete(ctx context.Context, vectorStoreID string, opts ...option.RequestOption) (res *VectorStoreDeleteResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if vectorStoreID == "" { err = errors.New("missing required vector_store_id parameter") return } - path := fmt.Sprintf("v1/openai/v1/vector_stores/%s", vectorStoreID) + path := fmt.Sprintf("v1/vector_stores/%s", vectorStoreID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) return } @@ -111,12 +121,12 @@ func (r *VectorStoreService) Delete(ctx context.Context, vectorStoreID string, o // 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 = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if vectorStoreID == "" { err = errors.New("missing required vector_store_id parameter") return } - path := fmt.Sprintf("v1/openai/v1/vector_stores/%s/search", vectorStoreID) + path := fmt.Sprintf("v1/vector_stores/%s/search", vectorStoreID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return } @@ -366,7 +376,7 @@ type VectorStoreSearchResponse struct { // 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"` + SearchQuery []string `json:"search_query,required"` // (Optional) Token for retrieving the next page of results NextPage string `json:"next_page"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. @@ -423,12 +433,21 @@ type VectorStoreSearchResponseDataContent struct { Text string `json:"text,required"` // Content type, currently only "text" is supported 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"` // 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 + Text respjson.Field + Type respjson.Field + ChunkMetadata respjson.Field + Embedding respjson.Field + Metadata respjson.Field + ExtraFields map[string]respjson.Field + raw string } `json:"-"` } @@ -438,6 +457,107 @@ func (r *VectorStoreSearchResponseDataContent) UnmarshalJSON(data []byte) error return apijson.UnmarshalRoot(data, r) } +// Optional chunk metadata +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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ChunkEmbeddingDimension respjson.Field + ChunkEmbeddingModel respjson.Field + ChunkID respjson.Field + ChunkTokenizer respjson.Field + ChunkWindow respjson.Field + ContentTokenCount respjson.Field + CreatedTimestamp respjson.Field + DocumentID respjson.Field + MetadataTokenCount respjson.Field + Source respjson.Field + UpdatedTimestamp respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r VectorStoreSearchResponseDataContentChunkMetadata) RawJSON() string { return r.JSON.raw } +func (r *VectorStoreSearchResponseDataContentChunkMetadata) UnmarshalJSON(data []byte) error { + 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]. // @@ -483,23 +603,15 @@ func (r *VectorStoreSearchResponseDataAttributeUnion) UnmarshalJSON(data []byte) } type VectorStoreNewParams struct { - // The dimension of the embedding vectors (default: 384). - EmbeddingDimension param.Opt[int64] `json:"embedding_dimension,omitzero"` - // The embedding model to use for this vector store. - EmbeddingModel param.Opt[string] `json:"embedding_model,omitzero"` - // A name for the vector store. + // (Optional) A name for the vector store Name param.Opt[string] `json:"name,omitzero"` - // The ID of the provider to use for this vector store. - ProviderID param.Opt[string] `json:"provider_id,omitzero"` - // The chunking strategy used to chunk the file(s). If not set, will use the `auto` - // strategy. - ChunkingStrategy map[string]VectorStoreNewParamsChunkingStrategyUnion `json:"chunking_strategy,omitzero"` - // The expiration policy for a vector store. + // (Optional) Strategy for splitting files into chunks + ChunkingStrategy VectorStoreNewParamsChunkingStrategyUnion `json:"chunking_strategy,omitzero"` + // (Optional) Expiration policy for the vector store ExpiresAfter map[string]VectorStoreNewParamsExpiresAfterUnion `json:"expires_after,omitzero"` - // A list of File IDs that the vector store should use. Useful for tools like - // `file_search` that can access files. + // List of file IDs to include in the vector store FileIDs []string `json:"file_ids,omitzero"` - // Set of 16 key-value pairs that can be attached to an object. + // Set of key-value pairs that can be attached to the vector store Metadata map[string]VectorStoreNewParamsMetadataUnion `json:"metadata,omitzero"` paramObj } @@ -516,33 +628,117 @@ func (r *VectorStoreNewParams) UnmarshalJSON(data []byte) error { // // Use [param.IsOmitted] to confirm if a field is set. type VectorStoreNewParamsChunkingStrategyUnion 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"` + OfAuto *VectorStoreNewParamsChunkingStrategyAuto `json:",omitzero,inline"` + OfStatic *VectorStoreNewParamsChunkingStrategyStatic `json:",omitzero,inline"` paramUnion } func (u VectorStoreNewParamsChunkingStrategyUnion) MarshalJSON() ([]byte, error) { - return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray) + return param.MarshalUnion(u, u.OfAuto, u.OfStatic) } func (u *VectorStoreNewParamsChunkingStrategyUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, u) } func (u *VectorStoreNewParamsChunkingStrategyUnion) 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 + if !param.IsOmitted(u.OfAuto) { + return u.OfAuto + } else if !param.IsOmitted(u.OfStatic) { + return u.OfStatic + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u VectorStoreNewParamsChunkingStrategyUnion) GetStatic() *VectorStoreNewParamsChunkingStrategyStaticStatic { + if vt := u.OfStatic; vt != nil { + return &vt.Static + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u VectorStoreNewParamsChunkingStrategyUnion) GetType() *string { + if vt := u.OfAuto; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfStatic; vt != nil { + return (*string)(&vt.Type) } return nil } +func init() { + apijson.RegisterUnion[VectorStoreNewParamsChunkingStrategyUnion]( + "type", + apijson.Discriminator[VectorStoreNewParamsChunkingStrategyAuto]("auto"), + apijson.Discriminator[VectorStoreNewParamsChunkingStrategyStatic]("static"), + ) +} + +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"` + paramObj +} + +func (r VectorStoreNewParamsChunkingStrategyAuto) MarshalJSON() (data []byte, err error) { + type shadow VectorStoreNewParamsChunkingStrategyAuto + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *VectorStoreNewParamsChunkingStrategyAuto) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Static chunking strategy with configurable parameters. +// +// The properties Static, Type are required. +type VectorStoreNewParamsChunkingStrategyStatic struct { + // Configuration parameters for the 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"` + paramObj +} + +func (r VectorStoreNewParamsChunkingStrategyStatic) MarshalJSON() (data []byte, err error) { + type shadow VectorStoreNewParamsChunkingStrategyStatic + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *VectorStoreNewParamsChunkingStrategyStatic) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Configuration parameters for the static chunking strategy +// +// The properties ChunkOverlapTokens, MaxChunkSizeTokens are required. +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"` + paramObj +} + +func (r VectorStoreNewParamsChunkingStrategyStaticStatic) MarshalJSON() (data []byte, err error) { + type shadow VectorStoreNewParamsChunkingStrategyStaticStatic + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *VectorStoreNewParamsChunkingStrategyStaticStatic) 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. diff --git a/vectorstore_test.go b/vectorstore_test.go index 535122e..6872e9a 100644 --- a/vectorstore_test.go +++ b/vectorstore_test.go @@ -1,3 +1,9 @@ +// 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 @@ -25,13 +31,9 @@ func TestVectorStoreNewWithOptionalParams(t *testing.T) { option.WithBaseURL(baseURL), ) _, err := client.VectorStores.New(context.TODO(), llamastackclient.VectorStoreNewParams{ - ChunkingStrategy: map[string]llamastackclient.VectorStoreNewParamsChunkingStrategyUnion{ - "foo": { - OfBool: llamastackclient.Bool(true), - }, + ChunkingStrategy: llamastackclient.VectorStoreNewParamsChunkingStrategyUnion{ + OfAuto: &llamastackclient.VectorStoreNewParamsChunkingStrategyAuto{}, }, - EmbeddingDimension: llamastackclient.Int(0), - EmbeddingModel: llamastackclient.String("embedding_model"), ExpiresAfter: map[string]llamastackclient.VectorStoreNewParamsExpiresAfterUnion{ "foo": { OfBool: llamastackclient.Bool(true), @@ -43,8 +45,7 @@ func TestVectorStoreNewWithOptionalParams(t *testing.T) { OfBool: llamastackclient.Bool(true), }, }, - Name: llamastackclient.String("name"), - ProviderID: llamastackclient.String("provider_id"), + Name: llamastackclient.String("name"), }) if err != nil { var apierr *llamastackclient.Error diff --git a/vectorstorefile.go b/vectorstorefile.go index c05d2c6..c716302 100644 --- a/vectorstorefile.go +++ b/vectorstorefile.go @@ -1,3 +1,9 @@ +// 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 @@ -9,6 +15,7 @@ import ( "fmt" "net/http" "net/url" + "slices" "github.com/llamastack/llama-stack-client-go/internal/apijson" "github.com/llamastack/llama-stack-client-go/internal/apiquery" @@ -41,19 +48,19 @@ func NewVectorStoreFileService(opts ...option.RequestOption) (r VectorStoreFileS // Attach a file to a vector store. func (r *VectorStoreFileService) New(ctx context.Context, vectorStoreID string, body VectorStoreFileNewParams, opts ...option.RequestOption) (res *VectorStoreFile, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if vectorStoreID == "" { err = errors.New("missing required vector_store_id parameter") return } - path := fmt.Sprintf("v1/openai/v1/vector_stores/%s/files", vectorStoreID) + path := fmt.Sprintf("v1/vector_stores/%s/files", vectorStoreID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) return } // Retrieves a vector store file. func (r *VectorStoreFileService) Get(ctx context.Context, fileID string, query VectorStoreFileGetParams, opts ...option.RequestOption) (res *VectorStoreFile, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if query.VectorStoreID == "" { err = errors.New("missing required vector_store_id parameter") return @@ -62,14 +69,14 @@ func (r *VectorStoreFileService) Get(ctx context.Context, fileID string, query V err = errors.New("missing required file_id parameter") return } - path := fmt.Sprintf("v1/openai/v1/vector_stores/%s/files/%s", query.VectorStoreID, fileID) + path := fmt.Sprintf("v1/vector_stores/%s/files/%s", query.VectorStoreID, fileID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return } // Updates a vector store file. func (r *VectorStoreFileService) Update(ctx context.Context, fileID string, params VectorStoreFileUpdateParams, opts ...option.RequestOption) (res *VectorStoreFile, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if params.VectorStoreID == "" { err = errors.New("missing required vector_store_id parameter") return @@ -78,7 +85,7 @@ func (r *VectorStoreFileService) Update(ctx context.Context, fileID string, para err = errors.New("missing required file_id parameter") return } - path := fmt.Sprintf("v1/openai/v1/vector_stores/%s/files/%s", params.VectorStoreID, fileID) + path := fmt.Sprintf("v1/vector_stores/%s/files/%s", params.VectorStoreID, fileID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...) return } @@ -86,13 +93,13 @@ func (r *VectorStoreFileService) Update(ctx context.Context, fileID string, para // List files in a vector store. func (r *VectorStoreFileService) List(ctx context.Context, vectorStoreID string, query VectorStoreFileListParams, opts ...option.RequestOption) (res *pagination.OpenAICursorPage[VectorStoreFile], err error) { var raw *http.Response - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) if vectorStoreID == "" { err = errors.New("missing required vector_store_id parameter") return } - path := fmt.Sprintf("v1/openai/v1/vector_stores/%s/files", vectorStoreID) + path := fmt.Sprintf("v1/vector_stores/%s/files", vectorStoreID) cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) if err != nil { return nil, err @@ -112,7 +119,7 @@ func (r *VectorStoreFileService) ListAutoPaging(ctx context.Context, vectorStore // Delete a vector store file. func (r *VectorStoreFileService) Delete(ctx context.Context, fileID string, body VectorStoreFileDeleteParams, opts ...option.RequestOption) (res *VectorStoreFileDeleteResponse, err error) { - opts = append(r.Options[:], opts...) + opts = slices.Concat(r.Options, opts) if body.VectorStoreID == "" { err = errors.New("missing required vector_store_id parameter") return @@ -121,15 +128,15 @@ func (r *VectorStoreFileService) Delete(ctx context.Context, fileID string, body err = errors.New("missing required file_id parameter") return } - path := fmt.Sprintf("v1/openai/v1/vector_stores/%s/files/%s", body.VectorStoreID, fileID) + path := fmt.Sprintf("v1/vector_stores/%s/files/%s", body.VectorStoreID, fileID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) return } // Retrieves the contents of a vector store file. -func (r *VectorStoreFileService) Content(ctx context.Context, fileID string, query VectorStoreFileContentParams, opts ...option.RequestOption) (res *VectorStoreFileContentResponse, err error) { - opts = append(r.Options[:], opts...) - if query.VectorStoreID == "" { +func (r *VectorStoreFileService) Content(ctx context.Context, fileID string, params VectorStoreFileContentParams, opts ...option.RequestOption) (res *VectorStoreFileContentResponse, err error) { + opts = slices.Concat(r.Options, opts) + if params.VectorStoreID == "" { err = errors.New("missing required vector_store_id parameter") return } @@ -137,8 +144,8 @@ func (r *VectorStoreFileService) Content(ctx context.Context, fileID string, que err = errors.New("missing required file_id parameter") return } - path := fmt.Sprintf("v1/openai/v1/vector_stores/%s/files/%s/content", query.VectorStoreID, fileID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + path := fmt.Sprintf("v1/vector_stores/%s/files/%s/content", params.VectorStoreID, fileID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &res, opts...) return } @@ -428,22 +435,22 @@ func (r *VectorStoreFileDeleteResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// Response from retrieving the contents of a vector store file. +// Represents the parsed content of a vector store file. type VectorStoreFileContentResponse struct { - // Key-value attributes associated with the file - Attributes map[string]VectorStoreFileContentResponseAttributeUnion `json:"attributes,required"` - // List of content items from the file - Content []VectorStoreFileContentResponseContent `json:"content,required"` - // Unique identifier for the file - FileID string `json:"file_id,required"` - // Name of the file - Filename string `json:"filename,required"` + // 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"` // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. JSON struct { - Attributes respjson.Field - Content respjson.Field - FileID respjson.Field - Filename respjson.Field + Data respjson.Field + HasMore respjson.Field + Object respjson.Field + NextPage respjson.Field ExtraFields map[string]respjson.Field raw string } `json:"-"` @@ -455,14 +462,93 @@ func (r *VectorStoreFileContentResponse) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } -// VectorStoreFileContentResponseAttributeUnion contains all possible properties +// 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 + 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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Text respjson.Field + Type respjson.Field + ChunkMetadata respjson.Field + Embedding respjson.Field + Metadata respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r VectorStoreFileContentResponseData) RawJSON() string { return r.JSON.raw } +func (r *VectorStoreFileContentResponseData) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Optional chunk metadata +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"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + ChunkEmbeddingDimension respjson.Field + ChunkEmbeddingModel respjson.Field + ChunkID respjson.Field + ChunkTokenizer respjson.Field + ChunkWindow respjson.Field + ContentTokenCount respjson.Field + CreatedTimestamp respjson.Field + DocumentID respjson.Field + MetadataTokenCount respjson.Field + Source respjson.Field + UpdatedTimestamp respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r VectorStoreFileContentResponseDataChunkMetadata) RawJSON() string { return r.JSON.raw } +func (r *VectorStoreFileContentResponseDataChunkMetadata) UnmarshalJSON(data []byte) error { + 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 VectorStoreFileContentResponseAttributeUnion struct { +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. @@ -480,51 +566,30 @@ type VectorStoreFileContentResponseAttributeUnion struct { } `json:"-"` } -func (u VectorStoreFileContentResponseAttributeUnion) AsBool() (v bool) { +func (u VectorStoreFileContentResponseDataMetadataUnion) AsBool() (v bool) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u VectorStoreFileContentResponseAttributeUnion) AsFloat() (v float64) { +func (u VectorStoreFileContentResponseDataMetadataUnion) AsFloat() (v float64) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u VectorStoreFileContentResponseAttributeUnion) AsString() (v string) { +func (u VectorStoreFileContentResponseDataMetadataUnion) AsString() (v string) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } -func (u VectorStoreFileContentResponseAttributeUnion) AsAnyArray() (v []any) { +func (u VectorStoreFileContentResponseDataMetadataUnion) AsAnyArray() (v []any) { apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v) return } // Returns the unmodified JSON received from the API -func (u VectorStoreFileContentResponseAttributeUnion) RawJSON() string { return u.JSON.raw } - -func (r *VectorStoreFileContentResponseAttributeUnion) UnmarshalJSON(data []byte) error { - return apijson.UnmarshalRoot(data, r) -} - -// Content item from a vector store file or search result. -type VectorStoreFileContentResponseContent struct { - // The actual text content - Text string `json:"text,required"` - // Content type, currently only "text" is supported - 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 (u VectorStoreFileContentResponseDataMetadataUnion) RawJSON() string { return u.JSON.raw } -// Returns the unmodified JSON received from the API -func (r VectorStoreFileContentResponseContent) RawJSON() string { return r.JSON.raw } -func (r *VectorStoreFileContentResponseContent) UnmarshalJSON(data []byte) error { +func (r *VectorStoreFileContentResponseDataMetadataUnion) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } @@ -789,5 +854,18 @@ type VectorStoreFileDeleteParams struct { type VectorStoreFileContentParams struct { VectorStoreID string `path:"vector_store_id,required" json:"-"` + // Whether to include embedding vectors in the response. + 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:"-"` paramObj } + +// URLQuery serializes [VectorStoreFileContentParams]'s query parameters as +// `url.Values`. +func (r VectorStoreFileContentParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} diff --git a/vectorstorefile_test.go b/vectorstorefile_test.go index f1e7836..7cc9a51 100644 --- a/vectorstorefile_test.go +++ b/vectorstorefile_test.go @@ -1,3 +1,9 @@ +// 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 @@ -165,7 +171,7 @@ func TestVectorStoreFileDelete(t *testing.T) { } } -func TestVectorStoreFileContent(t *testing.T) { +func TestVectorStoreFileContentWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -180,7 +186,9 @@ func TestVectorStoreFileContent(t *testing.T) { context.TODO(), "file_id", llamastackclient.VectorStoreFileContentParams{ - VectorStoreID: "vector_store_id", + VectorStoreID: "vector_store_id", + IncludeEmbeddings: llamastackclient.Bool(true), + IncludeMetadata: llamastackclient.Bool(true), }, ) if err != nil { diff --git a/vectorstorefilebatch.go b/vectorstorefilebatch.go new file mode 100644 index 0000000..c736d48 --- /dev/null +++ b/vectorstorefilebatch.go @@ -0,0 +1,429 @@ +// 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" +) + +// VectorStoreFileBatchService 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 [NewVectorStoreFileBatchService] method instead. +type VectorStoreFileBatchService struct { + Options []option.RequestOption +} + +// NewVectorStoreFileBatchService 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 NewVectorStoreFileBatchService(opts ...option.RequestOption) (r VectorStoreFileBatchService) { + r = VectorStoreFileBatchService{} + r.Options = opts + return +} + +// 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 == "" { + err = errors.New("missing required vector_store_id parameter") + return + } + path := fmt.Sprintf("v1/vector_stores/%s/file_batches", vectorStoreID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return +} + +// Retrieve a vector store file batch. +func (r *VectorStoreFileBatchService) Get(ctx context.Context, batchID string, query VectorStoreFileBatchGetParams, opts ...option.RequestOption) (res *VectorStoreFileBatches, err error) { + opts = slices.Concat(r.Options, opts) + if query.VectorStoreID == "" { + err = errors.New("missing required vector_store_id parameter") + return + } + if batchID == "" { + err = errors.New("missing required batch_id parameter") + return + } + path := fmt.Sprintf("v1/vector_stores/%s/file_batches/%s", query.VectorStoreID, batchID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return +} + +// Cancels a vector store file batch. +func (r *VectorStoreFileBatchService) Cancel(ctx context.Context, batchID string, body VectorStoreFileBatchCancelParams, opts ...option.RequestOption) (res *VectorStoreFileBatches, err error) { + opts = slices.Concat(r.Options, opts) + if body.VectorStoreID == "" { + err = errors.New("missing required vector_store_id parameter") + return + } + if batchID == "" { + err = errors.New("missing required batch_id parameter") + return + } + path := fmt.Sprintf("v1/vector_stores/%s/file_batches/%s/cancel", body.VectorStoreID, batchID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...) + return +} + +// Returns a list of vector store files in a batch. +func (r *VectorStoreFileBatchService) ListFiles(ctx context.Context, batchID string, params VectorStoreFileBatchListFilesParams, opts ...option.RequestOption) (res *pagination.OpenAICursorPage[VectorStoreFile], err error) { + var raw *http.Response + opts = slices.Concat(r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + if params.VectorStoreID == "" { + err = errors.New("missing required vector_store_id parameter") + return + } + if batchID == "" { + err = errors.New("missing required batch_id parameter") + return + } + path := fmt.Sprintf("v1/vector_stores/%s/file_batches/%s/files", params.VectorStoreID, batchID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Returns a list of vector store files in a batch. +func (r *VectorStoreFileBatchService) ListFilesAutoPaging(ctx context.Context, batchID string, params VectorStoreFileBatchListFilesParams, opts ...option.RequestOption) *pagination.OpenAICursorPageAutoPager[VectorStoreFile] { + return pagination.NewOpenAICursorPageAutoPager(r.ListFiles(ctx, batchID, params, opts...)) +} + +// 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"` + // 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 + LastID respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r ListVectorStoreFilesInBatchResponse) RawJSON() string { return r.JSON.raw } +func (r *ListVectorStoreFilesInBatchResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// 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 + 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"` + // 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 + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r VectorStoreFileBatches) RawJSON() string { return r.JSON.raw } +func (r *VectorStoreFileBatches) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// File processing status counts for the batch +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 + InProgress int64 `json:"in_progress,required"` + // Total number of files in the vector store + Total int64 `json:"total,required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Cancelled respjson.Field + Completed respjson.Field + Failed respjson.Field + InProgress respjson.Field + Total respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r VectorStoreFileBatchesFileCounts) RawJSON() string { return r.JSON.raw } +func (r *VectorStoreFileBatchesFileCounts) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Current processing status of the file batch +type VectorStoreFileBatchesStatus string + +const ( + VectorStoreFileBatchesStatusCompleted VectorStoreFileBatchesStatus = "completed" + VectorStoreFileBatchesStatusInProgress VectorStoreFileBatchesStatus = "in_progress" + VectorStoreFileBatchesStatusCancelled VectorStoreFileBatchesStatus = "cancelled" + VectorStoreFileBatchesStatusFailed VectorStoreFileBatchesStatus = "failed" +) + +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 + ChunkingStrategy VectorStoreFileBatchNewParamsChunkingStrategyUnion `json:"chunking_strategy,omitzero"` + paramObj +} + +func (r VectorStoreFileBatchNewParams) MarshalJSON() (data []byte, err error) { + type shadow VectorStoreFileBatchNewParams + return param.MarshalObject(r, (*shadow)(&r)) +} +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. +type VectorStoreFileBatchNewParamsChunkingStrategyUnion struct { + OfAuto *VectorStoreFileBatchNewParamsChunkingStrategyAuto `json:",omitzero,inline"` + OfStatic *VectorStoreFileBatchNewParamsChunkingStrategyStatic `json:",omitzero,inline"` + paramUnion +} + +func (u VectorStoreFileBatchNewParamsChunkingStrategyUnion) MarshalJSON() ([]byte, error) { + return param.MarshalUnion(u, u.OfAuto, u.OfStatic) +} +func (u *VectorStoreFileBatchNewParamsChunkingStrategyUnion) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, u) +} + +func (u *VectorStoreFileBatchNewParamsChunkingStrategyUnion) asAny() any { + if !param.IsOmitted(u.OfAuto) { + return u.OfAuto + } else if !param.IsOmitted(u.OfStatic) { + return u.OfStatic + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u VectorStoreFileBatchNewParamsChunkingStrategyUnion) GetStatic() *VectorStoreFileBatchNewParamsChunkingStrategyStaticStatic { + if vt := u.OfStatic; vt != nil { + return &vt.Static + } + return nil +} + +// Returns a pointer to the underlying variant's property, if present. +func (u VectorStoreFileBatchNewParamsChunkingStrategyUnion) GetType() *string { + if vt := u.OfAuto; vt != nil { + return (*string)(&vt.Type) + } else if vt := u.OfStatic; vt != nil { + return (*string)(&vt.Type) + } + return nil +} + +func init() { + apijson.RegisterUnion[VectorStoreFileBatchNewParamsChunkingStrategyUnion]( + "type", + apijson.Discriminator[VectorStoreFileBatchNewParamsChunkingStrategyAuto]("auto"), + apijson.Discriminator[VectorStoreFileBatchNewParamsChunkingStrategyStatic]("static"), + ) +} + +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"` + paramObj +} + +func (r VectorStoreFileBatchNewParamsChunkingStrategyAuto) MarshalJSON() (data []byte, err error) { + type shadow VectorStoreFileBatchNewParamsChunkingStrategyAuto + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *VectorStoreFileBatchNewParamsChunkingStrategyAuto) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Static chunking strategy with configurable parameters. +// +// The properties Static, Type are required. +type VectorStoreFileBatchNewParamsChunkingStrategyStatic struct { + // Configuration parameters for the 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"` + paramObj +} + +func (r VectorStoreFileBatchNewParamsChunkingStrategyStatic) MarshalJSON() (data []byte, err error) { + type shadow VectorStoreFileBatchNewParamsChunkingStrategyStatic + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *VectorStoreFileBatchNewParamsChunkingStrategyStatic) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +// Configuration parameters for the static chunking strategy +// +// The properties ChunkOverlapTokens, MaxChunkSizeTokens are required. +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"` + paramObj +} + +func (r VectorStoreFileBatchNewParamsChunkingStrategyStaticStatic) MarshalJSON() (data []byte, err error) { + type shadow VectorStoreFileBatchNewParamsChunkingStrategyStaticStatic + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *VectorStoreFileBatchNewParamsChunkingStrategyStaticStatic) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + +type VectorStoreFileBatchGetParams struct { + VectorStoreID string `path:"vector_store_id,required" json:"-"` + paramObj +} + +type VectorStoreFileBatchCancelParams struct { + VectorStoreID string `path:"vector_store_id,required" json:"-"` + paramObj +} + +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:"-"` + paramObj +} + +// URLQuery serializes [VectorStoreFileBatchListFilesParams]'s query parameters as +// `url.Values`. +func (r VectorStoreFileBatchListFilesParams) URLQuery() (v url.Values, err error) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} diff --git a/vectordb_test.go b/vectorstorefilebatch_test.go similarity index 54% rename from vectordb_test.go rename to vectorstorefilebatch_test.go index 5ab0bc4..a35cfc3 100644 --- a/vectordb_test.go +++ b/vectorstorefilebatch_test.go @@ -1,3 +1,9 @@ +// 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 @@ -13,7 +19,7 @@ import ( "github.com/llamastack/llama-stack-client-go/option" ) -func TestVectorDBGet(t *testing.T) { +func TestVectorStoreFileBatchNewWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -24,7 +30,21 @@ func TestVectorDBGet(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.VectorDBs.Get(context.TODO(), "vector_db_id") + _, err := client.VectorStores.FileBatches.New( + context.TODO(), + "vector_store_id", + llamastackclient.VectorStoreFileBatchNewParams{ + FileIDs: []string{"string"}, + Attributes: map[string]llamastackclient.VectorStoreFileBatchNewParamsAttributeUnion{ + "foo": { + OfBool: llamastackclient.Bool(true), + }, + }, + ChunkingStrategy: llamastackclient.VectorStoreFileBatchNewParamsChunkingStrategyUnion{ + OfAuto: &llamastackclient.VectorStoreFileBatchNewParamsChunkingStrategyAuto{}, + }, + }, + ) if err != nil { var apierr *llamastackclient.Error if errors.As(err, &apierr) { @@ -34,7 +54,7 @@ func TestVectorDBGet(t *testing.T) { } } -func TestVectorDBList(t *testing.T) { +func TestVectorStoreFileBatchGet(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -45,7 +65,13 @@ func TestVectorDBList(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.VectorDBs.List(context.TODO()) + _, err := client.VectorStores.FileBatches.Get( + context.TODO(), + "batch_id", + llamastackclient.VectorStoreFileBatchGetParams{ + VectorStoreID: "vector_store_id", + }, + ) if err != nil { var apierr *llamastackclient.Error if errors.As(err, &apierr) { @@ -55,7 +81,7 @@ func TestVectorDBList(t *testing.T) { } } -func TestVectorDBRegisterWithOptionalParams(t *testing.T) { +func TestVectorStoreFileBatchCancel(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -66,14 +92,13 @@ func TestVectorDBRegisterWithOptionalParams(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - _, err := client.VectorDBs.Register(context.TODO(), llamastackclient.VectorDBRegisterParams{ - EmbeddingModel: "embedding_model", - VectorDBID: "vector_db_id", - EmbeddingDimension: llamastackclient.Int(0), - ProviderID: llamastackclient.String("provider_id"), - ProviderVectorDBID: llamastackclient.String("provider_vector_db_id"), - VectorDBName: llamastackclient.String("vector_db_name"), - }) + _, err := client.VectorStores.FileBatches.Cancel( + context.TODO(), + "batch_id", + llamastackclient.VectorStoreFileBatchCancelParams{ + VectorStoreID: "vector_store_id", + }, + ) if err != nil { var apierr *llamastackclient.Error if errors.As(err, &apierr) { @@ -83,7 +108,7 @@ func TestVectorDBRegisterWithOptionalParams(t *testing.T) { } } -func TestVectorDBUnregister(t *testing.T) { +func TestVectorStoreFileBatchListFilesWithOptionalParams(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -94,7 +119,18 @@ func TestVectorDBUnregister(t *testing.T) { client := llamastackclient.NewClient( option.WithBaseURL(baseURL), ) - err := client.VectorDBs.Unregister(context.TODO(), "vector_db_id") + _, err := client.VectorStores.FileBatches.ListFiles( + context.TODO(), + "batch_id", + llamastackclient.VectorStoreFileBatchListFilesParams{ + VectorStoreID: "vector_store_id", + After: llamastackclient.String("after"), + Before: llamastackclient.String("before"), + Filter: llamastackclient.String("filter"), + Limit: llamastackclient.Int(0), + Order: llamastackclient.String("order"), + }, + ) if err != nil { var apierr *llamastackclient.Error if errors.As(err, &apierr) {