Skip to content

Commit dceaf80

Browse files
feat(api): Add fine_tune.delete API
1 parent 76909f9 commit dceaf80

File tree

4 files changed

+74
-2
lines changed

4 files changed

+74
-2
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 41
1+
configured_endpoints: 42
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-eacfa676c4ac9c051f61d4d25c1074315959b2e3d418bca529e6de2a9f6636e7.yml
33
openapi_spec_hash: 1d56caf3dd011e888fb911d34bd34aef
4-
config_hash: 3c3a676f96a972da95e0e85618e64c76
4+
config_hash: d4af46f57b37b7d37b8e0328101148b4

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ Response Types:
106106
- <a href="https://pkg.go.dev/github.com/togethercomputer/together-go">together</a>.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#TrainingMethodSft">TrainingMethodSft</a>
107107
- <a href="https://pkg.go.dev/github.com/togethercomputer/together-go">together</a>.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#FineTuneNewResponse">FineTuneNewResponse</a>
108108
- <a href="https://pkg.go.dev/github.com/togethercomputer/together-go">together</a>.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#FineTuneListResponse">FineTuneListResponse</a>
109+
- <a href="https://pkg.go.dev/github.com/togethercomputer/together-go">together</a>.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#FineTuneDeleteResponse">FineTuneDeleteResponse</a>
109110
- <a href="https://pkg.go.dev/github.com/togethercomputer/together-go">together</a>.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#FineTuneCancelResponse">FineTuneCancelResponse</a>
110111
- <a href="https://pkg.go.dev/github.com/togethercomputer/together-go">together</a>.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#FineTuneDownloadResponse">FineTuneDownloadResponse</a>
111112
- <a href="https://pkg.go.dev/github.com/togethercomputer/together-go">together</a>.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#FineTuneListEventsResponse">FineTuneListEventsResponse</a>
@@ -116,6 +117,7 @@ Methods:
116117
- <code title="post /fine-tunes">client.FineTune.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#FineTuneService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/togethercomputer/together-go">together</a>.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#FineTuneNewParams">FineTuneNewParams</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#FineTuneNewResponse">FineTuneNewResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
117118
- <code title="get /fine-tunes/{id}">client.FineTune.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#FineTuneService.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#FineTune">FineTune</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
118119
- <code title="get /fine-tunes">client.FineTune.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#FineTuneService.List">List</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#FineTuneListResponse">FineTuneListResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
120+
- <code title="delete /fine-tunes/{id}">client.FineTune.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#FineTuneService.Delete">Delete</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>, body <a href="https://pkg.go.dev/github.com/togethercomputer/together-go">together</a>.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#FineTuneDeleteParams">FineTuneDeleteParams</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#FineTuneDeleteResponse">FineTuneDeleteResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
119121
- <code title="post /fine-tunes/{id}/cancel">client.FineTune.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#FineTuneService.Cancel">Cancel</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#FineTuneCancelResponse">FineTuneCancelResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
120122
- <code title="get /finetune/download">client.FineTune.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#FineTuneService.Download">Download</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#FineTuneDownloadParams">FineTuneDownloadParams</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#FineTuneDownloadResponse">FineTuneDownloadResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
121123
- <code title="get /fine-tunes/{id}/events">client.FineTune.<a href="https://pkg.go.dev/github.com/togethercomputer/together-go#FineTuneService.ListEvents">ListEvents</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#FineTuneListEventsResponse">FineTuneListEventsResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

finetune.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ func (r *FineTuneService) List(ctx context.Context, opts ...option.RequestOption
6868
return
6969
}
7070

71+
// Delete a fine-tuning job.
72+
func (r *FineTuneService) Delete(ctx context.Context, id string, body FineTuneDeleteParams, opts ...option.RequestOption) (res *FineTuneDeleteResponse, err error) {
73+
opts = slices.Concat(r.Options, opts)
74+
if id == "" {
75+
err = errors.New("missing required id parameter")
76+
return
77+
}
78+
path := fmt.Sprintf("fine-tunes/%s", id)
79+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &res, opts...)
80+
return
81+
}
82+
7183
// Cancel a currently running fine-tuning job. Returns a FinetuneResponseTruncated
7284
// object.
7385
func (r *FineTuneService) Cancel(ctx context.Context, id string, opts ...option.RequestOption) (res *FineTuneCancelResponse, err error) {
@@ -1408,6 +1420,23 @@ func (r *FineTuneListResponseDataTrainingTypeUnion) UnmarshalJSON(data []byte) e
14081420
return apijson.UnmarshalRoot(data, r)
14091421
}
14101422

1423+
type FineTuneDeleteResponse struct {
1424+
// Message indicating the result of the deletion
1425+
Message string `json:"message"`
1426+
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
1427+
JSON struct {
1428+
Message respjson.Field
1429+
ExtraFields map[string]respjson.Field
1430+
raw string
1431+
} `json:"-"`
1432+
}
1433+
1434+
// Returns the unmodified JSON received from the API
1435+
func (r FineTuneDeleteResponse) RawJSON() string { return r.JSON.raw }
1436+
func (r *FineTuneDeleteResponse) UnmarshalJSON(data []byte) error {
1437+
return apijson.UnmarshalRoot(data, r)
1438+
}
1439+
14111440
// A truncated version of the fine-tune response, used for POST /fine-tunes, GET
14121441
// /fine-tunes and POST /fine-tunes/{id}/cancel endpoints
14131442
type FineTuneCancelResponse struct {
@@ -1994,6 +2023,19 @@ func (u FineTuneNewParamsTrainingTypeUnion) GetType() *string {
19942023
return nil
19952024
}
19962025

2026+
type FineTuneDeleteParams struct {
2027+
Force bool `query:"force,required" json:"-"`
2028+
paramObj
2029+
}
2030+
2031+
// URLQuery serializes [FineTuneDeleteParams]'s query parameters as `url.Values`.
2032+
func (r FineTuneDeleteParams) URLQuery() (v url.Values, err error) {
2033+
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
2034+
ArrayFormat: apiquery.ArrayQueryFormatComma,
2035+
NestedFormat: apiquery.NestedQueryFormatBrackets,
2036+
})
2037+
}
2038+
19972039
type FineTuneDownloadParams struct {
19982040
// Fine-tune ID to download. A string that starts with `ft-`.
19992041
FtID string `query:"ft_id,required" json:"-"`

finetune_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,34 @@ func TestFineTuneList(t *testing.T) {
127127
}
128128
}
129129

130+
func TestFineTuneDelete(t *testing.T) {
131+
baseURL := "http://localhost:4010"
132+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
133+
baseURL = envURL
134+
}
135+
if !testutil.CheckTestServer(t, baseURL) {
136+
return
137+
}
138+
client := together.NewClient(
139+
option.WithBaseURL(baseURL),
140+
option.WithAPIKey("My API Key"),
141+
)
142+
_, err := client.FineTune.Delete(
143+
context.TODO(),
144+
"id",
145+
together.FineTuneDeleteParams{
146+
Force: true,
147+
},
148+
)
149+
if err != nil {
150+
var apierr *together.Error
151+
if errors.As(err, &apierr) {
152+
t.Log(string(apierr.DumpRequest(true)))
153+
}
154+
t.Fatalf("err should be nil: %s", err.Error())
155+
}
156+
}
157+
130158
func TestFineTuneCancel(t *testing.T) {
131159
baseURL := "http://localhost:4010"
132160
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {

0 commit comments

Comments
 (0)