Skip to content

Commit 2c9ca33

Browse files
feat(api): api update
1 parent 704f413 commit 2c9ca33

File tree

4 files changed

+44
-61
lines changed

4 files changed

+44
-61
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 42
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-eee41ccf2ac9eb601853ae1d06a9c9f92b13aa4dc7a588117c41032490d69b2d.yml
3-
openapi_spec_hash: c5bf431d30ef57c992ef0200f6396acd
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-03d7fa44ead3c37be5cc4140d7273b836bc5a072a9d8c800425f5885f2f26899.yml
3+
openapi_spec_hash: 9538969b09ef333a046cf66c21187b11
44
config_hash: 50b86276412e927f8eb0e69e2857b1c7

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,5 +278,5 @@ Methods:
278278

279279
- <code title="get /evaluation/{id}">client.Evals.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#EvalService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/togethercomputer/together-go">together</a>.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#EvalGetResponse">EvalGetResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
280280
- <code title="get /evaluations">client.Evals.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#EvalService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/togethercomputer/together-go">together</a>.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#EvalListParams">EvalListParams</a>) ([]<a href="https://pkg.go.dev/github.com/togethercomputer/together-go">together</a>.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#EvalListResponse">EvalListResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
281-
- <code title="get /evaluations/model-list">client.Evals.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#EvalService.GetAllowedModels">GetAllowedModels</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) (<a href="https://pkg.go.dev/github.com/togethercomputer/together-go">together</a>.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#EvalGetAllowedModelsResponse">EvalGetAllowedModelsResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
281+
- <code title="get /evaluations/model-list">client.Evals.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#EvalService.GetAllowedModels">GetAllowedModels</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/togethercomputer/together-go">together</a>.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#EvalGetAllowedModelsParams">EvalGetAllowedModelsParams</a>) (<a href="https://pkg.go.dev/github.com/togethercomputer/together-go">together</a>.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#EvalGetAllowedModelsResponse">EvalGetAllowedModelsResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
282282
- <code title="get /evaluation/{id}/status">client.Evals.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#EvalService.GetStatus">GetStatus</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/togethercomputer/together-go">together</a>.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#EvalGetStatusResponse">EvalGetStatusResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

eval.go

Lines changed: 34 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func NewEvalService(opts ...option.RequestOption) (r EvalService) {
3939
return
4040
}
4141

42-
// Get details of a specific evaluation job
42+
// Get evaluation job details
4343
func (r *EvalService) Get(ctx context.Context, id string, opts ...option.RequestOption) (res *EvalGetResponse, err error) {
4444
opts = slices.Concat(r.Options, opts)
4545
if id == "" {
@@ -51,23 +51,23 @@ func (r *EvalService) Get(ctx context.Context, id string, opts ...option.Request
5151
return
5252
}
5353

54-
// Get a list of evaluation jobs with optional filtering
54+
// Get all evaluation jobs. Deprecated! Please use /evaluation
5555
func (r *EvalService) List(ctx context.Context, query EvalListParams, opts ...option.RequestOption) (res *[]EvalListResponse, err error) {
5656
opts = slices.Concat(r.Options, opts)
5757
path := "evaluations"
5858
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
5959
return
6060
}
6161

62-
// Get the list of models that are allowed for evaluation
63-
func (r *EvalService) GetAllowedModels(ctx context.Context, opts ...option.RequestOption) (res *EvalGetAllowedModelsResponse, err error) {
62+
// Get model list
63+
func (r *EvalService) GetAllowedModels(ctx context.Context, query EvalGetAllowedModelsParams, opts ...option.RequestOption) (res *EvalGetAllowedModelsResponse, err error) {
6464
opts = slices.Concat(r.Options, opts)
6565
path := "evaluations/model-list"
66-
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
66+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
6767
return
6868
}
6969

70-
// Get the status and results of a specific evaluation job
70+
// Get evaluation job status and results
7171
func (r *EvalService) GetStatus(ctx context.Context, id string, opts ...option.RequestOption) (res *EvalGetStatusResponse, err error) {
7272
opts = slices.Concat(r.Options, opts)
7373
if id == "" {
@@ -703,8 +703,11 @@ func (r *EvalGetAllowedModelsResponse) UnmarshalJSON(data []byte) error {
703703
}
704704

705705
type EvalGetStatusResponse struct {
706-
Results EvalGetStatusResponseResultsUnion `json:"results,nullable"`
707-
// Any of "pending", "queued", "running", "completed", "error", "user_error".
706+
// The results of the evaluation job
707+
Results EvalGetStatusResponseResultsUnion `json:"results"`
708+
// The status of the evaluation job
709+
//
710+
// Any of "completed", "error", "user_error", "running", "queued", "pending".
708711
Status EvalGetStatusResponseStatus `json:"status"`
709712
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
710713
JSON struct {
@@ -724,8 +727,7 @@ func (r *EvalGetStatusResponse) UnmarshalJSON(data []byte) error {
724727
// EvalGetStatusResponseResultsUnion contains all possible properties and values
725728
// from [EvalGetStatusResponseResultsEvaluationClassifyResults],
726729
// [EvalGetStatusResponseResultsEvaluationScoreResults],
727-
// [EvalGetStatusResponseResultsEvaluationCompareResults],
728-
// [EvalGetStatusResponseResultsError].
730+
// [EvalGetStatusResponseResultsEvaluationCompareResults].
729731
//
730732
// Use the methods beginning with 'As' to cast the union to one of its variants.
731733
type EvalGetStatusResponseResultsUnion struct {
@@ -759,9 +761,7 @@ type EvalGetStatusResponseResultsUnion struct {
759761
// This field is from variant
760762
// [EvalGetStatusResponseResultsEvaluationCompareResults].
761763
Ties int64 `json:"Ties"`
762-
// This field is from variant [EvalGetStatusResponseResultsError].
763-
Error string `json:"error"`
764-
JSON struct {
764+
JSON struct {
765765
GenerationFailCount respjson.Field
766766
InvalidLabelCount respjson.Field
767767
JudgeFailCount respjson.Field
@@ -775,7 +775,6 @@ type EvalGetStatusResponseResultsUnion struct {
775775
BWins respjson.Field
776776
NumSamples respjson.Field
777777
Ties respjson.Field
778-
Error respjson.Field
779778
raw string
780779
} `json:"-"`
781780
}
@@ -795,11 +794,6 @@ func (u EvalGetStatusResponseResultsUnion) AsEvalGetStatusResponseResultsEvaluat
795794
return
796795
}
797796

798-
func (u EvalGetStatusResponseResultsUnion) AsEvalGetStatusResponseResultsError() (v EvalGetStatusResponseResultsError) {
799-
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
800-
return
801-
}
802-
803797
// Returns the unmodified JSON received from the API
804798
func (u EvalGetStatusResponseResultsUnion) RawJSON() string { return u.JSON.raw }
805799

@@ -927,40 +921,24 @@ func (r *EvalGetStatusResponseResultsEvaluationCompareResults) UnmarshalJSON(dat
927921
return apijson.UnmarshalRoot(data, r)
928922
}
929923

930-
type EvalGetStatusResponseResultsError struct {
931-
Error string `json:"error"`
932-
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
933-
JSON struct {
934-
Error respjson.Field
935-
ExtraFields map[string]respjson.Field
936-
raw string
937-
} `json:"-"`
938-
}
939-
940-
// Returns the unmodified JSON received from the API
941-
func (r EvalGetStatusResponseResultsError) RawJSON() string { return r.JSON.raw }
942-
func (r *EvalGetStatusResponseResultsError) UnmarshalJSON(data []byte) error {
943-
return apijson.UnmarshalRoot(data, r)
944-
}
945-
924+
// The status of the evaluation job
946925
type EvalGetStatusResponseStatus string
947926

948927
const (
949-
EvalGetStatusResponseStatusPending EvalGetStatusResponseStatus = "pending"
950-
EvalGetStatusResponseStatusQueued EvalGetStatusResponseStatus = "queued"
951-
EvalGetStatusResponseStatusRunning EvalGetStatusResponseStatus = "running"
952928
EvalGetStatusResponseStatusCompleted EvalGetStatusResponseStatus = "completed"
953929
EvalGetStatusResponseStatusError EvalGetStatusResponseStatus = "error"
954930
EvalGetStatusResponseStatusUserError EvalGetStatusResponseStatus = "user_error"
931+
EvalGetStatusResponseStatusRunning EvalGetStatusResponseStatus = "running"
932+
EvalGetStatusResponseStatusQueued EvalGetStatusResponseStatus = "queued"
933+
EvalGetStatusResponseStatusPending EvalGetStatusResponseStatus = "pending"
955934
)
956935

957936
type EvalListParams struct {
958-
// Maximum number of results to return (max 100)
959-
Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
960-
// Filter by job status
961-
//
962-
// Any of "pending", "queued", "running", "completed", "error", "user_error".
963-
Status EvalListParamsStatus `query:"status,omitzero" json:"-"`
937+
Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
938+
Status param.Opt[string] `query:"status,omitzero" json:"-"`
939+
// Admin users can specify a user ID to filter jobs. Pass empty string to get all
940+
// jobs.
941+
UserID param.Opt[string] `query:"userId,omitzero" json:"-"`
964942
paramObj
965943
}
966944

@@ -972,14 +950,16 @@ func (r EvalListParams) URLQuery() (v url.Values, err error) {
972950
})
973951
}
974952

975-
// Filter by job status
976-
type EvalListParamsStatus string
953+
type EvalGetAllowedModelsParams struct {
954+
ModelSource param.Opt[string] `query:"model_source,omitzero" json:"-"`
955+
paramObj
956+
}
977957

978-
const (
979-
EvalListParamsStatusPending EvalListParamsStatus = "pending"
980-
EvalListParamsStatusQueued EvalListParamsStatus = "queued"
981-
EvalListParamsStatusRunning EvalListParamsStatus = "running"
982-
EvalListParamsStatusCompleted EvalListParamsStatus = "completed"
983-
EvalListParamsStatusError EvalListParamsStatus = "error"
984-
EvalListParamsStatusUserError EvalListParamsStatus = "user_error"
985-
)
958+
// URLQuery serializes [EvalGetAllowedModelsParams]'s query parameters as
959+
// `url.Values`.
960+
func (r EvalGetAllowedModelsParams) URLQuery() (v url.Values, err error) {
961+
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
962+
ArrayFormat: apiquery.ArrayQueryFormatComma,
963+
NestedFormat: apiquery.NestedQueryFormatBrackets,
964+
})
965+
}

eval_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ func TestEvalListWithOptionalParams(t *testing.T) {
4848
option.WithAPIKey("My API Key"),
4949
)
5050
_, err := client.Evals.List(context.TODO(), together.EvalListParams{
51-
Limit: together.Int(1),
52-
Status: together.EvalListParamsStatusPending,
51+
Limit: together.Int(0),
52+
Status: together.String("status"),
53+
UserID: together.String("userId"),
5354
})
5455
if err != nil {
5556
var apierr *together.Error
@@ -60,7 +61,7 @@ func TestEvalListWithOptionalParams(t *testing.T) {
6061
}
6162
}
6263

63-
func TestEvalGetAllowedModels(t *testing.T) {
64+
func TestEvalGetAllowedModelsWithOptionalParams(t *testing.T) {
6465
baseURL := "http://localhost:4010"
6566
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
6667
baseURL = envURL
@@ -72,7 +73,9 @@ func TestEvalGetAllowedModels(t *testing.T) {
7273
option.WithBaseURL(baseURL),
7374
option.WithAPIKey("My API Key"),
7475
)
75-
_, err := client.Evals.GetAllowedModels(context.TODO())
76+
_, err := client.Evals.GetAllowedModels(context.TODO(), together.EvalGetAllowedModelsParams{
77+
ModelSource: together.String("model_source"),
78+
})
7679
if err != nil {
7780
var apierr *together.Error
7881
if errors.As(err, &apierr) {

0 commit comments

Comments
 (0)