Skip to content

Commit 837277d

Browse files
feat(api): tool api (input_schema, etc.) changes
1 parent a16eaef commit 837277d

14 files changed

+2372
-4514
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 109
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-5f0f0b99d1b0bf40e00e11f5d134ed13de97799cf2dfea0c8612e2f003584505.yml
3-
openapi_spec_hash: 5f51544cb340c37aba54b93a526c536e
1+
configured_endpoints: 93
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-41cb5d8049e6ffd933a7ad6bbbb76b2fef2e864d0d857c91799ee16e9a796883.yml
3+
openapi_spec_hash: 5e0bdf64563e020ef14b968ab724d2db
44
config_hash: 0412cd40c0609550c1a47c69dd104e4f

alphaagent_test.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,22 @@ func TestAlphaAgentNewWithOptionalParams(t *testing.T) {
3131
ClientTools: []llamastackclient.ToolDefParam{{
3232
Name: "name",
3333
Description: llamastackclient.String("description"),
34-
InputSchema: map[string]llamastackclient.ToolDefInputSchemaUnionParam{
35-
"foo": {
36-
OfBool: llamastackclient.Bool(true),
37-
},
38-
},
3934
Metadata: map[string]llamastackclient.ToolDefMetadataUnionParam{
4035
"foo": {
4136
OfBool: llamastackclient.Bool(true),
4237
},
4338
},
44-
OutputSchema: map[string]llamastackclient.ToolDefOutputSchemaUnionParam{
45-
"foo": {
39+
Parameters: []llamastackclient.ToolDefParameterParam{{
40+
Description: "description",
41+
Name: "name",
42+
ParameterType: "parameter_type",
43+
Required: true,
44+
Default: llamastackclient.ToolDefParameterDefaultUnionParam{
4645
OfBool: llamastackclient.Bool(true),
4746
},
48-
},
47+
Items: map[string]interface{}{},
48+
Title: llamastackclient.String("title"),
49+
}},
4950
}},
5051
EnableSessionPersistence: llamastackclient.Bool(true),
5152
InputShields: []string{"string"},

api.md

Lines changed: 2 additions & 45 deletions
Large diffs are not rendered by default.

benchmark.go

Lines changed: 0 additions & 202 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,7 @@
33
package llamastackclient
44

55
import (
6-
"context"
7-
"encoding/json"
8-
"errors"
9-
"fmt"
10-
"net/http"
11-
"slices"
12-
13-
"github.com/llamastack/llama-stack-client-go/internal/apijson"
14-
"github.com/llamastack/llama-stack-client-go/internal/requestconfig"
156
"github.com/llamastack/llama-stack-client-go/option"
16-
"github.com/llamastack/llama-stack-client-go/packages/param"
17-
"github.com/llamastack/llama-stack-client-go/packages/respjson"
18-
"github.com/llamastack/llama-stack-client-go/shared/constant"
197
)
208

219
// BenchmarkService contains methods and other services that help with interacting
@@ -36,193 +24,3 @@ func NewBenchmarkService(opts ...option.RequestOption) (r BenchmarkService) {
3624
r.Options = opts
3725
return
3826
}
39-
40-
// Get a benchmark by its ID.
41-
func (r *BenchmarkService) Get(ctx context.Context, benchmarkID string, opts ...option.RequestOption) (res *Benchmark, err error) {
42-
opts = slices.Concat(r.Options, opts)
43-
if benchmarkID == "" {
44-
err = errors.New("missing required benchmark_id parameter")
45-
return
46-
}
47-
path := fmt.Sprintf("v1/eval/benchmarks/%s", benchmarkID)
48-
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
49-
return
50-
}
51-
52-
// List all benchmarks.
53-
func (r *BenchmarkService) List(ctx context.Context, opts ...option.RequestOption) (res *[]Benchmark, err error) {
54-
var env ListBenchmarksResponse
55-
opts = slices.Concat(r.Options, opts)
56-
path := "v1/eval/benchmarks"
57-
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...)
58-
if err != nil {
59-
return
60-
}
61-
res = &env.Data
62-
return
63-
}
64-
65-
// Register a benchmark.
66-
func (r *BenchmarkService) Register(ctx context.Context, body BenchmarkRegisterParams, opts ...option.RequestOption) (err error) {
67-
opts = slices.Concat(r.Options, opts)
68-
opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...)
69-
path := "v1/eval/benchmarks"
70-
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...)
71-
return
72-
}
73-
74-
// A benchmark resource for evaluating model performance.
75-
type Benchmark struct {
76-
// Identifier of the dataset to use for the benchmark evaluation
77-
DatasetID string `json:"dataset_id,required"`
78-
Identifier string `json:"identifier,required"`
79-
// Metadata for this evaluation task
80-
Metadata map[string]BenchmarkMetadataUnion `json:"metadata,required"`
81-
ProviderID string `json:"provider_id,required"`
82-
// List of scoring function identifiers to apply during evaluation
83-
ScoringFunctions []string `json:"scoring_functions,required"`
84-
// The resource type, always benchmark
85-
Type constant.Benchmark `json:"type,required"`
86-
ProviderResourceID string `json:"provider_resource_id"`
87-
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
88-
JSON struct {
89-
DatasetID respjson.Field
90-
Identifier respjson.Field
91-
Metadata respjson.Field
92-
ProviderID respjson.Field
93-
ScoringFunctions respjson.Field
94-
Type respjson.Field
95-
ProviderResourceID respjson.Field
96-
ExtraFields map[string]respjson.Field
97-
raw string
98-
} `json:"-"`
99-
}
100-
101-
// Returns the unmodified JSON received from the API
102-
func (r Benchmark) RawJSON() string { return r.JSON.raw }
103-
func (r *Benchmark) UnmarshalJSON(data []byte) error {
104-
return apijson.UnmarshalRoot(data, r)
105-
}
106-
107-
// BenchmarkMetadataUnion contains all possible properties and values from [bool],
108-
// [float64], [string], [[]any].
109-
//
110-
// Use the methods beginning with 'As' to cast the union to one of its variants.
111-
//
112-
// If the underlying value is not a json object, one of the following properties
113-
// will be valid: OfBool OfFloat OfString OfAnyArray]
114-
type BenchmarkMetadataUnion struct {
115-
// This field will be present if the value is a [bool] instead of an object.
116-
OfBool bool `json:",inline"`
117-
// This field will be present if the value is a [float64] instead of an object.
118-
OfFloat float64 `json:",inline"`
119-
// This field will be present if the value is a [string] instead of an object.
120-
OfString string `json:",inline"`
121-
// This field will be present if the value is a [[]any] instead of an object.
122-
OfAnyArray []any `json:",inline"`
123-
JSON struct {
124-
OfBool respjson.Field
125-
OfFloat respjson.Field
126-
OfString respjson.Field
127-
OfAnyArray respjson.Field
128-
raw string
129-
} `json:"-"`
130-
}
131-
132-
func (u BenchmarkMetadataUnion) AsBool() (v bool) {
133-
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
134-
return
135-
}
136-
137-
func (u BenchmarkMetadataUnion) AsFloat() (v float64) {
138-
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
139-
return
140-
}
141-
142-
func (u BenchmarkMetadataUnion) AsString() (v string) {
143-
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
144-
return
145-
}
146-
147-
func (u BenchmarkMetadataUnion) AsAnyArray() (v []any) {
148-
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
149-
return
150-
}
151-
152-
// Returns the unmodified JSON received from the API
153-
func (u BenchmarkMetadataUnion) RawJSON() string { return u.JSON.raw }
154-
155-
func (r *BenchmarkMetadataUnion) UnmarshalJSON(data []byte) error {
156-
return apijson.UnmarshalRoot(data, r)
157-
}
158-
159-
type ListBenchmarksResponse struct {
160-
Data []Benchmark `json:"data,required"`
161-
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
162-
JSON struct {
163-
Data respjson.Field
164-
ExtraFields map[string]respjson.Field
165-
raw string
166-
} `json:"-"`
167-
}
168-
169-
// Returns the unmodified JSON received from the API
170-
func (r ListBenchmarksResponse) RawJSON() string { return r.JSON.raw }
171-
func (r *ListBenchmarksResponse) UnmarshalJSON(data []byte) error {
172-
return apijson.UnmarshalRoot(data, r)
173-
}
174-
175-
type BenchmarkRegisterParams struct {
176-
// The ID of the benchmark to register.
177-
BenchmarkID string `json:"benchmark_id,required"`
178-
// The ID of the dataset to use for the benchmark.
179-
DatasetID string `json:"dataset_id,required"`
180-
// The scoring functions to use for the benchmark.
181-
ScoringFunctions []string `json:"scoring_functions,omitzero,required"`
182-
// The ID of the provider benchmark to use for the benchmark.
183-
ProviderBenchmarkID param.Opt[string] `json:"provider_benchmark_id,omitzero"`
184-
// The ID of the provider to use for the benchmark.
185-
ProviderID param.Opt[string] `json:"provider_id,omitzero"`
186-
// The metadata to use for the benchmark.
187-
Metadata map[string]BenchmarkRegisterParamsMetadataUnion `json:"metadata,omitzero"`
188-
paramObj
189-
}
190-
191-
func (r BenchmarkRegisterParams) MarshalJSON() (data []byte, err error) {
192-
type shadow BenchmarkRegisterParams
193-
return param.MarshalObject(r, (*shadow)(&r))
194-
}
195-
func (r *BenchmarkRegisterParams) UnmarshalJSON(data []byte) error {
196-
return apijson.UnmarshalRoot(data, r)
197-
}
198-
199-
// Only one field can be non-zero.
200-
//
201-
// Use [param.IsOmitted] to confirm if a field is set.
202-
type BenchmarkRegisterParamsMetadataUnion struct {
203-
OfBool param.Opt[bool] `json:",omitzero,inline"`
204-
OfFloat param.Opt[float64] `json:",omitzero,inline"`
205-
OfString param.Opt[string] `json:",omitzero,inline"`
206-
OfAnyArray []any `json:",omitzero,inline"`
207-
paramUnion
208-
}
209-
210-
func (u BenchmarkRegisterParamsMetadataUnion) MarshalJSON() ([]byte, error) {
211-
return param.MarshalUnion(u, u.OfBool, u.OfFloat, u.OfString, u.OfAnyArray)
212-
}
213-
func (u *BenchmarkRegisterParamsMetadataUnion) UnmarshalJSON(data []byte) error {
214-
return apijson.UnmarshalRoot(data, u)
215-
}
216-
217-
func (u *BenchmarkRegisterParamsMetadataUnion) asAny() any {
218-
if !param.IsOmitted(u.OfBool) {
219-
return &u.OfBool.Value
220-
} else if !param.IsOmitted(u.OfFloat) {
221-
return &u.OfFloat.Value
222-
} else if !param.IsOmitted(u.OfString) {
223-
return &u.OfString.Value
224-
} else if !param.IsOmitted(u.OfAnyArray) {
225-
return &u.OfAnyArray
226-
}
227-
return nil
228-
}

benchmark_test.go

Lines changed: 0 additions & 88 deletions
This file was deleted.

0 commit comments

Comments
 (0)