diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index ba6c348..f14b480 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "0.1.0-alpha.1"
+ ".": "0.1.0-alpha.2"
}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index b90091b..5588dfb 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: 108
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-b220f9f8667d2af8007134d0403b24452c20c9c512ca87d0b69b20b761272609.yml
+openapi_spec_hash: cde1096a830f2081d68f858f020fd53f
+config_hash: 8800bdff1a087b9d5211dda2a7b9f66f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 80af85e..78e75bf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,59 @@
# Changelog
+## 0.1.0-alpha.2 (2025-10-02)
+
+Full Changelog: [v0.1.0-alpha.1...v0.1.0-alpha.2](https://github.com/llamastack/llama-stack-client-go/compare/v0.1.0-alpha.1...v0.1.0-alpha.2)
+
+### ⚠ BREAKING CHANGES
+
+* **api:** use input_schema instead of parameters for tools
+* **api:** fixes to remove deprecated inference resources
+
+### Features
+
+* **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 ([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:** 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:** query_metrics, batches, changes ([06e03be](https://github.com/llamastack/llama-stack-client-go/commit/06e03be805d93736fcf4f848c5f9888e2871c911))
+* **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:** some updates to query metrics ([8243d43](https://github.com/llamastack/llama-stack-client-go/commit/8243d43dfa43bb9ec92d1edbed36f114240a265e))
+* **api:** tool api (input_schema, etc.) changes ([837277d](https://github.com/llamastack/llama-stack-client-go/commit/837277d4e6b4ffb57ce0136072b80400011da79a))
+* **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))
+
+
+### Bug Fixes
+
+* **api:** another fix to capture correct responses.create() params ([f3a9ee7](https://github.com/llamastack/llama-stack-client-go/commit/f3a9ee7303c890444802c76412d5d245a1420bdb))
+* **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))
+* use slices.Concat instead of sometimes modifying r.Options ([15dfa47](https://github.com/llamastack/llama-stack-client-go/commit/15dfa47636cc1cd0ccb6b089ae363a7e70a5f56c))
+
+
+### Chores
+
+* 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))
+* **internal:** codegen related update ([a3cccf1](https://github.com/llamastack/llama-stack-client-go/commit/a3cccf10d30121514bb6b07a6416c589a1881763))
+* 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..b43b1bb 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,11 @@
# Llama Stack Client Go API Library
+
+
+
+
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.1.0-alpha.2'
```
## Requirements
-This library requires Go 1.18+.
+This library requires Go 1.22+.
## Usage
@@ -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/aliases.go b/aliases.go
index 72179d3..378eb17 100644
--- a/aliases.go
+++ b/aliases.go
@@ -4,671 +4,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
-type paramUnion = param.APIUnion
-
-// aliased to make [param.APIObject] private when embedding
-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..c7791d6
--- /dev/null
+++ b/alpha.go
@@ -0,0 +1,34 @@
+// 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
+ Eval AlphaEvalService
+ Agents AlphaAgentService
+}
+
+// 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.Eval = NewAlphaEvalService(opts...)
+ r.Agents = NewAlphaAgentService(opts...)
+ return
+}
diff --git a/agent.go b/alphaagent.go
similarity index 80%
rename from agent.go
rename to alphaagent.go
index d5d87ef..7a75440 100644
--- a/agent.go
+++ b/alphaagent.go
@@ -9,6 +9,7 @@ import (
"fmt"
"net/http"
"net/url"
+ "slices"
"time"
"github.com/llamastack/llama-stack-client-go/internal/apijson"
@@ -17,72 +18,71 @@ 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"
"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.
+// AlphaAgentService 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 {
+// the [NewAlphaAgentService] method instead.
+type AlphaAgentService struct {
Options []option.RequestOption
- Session AgentSessionService
- Steps AgentStepService
- Turn AgentTurnService
+ Session AlphaAgentSessionService
+ Steps AlphaAgentStepService
+ Turn AlphaAgentTurnService
}
-// 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{}
+// NewAlphaAgentService 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 NewAlphaAgentService(opts ...option.RequestOption) (r AlphaAgentService) {
+ r = AlphaAgentService{}
r.Options = opts
- r.Session = NewAgentSessionService(opts...)
- r.Steps = NewAgentStepService(opts...)
- r.Turn = NewAgentTurnService(opts...)
+ r.Session = NewAlphaAgentSessionService(opts...)
+ r.Steps = NewAlphaAgentStepService(opts...)
+ r.Turn = NewAlphaAgentTurnService(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"
+func (r *AlphaAgentService) New(ctx context.Context, body AlphaAgentNewParams, opts ...option.RequestOption) (res *AlphaAgentNewResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ path := "v1alpha/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...)
+func (r *AlphaAgentService) Get(ctx context.Context, agentID string, opts ...option.RequestOption) (res *AlphaAgentGetResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
if agentID == "" {
err = errors.New("missing required agent_id parameter")
return
}
- path := fmt.Sprintf("v1/agents/%s", agentID)
+ path := fmt.Sprintf("v1alpha/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"
+func (r *AlphaAgentService) List(ctx context.Context, query AlphaAgentListParams, opts ...option.RequestOption) (res *AlphaAgentListResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
+ path := "v1alpha/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...)
+func (r *AlphaAgentService) Delete(ctx context.Context, agentID string, opts ...option.RequestOption) (err error) {
+ opts = slices.Concat(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)
+ path := fmt.Sprintf("v1alpha/agents/%s", agentID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
return
}
@@ -90,7 +90,7 @@ func (r *AgentService) Delete(ctx context.Context, agentID string, opts ...optio
// An inference step in an agent turn.
type InferenceStep struct {
// The response from the LLM.
- ModelResponse shared.CompletionMessage `json:"model_response,required"`
+ ModelResponse CompletionMessage `json:"model_response,required"`
// The ID of the step.
StepID string `json:"step_id,required"`
// Type of the step in an agent turn.
@@ -123,7 +123,7 @@ func (r *InferenceStep) UnmarshalJSON(data []byte) error {
// 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"`
+ InsertedContext InterleavedContentUnion `json:"inserted_context,required"`
// The ID of the step.
StepID string `json:"step_id,required"`
// Type of the step in an agent turn.
@@ -169,7 +169,7 @@ type ShieldCallStep struct {
// 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"`
+ Violation SafetyViolation `json:"violation"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
StepID respjson.Field
@@ -196,7 +196,7 @@ type ToolExecutionStep struct {
// 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"`
+ ToolCalls []ToolCall `json:"tool_calls,required"`
// The tool responses from the tool calls.
ToolResponses []ToolResponse `json:"tool_responses,required"`
// The ID of the turn.
@@ -230,7 +230,7 @@ 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"`
+ Content InterleavedContentUnion `json:"content,required"`
// Name of the tool that was invoked
ToolName ToolResponseToolName `json:"tool_name,required"`
// (Optional) Additional metadata about the tool response
@@ -330,7 +330,7 @@ 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"`
+ Content 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
@@ -378,7 +378,7 @@ func (u *ToolResponseMetadataUnionParam) asAny() any {
}
// Response returned when creating a new agent.
-type AgentNewResponse struct {
+type AlphaAgentNewResponse struct {
// Unique identifier for the created agent
AgentID string `json:"agent_id,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
@@ -390,15 +390,15 @@ type AgentNewResponse struct {
}
// Returns the unmodified JSON received from the API
-func (r AgentNewResponse) RawJSON() string { return r.JSON.raw }
-func (r *AgentNewResponse) UnmarshalJSON(data []byte) error {
+func (r AlphaAgentNewResponse) RawJSON() string { return r.JSON.raw }
+func (r *AlphaAgentNewResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// An agent instance with configuration and metadata.
-type AgentGetResponse struct {
+type AlphaAgentGetResponse struct {
// Configuration settings for the agent
- AgentConfig shared.AgentConfig `json:"agent_config,required"`
+ AgentConfig AgentConfig `json:"agent_config,required"`
// Unique identifier for the agent
AgentID string `json:"agent_id,required"`
// Timestamp when the agent was created
@@ -414,15 +414,15 @@ type AgentGetResponse struct {
}
// Returns the unmodified JSON received from the API
-func (r AgentGetResponse) RawJSON() string { return r.JSON.raw }
-func (r *AgentGetResponse) UnmarshalJSON(data []byte) error {
+func (r AlphaAgentGetResponse) RawJSON() string { return r.JSON.raw }
+func (r *AlphaAgentGetResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// A generic paginated response that follows a simple format.
-type AgentListResponse struct {
+type AlphaAgentListResponse struct {
// The list of items for the current page
- Data []map[string]AgentListResponseDataUnion `json:"data,required"`
+ Data []map[string]AlphaAgentListResponseDataUnion `json:"data,required"`
// Whether there are more items available after this set
HasMore bool `json:"has_more,required"`
// The URL for accessing this list
@@ -438,19 +438,19 @@ type AgentListResponse struct {
}
// Returns the unmodified JSON received from the API
-func (r AgentListResponse) RawJSON() string { return r.JSON.raw }
-func (r *AgentListResponse) UnmarshalJSON(data []byte) error {
+func (r AlphaAgentListResponse) RawJSON() string { return r.JSON.raw }
+func (r *AlphaAgentListResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
-// AgentListResponseDataUnion contains all possible properties and values from
+// AlphaAgentListResponseDataUnion 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 {
+type AlphaAgentListResponseDataUnion 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.
@@ -468,48 +468,48 @@ type AgentListResponseDataUnion struct {
} `json:"-"`
}
-func (u AgentListResponseDataUnion) AsBool() (v bool) {
+func (u AlphaAgentListResponseDataUnion) AsBool() (v bool) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
-func (u AgentListResponseDataUnion) AsFloat() (v float64) {
+func (u AlphaAgentListResponseDataUnion) AsFloat() (v float64) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
-func (u AgentListResponseDataUnion) AsString() (v string) {
+func (u AlphaAgentListResponseDataUnion) AsString() (v string) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
-func (u AgentListResponseDataUnion) AsAnyArray() (v []any) {
+func (u AlphaAgentListResponseDataUnion) 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 (u AlphaAgentListResponseDataUnion) RawJSON() string { return u.JSON.raw }
-func (r *AgentListResponseDataUnion) UnmarshalJSON(data []byte) error {
+func (r *AlphaAgentListResponseDataUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
-type AgentNewParams struct {
+type AlphaAgentNewParams struct {
// The configuration for the agent.
- AgentConfig shared.AgentConfigParam `json:"agent_config,omitzero,required"`
+ AgentConfig AgentConfigParam `json:"agent_config,omitzero,required"`
paramObj
}
-func (r AgentNewParams) MarshalJSON() (data []byte, err error) {
- type shadow AgentNewParams
+func (r AlphaAgentNewParams) MarshalJSON() (data []byte, err error) {
+ type shadow AlphaAgentNewParams
return param.MarshalObject(r, (*shadow)(&r))
}
-func (r *AgentNewParams) UnmarshalJSON(data []byte) error {
+func (r *AlphaAgentNewParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
-type AgentListParams struct {
+type AlphaAgentListParams struct {
// The number of agents to return.
Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
// The index to start the pagination from.
@@ -517,8 +517,8 @@ type AgentListParams struct {
paramObj
}
-// URLQuery serializes [AgentListParams]'s query parameters as `url.Values`.
-func (r AgentListParams) URLQuery() (v url.Values, err error) {
+// URLQuery serializes [AlphaAgentListParams]'s query parameters as `url.Values`.
+func (r AlphaAgentListParams) 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/alphaagent_test.go
similarity index 65%
rename from agent_test.go
rename to alphaagent_test.go
index 24d9e3c..521bf81 100644
--- a/agent_test.go
+++ b/alphaagent_test.go
@@ -11,10 +11,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 TestAgentNewWithOptionalParams(t *testing.T) {
+func TestAlphaAgentNewWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -25,58 +24,60 @@ func TestAgentNewWithOptionalParams(t *testing.T) {
client := llamastackclient.NewClient(
option.WithBaseURL(baseURL),
)
- _, err := client.Agents.New(context.TODO(), llamastackclient.AgentNewParams{
- AgentConfig: shared.AgentConfigParam{
+ _, err := client.Alpha.Agents.New(context.TODO(), llamastackclient.AlphaAgentNewParams{
+ AgentConfig: llamastackclient.AgentConfigParam{
Instructions: "instructions",
Model: "model",
- ClientTools: []shared.SharedToolDefParam{{
+ ClientTools: []llamastackclient.ToolDefParam{{
Name: "name",
Description: llamastackclient.String("description"),
- Metadata: map[string]shared.SharedToolDefMetadataUnionParam{
+ InputSchema: map[string]llamastackclient.ToolDefInputSchemaUnionParam{
"foo": {
OfBool: llamastackclient.Bool(true),
},
},
- Parameters: []shared.SharedToolDefParameterParam{{
- Description: "description",
- Name: "name",
- ParameterType: "parameter_type",
- Required: true,
- Default: shared.SharedToolDefParameterDefaultUnionParam{
+ Metadata: map[string]llamastackclient.ToolDefMetadataUnionParam{
+ "foo": {
+ OfBool: llamastackclient.Bool(true),
+ },
+ },
+ OutputSchema: map[string]llamastackclient.ToolDefOutputSchemaUnionParam{
+ "foo": {
OfBool: llamastackclient.Bool(true),
},
- }},
+ },
+ ToolgroupID: llamastackclient.String("toolgroup_id"),
}},
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{
+ ResponseFormat: llamastackclient.ResponseFormatUnionParam{
+ OfJsonSchema: &llamastackclient.ResponseFormatJsonSchemaParam{
+ JsonSchema: map[string]llamastackclient.ResponseFormatJsonSchemaJsonSchemaUnionParam{
"foo": {
OfBool: llamastackclient.Bool(true),
},
},
},
},
- SamplingParams: shared.SamplingParams{
- Strategy: shared.SamplingParamsStrategyUnion{
- OfGreedy: &shared.SamplingParamsStrategyGreedy{},
+ SamplingParams: llamastackclient.SamplingParams{
+ Strategy: llamastackclient.SamplingParamsStrategyUnion{
+ OfGreedy: &llamastackclient.SamplingParamsStrategyGreedy{},
},
MaxTokens: llamastackclient.Int(0),
RepetitionPenalty: llamastackclient.Float(0),
Stop: []string{"string"},
},
- ToolChoice: shared.AgentConfigToolChoiceAuto,
- ToolConfig: shared.AgentConfigToolConfigParam{
+ ToolChoice: llamastackclient.AgentConfigToolChoiceAuto,
+ ToolConfig: llamastackclient.AgentConfigToolConfigParam{
SystemMessageBehavior: "append",
ToolChoice: "auto",
ToolPromptFormat: "json",
},
- ToolPromptFormat: shared.AgentConfigToolPromptFormatJson,
- Toolgroups: []shared.AgentConfigToolgroupUnionParam{{
+ ToolPromptFormat: llamastackclient.AgentConfigToolPromptFormatJson,
+ Toolgroups: []llamastackclient.AgentConfigToolgroupUnionParam{{
OfString: llamastackclient.String("string"),
}},
},
@@ -90,7 +91,7 @@ func TestAgentNewWithOptionalParams(t *testing.T) {
}
}
-func TestAgentGet(t *testing.T) {
+func TestAlphaAgentGet(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -101,7 +102,7 @@ func TestAgentGet(t *testing.T) {
client := llamastackclient.NewClient(
option.WithBaseURL(baseURL),
)
- _, err := client.Agents.Get(context.TODO(), "agent_id")
+ _, err := client.Alpha.Agents.Get(context.TODO(), "agent_id")
if err != nil {
var apierr *llamastackclient.Error
if errors.As(err, &apierr) {
@@ -111,7 +112,7 @@ func TestAgentGet(t *testing.T) {
}
}
-func TestAgentListWithOptionalParams(t *testing.T) {
+func TestAlphaAgentListWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -122,7 +123,7 @@ func TestAgentListWithOptionalParams(t *testing.T) {
client := llamastackclient.NewClient(
option.WithBaseURL(baseURL),
)
- _, err := client.Agents.List(context.TODO(), llamastackclient.AgentListParams{
+ _, err := client.Alpha.Agents.List(context.TODO(), llamastackclient.AlphaAgentListParams{
Limit: llamastackclient.Int(0),
StartIndex: llamastackclient.Int(0),
})
@@ -135,7 +136,7 @@ func TestAgentListWithOptionalParams(t *testing.T) {
}
}
-func TestAgentDelete(t *testing.T) {
+func TestAlphaAgentDelete(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -146,7 +147,7 @@ func TestAgentDelete(t *testing.T) {
client := llamastackclient.NewClient(
option.WithBaseURL(baseURL),
)
- err := client.Agents.Delete(context.TODO(), "agent_id")
+ err := client.Alpha.Agents.Delete(context.TODO(), "agent_id")
if err != nil {
var apierr *llamastackclient.Error
if errors.As(err, &apierr) {
diff --git a/agentsession.go b/alphaagentsession.go
similarity index 64%
rename from agentsession.go
rename to alphaagentsession.go
index 6685efb..a928f51 100644
--- a/agentsession.go
+++ b/alphaagentsession.go
@@ -9,6 +9,7 @@ import (
"fmt"
"net/http"
"net/url"
+ "slices"
"time"
"github.com/llamastack/llama-stack-client-go/internal/apijson"
@@ -19,40 +20,40 @@ import (
"github.com/llamastack/llama-stack-client-go/packages/respjson"
)
-// AgentSessionService contains methods and other services that help with
+// AlphaAgentSessionService 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 {
+// the [NewAlphaAgentSessionService] method instead.
+type AlphaAgentSessionService 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{}
+// NewAlphaAgentSessionService 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 NewAlphaAgentSessionService(opts ...option.RequestOption) (r AlphaAgentSessionService) {
+ r = AlphaAgentSessionService{}
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...)
+func (r *AlphaAgentSessionService) New(ctx context.Context, agentID string, body AlphaAgentSessionNewParams, opts ...option.RequestOption) (res *AlphaAgentSessionNewResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
if agentID == "" {
err = errors.New("missing required agent_id parameter")
return
}
- path := fmt.Sprintf("v1/agents/%s/session", agentID)
+ path := fmt.Sprintf("v1alpha/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...)
+func (r *AlphaAgentSessionService) Get(ctx context.Context, sessionID string, params AlphaAgentSessionGetParams, opts ...option.RequestOption) (res *Session, err error) {
+ opts = slices.Concat(r.Options, opts)
if params.AgentID == "" {
err = errors.New("missing required agent_id parameter")
return
@@ -61,26 +62,26 @@ func (r *AgentSessionService) Get(ctx context.Context, sessionID string, params
err = errors.New("missing required session_id parameter")
return
}
- path := fmt.Sprintf("v1/agents/%s/session/%s", params.AgentID, sessionID)
+ path := fmt.Sprintf("v1alpha/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...)
+func (r *AlphaAgentSessionService) List(ctx context.Context, agentID string, query AlphaAgentSessionListParams, opts ...option.RequestOption) (res *AlphaAgentSessionListResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
if agentID == "" {
err = errors.New("missing required agent_id parameter")
return
}
- path := fmt.Sprintf("v1/agents/%s/sessions", agentID)
+ path := fmt.Sprintf("v1alpha/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...)
+func (r *AlphaAgentSessionService) Delete(ctx context.Context, sessionID string, body AlphaAgentSessionDeleteParams, opts ...option.RequestOption) (err error) {
+ opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...)
if body.AgentID == "" {
err = errors.New("missing required agent_id parameter")
@@ -90,7 +91,7 @@ func (r *AgentSessionService) Delete(ctx context.Context, sessionID string, body
err = errors.New("missing required session_id parameter")
return
}
- path := fmt.Sprintf("v1/agents/%s/session/%s", body.AgentID, sessionID)
+ path := fmt.Sprintf("v1alpha/agents/%s/session/%s", body.AgentID, sessionID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...)
return
}
@@ -123,7 +124,7 @@ func (r *Session) UnmarshalJSON(data []byte) error {
}
// Response returned when creating a new agent session.
-type AgentSessionNewResponse struct {
+type AlphaAgentSessionNewResponse struct {
// Unique identifier for the created session
SessionID string `json:"session_id,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
@@ -135,15 +136,15 @@ type AgentSessionNewResponse struct {
}
// Returns the unmodified JSON received from the API
-func (r AgentSessionNewResponse) RawJSON() string { return r.JSON.raw }
-func (r *AgentSessionNewResponse) UnmarshalJSON(data []byte) error {
+func (r AlphaAgentSessionNewResponse) RawJSON() string { return r.JSON.raw }
+func (r *AlphaAgentSessionNewResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// A generic paginated response that follows a simple format.
-type AgentSessionListResponse struct {
+type AlphaAgentSessionListResponse struct {
// The list of items for the current page
- Data []map[string]AgentSessionListResponseDataUnion `json:"data,required"`
+ Data []map[string]AlphaAgentSessionListResponseDataUnion `json:"data,required"`
// Whether there are more items available after this set
HasMore bool `json:"has_more,required"`
// The URL for accessing this list
@@ -159,19 +160,19 @@ type AgentSessionListResponse struct {
}
// Returns the unmodified JSON received from the API
-func (r AgentSessionListResponse) RawJSON() string { return r.JSON.raw }
-func (r *AgentSessionListResponse) UnmarshalJSON(data []byte) error {
+func (r AlphaAgentSessionListResponse) RawJSON() string { return r.JSON.raw }
+func (r *AlphaAgentSessionListResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
-// AgentSessionListResponseDataUnion contains all possible properties and values
-// from [bool], [float64], [string], [[]any].
+// AlphaAgentSessionListResponseDataUnion 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 {
+type AlphaAgentSessionListResponseDataUnion 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.
@@ -189,63 +190,64 @@ type AgentSessionListResponseDataUnion struct {
} `json:"-"`
}
-func (u AgentSessionListResponseDataUnion) AsBool() (v bool) {
+func (u AlphaAgentSessionListResponseDataUnion) AsBool() (v bool) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
-func (u AgentSessionListResponseDataUnion) AsFloat() (v float64) {
+func (u AlphaAgentSessionListResponseDataUnion) AsFloat() (v float64) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
-func (u AgentSessionListResponseDataUnion) AsString() (v string) {
+func (u AlphaAgentSessionListResponseDataUnion) AsString() (v string) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
-func (u AgentSessionListResponseDataUnion) AsAnyArray() (v []any) {
+func (u AlphaAgentSessionListResponseDataUnion) 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 (u AlphaAgentSessionListResponseDataUnion) RawJSON() string { return u.JSON.raw }
-func (r *AgentSessionListResponseDataUnion) UnmarshalJSON(data []byte) error {
+func (r *AlphaAgentSessionListResponseDataUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
-type AgentSessionNewParams struct {
+type AlphaAgentSessionNewParams 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
+func (r AlphaAgentSessionNewParams) MarshalJSON() (data []byte, err error) {
+ type shadow AlphaAgentSessionNewParams
return param.MarshalObject(r, (*shadow)(&r))
}
-func (r *AgentSessionNewParams) UnmarshalJSON(data []byte) error {
+func (r *AlphaAgentSessionNewParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
-type AgentSessionGetParams struct {
+type AlphaAgentSessionGetParams 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) {
+// URLQuery serializes [AlphaAgentSessionGetParams]'s query parameters as
+// `url.Values`.
+func (r AlphaAgentSessionGetParams) URLQuery() (v url.Values, err error) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
-type AgentSessionListParams struct {
+type AlphaAgentSessionListParams struct {
// The number of sessions to return.
Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
// The index to start the pagination from.
@@ -253,15 +255,16 @@ type AgentSessionListParams struct {
paramObj
}
-// URLQuery serializes [AgentSessionListParams]'s query parameters as `url.Values`.
-func (r AgentSessionListParams) URLQuery() (v url.Values, err error) {
+// URLQuery serializes [AlphaAgentSessionListParams]'s query parameters as
+// `url.Values`.
+func (r AlphaAgentSessionListParams) URLQuery() (v url.Values, err error) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
-type AgentSessionDeleteParams struct {
+type AlphaAgentSessionDeleteParams struct {
AgentID string `path:"agent_id,required" json:"-"`
paramObj
}
diff --git a/agentsession_test.go b/alphaagentsession_test.go
similarity index 80%
rename from agentsession_test.go
rename to alphaagentsession_test.go
index 1960a8f..e31dec5 100644
--- a/agentsession_test.go
+++ b/alphaagentsession_test.go
@@ -13,7 +13,7 @@ import (
"github.com/llamastack/llama-stack-client-go/option"
)
-func TestAgentSessionNew(t *testing.T) {
+func TestAlphaAgentSessionNew(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -24,10 +24,10 @@ func TestAgentSessionNew(t *testing.T) {
client := llamastackclient.NewClient(
option.WithBaseURL(baseURL),
)
- _, err := client.Agents.Session.New(
+ _, err := client.Alpha.Agents.Session.New(
context.TODO(),
"agent_id",
- llamastackclient.AgentSessionNewParams{
+ llamastackclient.AlphaAgentSessionNewParams{
SessionName: "session_name",
},
)
@@ -40,7 +40,7 @@ func TestAgentSessionNew(t *testing.T) {
}
}
-func TestAgentSessionGetWithOptionalParams(t *testing.T) {
+func TestAlphaAgentSessionGetWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -51,10 +51,10 @@ func TestAgentSessionGetWithOptionalParams(t *testing.T) {
client := llamastackclient.NewClient(
option.WithBaseURL(baseURL),
)
- _, err := client.Agents.Session.Get(
+ _, err := client.Alpha.Agents.Session.Get(
context.TODO(),
"session_id",
- llamastackclient.AgentSessionGetParams{
+ llamastackclient.AlphaAgentSessionGetParams{
AgentID: "agent_id",
TurnIDs: []string{"string"},
},
@@ -68,7 +68,7 @@ func TestAgentSessionGetWithOptionalParams(t *testing.T) {
}
}
-func TestAgentSessionListWithOptionalParams(t *testing.T) {
+func TestAlphaAgentSessionListWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -79,10 +79,10 @@ func TestAgentSessionListWithOptionalParams(t *testing.T) {
client := llamastackclient.NewClient(
option.WithBaseURL(baseURL),
)
- _, err := client.Agents.Session.List(
+ _, err := client.Alpha.Agents.Session.List(
context.TODO(),
"agent_id",
- llamastackclient.AgentSessionListParams{
+ llamastackclient.AlphaAgentSessionListParams{
Limit: llamastackclient.Int(0),
StartIndex: llamastackclient.Int(0),
},
@@ -96,7 +96,7 @@ func TestAgentSessionListWithOptionalParams(t *testing.T) {
}
}
-func TestAgentSessionDelete(t *testing.T) {
+func TestAlphaAgentSessionDelete(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -107,10 +107,10 @@ func TestAgentSessionDelete(t *testing.T) {
client := llamastackclient.NewClient(
option.WithBaseURL(baseURL),
)
- err := client.Agents.Session.Delete(
+ err := client.Alpha.Agents.Session.Delete(
context.TODO(),
"session_id",
- llamastackclient.AgentSessionDeleteParams{
+ llamastackclient.AlphaAgentSessionDeleteParams{
AgentID: "agent_id",
},
)
diff --git a/agentstep.go b/alphaagentstep.go
similarity index 57%
rename from agentstep.go
rename to alphaagentstep.go
index 40ddfa3..6d6f428 100644
--- a/agentstep.go
+++ b/alphaagentstep.go
@@ -8,37 +8,37 @@ import (
"errors"
"fmt"
"net/http"
+ "slices"
"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.
+// AlphaAgentStepService 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 {
+// the [NewAlphaAgentStepService] method instead.
+type AlphaAgentStepService 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
+// NewAlphaAgentStepService 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{}
+func NewAlphaAgentStepService(opts ...option.RequestOption) (r AlphaAgentStepService) {
+ r = AlphaAgentStepService{}
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...)
+func (r *AlphaAgentStepService) Get(ctx context.Context, stepID string, query AlphaAgentStepGetParams, opts ...option.RequestOption) (res *AlphaAgentStepGetResponse, err error) {
+ opts = slices.Concat(r.Options, opts)
if query.AgentID == "" {
err = errors.New("missing required agent_id parameter")
return
@@ -55,15 +55,15 @@ func (r *AgentStepService) Get(ctx context.Context, stepID string, query AgentSt
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)
+ path := fmt.Sprintf("v1alpha/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 {
+type AlphaAgentStepGetResponse struct {
// The complete step data and execution details
- Step AgentStepGetResponseStepUnion `json:"step,required"`
+ Step AlphaAgentStepGetResponseStepUnion `json:"step,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Step respjson.Field
@@ -73,34 +73,36 @@ type AgentStepGetResponse struct {
}
// Returns the unmodified JSON received from the API
-func (r AgentStepGetResponse) RawJSON() string { return r.JSON.raw }
-func (r *AgentStepGetResponse) UnmarshalJSON(data []byte) error {
+func (r AlphaAgentStepGetResponse) RawJSON() string { return r.JSON.raw }
+func (r *AlphaAgentStepGetResponse) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
-// AgentStepGetResponseStepUnion contains all possible properties and values from
-// [InferenceStep], [ToolExecutionStep], [ShieldCallStep], [MemoryRetrievalStep].
+// AlphaAgentStepGetResponseStepUnion contains all possible properties and values
+// from [InferenceStep], [ToolExecutionStep], [ShieldCallStep],
+// [MemoryRetrievalStep].
//
-// Use the [AgentStepGetResponseStepUnion.AsAny] method to switch on the variant.
+// Use the [AlphaAgentStepGetResponseStepUnion.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 {
+type AlphaAgentStepGetResponseStepUnion struct {
// This field is from variant [InferenceStep].
- ModelResponse shared.CompletionMessage `json:"model_response"`
- StepID string `json:"step_id"`
+ ModelResponse 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"`
+ ToolCalls []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"`
+ Violation SafetyViolation `json:"violation"`
// This field is from variant [MemoryRetrievalStep].
- InsertedContext shared.InterleavedContentUnion `json:"inserted_context"`
+ InsertedContext InterleavedContentUnion `json:"inserted_context"`
// This field is from variant [MemoryRetrievalStep].
VectorDBIDs string `json:"vector_db_ids"`
JSON struct {
@@ -119,21 +121,21 @@ type AgentStepGetResponseStepUnion struct {
} `json:"-"`
}
-// anyAgentStepGetResponseStep is implemented by each variant of
-// [AgentStepGetResponseStepUnion] to add type safety for the return type of
-// [AgentStepGetResponseStepUnion.AsAny]
-type anyAgentStepGetResponseStep interface {
- implAgentStepGetResponseStepUnion()
+// anyAlphaAgentStepGetResponseStep is implemented by each variant of
+// [AlphaAgentStepGetResponseStepUnion] to add type safety for the return type of
+// [AlphaAgentStepGetResponseStepUnion.AsAny]
+type anyAlphaAgentStepGetResponseStep interface {
+ implAlphaAgentStepGetResponseStepUnion()
}
-func (InferenceStep) implAgentStepGetResponseStepUnion() {}
-func (ToolExecutionStep) implAgentStepGetResponseStepUnion() {}
-func (ShieldCallStep) implAgentStepGetResponseStepUnion() {}
-func (MemoryRetrievalStep) implAgentStepGetResponseStepUnion() {}
+func (InferenceStep) implAlphaAgentStepGetResponseStepUnion() {}
+func (ToolExecutionStep) implAlphaAgentStepGetResponseStepUnion() {}
+func (ShieldCallStep) implAlphaAgentStepGetResponseStepUnion() {}
+func (MemoryRetrievalStep) implAlphaAgentStepGetResponseStepUnion() {}
// Use the following switch statement to find the correct variant
//
-// switch variant := AgentStepGetResponseStepUnion.AsAny().(type) {
+// switch variant := AlphaAgentStepGetResponseStepUnion.AsAny().(type) {
// case llamastackclient.InferenceStep:
// case llamastackclient.ToolExecutionStep:
// case llamastackclient.ShieldCallStep:
@@ -141,7 +143,7 @@ func (MemoryRetrievalStep) implAgentStepGetResponseStepUnion() {}
// default:
// fmt.Errorf("no variant present")
// }
-func (u AgentStepGetResponseStepUnion) AsAny() anyAgentStepGetResponseStep {
+func (u AlphaAgentStepGetResponseStepUnion) AsAny() anyAlphaAgentStepGetResponseStep {
switch u.StepType {
case "inference":
return u.AsInference()
@@ -155,34 +157,34 @@ func (u AgentStepGetResponseStepUnion) AsAny() anyAgentStepGetResponseStep {
return nil
}
-func (u AgentStepGetResponseStepUnion) AsInference() (v InferenceStep) {
+func (u AlphaAgentStepGetResponseStepUnion) AsInference() (v InferenceStep) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
-func (u AgentStepGetResponseStepUnion) AsToolExecution() (v ToolExecutionStep) {
+func (u AlphaAgentStepGetResponseStepUnion) AsToolExecution() (v ToolExecutionStep) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
-func (u AgentStepGetResponseStepUnion) AsShieldCall() (v ShieldCallStep) {
+func (u AlphaAgentStepGetResponseStepUnion) AsShieldCall() (v ShieldCallStep) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
-func (u AgentStepGetResponseStepUnion) AsMemoryRetrieval() (v MemoryRetrievalStep) {
+func (u AlphaAgentStepGetResponseStepUnion) 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 (u AlphaAgentStepGetResponseStepUnion) RawJSON() string { return u.JSON.raw }
-func (r *AgentStepGetResponseStepUnion) UnmarshalJSON(data []byte) error {
+func (r *AlphaAgentStepGetResponseStepUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
-type AgentStepGetParams struct {
+type AlphaAgentStepGetParams struct {
AgentID string `path:"agent_id,required" json:"-"`
SessionID string `path:"session_id,required" json:"-"`
TurnID string `path:"turn_id,required" json:"-"`
diff --git a/agentstep_test.go b/alphaagentstep_test.go
similarity index 87%
rename from agentstep_test.go
rename to alphaagentstep_test.go
index 7e8f080..cfc222b 100644
--- a/agentstep_test.go
+++ b/alphaagentstep_test.go
@@ -13,7 +13,7 @@ import (
"github.com/llamastack/llama-stack-client-go/option"
)
-func TestAgentStepGet(t *testing.T) {
+func TestAlphaAgentStepGet(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -24,10 +24,10 @@ func TestAgentStepGet(t *testing.T) {
client := llamastackclient.NewClient(
option.WithBaseURL(baseURL),
)
- _, err := client.Agents.Steps.Get(
+ _, err := client.Alpha.Agents.Steps.Get(
context.TODO(),
"step_id",
- llamastackclient.AgentStepGetParams{
+ llamastackclient.AlphaAgentStepGetParams{
AgentID: "agent_id",
SessionID: "session_id",
TurnID: "turn_id",
diff --git a/agentturn.go b/alphaagentturn.go
similarity index 70%
rename from agentturn.go
rename to alphaagentturn.go
index d3f14af..50da6a4 100644
--- a/agentturn.go
+++ b/alphaagentturn.go
@@ -8,6 +8,7 @@ import (
"errors"
"fmt"
"net/http"
+ "slices"
"time"
"github.com/llamastack/llama-stack-client-go/internal/apijson"
@@ -16,32 +17,31 @@ import (
"github.com/llamastack/llama-stack-client-go/packages/param"
"github.com/llamastack/llama-stack-client-go/packages/respjson"
"github.com/llamastack/llama-stack-client-go/packages/ssestream"
- "github.com/llamastack/llama-stack-client-go/shared"
"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.
+// AlphaAgentTurnService 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 {
+// the [NewAlphaAgentTurnService] method instead.
+type AlphaAgentTurnService 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
+// NewAlphaAgentTurnService 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{}
+func NewAlphaAgentTurnService(opts ...option.RequestOption) (r AlphaAgentTurnService) {
+ r = AlphaAgentTurnService{}
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...)
+func (r *AlphaAgentTurnService) New(ctx context.Context, sessionID string, params AlphaAgentTurnNewParams, opts ...option.RequestOption) (res *Turn, err error) {
+ opts = slices.Concat(r.Options, opts)
if params.AgentID == "" {
err = errors.New("missing required agent_id parameter")
return
@@ -50,18 +50,18 @@ func (r *AgentTurnService) New(ctx context.Context, sessionID string, params Age
err = errors.New("missing required session_id parameter")
return
}
- path := fmt.Sprintf("v1/agents/%s/session/%s/turn", params.AgentID, sessionID)
+ path := fmt.Sprintf("v1alpha/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]) {
+func (r *AlphaAgentTurnService) NewStreaming(ctx context.Context, sessionID string, params AlphaAgentTurnNewParams, opts ...option.RequestOption) (stream *ssestream.Stream[AgentTurnResponseStreamChunk]) {
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...)
if params.AgentID == "" {
err = errors.New("missing required agent_id parameter")
@@ -71,14 +71,14 @@ func (r *AgentTurnService) NewStreaming(ctx context.Context, sessionID string, p
err = errors.New("missing required session_id parameter")
return
}
- path := fmt.Sprintf("v1/agents/%s/session/%s/turn", params.AgentID, sessionID)
+ path := fmt.Sprintf("v1alpha/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...)
+func (r *AlphaAgentTurnService) Get(ctx context.Context, turnID string, query AlphaAgentTurnGetParams, opts ...option.RequestOption) (res *Turn, err error) {
+ opts = slices.Concat(r.Options, opts)
if query.AgentID == "" {
err = errors.New("missing required agent_id parameter")
return
@@ -91,7 +91,7 @@ func (r *AgentTurnService) Get(ctx context.Context, turnID string, query AgentTu
err = errors.New("missing required turn_id parameter")
return
}
- path := fmt.Sprintf("v1/agents/%s/session/%s/turn/%s", query.AgentID, query.SessionID, turnID)
+ path := fmt.Sprintf("v1alpha/agents/%s/session/%s/turn/%s", query.AgentID, query.SessionID, turnID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
@@ -100,8 +100,8 @@ func (r *AgentTurnService) Get(ctx context.Context, turnID string, query AgentTu
// 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...)
+func (r *AlphaAgentTurnService) Resume(ctx context.Context, turnID string, params AlphaAgentTurnResumeParams, opts ...option.RequestOption) (res *Turn, err error) {
+ opts = slices.Concat(r.Options, opts)
if params.AgentID == "" {
err = errors.New("missing required agent_id parameter")
return
@@ -114,7 +114,7 @@ func (r *AgentTurnService) Resume(ctx context.Context, turnID string, params Age
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)
+ path := fmt.Sprintf("v1alpha/agents/%s/session/%s/turn/%s/resume", params.AgentID, params.SessionID, turnID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
return
}
@@ -123,12 +123,12 @@ func (r *AgentTurnService) Resume(ctx context.Context, turnID string, params Age
// 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]) {
+func (r *AlphaAgentTurnService) ResumeStreaming(ctx context.Context, turnID string, params AlphaAgentTurnResumeParams, opts ...option.RequestOption) (stream *ssestream.Stream[AgentTurnResponseStreamChunk]) {
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...)
if params.AgentID == "" {
err = errors.New("missing required agent_id parameter")
@@ -142,7 +142,7 @@ func (r *AgentTurnService) ResumeStreaming(ctx context.Context, turnID string, p
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)
+ path := fmt.Sprintf("v1alpha/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)
}
@@ -170,7 +170,7 @@ 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"`
+ OutputMessage CompletionMessage `json:"output_message,required"`
// Unique identifier for the conversation session
SessionID string `json:"session_id,required"`
// Timestamp when the turn began
@@ -205,16 +205,16 @@ func (r *Turn) UnmarshalJSON(data []byte) error {
}
// TurnInputMessageUnion contains all possible properties and values from
-// [shared.UserMessage], [shared.ToolResponseMessage].
+// [UserMessage], [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].
+ // This field is from variant [UserMessage].
+ Content InterleavedContentUnion `json:"content"`
+ Role string `json:"role"`
+ // This field is from variant [UserMessage].
+ Context InterleavedContentUnion `json:"context"`
+ // This field is from variant [ToolResponseMessage].
CallID string `json:"call_id"`
JSON struct {
Content respjson.Field
@@ -225,12 +225,12 @@ type TurnInputMessageUnion struct {
} `json:"-"`
}
-func (u TurnInputMessageUnion) AsUserMessage() (v shared.UserMessage) {
+func (u TurnInputMessageUnion) AsUserMessage() (v UserMessage) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
-func (u TurnInputMessageUnion) AsToolResponseMessage() (v shared.ToolResponseMessage) {
+func (u TurnInputMessageUnion) AsToolResponseMessage() (v ToolResponseMessage) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
@@ -250,21 +250,21 @@ func (r *TurnInputMessageUnion) UnmarshalJSON(data []byte) error {
// 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"`
+ ModelResponse 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"`
+ ToolCalls []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"`
+ Violation SafetyViolation `json:"violation"`
// This field is from variant [MemoryRetrievalStep].
- InsertedContext shared.InterleavedContentUnion `json:"inserted_context"`
+ InsertedContext InterleavedContentUnion `json:"inserted_context"`
// This field is from variant [MemoryRetrievalStep].
VectorDBIDs string `json:"vector_db_ids"`
JSON struct {
@@ -368,8 +368,8 @@ func (r *TurnOutputAttachment) UnmarshalJSON(data []byte) error {
// TurnOutputAttachmentContentUnion contains all possible properties and values
// from [string], [TurnOutputAttachmentContentImageContentItem],
-// [TurnOutputAttachmentContentTextContentItem],
-// [[]shared.InterleavedContentItemUnion], [TurnOutputAttachmentContentURL].
+// [TurnOutputAttachmentContentTextContentItem], [[]InterleavedContentItemUnion],
+// [TurnOutputAttachmentContentURL].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
//
@@ -378,9 +378,9 @@ func (r *TurnOutputAttachment) UnmarshalJSON(data []byte) error {
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 will be present if the value is a [[]InterleavedContentItemUnion]
+ // instead of an object.
+ OfInterleavedContentItemArray []InterleavedContentItemUnion `json:",inline"`
// This field is from variant [TurnOutputAttachmentContentImageContentItem].
Image TurnOutputAttachmentContentImageContentItemImage `json:"image"`
Type string `json:"type"`
@@ -414,7 +414,7 @@ func (u TurnOutputAttachmentContentUnion) AsTextContentItem() (v TurnOutputAttac
return
}
-func (u TurnOutputAttachmentContentUnion) AsInterleavedContentItemArray() (v []shared.InterleavedContentItemUnion) {
+func (u TurnOutputAttachmentContentUnion) AsInterleavedContentItemArray() (v []InterleavedContentItemUnion) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
@@ -568,7 +568,7 @@ type TurnResponseEventPayloadUnion struct {
// This field is from variant [TurnResponseEventPayloadStepStart].
Metadata map[string]TurnResponseEventPayloadStepStartMetadataUnion `json:"metadata"`
// This field is from variant [TurnResponseEventPayloadStepProgress].
- Delta shared.ContentDeltaUnion `json:"delta"`
+ Delta TurnResponseEventPayloadStepProgressDeltaUnion `json:"delta"`
// This field is from variant [TurnResponseEventPayloadStepComplete].
StepDetails TurnResponseEventPayloadStepCompleteStepDetailsUnion `json:"step_details"`
// This field is from variant [TurnResponseEventPayloadTurnStart].
@@ -753,7 +753,7 @@ func (r *TurnResponseEventPayloadStepStartMetadataUnion) UnmarshalJSON(data []by
// Payload for step progress events in agent turn responses.
type TurnResponseEventPayloadStepProgress struct {
// Incremental content changes during step execution
- Delta shared.ContentDeltaUnion `json:"delta,required"`
+ Delta TurnResponseEventPayloadStepProgressDeltaUnion `json:"delta,required"`
// Type of event being reported
EventType constant.StepProgress `json:"event_type,required"`
// Unique identifier for the step within a turn
@@ -779,6 +779,205 @@ func (r *TurnResponseEventPayloadStepProgress) UnmarshalJSON(data []byte) error
return apijson.UnmarshalRoot(data, r)
}
+// TurnResponseEventPayloadStepProgressDeltaUnion contains all possible properties
+// and values from [TurnResponseEventPayloadStepProgressDeltaText],
+// [TurnResponseEventPayloadStepProgressDeltaImage],
+// [TurnResponseEventPayloadStepProgressDeltaToolCall].
+//
+// Use the [TurnResponseEventPayloadStepProgressDeltaUnion.AsAny] method to switch
+// on the variant.
+//
+// Use the methods beginning with 'As' to cast the union to one of its variants.
+type TurnResponseEventPayloadStepProgressDeltaUnion struct {
+ // This field is from variant [TurnResponseEventPayloadStepProgressDeltaText].
+ Text string `json:"text"`
+ // Any of "text", "image", "tool_call".
+ Type string `json:"type"`
+ // This field is from variant [TurnResponseEventPayloadStepProgressDeltaImage].
+ Image string `json:"image"`
+ // This field is from variant [TurnResponseEventPayloadStepProgressDeltaToolCall].
+ ParseStatus string `json:"parse_status"`
+ // This field is from variant [TurnResponseEventPayloadStepProgressDeltaToolCall].
+ ToolCall TurnResponseEventPayloadStepProgressDeltaToolCallToolCallUnion `json:"tool_call"`
+ JSON struct {
+ Text respjson.Field
+ Type respjson.Field
+ Image respjson.Field
+ ParseStatus respjson.Field
+ ToolCall respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// anyTurnResponseEventPayloadStepProgressDelta is implemented by each variant of
+// [TurnResponseEventPayloadStepProgressDeltaUnion] to add type safety for the
+// return type of [TurnResponseEventPayloadStepProgressDeltaUnion.AsAny]
+type anyTurnResponseEventPayloadStepProgressDelta interface {
+ implTurnResponseEventPayloadStepProgressDeltaUnion()
+}
+
+func (TurnResponseEventPayloadStepProgressDeltaText) implTurnResponseEventPayloadStepProgressDeltaUnion() {
+}
+func (TurnResponseEventPayloadStepProgressDeltaImage) implTurnResponseEventPayloadStepProgressDeltaUnion() {
+}
+func (TurnResponseEventPayloadStepProgressDeltaToolCall) implTurnResponseEventPayloadStepProgressDeltaUnion() {
+}
+
+// Use the following switch statement to find the correct variant
+//
+// switch variant := TurnResponseEventPayloadStepProgressDeltaUnion.AsAny().(type) {
+// case llamastackclient.TurnResponseEventPayloadStepProgressDeltaText:
+// case llamastackclient.TurnResponseEventPayloadStepProgressDeltaImage:
+// case llamastackclient.TurnResponseEventPayloadStepProgressDeltaToolCall:
+// default:
+// fmt.Errorf("no variant present")
+// }
+func (u TurnResponseEventPayloadStepProgressDeltaUnion) AsAny() anyTurnResponseEventPayloadStepProgressDelta {
+ switch u.Type {
+ case "text":
+ return u.AsText()
+ case "image":
+ return u.AsImage()
+ case "tool_call":
+ return u.AsToolCall()
+ }
+ return nil
+}
+
+func (u TurnResponseEventPayloadStepProgressDeltaUnion) AsText() (v TurnResponseEventPayloadStepProgressDeltaText) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u TurnResponseEventPayloadStepProgressDeltaUnion) AsImage() (v TurnResponseEventPayloadStepProgressDeltaImage) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u TurnResponseEventPayloadStepProgressDeltaUnion) AsToolCall() (v TurnResponseEventPayloadStepProgressDeltaToolCall) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u TurnResponseEventPayloadStepProgressDeltaUnion) RawJSON() string { return u.JSON.raw }
+
+func (r *TurnResponseEventPayloadStepProgressDeltaUnion) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// A text content delta for streaming responses.
+type TurnResponseEventPayloadStepProgressDeltaText 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 TurnResponseEventPayloadStepProgressDeltaText) RawJSON() string { return r.JSON.raw }
+func (r *TurnResponseEventPayloadStepProgressDeltaText) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// An image content delta for streaming responses.
+type TurnResponseEventPayloadStepProgressDeltaImage 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 TurnResponseEventPayloadStepProgressDeltaImage) RawJSON() string { return r.JSON.raw }
+func (r *TurnResponseEventPayloadStepProgressDeltaImage) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// A tool call content delta for streaming responses.
+type TurnResponseEventPayloadStepProgressDeltaToolCall 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 TurnResponseEventPayloadStepProgressDeltaToolCallToolCallUnion `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 TurnResponseEventPayloadStepProgressDeltaToolCall) RawJSON() string { return r.JSON.raw }
+func (r *TurnResponseEventPayloadStepProgressDeltaToolCall) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// TurnResponseEventPayloadStepProgressDeltaToolCallToolCallUnion 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 TurnResponseEventPayloadStepProgressDeltaToolCallToolCallUnion 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 string `json:"arguments"`
+ // This field is from variant [ToolCall].
+ CallID string `json:"call_id"`
+ // This field is from variant [ToolCall].
+ ToolName ToolCallToolName `json:"tool_name"`
+ JSON struct {
+ OfString respjson.Field
+ Arguments respjson.Field
+ CallID respjson.Field
+ ToolName respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+func (u TurnResponseEventPayloadStepProgressDeltaToolCallToolCallUnion) AsString() (v string) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u TurnResponseEventPayloadStepProgressDeltaToolCallToolCallUnion) AsToolCall() (v ToolCall) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+// Returns the unmodified JSON received from the API
+func (u TurnResponseEventPayloadStepProgressDeltaToolCallToolCallUnion) RawJSON() string {
+ return u.JSON.raw
+}
+
+func (r *TurnResponseEventPayloadStepProgressDeltaToolCallToolCallUnion) 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
@@ -818,21 +1017,21 @@ func (r *TurnResponseEventPayloadStepComplete) UnmarshalJSON(data []byte) error
// 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"`
+ ModelResponse 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"`
+ ToolCalls []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"`
+ Violation SafetyViolation `json:"violation"`
// This field is from variant [MemoryRetrievalStep].
- InsertedContext shared.InterleavedContentUnion `json:"inserted_context"`
+ InsertedContext InterleavedContentUnion `json:"inserted_context"`
// This field is from variant [MemoryRetrievalStep].
VectorDBIDs string `json:"vector_db_ids"`
JSON struct {
@@ -978,46 +1177,46 @@ func (r *TurnResponseEventPayloadTurnAwaitingInput) UnmarshalJSON(data []byte) e
return apijson.UnmarshalRoot(data, r)
}
-type AgentTurnNewParams struct {
+type AlphaAgentTurnNewParams struct {
AgentID string `path:"agent_id,required" json:"-"`
// List of messages to start the turn with.
- Messages []AgentTurnNewParamsMessageUnion `json:"messages,omitzero,required"`
+ Messages []AlphaAgentTurnNewParamsMessageUnion `json:"messages,omitzero,required"`
// (Optional) List of documents to create the turn with.
- Documents []AgentTurnNewParamsDocument `json:"documents,omitzero"`
+ Documents []AlphaAgentTurnNewParamsDocument `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"`
+ ToolConfig AlphaAgentTurnNewParamsToolConfig `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"`
+ Toolgroups []AlphaAgentTurnNewParamsToolgroupUnion `json:"toolgroups,omitzero"`
paramObj
}
-func (r AgentTurnNewParams) MarshalJSON() (data []byte, err error) {
- type shadow AgentTurnNewParams
+func (r AlphaAgentTurnNewParams) MarshalJSON() (data []byte, err error) {
+ type shadow AlphaAgentTurnNewParams
return param.MarshalObject(r, (*shadow)(&r))
}
-func (r *AgentTurnNewParams) UnmarshalJSON(data []byte) error {
+func (r *AlphaAgentTurnNewParams) 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"`
+type AlphaAgentTurnNewParamsMessageUnion struct {
+ OfUserMessage *UserMessageParam `json:",omitzero,inline"`
+ OfToolResponseMessage *ToolResponseMessageParam `json:",omitzero,inline"`
paramUnion
}
-func (u AgentTurnNewParamsMessageUnion) MarshalJSON() ([]byte, error) {
+func (u AlphaAgentTurnNewParamsMessageUnion) MarshalJSON() ([]byte, error) {
return param.MarshalUnion(u, u.OfUserMessage, u.OfToolResponseMessage)
}
-func (u *AgentTurnNewParamsMessageUnion) UnmarshalJSON(data []byte) error {
+func (u *AlphaAgentTurnNewParamsMessageUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, u)
}
-func (u *AgentTurnNewParamsMessageUnion) asAny() any {
+func (u *AlphaAgentTurnNewParamsMessageUnion) asAny() any {
if !param.IsOmitted(u.OfUserMessage) {
return u.OfUserMessage
} else if !param.IsOmitted(u.OfToolResponseMessage) {
@@ -1027,7 +1226,7 @@ func (u *AgentTurnNewParamsMessageUnion) asAny() any {
}
// Returns a pointer to the underlying variant's property, if present.
-func (u AgentTurnNewParamsMessageUnion) GetContext() *shared.InterleavedContentUnionParam {
+func (u AlphaAgentTurnNewParamsMessageUnion) GetContext() *InterleavedContentUnionParam {
if vt := u.OfUserMessage; vt != nil {
return &vt.Context
}
@@ -1035,7 +1234,7 @@ func (u AgentTurnNewParamsMessageUnion) GetContext() *shared.InterleavedContentU
}
// Returns a pointer to the underlying variant's property, if present.
-func (u AgentTurnNewParamsMessageUnion) GetCallID() *string {
+func (u AlphaAgentTurnNewParamsMessageUnion) GetCallID() *string {
if vt := u.OfToolResponseMessage; vt != nil {
return &vt.CallID
}
@@ -1043,7 +1242,7 @@ func (u AgentTurnNewParamsMessageUnion) GetCallID() *string {
}
// Returns a pointer to the underlying variant's property, if present.
-func (u AgentTurnNewParamsMessageUnion) GetRole() *string {
+func (u AlphaAgentTurnNewParamsMessageUnion) GetRole() *string {
if vt := u.OfUserMessage; vt != nil {
return (*string)(&vt.Role)
} else if vt := u.OfToolResponseMessage; vt != nil {
@@ -1053,7 +1252,7 @@ func (u AgentTurnNewParamsMessageUnion) GetRole() *string {
}
// Returns a pointer to the underlying variant's Content property, if present.
-func (u AgentTurnNewParamsMessageUnion) GetContent() *shared.InterleavedContentUnionParam {
+func (u AlphaAgentTurnNewParamsMessageUnion) GetContent() *InterleavedContentUnionParam {
if vt := u.OfUserMessage; vt != nil {
return &vt.Content
} else if vt := u.OfToolResponseMessage; vt != nil {
@@ -1065,46 +1264,46 @@ func (u AgentTurnNewParamsMessageUnion) GetContent() *shared.InterleavedContentU
// A document to be used by an agent.
//
// The properties Content, MimeType are required.
-type AgentTurnNewParamsDocument struct {
+type AlphaAgentTurnNewParamsDocument struct {
// The content of the document.
- Content AgentTurnNewParamsDocumentContentUnion `json:"content,omitzero,required"`
+ Content AlphaAgentTurnNewParamsDocumentContentUnion `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
+func (r AlphaAgentTurnNewParamsDocument) MarshalJSON() (data []byte, err error) {
+ type shadow AlphaAgentTurnNewParamsDocument
return param.MarshalObject(r, (*shadow)(&r))
}
-func (r *AgentTurnNewParamsDocument) UnmarshalJSON(data []byte) error {
+func (r *AlphaAgentTurnNewParamsDocument) 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"`
+type AlphaAgentTurnNewParamsDocumentContentUnion struct {
+ OfString param.Opt[string] `json:",omitzero,inline"`
+ OfImageContentItem *AlphaAgentTurnNewParamsDocumentContentImageContentItem `json:",omitzero,inline"`
+ OfTextContentItem *AlphaAgentTurnNewParamsDocumentContentTextContentItem `json:",omitzero,inline"`
+ OfInterleavedContentItemArray []InterleavedContentItemUnionParam `json:",omitzero,inline"`
+ OfURL *AlphaAgentTurnNewParamsDocumentContentURL `json:",omitzero,inline"`
paramUnion
}
-func (u AgentTurnNewParamsDocumentContentUnion) MarshalJSON() ([]byte, error) {
+func (u AlphaAgentTurnNewParamsDocumentContentUnion) MarshalJSON() ([]byte, error) {
return param.MarshalUnion(u, u.OfString,
u.OfImageContentItem,
u.OfTextContentItem,
u.OfInterleavedContentItemArray,
u.OfURL)
}
-func (u *AgentTurnNewParamsDocumentContentUnion) UnmarshalJSON(data []byte) error {
+func (u *AlphaAgentTurnNewParamsDocumentContentUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, u)
}
-func (u *AgentTurnNewParamsDocumentContentUnion) asAny() any {
+func (u *AlphaAgentTurnNewParamsDocumentContentUnion) asAny() any {
if !param.IsOmitted(u.OfString) {
return &u.OfString.Value
} else if !param.IsOmitted(u.OfImageContentItem) {
@@ -1120,7 +1319,7 @@ func (u *AgentTurnNewParamsDocumentContentUnion) asAny() any {
}
// Returns a pointer to the underlying variant's property, if present.
-func (u AgentTurnNewParamsDocumentContentUnion) GetImage() *AgentTurnNewParamsDocumentContentImageContentItemImage {
+func (u AlphaAgentTurnNewParamsDocumentContentUnion) GetImage() *AlphaAgentTurnNewParamsDocumentContentImageContentItemImage {
if vt := u.OfImageContentItem; vt != nil {
return &vt.Image
}
@@ -1128,7 +1327,7 @@ func (u AgentTurnNewParamsDocumentContentUnion) GetImage() *AgentTurnNewParamsDo
}
// Returns a pointer to the underlying variant's property, if present.
-func (u AgentTurnNewParamsDocumentContentUnion) GetText() *string {
+func (u AlphaAgentTurnNewParamsDocumentContentUnion) GetText() *string {
if vt := u.OfTextContentItem; vt != nil {
return &vt.Text
}
@@ -1136,7 +1335,7 @@ func (u AgentTurnNewParamsDocumentContentUnion) GetText() *string {
}
// Returns a pointer to the underlying variant's property, if present.
-func (u AgentTurnNewParamsDocumentContentUnion) GetUri() *string {
+func (u AlphaAgentTurnNewParamsDocumentContentUnion) GetUri() *string {
if vt := u.OfURL; vt != nil {
return &vt.Uri
}
@@ -1144,7 +1343,7 @@ func (u AgentTurnNewParamsDocumentContentUnion) GetUri() *string {
}
// Returns a pointer to the underlying variant's property, if present.
-func (u AgentTurnNewParamsDocumentContentUnion) GetType() *string {
+func (u AlphaAgentTurnNewParamsDocumentContentUnion) GetType() *string {
if vt := u.OfImageContentItem; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfTextContentItem; vt != nil {
@@ -1156,9 +1355,9 @@ func (u AgentTurnNewParamsDocumentContentUnion) GetType() *string {
// A image content item
//
// The properties Image, Type are required.
-type AgentTurnNewParamsDocumentContentImageContentItem struct {
+type AlphaAgentTurnNewParamsDocumentContentImageContentItem struct {
// Image as a base64 encoded string or an URL
- Image AgentTurnNewParamsDocumentContentImageContentItemImage `json:"image,omitzero,required"`
+ Image AlphaAgentTurnNewParamsDocumentContentImageContentItemImage `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".
@@ -1166,29 +1365,29 @@ type AgentTurnNewParamsDocumentContentImageContentItem struct {
paramObj
}
-func (r AgentTurnNewParamsDocumentContentImageContentItem) MarshalJSON() (data []byte, err error) {
- type shadow AgentTurnNewParamsDocumentContentImageContentItem
+func (r AlphaAgentTurnNewParamsDocumentContentImageContentItem) MarshalJSON() (data []byte, err error) {
+ type shadow AlphaAgentTurnNewParamsDocumentContentImageContentItem
return param.MarshalObject(r, (*shadow)(&r))
}
-func (r *AgentTurnNewParamsDocumentContentImageContentItem) UnmarshalJSON(data []byte) error {
+func (r *AlphaAgentTurnNewParamsDocumentContentImageContentItem) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Image as a base64 encoded string or an URL
-type AgentTurnNewParamsDocumentContentImageContentItemImage struct {
+type AlphaAgentTurnNewParamsDocumentContentImageContentItemImage 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"`
+ URL AlphaAgentTurnNewParamsDocumentContentImageContentItemImageURL `json:"url,omitzero"`
paramObj
}
-func (r AgentTurnNewParamsDocumentContentImageContentItemImage) MarshalJSON() (data []byte, err error) {
- type shadow AgentTurnNewParamsDocumentContentImageContentItemImage
+func (r AlphaAgentTurnNewParamsDocumentContentImageContentItemImage) MarshalJSON() (data []byte, err error) {
+ type shadow AlphaAgentTurnNewParamsDocumentContentImageContentItemImage
return param.MarshalObject(r, (*shadow)(&r))
}
-func (r *AgentTurnNewParamsDocumentContentImageContentItemImage) UnmarshalJSON(data []byte) error {
+func (r *AlphaAgentTurnNewParamsDocumentContentImageContentItemImage) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
@@ -1196,24 +1395,24 @@ func (r *AgentTurnNewParamsDocumentContentImageContentItemImage) UnmarshalJSON(d
// Note that URL could have length limits.
//
// The property Uri is required.
-type AgentTurnNewParamsDocumentContentImageContentItemImageURL struct {
+type AlphaAgentTurnNewParamsDocumentContentImageContentItemImageURL 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
+func (r AlphaAgentTurnNewParamsDocumentContentImageContentItemImageURL) MarshalJSON() (data []byte, err error) {
+ type shadow AlphaAgentTurnNewParamsDocumentContentImageContentItemImageURL
return param.MarshalObject(r, (*shadow)(&r))
}
-func (r *AgentTurnNewParamsDocumentContentImageContentItemImageURL) UnmarshalJSON(data []byte) error {
+func (r *AlphaAgentTurnNewParamsDocumentContentImageContentItemImageURL) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// A text content item
//
// The properties Text, Type are required.
-type AgentTurnNewParamsDocumentContentTextContentItem struct {
+type AlphaAgentTurnNewParamsDocumentContentTextContentItem struct {
// Text content
Text string `json:"text,required"`
// Discriminator type of the content item. Always "text"
@@ -1223,34 +1422,34 @@ type AgentTurnNewParamsDocumentContentTextContentItem struct {
paramObj
}
-func (r AgentTurnNewParamsDocumentContentTextContentItem) MarshalJSON() (data []byte, err error) {
- type shadow AgentTurnNewParamsDocumentContentTextContentItem
+func (r AlphaAgentTurnNewParamsDocumentContentTextContentItem) MarshalJSON() (data []byte, err error) {
+ type shadow AlphaAgentTurnNewParamsDocumentContentTextContentItem
return param.MarshalObject(r, (*shadow)(&r))
}
-func (r *AgentTurnNewParamsDocumentContentTextContentItem) UnmarshalJSON(data []byte) error {
+func (r *AlphaAgentTurnNewParamsDocumentContentTextContentItem) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// A URL reference to external content.
//
// The property Uri is required.
-type AgentTurnNewParamsDocumentContentURL struct {
+type AlphaAgentTurnNewParamsDocumentContentURL 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
+func (r AlphaAgentTurnNewParamsDocumentContentURL) MarshalJSON() (data []byte, err error) {
+ type shadow AlphaAgentTurnNewParamsDocumentContentURL
return param.MarshalObject(r, (*shadow)(&r))
}
-func (r *AgentTurnNewParamsDocumentContentURL) UnmarshalJSON(data []byte) error {
+func (r *AlphaAgentTurnNewParamsDocumentContentURL) 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 {
+type AlphaAgentTurnNewParamsToolConfig 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
@@ -1275,19 +1474,19 @@ type AgentTurnNewParamsToolConfig struct {
paramObj
}
-func (r AgentTurnNewParamsToolConfig) MarshalJSON() (data []byte, err error) {
- type shadow AgentTurnNewParamsToolConfig
+func (r AlphaAgentTurnNewParamsToolConfig) MarshalJSON() (data []byte, err error) {
+ type shadow AlphaAgentTurnNewParamsToolConfig
return param.MarshalObject(r, (*shadow)(&r))
}
-func (r *AgentTurnNewParamsToolConfig) UnmarshalJSON(data []byte) error {
+func (r *AlphaAgentTurnNewParamsToolConfig) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
func init() {
- apijson.RegisterFieldValidator[AgentTurnNewParamsToolConfig](
+ apijson.RegisterFieldValidator[AlphaAgentTurnNewParamsToolConfig](
"system_message_behavior", "append", "replace",
)
- apijson.RegisterFieldValidator[AgentTurnNewParamsToolConfig](
+ apijson.RegisterFieldValidator[AlphaAgentTurnNewParamsToolConfig](
"tool_prompt_format", "json", "function_tag", "python_list",
)
}
@@ -1295,20 +1494,20 @@ func init() {
// 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"`
+type AlphaAgentTurnNewParamsToolgroupUnion struct {
+ OfString param.Opt[string] `json:",omitzero,inline"`
+ OfAgentToolGroupWithArgs *AlphaAgentTurnNewParamsToolgroupAgentToolGroupWithArgs `json:",omitzero,inline"`
paramUnion
}
-func (u AgentTurnNewParamsToolgroupUnion) MarshalJSON() ([]byte, error) {
+func (u AlphaAgentTurnNewParamsToolgroupUnion) MarshalJSON() ([]byte, error) {
return param.MarshalUnion(u, u.OfString, u.OfAgentToolGroupWithArgs)
}
-func (u *AgentTurnNewParamsToolgroupUnion) UnmarshalJSON(data []byte) error {
+func (u *AlphaAgentTurnNewParamsToolgroupUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, u)
}
-func (u *AgentTurnNewParamsToolgroupUnion) asAny() any {
+func (u *AlphaAgentTurnNewParamsToolgroupUnion) asAny() any {
if !param.IsOmitted(u.OfString) {
return &u.OfString.Value
} else if !param.IsOmitted(u.OfAgentToolGroupWithArgs) {
@@ -1318,24 +1517,24 @@ func (u *AgentTurnNewParamsToolgroupUnion) asAny() any {
}
// The properties Args, Name are required.
-type AgentTurnNewParamsToolgroupAgentToolGroupWithArgs struct {
- Args map[string]AgentTurnNewParamsToolgroupAgentToolGroupWithArgsArgUnion `json:"args,omitzero,required"`
- Name string `json:"name,required"`
+type AlphaAgentTurnNewParamsToolgroupAgentToolGroupWithArgs struct {
+ Args map[string]AlphaAgentTurnNewParamsToolgroupAgentToolGroupWithArgsArgUnion `json:"args,omitzero,required"`
+ Name string `json:"name,required"`
paramObj
}
-func (r AgentTurnNewParamsToolgroupAgentToolGroupWithArgs) MarshalJSON() (data []byte, err error) {
- type shadow AgentTurnNewParamsToolgroupAgentToolGroupWithArgs
+func (r AlphaAgentTurnNewParamsToolgroupAgentToolGroupWithArgs) MarshalJSON() (data []byte, err error) {
+ type shadow AlphaAgentTurnNewParamsToolgroupAgentToolGroupWithArgs
return param.MarshalObject(r, (*shadow)(&r))
}
-func (r *AgentTurnNewParamsToolgroupAgentToolGroupWithArgs) UnmarshalJSON(data []byte) error {
+func (r *AlphaAgentTurnNewParamsToolgroupAgentToolGroupWithArgs) 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 {
+type AlphaAgentTurnNewParamsToolgroupAgentToolGroupWithArgsArgUnion struct {
OfBool param.Opt[bool] `json:",omitzero,inline"`
OfFloat param.Opt[float64] `json:",omitzero,inline"`
OfString param.Opt[string] `json:",omitzero,inline"`
@@ -1343,14 +1542,14 @@ type AgentTurnNewParamsToolgroupAgentToolGroupWithArgsArgUnion struct {
paramUnion
}
-func (u AgentTurnNewParamsToolgroupAgentToolGroupWithArgsArgUnion) MarshalJSON() ([]byte, error) {
+func (u AlphaAgentTurnNewParamsToolgroupAgentToolGroupWithArgsArgUnion) MarshalJSON() ([]byte, error) {
return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray)
}
-func (u *AgentTurnNewParamsToolgroupAgentToolGroupWithArgsArgUnion) UnmarshalJSON(data []byte) error {
+func (u *AlphaAgentTurnNewParamsToolgroupAgentToolGroupWithArgsArgUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, u)
}
-func (u *AgentTurnNewParamsToolgroupAgentToolGroupWithArgsArgUnion) asAny() any {
+func (u *AlphaAgentTurnNewParamsToolgroupAgentToolGroupWithArgsArgUnion) asAny() any {
if !param.IsOmitted(u.OfBool) {
return &u.OfBool.Value
} else if !param.IsOmitted(u.OfFloat) {
@@ -1363,13 +1562,13 @@ func (u *AgentTurnNewParamsToolgroupAgentToolGroupWithArgsArgUnion) asAny() any
return nil
}
-type AgentTurnGetParams struct {
+type AlphaAgentTurnGetParams struct {
AgentID string `path:"agent_id,required" json:"-"`
SessionID string `path:"session_id,required" json:"-"`
paramObj
}
-type AgentTurnResumeParams struct {
+type AlphaAgentTurnResumeParams struct {
AgentID string `path:"agent_id,required" json:"-"`
SessionID string `path:"session_id,required" json:"-"`
// The tool call responses to resume the turn with.
@@ -1377,10 +1576,10 @@ type AgentTurnResumeParams struct {
paramObj
}
-func (r AgentTurnResumeParams) MarshalJSON() (data []byte, err error) {
- type shadow AgentTurnResumeParams
+func (r AlphaAgentTurnResumeParams) MarshalJSON() (data []byte, err error) {
+ type shadow AlphaAgentTurnResumeParams
return param.MarshalObject(r, (*shadow)(&r))
}
-func (r *AgentTurnResumeParams) UnmarshalJSON(data []byte) error {
+func (r *AlphaAgentTurnResumeParams) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
diff --git a/agentturn_test.go b/alphaagentturn_test.go
similarity index 72%
rename from agentturn_test.go
rename to alphaagentturn_test.go
index 72ef6ce..090b375 100644
--- a/agentturn_test.go
+++ b/alphaagentturn_test.go
@@ -11,10 +11,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 TestAgentTurnNewWithOptionalParams(t *testing.T) {
+func TestAlphaAgentTurnNewWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -25,33 +24,33 @@ func TestAgentTurnNewWithOptionalParams(t *testing.T) {
client := llamastackclient.NewClient(
option.WithBaseURL(baseURL),
)
- _, err := client.Agents.Turn.New(
+ _, err := client.Alpha.Agents.Turn.New(
context.TODO(),
"session_id",
- llamastackclient.AgentTurnNewParams{
+ llamastackclient.AlphaAgentTurnNewParams{
AgentID: "agent_id",
- Messages: []llamastackclient.AgentTurnNewParamsMessageUnion{{
- OfUserMessage: &shared.UserMessageParam{
- Content: shared.InterleavedContentUnionParam{
+ Messages: []llamastackclient.AlphaAgentTurnNewParamsMessageUnion{{
+ OfUserMessage: &llamastackclient.UserMessageParam{
+ Content: llamastackclient.InterleavedContentUnionParam{
OfString: llamastackclient.String("string"),
},
- Context: shared.InterleavedContentUnionParam{
+ Context: llamastackclient.InterleavedContentUnionParam{
OfString: llamastackclient.String("string"),
},
},
}},
- Documents: []llamastackclient.AgentTurnNewParamsDocument{{
- Content: llamastackclient.AgentTurnNewParamsDocumentContentUnion{
+ Documents: []llamastackclient.AlphaAgentTurnNewParamsDocument{{
+ Content: llamastackclient.AlphaAgentTurnNewParamsDocumentContentUnion{
OfString: llamastackclient.String("string"),
},
MimeType: "mime_type",
}},
- ToolConfig: llamastackclient.AgentTurnNewParamsToolConfig{
+ ToolConfig: llamastackclient.AlphaAgentTurnNewParamsToolConfig{
SystemMessageBehavior: "append",
ToolChoice: "auto",
ToolPromptFormat: "json",
},
- Toolgroups: []llamastackclient.AgentTurnNewParamsToolgroupUnion{{
+ Toolgroups: []llamastackclient.AlphaAgentTurnNewParamsToolgroupUnion{{
OfString: llamastackclient.String("string"),
}},
},
@@ -65,7 +64,7 @@ func TestAgentTurnNewWithOptionalParams(t *testing.T) {
}
}
-func TestAgentTurnGet(t *testing.T) {
+func TestAlphaAgentTurnGet(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -76,10 +75,10 @@ func TestAgentTurnGet(t *testing.T) {
client := llamastackclient.NewClient(
option.WithBaseURL(baseURL),
)
- _, err := client.Agents.Turn.Get(
+ _, err := client.Alpha.Agents.Turn.Get(
context.TODO(),
"turn_id",
- llamastackclient.AgentTurnGetParams{
+ llamastackclient.AlphaAgentTurnGetParams{
AgentID: "agent_id",
SessionID: "session_id",
},
@@ -93,7 +92,7 @@ func TestAgentTurnGet(t *testing.T) {
}
}
-func TestAgentTurnResumeWithOptionalParams(t *testing.T) {
+func TestAlphaAgentTurnResumeWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -104,15 +103,15 @@ func TestAgentTurnResumeWithOptionalParams(t *testing.T) {
client := llamastackclient.NewClient(
option.WithBaseURL(baseURL),
)
- _, err := client.Agents.Turn.Resume(
+ _, err := client.Alpha.Agents.Turn.Resume(
context.TODO(),
"turn_id",
- llamastackclient.AgentTurnResumeParams{
+ llamastackclient.AlphaAgentTurnResumeParams{
AgentID: "agent_id",
SessionID: "session_id",
ToolResponses: []llamastackclient.ToolResponseParam{{
CallID: "call_id",
- Content: shared.InterleavedContentUnionParam{
+ Content: llamastackclient.InterleavedContentUnionParam{
OfString: llamastackclient.String("string"),
},
ToolName: llamastackclient.ToolResponseToolNameBraveSearch,
diff --git a/eval.go b/alphaeval.go
similarity index 67%
rename from eval.go
rename to alphaeval.go
index 779d51d..25fdf6f 100644
--- a/eval.go
+++ b/alphaeval.go
@@ -8,81 +8,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 +92,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 BenchmarkConfigEvalCandidateUnionParam `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,36 +110,23 @@ 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"`
+type BenchmarkConfigEvalCandidateUnionParam struct {
+ OfModel *BenchmarkConfigEvalCandidateModelParam `json:",omitzero,inline"`
+ OfAgent *BenchmarkConfigEvalCandidateAgentParam `json:",omitzero,inline"`
paramUnion
}
-func (u EvalCandidateUnionParam) MarshalJSON() ([]byte, error) {
+func (u BenchmarkConfigEvalCandidateUnionParam) MarshalJSON() ([]byte, error) {
return param.MarshalUnion(u, u.OfModel, u.OfAgent)
}
-func (u *EvalCandidateUnionParam) UnmarshalJSON(data []byte) error {
+func (u *BenchmarkConfigEvalCandidateUnionParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, u)
}
-func (u *EvalCandidateUnionParam) asAny() any {
+func (u *BenchmarkConfigEvalCandidateUnionParam) asAny() any {
if !param.IsOmitted(u.OfModel) {
return u.OfModel
} else if !param.IsOmitted(u.OfAgent) {
@@ -149,7 +136,7 @@ func (u *EvalCandidateUnionParam) asAny() any {
}
// Returns a pointer to the underlying variant's property, if present.
-func (u EvalCandidateUnionParam) GetModel() *string {
+func (u BenchmarkConfigEvalCandidateUnionParam) GetModel() *string {
if vt := u.OfModel; vt != nil {
return &vt.Model
}
@@ -157,7 +144,7 @@ func (u EvalCandidateUnionParam) GetModel() *string {
}
// Returns a pointer to the underlying variant's property, if present.
-func (u EvalCandidateUnionParam) GetSamplingParams() *shared.SamplingParams {
+func (u BenchmarkConfigEvalCandidateUnionParam) GetSamplingParams() *SamplingParams {
if vt := u.OfModel; vt != nil {
return &vt.SamplingParams
}
@@ -165,7 +152,7 @@ func (u EvalCandidateUnionParam) GetSamplingParams() *shared.SamplingParams {
}
// Returns a pointer to the underlying variant's property, if present.
-func (u EvalCandidateUnionParam) GetSystemMessage() *shared.SystemMessageParam {
+func (u BenchmarkConfigEvalCandidateUnionParam) GetSystemMessage() *SystemMessageParam {
if vt := u.OfModel; vt != nil {
return &vt.SystemMessage
}
@@ -173,7 +160,7 @@ func (u EvalCandidateUnionParam) GetSystemMessage() *shared.SystemMessageParam {
}
// Returns a pointer to the underlying variant's property, if present.
-func (u EvalCandidateUnionParam) GetConfig() *shared.AgentConfigParam {
+func (u BenchmarkConfigEvalCandidateUnionParam) GetConfig() *AgentConfigParam {
if vt := u.OfAgent; vt != nil {
return &vt.Config
}
@@ -181,7 +168,7 @@ func (u EvalCandidateUnionParam) GetConfig() *shared.AgentConfigParam {
}
// Returns a pointer to the underlying variant's property, if present.
-func (u EvalCandidateUnionParam) GetType() *string {
+func (u BenchmarkConfigEvalCandidateUnionParam) GetType() *string {
if vt := u.OfModel; vt != nil {
return (*string)(&vt.Type)
} else if vt := u.OfAgent; vt != nil {
@@ -191,52 +178,52 @@ func (u EvalCandidateUnionParam) GetType() *string {
}
func init() {
- apijson.RegisterUnion[EvalCandidateUnionParam](
+ apijson.RegisterUnion[BenchmarkConfigEvalCandidateUnionParam](
"type",
- apijson.Discriminator[EvalCandidateModelParam]("model"),
- apijson.Discriminator[EvalCandidateAgentParam]("agent"),
+ apijson.Discriminator[BenchmarkConfigEvalCandidateModelParam]("model"),
+ apijson.Discriminator[BenchmarkConfigEvalCandidateAgentParam]("agent"),
)
}
// A model candidate for evaluation.
//
// The properties Model, SamplingParams, Type are required.
-type EvalCandidateModelParam struct {
+type BenchmarkConfigEvalCandidateModelParam 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
+func (r BenchmarkConfigEvalCandidateModelParam) MarshalJSON() (data []byte, err error) {
+ type shadow BenchmarkConfigEvalCandidateModelParam
return param.MarshalObject(r, (*shadow)(&r))
}
-func (r *EvalCandidateModelParam) UnmarshalJSON(data []byte) error {
+func (r *BenchmarkConfigEvalCandidateModelParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// An agent candidate for evaluation.
//
// The properties Config, Type are required.
-type EvalCandidateAgentParam struct {
+type BenchmarkConfigEvalCandidateAgentParam struct {
// The configuration for the agent candidate.
- Config shared.AgentConfigParam `json:"config,omitzero,required"`
+ Config 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 BenchmarkConfigEvalCandidateAgentParam) MarshalJSON() (data []byte, err error) {
+ type shadow BenchmarkConfigEvalCandidateAgentParam
return param.MarshalObject(r, (*shadow)(&r))
}
-func (r *EvalCandidateAgentParam) UnmarshalJSON(data []byte) error {
+func (r *BenchmarkConfigEvalCandidateAgentParam) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
@@ -245,7 +232,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 +334,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 +363,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 +383,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 +412,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 +432,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 67%
rename from eval_test.go
rename to alphaeval_test.go
index 7ae74bc..0949d52 100644
--- a/eval_test.go
+++ b/alphaeval_test.go
@@ -11,10 +11,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,24 +24,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{
+ EvalCandidate: llamastackclient.BenchmarkConfigEvalCandidateUnionParam{
+ OfModel: &llamastackclient.BenchmarkConfigEvalCandidateModelParam{
Model: "model",
- SamplingParams: shared.SamplingParams{
- Strategy: shared.SamplingParamsStrategyUnion{
- OfGreedy: &shared.SamplingParamsStrategyGreedy{},
+ SamplingParams: llamastackclient.SamplingParams{
+ Strategy: llamastackclient.SamplingParamsStrategyUnion{
+ OfGreedy: &llamastackclient.SamplingParamsStrategyGreedy{},
},
MaxTokens: llamastackclient.Int(0),
RepetitionPenalty: llamastackclient.Float(0),
Stop: []string{"string"},
},
- SystemMessage: shared.SystemMessageParam{
- Content: shared.InterleavedContentUnionParam{
+ SystemMessage: llamastackclient.SystemMessageParam{
+ Content: llamastackclient.InterleavedContentUnionParam{
OfString: llamastackclient.String("string"),
},
},
@@ -60,7 +59,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 +76,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,24 +87,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{
+ EvalCandidate: llamastackclient.BenchmarkConfigEvalCandidateUnionParam{
+ OfModel: &llamastackclient.BenchmarkConfigEvalCandidateModelParam{
Model: "model",
- SamplingParams: shared.SamplingParams{
- Strategy: shared.SamplingParamsStrategyUnion{
- OfGreedy: &shared.SamplingParamsStrategyGreedy{},
+ SamplingParams: llamastackclient.SamplingParams{
+ Strategy: llamastackclient.SamplingParamsStrategyUnion{
+ OfGreedy: &llamastackclient.SamplingParamsStrategyGreedy{},
},
MaxTokens: llamastackclient.Int(0),
RepetitionPenalty: llamastackclient.Float(0),
Stop: []string{"string"},
},
- SystemMessage: shared.SystemMessageParam{
- Content: shared.InterleavedContentUnionParam{
+ SystemMessage: llamastackclient.SystemMessageParam{
+ Content: llamastackclient.InterleavedContentUnionParam{
OfString: llamastackclient.String("string"),
},
},
@@ -123,7 +122,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 +139,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,24 +150,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{
+ EvalCandidate: llamastackclient.BenchmarkConfigEvalCandidateUnionParam{
+ OfModel: &llamastackclient.BenchmarkConfigEvalCandidateModelParam{
Model: "model",
- SamplingParams: shared.SamplingParams{
- Strategy: shared.SamplingParamsStrategyUnion{
- OfGreedy: &shared.SamplingParamsStrategyGreedy{},
+ SamplingParams: llamastackclient.SamplingParams{
+ Strategy: llamastackclient.SamplingParamsStrategyUnion{
+ OfGreedy: &llamastackclient.SamplingParamsStrategyGreedy{},
},
MaxTokens: llamastackclient.Int(0),
RepetitionPenalty: llamastackclient.Float(0),
Stop: []string{"string"},
},
- SystemMessage: shared.SystemMessageParam{
- Content: shared.InterleavedContentUnionParam{
+ 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,24 +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{
+ EvalCandidate: llamastackclient.BenchmarkConfigEvalCandidateUnionParam{
+ OfModel: &llamastackclient.BenchmarkConfigEvalCandidateModelParam{
Model: "model",
- SamplingParams: shared.SamplingParams{
- Strategy: shared.SamplingParamsStrategyUnion{
- OfGreedy: &shared.SamplingParamsStrategyGreedy{},
+ SamplingParams: llamastackclient.SamplingParams{
+ Strategy: llamastackclient.SamplingParamsStrategyUnion{
+ OfGreedy: &llamastackclient.SamplingParamsStrategyGreedy{},
},
MaxTokens: llamastackclient.Int(0),
RepetitionPenalty: llamastackclient.Float(0),
Stop: []string{"string"},
},
- SystemMessage: shared.SystemMessageParam{
- Content: shared.InterleavedContentUnionParam{
+ SystemMessage: llamastackclient.SystemMessageParam{
+ Content: llamastackclient.InterleavedContentUnionParam{
OfString: llamastackclient.String("string"),
},
},
diff --git a/evaljob.go b/alphaevaljob.go
similarity index 53%
rename from evaljob.go
rename to alphaevaljob.go
index f7e700b..207b027 100644
--- a/evaljob.go
+++ b/alphaevaljob.go
@@ -7,33 +7,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 +43,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 +60,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 +76,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 82%
rename from evaljob_test.go
rename to alphaevaljob_test.go
index 4af20d9..0d68bc5 100644
--- a/evaljob_test.go
+++ b/alphaevaljob_test.go
@@ -13,7 +13,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 +24,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 +40,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 +51,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 +67,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 +78,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..ec20df7
--- /dev/null
+++ b/alphainference.go
@@ -0,0 +1,341 @@
+// 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/alphainference_test.go b/alphainference_test.go
new file mode 100644
index 0000000..fa57fab
--- /dev/null
+++ b/alphainference_test.go
@@ -0,0 +1,44 @@
+// 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 TestAlphaInferenceRerankWithOptionalParams(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := llamastackclient.NewClient(
+ option.WithBaseURL(baseURL),
+ )
+ _, err := client.Alpha.Inference.Rerank(context.TODO(), llamastackclient.AlphaInferenceRerankParams{
+ Items: []llamastackclient.AlphaInferenceRerankParamsItemUnion{{
+ OfString: llamastackclient.String("string"),
+ }},
+ Model: "model",
+ Query: llamastackclient.AlphaInferenceRerankParamsQueryUnion{
+ OfString: llamastackclient.String("string"),
+ },
+ MaxNumResults: 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/posttraining.go b/alphaposttraining.go
similarity index 68%
rename from posttraining.go
rename to alphaposttraining.go
index b919dfd..cbaa57e 100644
--- a/posttraining.go
+++ b/alphaposttraining.go
@@ -5,6 +5,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 +15,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
}
@@ -246,34 +247,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 +284,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 +301,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 +309,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 +332,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 +340,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 +364,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 +376,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 +416,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 +443,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 +468,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 +500,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 +519,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 +542,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 +550,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 +574,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 +586,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 +626,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 +653,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 +678,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 68%
rename from posttraining_test.go
rename to alphaposttraining_test.go
index f43920e..d663687 100644
--- a/posttraining_test.go
+++ b/alphaposttraining_test.go
@@ -13,7 +13,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 +24,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 +55,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 +79,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 +90,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 +116,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 64%
rename from posttrainingjob.go
rename to alphaposttrainingjob.go
index 45109d8..2d2959c 100644
--- a/posttrainingjob.go
+++ b/alphaposttrainingjob.go
@@ -7,6 +7,7 @@ import (
"encoding/json"
"net/http"
"net/url"
+ "slices"
"time"
"github.com/llamastack/llama-stack-client-go/internal/apijson"
@@ -17,30 +18,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 +51,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 +91,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 +109,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 +124,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 +151,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 +191,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 +209,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 +224,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 +251,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,30 +294,32 @@ 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 (u AlphaPostTrainingJobStatusResponseResourcesAllocatedUnion) RawJSON() string {
+ return u.JSON.raw
+}
-func (r *PostTrainingJobStatusResponseResourcesAllocatedUnion) UnmarshalJSON(data []byte) error {
+func (r *AlphaPostTrainingJobStatusResponseResourcesAllocatedUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
@@ -350,44 +355,44 @@ func (r *ListPostTrainingJobsResponseData) 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 77%
rename from posttrainingjob_test.go
rename to alphaposttrainingjob_test.go
index 0771c91..d0e32d2 100644
--- a/posttrainingjob_test.go
+++ b/alphaposttrainingjob_test.go
@@ -13,7 +13,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 +24,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 +34,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 +45,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 +57,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 +68,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 +80,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 +91,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..f1e12cd 100644
--- a/api.md
+++ b/api.md
@@ -1,44 +1,33 @@
# 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.AgentConfigParam
+- llamastackclient.CompletionMessageParam
+- llamastackclient.DocumentParam
+- llamastackclient.InterleavedContentUnionParam
+- llamastackclient.InterleavedContentItemUnionParam
+- llamastackclient.MessageUnionParam
+- llamastackclient.QueryConfigParam
+- llamastackclient.ResponseFormatUnionParam
+- llamastackclient.SamplingParams
+- llamastackclient.SystemMessageParam
+- llamastackclient.ToolCallParam
+- llamastackclient.ToolResponseMessageParam
+- llamastackclient.UserMessageParam
# 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.AgentConfig
+- llamastackclient.CompletionMessage
+- llamastackclient.InterleavedContentUnion
+- llamastackclient.InterleavedContentItemUnion
+- llamastackclient.QueryResult
+- llamastackclient.ResponseFormatUnion
+- llamastackclient.SafetyViolation
+- llamastackclient.SamplingParamsResp
+- llamastackclient.ScoringResult
+- llamastackclient.ToolCall
+- llamastackclient.ToolResponseMessage
+- llamastackclient.UserMessage
# Toolgroups
@@ -56,33 +45,33 @@ 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
+Params Types:
+
+- llamastackclient.ToolDefParam
+
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)
+- client.ToolRuntime.RagTool.Query(ctx context.Context, body llamastackclient.ToolRuntimeRagToolQueryParams) (llamastackclient.QueryResult, error)
# Responses
@@ -91,12 +80,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,71 +97,7 @@ 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
-
-## Steps
-
-Response Types:
-
-- llamastackclient.AgentStepGetResponse
-
-Methods:
-
-- client.Agents.Steps.Get(ctx context.Context, stepID string, query llamastackclient.AgentStepGetParams) (llamastackclient.AgentStepGetResponse, error)
-
-## Turn
-
-Response Types:
-
-- llamastackclient.AgentTurnResponseStreamChunk
-- llamastackclient.Turn
-- llamastackclient.TurnResponseEvent
-- llamastackclient.TurnResponseEventPayloadUnion
-
-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.Responses.InputItems.List(ctx context.Context, responseID string, query llamastackclient.ResponseInputItemListParams) (llamastackclient.ResponseInputItemListResponse, error)
# Datasets
@@ -183,39 +110,12 @@ Response Types:
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
-
-# Eval
-
-Params Types:
-
-- llamastackclient.BenchmarkConfigParam
-- llamastackclient.EvalCandidateUnionParam
-
-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
-
-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.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
# Inspect
@@ -231,22 +131,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 +139,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 +157,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 +169,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
@@ -324,12 +208,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 +225,46 @@ 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, query 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
+- 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)
-Params Types:
-
-- llamastackclient.AlgorithmConfigUnionParam
+# Models
Response Types:
-- llamastackclient.ListPostTrainingJobsResponse
-- llamastackclient.PostTrainingJob
+- llamastackclient.ListModelsResponse
+- llamastackclient.Model
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.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
-- 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
@@ -421,7 +295,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,6 +318,7 @@ 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
@@ -460,7 +335,6 @@ Methods:
Params Types:
-- llamastackclient.EventUnionParam
- llamastackclient.QueryConditionParam
Response Types:
@@ -470,16 +344,17 @@ Response Types:
- llamastackclient.Trace
- llamastackclient.TelemetryGetSpanResponse
- llamastackclient.TelemetryGetSpanTreeResponse
+- llamastackclient.TelemetryQueryMetricsResponse
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.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.QueryMetrics(ctx context.Context, metricName string, body llamastackclient.TelemetryQueryMetricsParams) ([]llamastackclient.TelemetryQueryMetricsResponse, 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
# Scoring
@@ -520,9 +395,9 @@ 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.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
# Files
@@ -535,8 +410,139 @@ Response Types:
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.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)
+
+# Alpha
+
+## Inference
+
+Response Types:
+
+- llamastackclient.AlphaInferenceRerankResponse
+
+Methods:
+
+- client.Alpha.Inference.Rerank(ctx context.Context, body llamastackclient.AlphaInferenceRerankParams) ([]llamastackclient.AlphaInferenceRerankResponse, error)
+
+## PostTraining
+
+Params Types:
+
+- llamastackclient.AlgorithmConfigUnionParam
+
+Response Types:
+
+- llamastackclient.ListPostTrainingJobsResponse
+- llamastackclient.PostTrainingJob
+
+Methods:
+
+- 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)
+
+## Eval
+
+Params Types:
+
+- llamastackclient.BenchmarkConfigParam
+
+Response Types:
+
+- 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)
+
+## Agents
+
+Params Types:
+
+- llamastackclient.ToolResponseParam
+
+Response Types:
+
+- llamastackclient.InferenceStep
+- llamastackclient.MemoryRetrievalStep
+- llamastackclient.ShieldCallStep
+- llamastackclient.ToolExecutionStep
+- llamastackclient.ToolResponse
+- llamastackclient.AlphaAgentNewResponse
+- llamastackclient.AlphaAgentGetResponse
+- llamastackclient.AlphaAgentListResponse
+
+Methods:
+
+- client.Alpha.Agents.New(ctx context.Context, body llamastackclient.AlphaAgentNewParams) (llamastackclient.AlphaAgentNewResponse, error)
+- client.Alpha.Agents.Get(ctx context.Context, agentID string) (llamastackclient.AlphaAgentGetResponse, error)
+- client.Alpha.Agents.List(ctx context.Context, query llamastackclient.AlphaAgentListParams) (llamastackclient.AlphaAgentListResponse, error)
+- client.Alpha.Agents.Delete(ctx context.Context, agentID string) error
+
+### Session
+
+Response Types:
+
+- llamastackclient.Session
+- llamastackclient.AlphaAgentSessionNewResponse
+- llamastackclient.AlphaAgentSessionListResponse
+
+Methods:
+
+- client.Alpha.Agents.Session.New(ctx context.Context, agentID string, body llamastackclient.AlphaAgentSessionNewParams) (llamastackclient.AlphaAgentSessionNewResponse, error)
+- client.Alpha.Agents.Session.Get(ctx context.Context, sessionID string, params llamastackclient.AlphaAgentSessionGetParams) (llamastackclient.Session, error)
+- client.Alpha.Agents.Session.List(ctx context.Context, agentID string, query llamastackclient.AlphaAgentSessionListParams) (llamastackclient.AlphaAgentSessionListResponse, error)
+- client.Alpha.Agents.Session.Delete(ctx context.Context, sessionID string, body llamastackclient.AlphaAgentSessionDeleteParams) error
+
+### Steps
+
+Response Types:
+
+- llamastackclient.AlphaAgentStepGetResponse
+
+Methods:
+
+- client.Alpha.Agents.Steps.Get(ctx context.Context, stepID string, query llamastackclient.AlphaAgentStepGetParams) (llamastackclient.AlphaAgentStepGetResponse, error)
+
+### Turn
+
+Response Types:
+
+- llamastackclient.AgentTurnResponseStreamChunk
+- llamastackclient.Turn
+- llamastackclient.TurnResponseEvent
+
+Methods:
+
+- client.Alpha.Agents.Turn.New(ctx context.Context, sessionID string, params llamastackclient.AlphaAgentTurnNewParams) (llamastackclient.Turn, error)
+- client.Alpha.Agents.Turn.Get(ctx context.Context, turnID string, query llamastackclient.AlphaAgentTurnGetParams) (llamastackclient.Turn, error)
+- client.Alpha.Agents.Turn.Resume(ctx context.Context, turnID string, params llamastackclient.AlphaAgentTurnResumeParams) (llamastackclient.Turn, error)
diff --git a/benchmark.go b/benchmark.go
index b11a273..2e68c53 100644
--- a/benchmark.go
+++ b/benchmark.go
@@ -8,6 +8,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,12 +39,12 @@ func NewBenchmarkService(opts ...option.RequestOption) (r BenchmarkService) {
// 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...)
+ 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
}
@@ -51,8 +52,8 @@ func (r *BenchmarkService) Get(ctx context.Context, benchmarkID string, opts ...
// List all benchmarks.
func (r *BenchmarkService) 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
@@ -63,9 +64,9 @@ 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...)
+ 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
}
diff --git a/chatcompletion.go b/chatcompletion.go
index 89356fc..d882370 100644
--- a/chatcompletion.go
+++ b/chatcompletion.go
@@ -9,6 +9,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"
@@ -43,8 +44,8 @@ func NewChatCompletionService(opts ...option.RequestOption) (r ChatCompletionSer
// 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
}
@@ -56,21 +57,21 @@ func (r *ChatCompletionService) NewStreaming(ctx context.Context, body ChatCompl
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.
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
}
@@ -78,9 +79,9 @@ func (r *ChatCompletionService) Get(ctx context.Context, completionID string, op
// List all 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
diff --git a/client.go b/client.go
index 871db20..212cf91 100644
--- a/client.go
+++ b/client.go
@@ -6,6 +6,7 @@ import (
"context"
"net/http"
"os"
+ "slices"
"github.com/llamastack/llama-stack-client-go/internal/requestconfig"
"github.com/llamastack/llama-stack-client-go/option"
@@ -20,11 +21,8 @@ type Client struct {
Tools ToolService
ToolRuntime ToolRuntimeService
Responses ResponseService
- Agents AgentService
Datasets DatasetService
- Eval EvalService
Inspect InspectService
- Inference InferenceService
Embeddings EmbeddingService
Chat ChatService
Completions CompletionService
@@ -32,7 +30,6 @@ type Client struct {
VectorDBs VectorDBService
VectorStores VectorStoreService
Models ModelService
- PostTraining PostTrainingService
Providers ProviderService
Routes RouteService
Moderations ModerationService
@@ -44,6 +41,7 @@ type Client struct {
ScoringFunctions ScoringFunctionService
Benchmarks BenchmarkService
Files FileService
+ Alpha AlphaService
}
// DefaultClientOptions read from the environment (LLAMA_STACK_CLIENT_API_KEY,
@@ -72,11 +70,8 @@ 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.Inspect = NewInspectService(opts...)
- r.Inference = NewInferenceService(opts...)
r.Embeddings = NewEmbeddingService(opts...)
r.Chat = NewChatService(opts...)
r.Completions = NewCompletionService(opts...)
@@ -84,7 +79,6 @@ func NewClient(opts ...option.RequestOption) (r Client) {
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...)
@@ -96,6 +90,7 @@ func NewClient(opts ...option.RequestOption) (r Client) {
r.ScoringFunctions = NewScoringFunctionService(opts...)
r.Benchmarks = NewBenchmarkService(opts...)
r.Files = NewFileService(opts...)
+ r.Alpha = NewAlphaService(opts...)
return
}
@@ -132,7 +127,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..f518596 100644
--- a/client_test.go
+++ b/client_test.go
@@ -14,7 +14,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 +38,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 +70,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 +113,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 +151,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 +188,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 +219,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 +247,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 +281,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 +334,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 +387,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..fc824a0 100644
--- a/completion.go
+++ b/completion.go
@@ -5,6 +5,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"
@@ -37,8 +38,8 @@ func NewCompletionService(opts ...option.RequestOption) (r CompletionService) {
// 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
}
@@ -50,9 +51,9 @@ func (r *CompletionService) NewStreaming(ctx context.Context, body CompletionNew
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)
}
diff --git a/dataset.go b/dataset.go
index f31e6b3..018219b 100644
--- a/dataset.go
+++ b/dataset.go
@@ -9,6 +9,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,12 +41,12 @@ func NewDatasetService(opts ...option.RequestOption) (r DatasetService) {
// 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...)
+ 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
}
@@ -53,8 +54,8 @@ func (r *DatasetService) Get(ctx context.Context, datasetID string, opts ...opti
// List all datasets.
func (r *DatasetService) 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
@@ -65,13 +66,13 @@ 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...)
+ 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
}
@@ -86,33 +87,33 @@ 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...)
+ 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"
+ 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...)
+ 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
}
diff --git a/embedding.go b/embedding.go
index 168acd8..889a7c4 100644
--- a/embedding.go
+++ b/embedding.go
@@ -6,6 +6,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"
@@ -37,8 +38,8 @@ func NewEmbeddingService(opts ...option.RequestOption) (r EmbeddingService) {
// 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/file.go b/file.go
index 166eebd..49fbbe3 100644
--- a/file.go
+++ b/file.go
@@ -11,6 +11,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"
@@ -47,21 +48,22 @@ func NewFileService(opts ...option.RequestOption) (r FileService) {
//
// - 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.
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
}
@@ -69,9 +71,9 @@ func (r *FileService) Get(ctx context.Context, fileID string, opts ...option.Req
// 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
@@ -91,24 +93,24 @@ func (r *FileService) ListAutoPaging(ctx context.Context, query FileListParams,
// Delete a 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.
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 +155,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 +182,7 @@ type FilePurpose string
const (
FilePurposeAssistants FilePurpose = "assistants"
+ FilePurposeBatch FilePurpose = "batch"
)
// Response for listing files in OpenAI Files API.
@@ -218,8 +221,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 +254,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 +294,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 +321,5 @@ type FileListParamsPurpose string
const (
FileListParamsPurposeAssistants FileListParamsPurpose = "assistants"
+ FileListParamsPurposeBatch FileListParamsPurpose = "batch"
)
diff --git a/file_test.go b/file_test.go
index 8f6b65c..d00c0a7 100644
--- a/file_test.go
+++ b/file_test.go
@@ -15,7 +15,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 +29,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..fd4d013 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
module github.com/llamastack/llama-stack-client-go
-go 1.21
+go 1.22
require (
github.com/tidwall/gjson v1.14.4
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..4250123 100644
--- a/inspect.go
+++ b/inspect.go
@@ -6,6 +6,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,7 +35,7 @@ func NewInspectService(opts ...option.RequestOption) (r InspectService) {
// 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
@@ -42,7 +43,7 @@ func (r *InspectService) Health(ctx context.Context, opts ...option.RequestOptio
// 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/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..8b4d023 100644
--- a/internal/requestconfig/requestconfig.go
+++ b/internal/requestconfig/requestconfig.go
@@ -461,6 +461,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..d6f40b3 100644
--- a/internal/version.go
+++ b/internal/version.go
@@ -2,4 +2,4 @@
package internal
-const PackageVersion = "0.1.0-alpha.1" // x-release-please-version
+const PackageVersion = "0.1.0-alpha.2" // x-release-please-version
diff --git a/model.go b/model.go
index d3cc1d2..8e92752 100644
--- a/model.go
+++ b/model.go
@@ -8,6 +8,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 +26,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 +35,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...)
+ opts = slices.Concat(r.Options, opts)
if modelID == "" {
err = errors.New("missing required model_id parameter")
return
@@ -51,7 +54,7 @@ func (r *ModelService) Get(ctx context.Context, modelID string, opts ...option.R
// List all models.
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 {
@@ -63,7 +66,7 @@ func (r *ModelService) List(ctx context.Context, opts ...option.RequestOption) (
// Register a model.
func (r *ModelService) Register(ctx context.Context, body ModelRegisterParams, opts ...option.RequestOption) (res *Model, err error) {
- opts = append(r.Options[:], opts...)
+ opts = slices.Concat(r.Options, opts)
path := "v1/models"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
@@ -71,7 +74,7 @@ func (r *ModelService) Register(ctx context.Context, body ModelRegisterParams, o
// Unregister a model.
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")
diff --git a/modelopenai.go b/modelopenai.go
new file mode 100644
index 0000000..e2c51c1
--- /dev/null
+++ b/modelopenai.go
@@ -0,0 +1,62 @@
+// 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/respjson"
+)
+
+// 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 all models.
+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
+}
+
+type ListModelsResponse struct {
+ Data []Model `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 ListModelsResponse) RawJSON() string { return r.JSON.raw }
+func (r *ListModelsResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
diff --git a/modelopenai_test.go b/modelopenai_test.go
new file mode 100644
index 0000000..03bfd79
--- /dev/null
+++ b/modelopenai_test.go
@@ -0,0 +1,35 @@
+// 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 TestModelOpenAIList(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.Models.OpenAI.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())
+ }
+}
diff --git a/moderation.go b/moderation.go
index fe54384..eb7ddab 100644
--- a/moderation.go
+++ b/moderation.go
@@ -6,6 +6,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"
@@ -35,8 +36,8 @@ func NewModerationService(opts ...option.RequestOption) (r ModerationService) {
// 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 +75,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].
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/provider.go b/provider.go
index 87e7f3c..d93c0ba 100644
--- a/provider.go
+++ b/provider.go
@@ -7,6 +7,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"
@@ -35,7 +36,7 @@ func NewProviderService(opts ...option.RequestOption) (r ProviderService) {
// 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
@@ -48,7 +49,7 @@ func (r *ProviderService) Get(ctx context.Context, providerID string, opts ...op
// 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/response.go b/response.go
index a58d06e..37ce156 100644
--- a/response.go
+++ b/response.go
@@ -9,6 +9,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"
@@ -44,8 +45,8 @@ func NewResponseService(opts ...option.RequestOption) (r ResponseService) {
// Create a new OpenAI 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
}
@@ -56,21 +57,21 @@ func (r *ResponseService) NewStreaming(ctx context.Context, body ResponseNewPara
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.
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
}
@@ -78,9 +79,9 @@ func (r *ResponseService) Get(ctx context.Context, responseID string, opts ...op
// List all OpenAI 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
@@ -98,6 +99,18 @@ func (r *ResponseService) ListAutoPaging(ctx context.Context, query ResponseList
return pagination.NewOpenAICursorPageAutoPager(r.List(ctx, query, opts...))
}
+// Delete an OpenAI response by its ID.
+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
@@ -126,8 +139,6 @@ type ResponseObject struct {
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"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
@@ -143,7 +154,6 @@ type ResponseObject struct {
Temperature respjson.Field
TopP respjson.Field
Truncation respjson.Field
- User respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
@@ -158,7 +168,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 +180,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 +225,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 +242,7 @@ func (ResponseObjectOutputMcpListTools) implResponseObjectOutputUnion() {}
// case llamastackclient.ResponseObjectOutputFunctionCall:
// case llamastackclient.ResponseObjectOutputMcpCall:
// case llamastackclient.ResponseObjectOutputMcpListTools:
+// case llamastackclient.ResponseObjectOutputMcpApprovalRequest:
// default:
// fmt.Errorf("no variant present")
// }
@@ -247,6 +260,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 +296,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 }
@@ -1065,6 +1085,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 (
@@ -1732,7 +1777,8 @@ func (r *ResponseObjectStreamResponseOutputItemAdded) UnmarshalJSON(data []byte)
// [ResponseObjectStreamResponseOutputItemAddedItemFileSearchCall],
// [ResponseObjectStreamResponseOutputItemAddedItemFunctionCall],
// [ResponseObjectStreamResponseOutputItemAddedItemMcpCall],
-// [ResponseObjectStreamResponseOutputItemAddedItemMcpListTools].
+// [ResponseObjectStreamResponseOutputItemAddedItemMcpListTools],
+// [ResponseObjectStreamResponseOutputItemAddedItemMcpApprovalRequest].
//
// Use the [ResponseObjectStreamResponseOutputItemAddedItemUnion.AsAny] method to
// switch on the variant.
@@ -1746,7 +1792,7 @@ type ResponseObjectStreamResponseOutputItemAddedItemUnion struct {
// [ResponseObjectStreamResponseOutputItemAddedItemMessage].
Role ResponseObjectStreamResponseOutputItemAddedItemMessageRole `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"`
@@ -1810,6 +1856,8 @@ func (ResponseObjectStreamResponseOutputItemAddedItemMcpCall) implResponseObject
}
func (ResponseObjectStreamResponseOutputItemAddedItemMcpListTools) implResponseObjectStreamResponseOutputItemAddedItemUnion() {
}
+func (ResponseObjectStreamResponseOutputItemAddedItemMcpApprovalRequest) implResponseObjectStreamResponseOutputItemAddedItemUnion() {
+}
// Use the following switch statement to find the correct variant
//
@@ -1820,6 +1868,7 @@ func (ResponseObjectStreamResponseOutputItemAddedItemMcpListTools) implResponseO
// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemFunctionCall:
// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMcpCall:
// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMcpListTools:
+// case llamastackclient.ResponseObjectStreamResponseOutputItemAddedItemMcpApprovalRequest:
// default:
// fmt.Errorf("no variant present")
// }
@@ -1837,6 +1886,8 @@ func (u ResponseObjectStreamResponseOutputItemAddedItemUnion) AsAny() anyRespons
return u.AsMcpCall()
case "mcp_list_tools":
return u.AsMcpListTools()
+ case "mcp_approval_request":
+ return u.AsMcpApprovalRequest()
}
return nil
}
@@ -1871,6 +1922,11 @@ func (u ResponseObjectStreamResponseOutputItemAddedItemUnion) AsMcpListTools() (
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 }
@@ -2692,6 +2748,33 @@ func (r *ResponseObjectStreamResponseOutputItemAddedItemMcpListToolsToolInputSch
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 (
@@ -2738,7 +2821,8 @@ func (r *ResponseObjectStreamResponseOutputItemDone) UnmarshalJSON(data []byte)
// [ResponseObjectStreamResponseOutputItemDoneItemFileSearchCall],
// [ResponseObjectStreamResponseOutputItemDoneItemFunctionCall],
// [ResponseObjectStreamResponseOutputItemDoneItemMcpCall],
-// [ResponseObjectStreamResponseOutputItemDoneItemMcpListTools].
+// [ResponseObjectStreamResponseOutputItemDoneItemMcpListTools],
+// [ResponseObjectStreamResponseOutputItemDoneItemMcpApprovalRequest].
//
// Use the [ResponseObjectStreamResponseOutputItemDoneItemUnion.AsAny] method to
// switch on the variant.
@@ -2752,7 +2836,7 @@ type ResponseObjectStreamResponseOutputItemDoneItemUnion struct {
// [ResponseObjectStreamResponseOutputItemDoneItemMessage].
Role ResponseObjectStreamResponseOutputItemDoneItemMessageRole `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"`
@@ -2815,6 +2899,8 @@ func (ResponseObjectStreamResponseOutputItemDoneItemMcpCall) implResponseObjectS
}
func (ResponseObjectStreamResponseOutputItemDoneItemMcpListTools) implResponseObjectStreamResponseOutputItemDoneItemUnion() {
}
+func (ResponseObjectStreamResponseOutputItemDoneItemMcpApprovalRequest) implResponseObjectStreamResponseOutputItemDoneItemUnion() {
+}
// Use the following switch statement to find the correct variant
//
@@ -2825,6 +2911,7 @@ func (ResponseObjectStreamResponseOutputItemDoneItemMcpListTools) implResponseOb
// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemFunctionCall:
// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMcpCall:
// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMcpListTools:
+// case llamastackclient.ResponseObjectStreamResponseOutputItemDoneItemMcpApprovalRequest:
// default:
// fmt.Errorf("no variant present")
// }
@@ -2842,6 +2929,8 @@ func (u ResponseObjectStreamResponseOutputItemDoneItemUnion) AsAny() anyResponse
return u.AsMcpCall()
case "mcp_list_tools":
return u.AsMcpListTools()
+ case "mcp_approval_request":
+ return u.AsMcpApprovalRequest()
}
return nil
}
@@ -2876,6 +2965,11 @@ func (u ResponseObjectStreamResponseOutputItemDoneItemUnion) AsMcpListTools() (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 }
@@ -3697,6 +3791,33 @@ func (r *ResponseObjectStreamResponseOutputItemDoneItemMcpListToolsToolInputSche
return apijson.UnmarshalRoot(data, r)
}
+// A request for human approval of a tool invocation.
+type ResponseObjectStreamResponseOutputItemDoneItemMcpApprovalRequest struct {
+ ID string `json:"id,required"`
+ Arguments string `json:"arguments,required"`
+ Name string `json:"name,required"`
+ ServerLabel string `json:"server_label,required"`
+ Type constant.McpApprovalRequest `json:"type,required"`
+ // 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 (
@@ -4414,8 +4535,6 @@ type ResponseListResponse struct {
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"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
@@ -4432,7 +4551,6 @@ type ResponseListResponse struct {
Temperature respjson.Field
TopP respjson.Field
Truncation respjson.Field
- User respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
@@ -4449,6 +4567,8 @@ func (r *ResponseListResponse) UnmarshalJSON(data []byte) error {
// [ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCall],
// [ResponseListResponseInputOpenAIResponseOutputMessageFunctionToolCall],
// [ResponseListResponseInputOpenAIResponseInputFunctionToolCallOutput],
+// [ResponseListResponseInputOpenAIResponseMcpApprovalRequest],
+// [ResponseListResponseInputOpenAIResponseMcpApprovalResponse],
// [ResponseListResponseInputOpenAIResponseMessage].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
@@ -4461,34 +4581,46 @@ type ResponseListResponseInputUnion struct {
Queries []string `json:"queries"`
// This field is from variant
// [ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCall].
- Results []ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResult `json:"results"`
- // This field is from variant
- // [ResponseListResponseInputOpenAIResponseOutputMessageFunctionToolCall].
- Arguments string `json:"arguments"`
- CallID string `json:"call_id"`
- // This field is from variant
- // [ResponseListResponseInputOpenAIResponseOutputMessageFunctionToolCall].
- Name string `json:"name"`
+ Results []ResponseListResponseInputOpenAIResponseOutputMessageFileSearchToolCallResult `json:"results"`
+ Arguments string `json:"arguments"`
+ CallID string `json:"call_id"`
+ Name string `json:"name"`
// This field is from variant
// [ResponseListResponseInputOpenAIResponseInputFunctionToolCallOutput].
Output string `json:"output"`
+ // This field is from variant
+ // [ResponseListResponseInputOpenAIResponseMcpApprovalRequest].
+ ServerLabel string `json:"server_label"`
+ // This field is from variant
+ // [ResponseListResponseInputOpenAIResponseMcpApprovalResponse].
+ ApprovalRequestID string `json:"approval_request_id"`
+ // This field is from variant
+ // [ResponseListResponseInputOpenAIResponseMcpApprovalResponse].
+ Approve bool `json:"approve"`
+ // This field is from variant
+ // [ResponseListResponseInputOpenAIResponseMcpApprovalResponse].
+ Reason string `json:"reason"`
// This field is from variant [ResponseListResponseInputOpenAIResponseMessage].
Content ResponseListResponseInputOpenAIResponseMessageContentUnion `json:"content"`
// This field is from variant [ResponseListResponseInputOpenAIResponseMessage].
Role ResponseListResponseInputOpenAIResponseMessageRole `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
+ 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
+ ServerLabel respjson.Field
+ ApprovalRequestID respjson.Field
+ Approve respjson.Field
+ Reason respjson.Field
+ Content respjson.Field
+ Role respjson.Field
+ raw string
} `json:"-"`
}
@@ -4512,6 +4644,16 @@ func (u ResponseListResponseInputUnion) AsOpenAIResponseInputFunctionToolCallOut
return
}
+func (u ResponseListResponseInputUnion) AsOpenAIResponseMcpApprovalRequest() (v ResponseListResponseInputOpenAIResponseMcpApprovalRequest) {
+ 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) AsOpenAIResponseMessage() (v ResponseListResponseInputOpenAIResponseMessage) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
@@ -4732,6 +4874,60 @@ func (r *ResponseListResponseInputOpenAIResponseInputFunctionToolCallOutput) Unm
return apijson.UnmarshalRoot(data, r)
}
+// A request for human approval of a tool invocation.
+type ResponseListResponseInputOpenAIResponseMcpApprovalRequest struct {
+ ID string `json:"id,required"`
+ Arguments string `json:"arguments,required"`
+ Name string `json:"name,required"`
+ ServerLabel string `json:"server_label,required"`
+ Type constant.McpApprovalRequest `json:"type,required"`
+ // 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 ResponseListResponseInputOpenAIResponseMcpApprovalRequest) RawJSON() string {
+ return r.JSON.raw
+}
+func (r *ResponseListResponseInputOpenAIResponseMcpApprovalRequest) UnmarshalJSON(data []byte) error {
+ 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)
+}
+
// 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.
@@ -5233,7 +5429,8 @@ const (
// [ResponseListResponseOutputMessage], [ResponseListResponseOutputWebSearchCall],
// [ResponseListResponseOutputFileSearchCall],
// [ResponseListResponseOutputFunctionCall], [ResponseListResponseOutputMcpCall],
-// [ResponseListResponseOutputMcpListTools].
+// [ResponseListResponseOutputMcpListTools],
+// [ResponseListResponseOutputMcpApprovalRequest].
//
// Use the [ResponseListResponseOutputUnion.AsAny] method to switch on the variant.
//
@@ -5244,7 +5441,7 @@ type ResponseListResponseOutputUnion struct {
// 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_call", "mcp_list_tools", "mcp_approval_request".
Type string `json:"type"`
ID string `json:"id"`
Status string `json:"status"`
@@ -5289,12 +5486,13 @@ type anyResponseListResponseOutput interface {
implResponseListResponseOutputUnion()
}
-func (ResponseListResponseOutputMessage) implResponseListResponseOutputUnion() {}
-func (ResponseListResponseOutputWebSearchCall) implResponseListResponseOutputUnion() {}
-func (ResponseListResponseOutputFileSearchCall) implResponseListResponseOutputUnion() {}
-func (ResponseListResponseOutputFunctionCall) implResponseListResponseOutputUnion() {}
-func (ResponseListResponseOutputMcpCall) implResponseListResponseOutputUnion() {}
-func (ResponseListResponseOutputMcpListTools) 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
//
@@ -5305,6 +5503,7 @@ func (ResponseListResponseOutputMcpListTools) implResponseListResponseOutputUnio
// case llamastackclient.ResponseListResponseOutputFunctionCall:
// case llamastackclient.ResponseListResponseOutputMcpCall:
// case llamastackclient.ResponseListResponseOutputMcpListTools:
+// case llamastackclient.ResponseListResponseOutputMcpApprovalRequest:
// default:
// fmt.Errorf("no variant present")
// }
@@ -5322,6 +5521,8 @@ func (u ResponseListResponseOutputUnion) AsAny() anyResponseListResponseOutput {
return u.AsMcpCall()
case "mcp_list_tools":
return u.AsMcpListTools()
+ case "mcp_approval_request":
+ return u.AsMcpApprovalRequest()
}
return nil
}
@@ -5356,6 +5557,11 @@ func (u ResponseListResponseOutputUnion) AsMcpListTools() (v ResponseListRespons
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 }
@@ -6152,6 +6358,31 @@ func (r *ResponseListResponseOutputMcpListToolsToolInputSchemaUnion) UnmarshalJS
return apijson.UnmarshalRoot(data, r)
}
+// A request for human approval of a tool invocation.
+type ResponseListResponseOutputMcpApprovalRequest struct {
+ ID string `json:"id,required"`
+ Arguments string `json:"arguments,required"`
+ Name string `json:"name,required"`
+ ServerLabel string `json:"server_label,required"`
+ Type constant.McpApprovalRequest `json:"type,required"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ ID respjson.Field
+ Arguments respjson.Field
+ Name respjson.Field
+ ServerLabel respjson.Field
+ Type respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseListResponseOutputMcpApprovalRequest) RawJSON() string { return r.JSON.raw }
+func (r *ResponseListResponseOutputMcpApprovalRequest) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
type ResponseListResponseOutputRole string
const (
@@ -6295,6 +6526,30 @@ func (r *ResponseListResponseError) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
+// 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 {
+ 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 ResponseDeleteResponse) RawJSON() string { return r.JSON.raw }
+func (r *ResponseDeleteResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
type ResponseNewParams struct {
// Input message(s) to create the response.
Input ResponseNewParamsInputUnion `json:"input,omitzero,required"`
@@ -6357,6 +6612,8 @@ type ResponseNewParamsInputArrayItemUnion struct {
OfOpenAIResponseOutputMessageFileSearchToolCall *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFileSearchToolCall `json:",omitzero,inline"`
OfOpenAIResponseOutputMessageFunctionToolCall *ResponseNewParamsInputArrayItemOpenAIResponseOutputMessageFunctionToolCall `json:",omitzero,inline"`
OfOpenAIResponseInputFunctionToolCallOutput *ResponseNewParamsInputArrayItemOpenAIResponseInputFunctionToolCallOutput `json:",omitzero,inline"`
+ OfOpenAIResponseMcpApprovalRequest *ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalRequest `json:",omitzero,inline"`
+ OfOpenAIResponseMcpApprovalResponse *ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalResponse `json:",omitzero,inline"`
OfOpenAIResponseMessage *ResponseNewParamsInputArrayItemOpenAIResponseMessage `json:",omitzero,inline"`
paramUnion
}
@@ -6366,6 +6623,8 @@ func (u ResponseNewParamsInputArrayItemUnion) MarshalJSON() ([]byte, error) {
u.OfOpenAIResponseOutputMessageFileSearchToolCall,
u.OfOpenAIResponseOutputMessageFunctionToolCall,
u.OfOpenAIResponseInputFunctionToolCallOutput,
+ u.OfOpenAIResponseMcpApprovalRequest,
+ u.OfOpenAIResponseMcpApprovalResponse,
u.OfOpenAIResponseMessage)
}
func (u *ResponseNewParamsInputArrayItemUnion) UnmarshalJSON(data []byte) error {
@@ -6381,6 +6640,10 @@ func (u *ResponseNewParamsInputArrayItemUnion) asAny() any {
return u.OfOpenAIResponseOutputMessageFunctionToolCall
} else if !param.IsOmitted(u.OfOpenAIResponseInputFunctionToolCallOutput) {
return u.OfOpenAIResponseInputFunctionToolCallOutput
+ } else if !param.IsOmitted(u.OfOpenAIResponseMcpApprovalRequest) {
+ return u.OfOpenAIResponseMcpApprovalRequest
+ } else if !param.IsOmitted(u.OfOpenAIResponseMcpApprovalResponse) {
+ return u.OfOpenAIResponseMcpApprovalResponse
} else if !param.IsOmitted(u.OfOpenAIResponseMessage) {
return u.OfOpenAIResponseMessage
}
@@ -6404,25 +6667,41 @@ func (u ResponseNewParamsInputArrayItemUnion) GetResults() []ResponseNewParamsIn
}
// 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
+func (u ResponseNewParamsInputArrayItemUnion) GetOutput() *string {
+ if vt := u.OfOpenAIResponseInputFunctionToolCallOutput; vt != nil {
+ return &vt.Output
}
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 ResponseNewParamsInputArrayItemUnion) GetServerLabel() *string {
+ if vt := u.OfOpenAIResponseMcpApprovalRequest; vt != nil {
+ return &vt.ServerLabel
}
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 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
}
@@ -6453,6 +6732,10 @@ func (u ResponseNewParamsInputArrayItemUnion) GetID() *string {
return &vt.ID.Value
} else if vt := u.OfOpenAIResponseInputFunctionToolCallOutput; vt != nil && vt.ID.Valid() {
return &vt.ID.Value
+ } else if vt := u.OfOpenAIResponseMcpApprovalRequest; vt != nil {
+ return (*string)(&vt.ID)
+ } else if vt := u.OfOpenAIResponseMcpApprovalResponse; vt != nil && vt.ID.Valid() {
+ return &vt.ID.Value
} else if vt := u.OfOpenAIResponseMessage; vt != nil && vt.ID.Valid() {
return &vt.ID.Value
}
@@ -6485,12 +6768,26 @@ func (u ResponseNewParamsInputArrayItemUnion) GetType() *string {
return (*string)(&vt.Type)
} else if vt := u.OfOpenAIResponseInputFunctionToolCallOutput; vt != nil {
return (*string)(&vt.Type)
+ } else if vt := u.OfOpenAIResponseMcpApprovalRequest; vt != nil {
+ return (*string)(&vt.Type)
+ } else if vt := u.OfOpenAIResponseMcpApprovalResponse; vt != nil {
+ return (*string)(&vt.Type)
} else if vt := u.OfOpenAIResponseMessage; vt != nil {
return (*string)(&vt.Type)
}
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 (*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 {
@@ -6501,6 +6798,16 @@ func (u ResponseNewParamsInputArrayItemUnion) GetCallID() *string {
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.OfOpenAIResponseMcpApprovalRequest; vt != nil {
+ return (*string)(&vt.Name)
+ }
+ return nil
+}
+
// Web search tool call output message for OpenAI responses.
//
// The properties ID, Status, Type are required.
@@ -6659,6 +6966,50 @@ func (r *ResponseNewParamsInputArrayItemOpenAIResponseInputFunctionToolCallOutpu
return apijson.UnmarshalRoot(data, r)
}
+// A request for human approval of a tool invocation.
+//
+// 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 ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalRequest) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalRequest
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalRequest) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// A response to an MCP approval request.
+//
+// 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 ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalResponse) MarshalJSON() (data []byte, err error) {
+ type shadow ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalResponse
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ResponseNewParamsInputArrayItemOpenAIResponseMcpApprovalResponse) 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.
diff --git a/response_test.go b/response_test.go
index ea61345..829b38b 100644
--- a/response_test.go
+++ b/response_test.go
@@ -110,3 +110,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..8ca9295 100644
--- a/responseinputitem.go
+++ b/responseinputitem.go
@@ -9,6 +9,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,12 +41,12 @@ func NewResponseInputItemService(opts ...option.RequestOption) (r ResponseInputI
// List input items for a given OpenAI response.
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
}
@@ -77,6 +78,8 @@ func (r *ResponseInputItemListResponse) UnmarshalJSON(data []byte) error {
// [ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCall],
// [ResponseInputItemListResponseDataOpenAIResponseOutputMessageFunctionToolCall],
// [ResponseInputItemListResponseDataOpenAIResponseInputFunctionToolCallOutput],
+// [ResponseInputItemListResponseDataOpenAIResponseMcpApprovalRequest],
+// [ResponseInputItemListResponseDataOpenAIResponseMcpApprovalResponse],
// [ResponseInputItemListResponseDataOpenAIResponseMessage].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
@@ -89,36 +92,48 @@ type ResponseInputItemListResponseDataUnion struct {
Queries []string `json:"queries"`
// This field is from variant
// [ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCall].
- Results []ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResult `json:"results"`
- // This field is from variant
- // [ResponseInputItemListResponseDataOpenAIResponseOutputMessageFunctionToolCall].
- Arguments string `json:"arguments"`
- CallID string `json:"call_id"`
- // This field is from variant
- // [ResponseInputItemListResponseDataOpenAIResponseOutputMessageFunctionToolCall].
- Name string `json:"name"`
+ Results []ResponseInputItemListResponseDataOpenAIResponseOutputMessageFileSearchToolCallResult `json:"results"`
+ Arguments string `json:"arguments"`
+ CallID string `json:"call_id"`
+ Name string `json:"name"`
// This field is from variant
// [ResponseInputItemListResponseDataOpenAIResponseInputFunctionToolCallOutput].
Output string `json:"output"`
// This field is from variant
+ // [ResponseInputItemListResponseDataOpenAIResponseMcpApprovalRequest].
+ ServerLabel string `json:"server_label"`
+ // This field is from variant
+ // [ResponseInputItemListResponseDataOpenAIResponseMcpApprovalResponse].
+ ApprovalRequestID string `json:"approval_request_id"`
+ // This field is from variant
+ // [ResponseInputItemListResponseDataOpenAIResponseMcpApprovalResponse].
+ Approve bool `json:"approve"`
+ // This field is from variant
+ // [ResponseInputItemListResponseDataOpenAIResponseMcpApprovalResponse].
+ Reason string `json:"reason"`
+ // This field is from variant
// [ResponseInputItemListResponseDataOpenAIResponseMessage].
Content ResponseInputItemListResponseDataOpenAIResponseMessageContentUnion `json:"content"`
// 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
+ 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
+ ServerLabel respjson.Field
+ ApprovalRequestID respjson.Field
+ Approve respjson.Field
+ Reason respjson.Field
+ Content respjson.Field
+ Role respjson.Field
+ raw string
} `json:"-"`
}
@@ -142,6 +157,16 @@ func (u ResponseInputItemListResponseDataUnion) AsOpenAIResponseInputFunctionToo
return
}
+func (u ResponseInputItemListResponseDataUnion) AsOpenAIResponseMcpApprovalRequest() (v ResponseInputItemListResponseDataOpenAIResponseMcpApprovalRequest) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
+func (u ResponseInputItemListResponseDataUnion) AsOpenAIResponseMcpApprovalResponse() (v ResponseInputItemListResponseDataOpenAIResponseMcpApprovalResponse) {
+ apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
+ return
+}
+
func (u ResponseInputItemListResponseDataUnion) AsOpenAIResponseMessage() (v ResponseInputItemListResponseDataOpenAIResponseMessage) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
@@ -362,6 +387,60 @@ func (r *ResponseInputItemListResponseDataOpenAIResponseInputFunctionToolCallOut
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
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r ResponseInputItemListResponseDataOpenAIResponseMcpApprovalRequest) RawJSON() string {
+ return r.JSON.raw
+}
+func (r *ResponseInputItemListResponseDataOpenAIResponseMcpApprovalRequest) 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)
+}
+
// 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.
diff --git a/route.go b/route.go
index 9ab5dfb..60208fa 100644
--- a/route.go
+++ b/route.go
@@ -5,6 +5,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,7 +35,7 @@ func NewRouteService(opts ...option.RequestOption) (r RouteService) {
// 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) {
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...)
if err != nil {
diff --git a/safety.go b/safety.go
index 1c01cfe..015d128 100644
--- a/safety.go
+++ b/safety.go
@@ -5,13 +5,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"
)
// SafetyService contains methods and other services that help with interacting
@@ -35,7 +35,7 @@ func NewSafetyService(opts ...option.RequestOption) (r SafetyService) {
// 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 +44,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 +61,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 []MessageUnionParam `json:"messages,omitzero,required"`
// The parameters of the shield.
Params map[string]SafetyRunShieldParamsParamUnion `json:"params,omitzero,required"`
// The identifier of the shield to run.
diff --git a/safety_test.go b/safety_test.go
index 012daef..d7e98d4 100644
--- a/safety_test.go
+++ b/safety_test.go
@@ -11,7 +11,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,12 +25,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{
+ Messages: []llamastackclient.MessageUnionParam{{
+ OfUser: &llamastackclient.UserMessageParam{
+ Content: llamastackclient.InterleavedContentUnionParam{
OfString: llamastackclient.String("string"),
},
- Context: shared.InterleavedContentUnionParam{
+ Context: llamastackclient.InterleavedContentUnionParam{
OfString: llamastackclient.String("string"),
},
},
diff --git a/scoring.go b/scoring.go
index 19b5c06..3f4a0b6 100644
--- a/scoring.go
+++ b/scoring.go
@@ -5,13 +5,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 +35,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 +43,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 +52,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 +70,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/scoringfunction.go b/scoringfunction.go
index 898bca7..76fbef0 100644
--- a/scoringfunction.go
+++ b/scoringfunction.go
@@ -8,13 +8,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 +39,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 +52,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 {
@@ -64,7 +64,7 @@ func (r *ScoringFunctionService) List(ctx context.Context, opts ...option.Reques
// Register a scoring function.
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 +92,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 +172,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 +559,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 +580,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..189050a 100644
--- a/scoringfunction_test.go
+++ b/scoringfunction_test.go
@@ -11,7 +11,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 +68,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/shared.go b/shared.go
similarity index 72%
rename from shared/shared.go
rename to shared.go
index 23bf070..bac7869 100644
--- a/shared/shared.go
+++ b/shared.go
@@ -1,6 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-package shared
+package llamastackclient
import (
"encoding/json"
@@ -22,8 +22,8 @@ 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"`
+ Model string `json:"model,required"`
+ ClientTools []ToolDef `json:"client_tools"`
// Optional flag indicating whether session data has to be persisted
EnableSessionPersistence bool `json:"enable_session_persistence"`
InputShields []string `json:"input_shields"`
@@ -268,10 +268,10 @@ type AgentConfigParam struct {
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"`
+ Name param.Opt[string] `json:"name,omitzero"`
+ ClientTools []ToolDefParam `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.
@@ -418,90 +418,6 @@ func (u *AgentConfigToolgroupAgentToolGroupWithArgsArgUnionParam) asAny() any {
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
@@ -591,156 +507,6 @@ 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.
@@ -1288,8 +1054,8 @@ type anyInterleavedContentItem interface {
// Use the following switch statement to find the correct variant
//
// switch variant := InterleavedContentItemUnion.AsAny().(type) {
-// case shared.InterleavedContentItemImage:
-// case shared.InterleavedContentItemText:
+// case llamastackclient.InterleavedContentItemImage:
+// case llamastackclient.InterleavedContentItemText:
// default:
// fmt.Errorf("no variant present")
// }
@@ -1752,7 +1518,7 @@ type QueryConfigParam struct {
// 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"`
+ QueryGeneratorConfig QueryConfigQueryGeneratorConfigUnionParam `json:"query_generator_config,omitzero,required"`
// Search mode for retrieval—either "vector", "keyword", or "hybrid". Default
// "vector".
//
@@ -1771,6 +1537,117 @@ func (r *QueryConfigParam) 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 QueryConfigQueryGeneratorConfigUnionParam struct {
+ OfDefault *QueryConfigQueryGeneratorConfigDefaultParam `json:",omitzero,inline"`
+ OfLlm *QueryConfigQueryGeneratorConfigLlmParam `json:",omitzero,inline"`
+ paramUnion
+}
+
+func (u QueryConfigQueryGeneratorConfigUnionParam) MarshalJSON() ([]byte, error) {
+ return param.MarshalUnion(u, u.OfDefault, u.OfLlm)
+}
+func (u *QueryConfigQueryGeneratorConfigUnionParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, u)
+}
+
+func (u *QueryConfigQueryGeneratorConfigUnionParam) 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 QueryConfigQueryGeneratorConfigUnionParam) 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 QueryConfigQueryGeneratorConfigUnionParam) 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 QueryConfigQueryGeneratorConfigUnionParam) 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 QueryConfigQueryGeneratorConfigUnionParam) 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[QueryConfigQueryGeneratorConfigUnionParam](
+ "type",
+ apijson.Discriminator[QueryConfigQueryGeneratorConfigDefaultParam]("default"),
+ apijson.Discriminator[QueryConfigQueryGeneratorConfigLlmParam]("llm"),
+ )
+}
+
+// Configuration for the default RAG query generator.
+//
+// The properties Separator, Type are required.
+type QueryConfigQueryGeneratorConfigDefaultParam 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 QueryConfigQueryGeneratorConfigDefaultParam) MarshalJSON() (data []byte, err error) {
+ type shadow QueryConfigQueryGeneratorConfigDefaultParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *QueryConfigQueryGeneratorConfigDefaultParam) 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 QueryConfigQueryGeneratorConfigLlmParam 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 QueryConfigQueryGeneratorConfigLlmParam) MarshalJSON() (data []byte, err error) {
+ type shadow QueryConfigQueryGeneratorConfigLlmParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *QueryConfigQueryGeneratorConfigLlmParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
// Search mode for retrieval—either "vector", "keyword", or "hybrid". Default
// "vector".
type QueryConfigMode string
@@ -1884,153 +1761,29 @@ 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_}
+// 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:"-"`
}
-func QueryGeneratorConfigParamOfLlm(model string, template string) QueryGeneratorConfigUnionParam {
- var llm QueryGeneratorConfigLlmParam
- llm.Model = model
- llm.Template = template
- return QueryGeneratorConfigUnionParam{OfLlm: &llm}
+// 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)
}
-// 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].
+// 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.
//
@@ -2111,8 +1864,8 @@ type anyResponseFormat interface {
// Use the following switch statement to find the correct variant
//
// switch variant := ResponseFormatUnion.AsAny().(type) {
-// case shared.ResponseFormatJsonSchema:
-// case shared.ResponseFormatGrammar:
+// case llamastackclient.ResponseFormatJsonSchema:
+// case llamastackclient.ResponseFormatGrammar:
// default:
// fmt.Errorf("no variant present")
// }
@@ -2479,64 +2232,6 @@ func (u *ResponseFormatGrammarBnfUnionParam) asAny() any {
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
@@ -2700,9 +2395,9 @@ type anySamplingParamsStrategyResp interface {
// Use the following switch statement to find the correct variant
//
// switch variant := SamplingParamsStrategyUnionResp.AsAny().(type) {
-// case shared.SamplingParamsStrategyGreedyResp:
-// case shared.SamplingParamsStrategyTopPResp:
-// case shared.SamplingParamsStrategyTopKResp:
+// case llamastackclient.SamplingParamsStrategyGreedyResp:
+// case llamastackclient.SamplingParamsStrategyTopPResp:
+// case llamastackclient.SamplingParamsStrategyTopKResp:
// default:
// fmt.Errorf("no variant present")
// }
@@ -3106,848 +2801,83 @@ 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
+// 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
//
- // 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)
+ // This field can be elided, and will marshal its zero value as "system".
+ Role constant.System `json:"role,required"`
+ paramObj
}
-// 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:"-"`
+func (r SystemMessageParam) MarshalJSON() (data []byte, err error) {
+ type shadow SystemMessageParam
+ return param.MarshalObject(r, (*shadow)(&r))
}
-
-// Returns the unmodified JSON received from the API
-func (r SharedCompletionResponseMetric) RawJSON() string { return r.JSON.raw }
-func (r *SharedCompletionResponseMetric) UnmarshalJSON(data []byte) error {
+func (r *SystemMessageParam) 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"`
+type ToolCall struct {
+ Arguments string `json:"arguments,required"`
+ CallID string `json:"call_id,required"`
+ ToolName ToolCallToolName `json:"tool_name,required"`
// 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
+ Arguments respjson.Field
+ CallID respjson.Field
+ ToolName 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 {
+func (r ToolCall) RawJSON() string { return r.JSON.raw }
+func (r *ToolCall) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
-// ToParam converts this SharedToolDef to a SharedToolDefParam.
+// 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
-// 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
+// ToolCallParam.Overrides()
+func (r ToolCall) ToParam() ToolCallParam {
+ return param.Override[ToolCallParam](json.RawMessage(r.RawJSON()))
}
-func (u SharedToolDefMetadataUnion) AsAnyArray() (v []any) {
- apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
- return
-}
+type ToolCallToolName string
-// Returns the unmodified JSON received from the API
-func (u SharedToolDefMetadataUnion) RawJSON() string { return u.JSON.raw }
+const (
+ ToolCallToolNameBraveSearch ToolCallToolName = "brave_search"
+ ToolCallToolNameWolframAlpha ToolCallToolName = "wolfram_alpha"
+ ToolCallToolNamePhotogen ToolCallToolName = "photogen"
+ ToolCallToolNameCodeInterpreter ToolCallToolName = "code_interpreter"
+)
-func (r *SharedToolDefMetadataUnion) UnmarshalJSON(data []byte) error {
- return apijson.UnmarshalRoot(data, r)
+// The properties Arguments, CallID, ToolName are required.
+type ToolCallParam struct {
+ Arguments string `json:"arguments,required"`
+ CallID string `json:"call_id,required"`
+ ToolName ToolCallToolName `json:"tool_name,omitzero,required"`
+ paramObj
}
-// 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:"-"`
+func (r ToolCallParam) MarshalJSON() (data []byte, err error) {
+ type shadow ToolCallParam
+ return param.MarshalObject(r, (*shadow)(&r))
}
-
-// Returns the unmodified JSON received from the API
-func (r SharedToolDefParameter) RawJSON() string { return r.JSON.raw }
-func (r *SharedToolDefParameter) UnmarshalJSON(data []byte) error {
+func (r *ToolCallParam) 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
diff --git a/shared/constant/constants.go b/shared/constant/constants.go
index 9a0304b..8666cd4 100644
--- a/shared/constant/constants.go
+++ b/shared/constant/constants.go
@@ -31,6 +31,7 @@ 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 CreatedAt string // Always "created_at"
type Dataset string // Always "dataset"
type Default string // Always "default"
type Developer string // Always "developer"
@@ -58,6 +59,8 @@ 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"
@@ -139,6 +142,7 @@ 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 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" }
@@ -166,6 +170,8 @@ 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" }
@@ -279,6 +285,7 @@ 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 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) }
@@ -306,6 +313,8 @@ func (c Llm) MarshalJSON() ([]byte, error) { retu
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) }
diff --git a/shield.go b/shield.go
index 575f942..f50b7e3 100644
--- a/shield.go
+++ b/shield.go
@@ -8,6 +8,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 +39,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 +52,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 +62,22 @@ func (r *ShieldService) List(ctx context.Context, opts ...option.RequestOption)
return
}
+// Unregister a shield.
+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.
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..7aadb27 100644
--- a/shield_test.go
+++ b/shield_test.go
@@ -55,6 +55,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
index 91f49ad..14aae36 100644
--- a/syntheticdatageneration.go
+++ b/syntheticdatageneration.go
@@ -6,13 +6,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"
)
// SyntheticDataGenerationService contains methods and other services that help
@@ -36,7 +36,7 @@ func NewSyntheticDataGenerationService(opts ...option.RequestOption) (r Syntheti
// 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...)
+ opts = slices.Concat(r.Options, opts)
path := "v1/synthetic-data-generation/generate"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
@@ -171,7 +171,7 @@ func (r *SyntheticDataGenerationResponseStatisticUnion) UnmarshalJSON(data []byt
type SyntheticDataGenerationGenerateParams struct {
// List of conversation messages to use as input for synthetic data generation
- Dialogs []shared.MessageUnionParam `json:"dialogs,omitzero,required"`
+ Dialogs []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".
diff --git a/syntheticdatageneration_test.go b/syntheticdatageneration_test.go
index 02c3a1b..eb4f5a1 100644
--- a/syntheticdatageneration_test.go
+++ b/syntheticdatageneration_test.go
@@ -11,7 +11,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 TestSyntheticDataGenerationGenerateWithOptionalParams(t *testing.T) {
@@ -26,12 +25,12 @@ func TestSyntheticDataGenerationGenerateWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
)
_, err := client.SyntheticDataGeneration.Generate(context.TODO(), llamastackclient.SyntheticDataGenerationGenerateParams{
- Dialogs: []shared.MessageUnionParam{{
- OfUser: &shared.UserMessageParam{
- Content: shared.InterleavedContentUnionParam{
+ Dialogs: []llamastackclient.MessageUnionParam{{
+ OfUser: &llamastackclient.UserMessageParam{
+ Content: llamastackclient.InterleavedContentUnionParam{
OfString: llamastackclient.String("string"),
},
- Context: shared.InterleavedContentUnionParam{
+ Context: llamastackclient.InterleavedContentUnionParam{
OfString: llamastackclient.String("string"),
},
},
diff --git a/telemetry.go b/telemetry.go
index 5349bd8..23409da 100644
--- a/telemetry.go
+++ b/telemetry.go
@@ -8,6 +8,7 @@ import (
"errors"
"fmt"
"net/http"
+ "slices"
"time"
"github.com/llamastack/llama-stack-client-go/internal/apijson"
@@ -15,7 +16,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"
)
// TelemetryService contains methods and other services that help with interacting
@@ -39,7 +39,7 @@ func NewTelemetryService(opts ...option.RequestOption) (r TelemetryService) {
// 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...)
+ opts = slices.Concat(r.Options, opts)
if query.TraceID == "" {
err = errors.New("missing required trace_id parameter")
return
@@ -48,7 +48,7 @@ func (r *TelemetryService) GetSpan(ctx context.Context, spanID string, query Tel
err = errors.New("missing required span_id parameter")
return
}
- path := fmt.Sprintf("v1/telemetry/traces/%s/spans/%s", query.TraceID, spanID)
+ path := fmt.Sprintf("v1alpha/telemetry/traces/%s/spans/%s", query.TraceID, spanID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
@@ -56,12 +56,12 @@ func (r *TelemetryService) GetSpan(ctx context.Context, spanID string, query Tel
// 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...)
+ opts = slices.Concat(r.Options, opts)
if spanID == "" {
err = errors.New("missing required span_id parameter")
return
}
- path := fmt.Sprintf("v1/telemetry/spans/%s/tree", spanID)
+ path := fmt.Sprintf("v1alpha/telemetry/spans/%s/tree", spanID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...)
if err != nil {
return
@@ -72,30 +72,38 @@ func (r *TelemetryService) GetSpanTree(ctx context.Context, spanID string, body
// 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...)
+ opts = slices.Concat(r.Options, opts)
if traceID == "" {
err = errors.New("missing required trace_id parameter")
return
}
- path := fmt.Sprintf("v1/telemetry/traces/%s", traceID)
+ path := fmt.Sprintf("v1alpha/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...)
+// Query metrics.
+func (r *TelemetryService) QueryMetrics(ctx context.Context, metricName string, body TelemetryQueryMetricsParams, opts ...option.RequestOption) (res *[]TelemetryQueryMetricsResponse, err error) {
+ var env TelemetryQueryMetricsResponseEnvelope
+ opts = slices.Concat(r.Options, opts)
+ if metricName == "" {
+ err = errors.New("missing required metric_name parameter")
+ return
+ }
+ path := fmt.Sprintf("v1alpha/telemetry/metrics/%s", metricName)
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...)
+ if err != nil {
+ return
+ }
+ res = &env.Data
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"
+ opts = slices.Concat(r.Options, opts)
+ path := "v1alpha/telemetry/spans"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...)
if err != nil {
return
@@ -107,8 +115,8 @@ func (r *TelemetryService) QuerySpans(ctx context.Context, body TelemetryQuerySp
// 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"
+ opts = slices.Concat(r.Options, opts)
+ path := "v1alpha/telemetry/traces"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...)
if err != nil {
return
@@ -119,482 +127,13 @@ func (r *TelemetryService) QueryTraces(ctx context.Context, body TelemetryQueryT
// 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 = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...)
- path := "v1/telemetry/spans/export"
+ path := "v1alpha/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.
@@ -984,6 +523,74 @@ func (r *TelemetryGetSpanResponseAttributeUnion) UnmarshalJSON(data []byte) erro
type TelemetryGetSpanTreeResponse map[string]SpanWithStatus
+// A time series of metric data points.
+type TelemetryQueryMetricsResponse struct {
+ // List of labels associated with this metric series
+ Labels []TelemetryQueryMetricsResponseLabel `json:"labels,required"`
+ // The name of the metric
+ Metric string `json:"metric,required"`
+ // List of data points in chronological order
+ Values []TelemetryQueryMetricsResponseValue `json:"values,required"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ Labels respjson.Field
+ Metric respjson.Field
+ Values respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r TelemetryQueryMetricsResponse) RawJSON() string { return r.JSON.raw }
+func (r *TelemetryQueryMetricsResponse) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// A label associated with a metric.
+type TelemetryQueryMetricsResponseLabel struct {
+ // The name of the label
+ Name string `json:"name,required"`
+ // The value of the label
+ Value string `json:"value,required"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ Name respjson.Field
+ Value respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r TelemetryQueryMetricsResponseLabel) RawJSON() string { return r.JSON.raw }
+func (r *TelemetryQueryMetricsResponseLabel) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// A single data point in a metric time series.
+type TelemetryQueryMetricsResponseValue struct {
+ // Unix timestamp when the metric value was recorded
+ Timestamp int64 `json:"timestamp,required"`
+ Unit string `json:"unit,required"`
+ // The numeric value of the metric at this timestamp
+ Value float64 `json:"value,required"`
+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
+ JSON struct {
+ Timestamp respjson.Field
+ Unit respjson.Field
+ Value respjson.Field
+ ExtraFields map[string]respjson.Field
+ raw string
+ } `json:"-"`
+}
+
+// Returns the unmodified JSON received from the API
+func (r TelemetryQueryMetricsResponseValue) RawJSON() string { return r.JSON.raw }
+func (r *TelemetryQueryMetricsResponseValue) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
type TelemetryGetSpanParams struct {
TraceID string `path:"trace_id,required" json:"-"`
paramObj
@@ -1023,19 +630,82 @@ 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"`
+type TelemetryQueryMetricsParams struct {
+ // The type of query to perform.
+ //
+ // Any of "range", "instant".
+ QueryType TelemetryQueryMetricsParamsQueryType `json:"query_type,omitzero,required"`
+ // The start time of the metric to query.
+ StartTime int64 `json:"start_time,required"`
+ // The end time of the metric to query.
+ EndTime param.Opt[int64] `json:"end_time,omitzero"`
+ // The granularity of the metric to query.
+ Granularity param.Opt[string] `json:"granularity,omitzero"`
+ // The label matchers to apply to the metric.
+ LabelMatchers []TelemetryQueryMetricsParamsLabelMatcher `json:"label_matchers,omitzero"`
paramObj
}
-func (r TelemetryLogEventParams) MarshalJSON() (data []byte, err error) {
- type shadow TelemetryLogEventParams
+func (r TelemetryQueryMetricsParams) MarshalJSON() (data []byte, err error) {
+ type shadow TelemetryQueryMetricsParams
return param.MarshalObject(r, (*shadow)(&r))
}
-func (r *TelemetryLogEventParams) UnmarshalJSON(data []byte) error {
+func (r *TelemetryQueryMetricsParams) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// The type of query to perform.
+type TelemetryQueryMetricsParamsQueryType string
+
+const (
+ TelemetryQueryMetricsParamsQueryTypeRange TelemetryQueryMetricsParamsQueryType = "range"
+ TelemetryQueryMetricsParamsQueryTypeInstant TelemetryQueryMetricsParamsQueryType = "instant"
+)
+
+// A matcher for filtering metrics by label values.
+//
+// The properties Name, Operator, Value are required.
+type TelemetryQueryMetricsParamsLabelMatcher struct {
+ // The name of the label to match
+ Name string `json:"name,required"`
+ // The comparison operator to use for matching
+ //
+ // Any of "=", "!=", "=~", "!~".
+ Operator string `json:"operator,omitzero,required"`
+ // The value to match against
+ Value string `json:"value,required"`
+ paramObj
+}
+
+func (r TelemetryQueryMetricsParamsLabelMatcher) MarshalJSON() (data []byte, err error) {
+ type shadow TelemetryQueryMetricsParamsLabelMatcher
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *TelemetryQueryMetricsParamsLabelMatcher) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func init() {
+ apijson.RegisterFieldValidator[TelemetryQueryMetricsParamsLabelMatcher](
+ "operator", "=", "!=", "=~", "!~",
+ )
+}
+
+// Response containing metric time series data.
+type TelemetryQueryMetricsResponseEnvelope struct {
+ // List of metric series matching the query criteria
+ Data []TelemetryQueryMetricsResponse `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 TelemetryQueryMetricsResponseEnvelope) RawJSON() string { return r.JSON.raw }
+func (r *TelemetryQueryMetricsResponseEnvelope) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
diff --git a/telemetry_test.go b/telemetry_test.go
index 924d900..22dd438 100644
--- a/telemetry_test.go
+++ b/telemetry_test.go
@@ -7,7 +7,6 @@ import (
"errors"
"os"
"testing"
- "time"
"github.com/llamastack/llama-stack-client-go"
"github.com/llamastack/llama-stack-client-go/internal/testutil"
@@ -90,7 +89,8 @@ func TestTelemetryGetTrace(t *testing.T) {
}
}
-func TestTelemetryLogEventWithOptionalParams(t *testing.T) {
+func TestTelemetryQueryMetricsWithOptionalParams(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
@@ -101,23 +101,21 @@ func TestTelemetryLogEventWithOptionalParams(t *testing.T) {
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"),
- },
- },
- },
+ _, err := client.Telemetry.QueryMetrics(
+ context.TODO(),
+ "metric_name",
+ llamastackclient.TelemetryQueryMetricsParams{
+ QueryType: llamastackclient.TelemetryQueryMetricsParamsQueryTypeRange,
+ StartTime: 0,
+ EndTime: llamastackclient.Int(0),
+ Granularity: llamastackclient.String("granularity"),
+ LabelMatchers: []llamastackclient.TelemetryQueryMetricsParamsLabelMatcher{{
+ Name: "name",
+ Operator: "=",
+ Value: "value",
+ }},
},
- TtlSeconds: 0,
- })
+ )
if err != nil {
var apierr *llamastackclient.Error
if errors.As(err, &apierr) {
diff --git a/tool.go b/tool.go
index 3518704..c2897cb 100644
--- a/tool.go
+++ b/tool.go
@@ -4,11 +4,11 @@ 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 +16,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 +38,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 +51,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 +62,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 +75,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/toolgroup.go b/toolgroup.go
index bed1c74..66ea272 100644
--- a/toolgroup.go
+++ b/toolgroup.go
@@ -8,6 +8,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 +40,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 +52,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
@@ -63,7 +64,7 @@ func (r *ToolgroupService) Get(ctx context.Context, toolgroupID string, opts ...
// Register a tool group.
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...)
@@ -72,7 +73,7 @@ func (r *ToolgroupService) Register(ctx context.Context, body ToolgroupRegisterP
// Unregister a tool group.
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/toolruntime.go b/toolruntime.go
index 59067b3..8a9db97 100644
--- a/toolruntime.go
+++ b/toolruntime.go
@@ -7,6 +7,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 +15,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 +40,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 +59,328 @@ 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)
+}
+
+// ToParam converts this ToolDef to a ToolDefParam.
+//
+// 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
+// ToolDefParam.Overrides()
+func (r ToolDef) ToParam() ToolDefParam {
+ return param.Override[ToolDefParam](json.RawMessage(r.RawJSON()))
+}
+
+// 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)
+}
+
+// Tool definition used in runtime contexts.
+//
+// The property Name is required.
+type ToolDefParam 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) ID of the tool group this tool belongs to
+ ToolgroupID param.Opt[string] `json:"toolgroup_id,omitzero"`
+ // (Optional) JSON Schema for tool inputs (MCP inputSchema)
+ InputSchema map[string]ToolDefInputSchemaUnionParam `json:"input_schema,omitzero"`
+ // (Optional) Additional metadata about the tool
+ Metadata map[string]ToolDefMetadataUnionParam `json:"metadata,omitzero"`
+ // (Optional) JSON Schema for tool outputs (MCP outputSchema)
+ OutputSchema map[string]ToolDefOutputSchemaUnionParam `json:"output_schema,omitzero"`
+ paramObj
+}
+
+func (r ToolDefParam) MarshalJSON() (data []byte, err error) {
+ type shadow ToolDefParam
+ return param.MarshalObject(r, (*shadow)(&r))
+}
+func (r *ToolDefParam) 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 ToolDefInputSchemaUnionParam 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 ToolDefInputSchemaUnionParam) MarshalJSON() ([]byte, error) {
+ return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray)
+}
+func (u *ToolDefInputSchemaUnionParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, u)
+}
+
+func (u *ToolDefInputSchemaUnionParam) 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 ToolDefMetadataUnionParam 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 ToolDefMetadataUnionParam) MarshalJSON() ([]byte, error) {
+ return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray)
+}
+func (u *ToolDefMetadataUnionParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, u)
+}
+
+func (u *ToolDefMetadataUnionParam) 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 ToolDefOutputSchemaUnionParam 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 ToolDefOutputSchemaUnionParam) MarshalJSON() ([]byte, error) {
+ return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray)
+}
+func (u *ToolDefOutputSchemaUnionParam) UnmarshalJSON(data []byte) error {
+ return apijson.UnmarshalRoot(data, u)
+}
+
+func (u *ToolDefOutputSchemaUnionParam) 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
+}
+
// 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
@@ -223,7 +541,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/toolruntimeragtool.go b/toolruntimeragtool.go
index 603e9cb..322954f 100644
--- a/toolruntimeragtool.go
+++ b/toolruntimeragtool.go
@@ -5,12 +5,12 @@ 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/shared"
)
// ToolRuntimeRagToolService contains methods and other services that help with
@@ -34,7 +34,7 @@ func NewToolRuntimeRagToolService(opts ...option.RequestOption) (r ToolRuntimeRa
// 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 = slices.Concat(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...)
@@ -42,8 +42,8 @@ func (r *ToolRuntimeRagToolService) Insert(ctx context.Context, body ToolRuntime
}
// 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...)
+func (r *ToolRuntimeRagToolService) Query(ctx context.Context, body ToolRuntimeRagToolQueryParams, opts ...option.RequestOption) (res *QueryResult, err error) {
+ opts = slices.Concat(r.Options, opts)
path := "v1/tool-runtime/rag-tool/query"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
@@ -53,7 +53,7 @@ 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"`
+ Documents []DocumentParam `json:"documents,omitzero,required"`
// ID of the vector database to store the document embeddings
VectorDBID string `json:"vector_db_id,required"`
paramObj
@@ -69,11 +69,11 @@ func (r *ToolRuntimeRagToolInsertParams) UnmarshalJSON(data []byte) error {
type ToolRuntimeRagToolQueryParams struct {
// The query content to search for in the indexed documents
- Content shared.InterleavedContentUnionParam `json:"content,omitzero,required"`
+ Content 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"`
+ QueryConfig QueryConfigParam `json:"query_config,omitzero"`
paramObj
}
diff --git a/toolruntimeragtool_test.go b/toolruntimeragtool_test.go
index a2dcfb6..670e0e3 100644
--- a/toolruntimeragtool_test.go
+++ b/toolruntimeragtool_test.go
@@ -11,7 +11,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 TestToolRuntimeRagToolInsert(t *testing.T) {
@@ -27,12 +26,12 @@ func TestToolRuntimeRagToolInsert(t *testing.T) {
)
err := client.ToolRuntime.RagTool.Insert(context.TODO(), llamastackclient.ToolRuntimeRagToolInsertParams{
ChunkSizeInTokens: 0,
- Documents: []shared.DocumentParam{{
- Content: shared.DocumentContentUnionParam{
+ Documents: []llamastackclient.DocumentParam{{
+ Content: llamastackclient.DocumentContentUnionParam{
OfString: llamastackclient.String("string"),
},
DocumentID: "document_id",
- Metadata: map[string]shared.DocumentMetadataUnionParam{
+ Metadata: map[string]llamastackclient.DocumentMetadataUnionParam{
"foo": {
OfBool: llamastackclient.Bool(true),
},
@@ -62,22 +61,22 @@ func TestToolRuntimeRagToolQueryWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
)
_, err := client.ToolRuntime.RagTool.Query(context.TODO(), llamastackclient.ToolRuntimeRagToolQueryParams{
- Content: shared.InterleavedContentUnionParam{
+ Content: llamastackclient.InterleavedContentUnionParam{
OfString: llamastackclient.String("string"),
},
VectorDBIDs: []string{"string"},
- QueryConfig: shared.QueryConfigParam{
+ QueryConfig: llamastackclient.QueryConfigParam{
ChunkTemplate: "chunk_template",
MaxChunks: 0,
MaxTokensInContext: 0,
- QueryGeneratorConfig: shared.QueryGeneratorConfigUnionParam{
- OfDefault: &shared.QueryGeneratorConfigDefaultParam{
+ QueryGeneratorConfig: llamastackclient.QueryConfigQueryGeneratorConfigUnionParam{
+ OfDefault: &llamastackclient.QueryConfigQueryGeneratorConfigDefaultParam{
Separator: "separator",
},
},
- Mode: shared.QueryConfigModeVector,
- Ranker: shared.QueryConfigRankerUnionParam{
- OfRrf: &shared.QueryConfigRankerRrfParam{
+ Mode: llamastackclient.QueryConfigModeVector,
+ Ranker: llamastackclient.QueryConfigRankerUnionParam{
+ OfRrf: &llamastackclient.QueryConfigRankerRrfParam{
ImpactFactor: 0,
},
},
diff --git a/vectordb.go b/vectordb.go
index 99547fa..0319191 100644
--- a/vectordb.go
+++ b/vectordb.go
@@ -7,6 +7,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"
@@ -37,7 +38,7 @@ func NewVectorDBService(opts ...option.RequestOption) (r VectorDBService) {
// 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...)
+ opts = slices.Concat(r.Options, opts)
if vectorDBID == "" {
err = errors.New("missing required vector_db_id parameter")
return
@@ -50,7 +51,7 @@ func (r *VectorDBService) Get(ctx context.Context, vectorDBID string, opts ...op
// 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...)
+ opts = slices.Concat(r.Options, opts)
path := "v1/vector-dbs"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...)
if err != nil {
@@ -62,7 +63,7 @@ func (r *VectorDBService) List(ctx context.Context, opts ...option.RequestOption
// 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...)
+ opts = slices.Concat(r.Options, opts)
path := "v1/vector-dbs"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
@@ -70,7 +71,7 @@ func (r *VectorDBService) Register(ctx context.Context, body VectorDBRegisterPar
// Unregister a vector database.
func (r *VectorDBService) Unregister(ctx context.Context, vectorDBID 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 vectorDBID == "" {
err = errors.New("missing required vector_db_id parameter")
diff --git a/vectorio.go b/vectorio.go
index b830aed..5a16929 100644
--- a/vectorio.go
+++ b/vectorio.go
@@ -6,13 +6,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 +36,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 +45,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
@@ -75,7 +75,7 @@ func (r *QueryChunksResponse) UnmarshalJSON(data []byte) error {
// A chunk of content that can be inserted into a vector database.
type QueryChunksResponseChunk struct {
// 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"`
@@ -234,7 +234,7 @@ func (r *VectorIoInsertParams) UnmarshalJSON(data []byte) error {
// The properties Content, Metadata are required.
type VectorIoInsertParamsChunk struct {
// 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"`
@@ -327,7 +327,7 @@ 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"`
// The parameters of the query.
diff --git a/vectorio_test.go b/vectorio_test.go
index 73d696e..0abce84 100644
--- a/vectorio_test.go
+++ b/vectorio_test.go
@@ -11,7 +11,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 +26,7 @@ func TestVectorIoInsertWithOptionalParams(t *testing.T) {
)
err := client.VectorIo.Insert(context.TODO(), llamastackclient.VectorIoInsertParams{
Chunks: []llamastackclient.VectorIoInsertParamsChunk{{
- Content: shared.InterleavedContentUnionParam{
+ Content: llamastackclient.InterleavedContentUnionParam{
OfString: llamastackclient.String("string"),
},
Metadata: map[string]llamastackclient.VectorIoInsertParamsChunkMetadataUnion{
@@ -75,7 +74,7 @@ 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",
diff --git a/vectorstore.go b/vectorstore.go
index 8a41fde..dbb740d 100644
--- a/vectorstore.go
+++ b/vectorstore.go
@@ -9,6 +9,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 +28,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 +40,38 @@ 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.
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 +79,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 +101,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 +114,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
}
diff --git a/vectorstorefile.go b/vectorstorefile.go
index c05d2c6..3cabaac 100644
--- a/vectorstorefile.go
+++ b/vectorstorefile.go
@@ -9,6 +9,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 +42,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 +63,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 +79,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 +87,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 +113,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,14 +122,14 @@ 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...)
+ opts = slices.Concat(r.Options, opts)
if query.VectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
return
@@ -137,7 +138,7 @@ 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)
+ path := fmt.Sprintf("v1/vector_stores/%s/files/%s/content", query.VectorStoreID, fileID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
diff --git a/vectorstorefilebatch.go b/vectorstorefilebatch.go
new file mode 100644
index 0000000..2982d33
--- /dev/null
+++ b/vectorstorefilebatch.go
@@ -0,0 +1,422 @@
+// 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.
+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/vectorstorefilebatch_test.go b/vectorstorefilebatch_test.go
new file mode 100644
index 0000000..9861098
--- /dev/null
+++ b/vectorstorefilebatch_test.go
@@ -0,0 +1,135 @@
+// 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 TestVectorStoreFileBatchNewWithOptionalParams(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.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) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestVectorStoreFileBatchGet(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.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) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestVectorStoreFileBatchCancel(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.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) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestVectorStoreFileBatchListFilesWithOptionalParams(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.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) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}