@@ -10,7 +10,6 @@ package llamastackclient
1010
1111import (
1212 "context"
13- "encoding/json"
1413 "errors"
1514 "fmt"
1615 "net/http"
@@ -21,7 +20,6 @@ import (
2120 "github.com/llamastack/llama-stack-client-go/option"
2221 "github.com/llamastack/llama-stack-client-go/packages/param"
2322 "github.com/llamastack/llama-stack-client-go/packages/respjson"
24- "github.com/llamastack/llama-stack-client-go/shared/constant"
2523)
2624
2725// AlphaBenchmarkService contains methods and other services that help with
@@ -79,28 +77,44 @@ func (r *AlphaBenchmarkService) Register(ctx context.Context, body AlphaBenchmar
7977 return
8078}
8179
80+ // Unregister a benchmark.
81+ //
82+ // Deprecated: deprecated
83+ func (r * AlphaBenchmarkService ) Unregister (ctx context.Context , benchmarkID string , opts ... option.RequestOption ) (err error ) {
84+ opts = slices .Concat (r .Options , opts )
85+ opts = append ([]option.RequestOption {option .WithHeader ("Accept" , "" )}, opts ... )
86+ if benchmarkID == "" {
87+ err = errors .New ("missing required benchmark_id parameter" )
88+ return
89+ }
90+ path := fmt .Sprintf ("v1alpha/eval/benchmarks/%s" , benchmarkID )
91+ err = requestconfig .ExecuteNewRequest (ctx , http .MethodDelete , path , nil , nil , opts ... )
92+ return
93+ }
94+
8295// A benchmark resource for evaluating model performance.
8396type Benchmark struct {
84- // Identifier of the dataset to use for the benchmark evaluation
85- DatasetID string `json:"dataset_id,required"`
97+ DatasetID string `json:"dataset_id,required"`
98+ // Unique identifier for this resource in llama stack
8699 Identifier string `json:"identifier,required"`
87- // Metadata for this evaluation task
88- Metadata map [string ]BenchmarkMetadataUnion `json:"metadata,required"`
89- ProviderID string `json:"provider_id,required"`
90- // List of scoring function identifiers to apply during evaluation
100+ // ID of the provider that owns this resource
101+ ProviderID string `json:"provider_id,required"`
91102 ScoringFunctions []string `json:"scoring_functions,required"`
92- // The resource type, always benchmark
93- Type constant.Benchmark `json:"type,required"`
94- ProviderResourceID string `json:"provider_resource_id"`
103+ // Metadata for this evaluation task
104+ Metadata map [string ]any `json:"metadata"`
105+ // Unique identifier for this resource in the provider
106+ ProviderResourceID string `json:"provider_resource_id,nullable"`
107+ // Any of "benchmark".
108+ Type BenchmarkType `json:"type"`
95109 // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
96110 JSON struct {
97111 DatasetID respjson.Field
98112 Identifier respjson.Field
99- Metadata respjson.Field
100113 ProviderID respjson.Field
101114 ScoringFunctions respjson.Field
102- Type respjson.Field
115+ Metadata respjson.Field
103116 ProviderResourceID respjson.Field
117+ Type respjson.Field
104118 ExtraFields map [string ]respjson.Field
105119 raw string
106120 } `json:"-"`
@@ -112,57 +126,11 @@ func (r *Benchmark) UnmarshalJSON(data []byte) error {
112126 return apijson .UnmarshalRoot (data , r )
113127}
114128
115- // BenchmarkMetadataUnion contains all possible properties and values from [bool],
116- // [float64], [string], [[]any].
117- //
118- // Use the methods beginning with 'As' to cast the union to one of its variants.
119- //
120- // If the underlying value is not a json object, one of the following properties
121- // will be valid: OfBool OfFloat OfString OfAnyArray]
122- type BenchmarkMetadataUnion struct {
123- // This field will be present if the value is a [bool] instead of an object.
124- OfBool bool `json:",inline"`
125- // This field will be present if the value is a [float64] instead of an object.
126- OfFloat float64 `json:",inline"`
127- // This field will be present if the value is a [string] instead of an object.
128- OfString string `json:",inline"`
129- // This field will be present if the value is a [[]any] instead of an object.
130- OfAnyArray []any `json:",inline"`
131- JSON struct {
132- OfBool respjson.Field
133- OfFloat respjson.Field
134- OfString respjson.Field
135- OfAnyArray respjson.Field
136- raw string
137- } `json:"-"`
138- }
139-
140- func (u BenchmarkMetadataUnion ) AsBool () (v bool ) {
141- apijson .UnmarshalRoot (json .RawMessage (u .JSON .raw ), & v )
142- return
143- }
144-
145- func (u BenchmarkMetadataUnion ) AsFloat () (v float64 ) {
146- apijson .UnmarshalRoot (json .RawMessage (u .JSON .raw ), & v )
147- return
148- }
149-
150- func (u BenchmarkMetadataUnion ) AsString () (v string ) {
151- apijson .UnmarshalRoot (json .RawMessage (u .JSON .raw ), & v )
152- return
153- }
129+ type BenchmarkType string
154130
155- func (u BenchmarkMetadataUnion ) AsAnyArray () (v []any ) {
156- apijson .UnmarshalRoot (json .RawMessage (u .JSON .raw ), & v )
157- return
158- }
159-
160- // Returns the unmodified JSON received from the API
161- func (u BenchmarkMetadataUnion ) RawJSON () string { return u .JSON .raw }
162-
163- func (r * BenchmarkMetadataUnion ) UnmarshalJSON (data []byte ) error {
164- return apijson .UnmarshalRoot (data , r )
165- }
131+ const (
132+ BenchmarkTypeBenchmark BenchmarkType = "benchmark"
133+ )
166134
167135type ListBenchmarksResponse struct {
168136 Data []Benchmark `json:"data,required"`
@@ -181,18 +149,12 @@ func (r *ListBenchmarksResponse) UnmarshalJSON(data []byte) error {
181149}
182150
183151type AlphaBenchmarkRegisterParams struct {
184- // The ID of the benchmark to register.
185- BenchmarkID string `json:"benchmark_id,required"`
186- // The ID of the dataset to use for the benchmark.
187- DatasetID string `json:"dataset_id,required"`
188- // The scoring functions to use for the benchmark.
189- ScoringFunctions []string `json:"scoring_functions,omitzero,required"`
190- // The ID of the provider benchmark to use for the benchmark.
152+ BenchmarkID string `json:"benchmark_id,required"`
153+ DatasetID string `json:"dataset_id,required"`
154+ ScoringFunctions []string `json:"scoring_functions,omitzero,required"`
191155 ProviderBenchmarkID param.Opt [string ] `json:"provider_benchmark_id,omitzero"`
192- // The ID of the provider to use for the benchmark.
193- ProviderID param.Opt [string ] `json:"provider_id,omitzero"`
194- // The metadata to use for the benchmark.
195- Metadata map [string ]AlphaBenchmarkRegisterParamsMetadataUnion `json:"metadata,omitzero"`
156+ ProviderID param.Opt [string ] `json:"provider_id,omitzero"`
157+ Metadata map [string ]any `json:"metadata,omitzero"`
196158 paramObj
197159}
198160
@@ -203,34 +165,3 @@ func (r AlphaBenchmarkRegisterParams) MarshalJSON() (data []byte, err error) {
203165func (r * AlphaBenchmarkRegisterParams ) UnmarshalJSON (data []byte ) error {
204166 return apijson .UnmarshalRoot (data , r )
205167}
206-
207- // Only one field can be non-zero.
208- //
209- // Use [param.IsOmitted] to confirm if a field is set.
210- type AlphaBenchmarkRegisterParamsMetadataUnion struct {
211- OfBool param.Opt [bool ] `json:",omitzero,inline"`
212- OfFloat param.Opt [float64 ] `json:",omitzero,inline"`
213- OfString param.Opt [string ] `json:",omitzero,inline"`
214- OfAnyArray []any `json:",omitzero,inline"`
215- paramUnion
216- }
217-
218- func (u AlphaBenchmarkRegisterParamsMetadataUnion ) MarshalJSON () ([]byte , error ) {
219- return param .MarshalUnion (u , u .OfBool , u .OfFloat , u .OfString , u .OfAnyArray )
220- }
221- func (u * AlphaBenchmarkRegisterParamsMetadataUnion ) UnmarshalJSON (data []byte ) error {
222- return apijson .UnmarshalRoot (data , u )
223- }
224-
225- func (u * AlphaBenchmarkRegisterParamsMetadataUnion ) asAny () any {
226- if ! param .IsOmitted (u .OfBool ) {
227- return & u .OfBool .Value
228- } else if ! param .IsOmitted (u .OfFloat ) {
229- return & u .OfFloat .Value
230- } else if ! param .IsOmitted (u .OfString ) {
231- return & u .OfString .Value
232- } else if ! param .IsOmitted (u .OfAnyArray ) {
233- return & u .OfAnyArray
234- }
235- return nil
236- }
0 commit comments