- Notifications
You must be signed in to change notification settings - Fork 129
/
Copy pathfinetuningcheckpointpermission.go
263 lines (238 loc) · 10.9 KB
/
finetuningcheckpointpermission.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package openai
import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
"github.com/openai/openai-go/internal/apijson"
"github.com/openai/openai-go/internal/apiquery"
"github.com/openai/openai-go/internal/requestconfig"
"github.com/openai/openai-go/option"
"github.com/openai/openai-go/packages/pagination"
"github.com/openai/openai-go/packages/param"
"github.com/openai/openai-go/packages/resp"
"github.com/openai/openai-go/shared/constant"
)
// FineTuningCheckpointPermissionService contains methods and other services that
// help with interacting with the openai 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 [NewFineTuningCheckpointPermissionService] method instead.
typeFineTuningCheckpointPermissionServicestruct {
Options []option.RequestOption
}
// NewFineTuningCheckpointPermissionService 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.
funcNewFineTuningCheckpointPermissionService(opts...option.RequestOption) (rFineTuningCheckpointPermissionService) {
r=FineTuningCheckpointPermissionService{}
r.Options=opts
return
}
// **NOTE:** Calling this endpoint requires an [admin API key](../admin-api-keys).
//
// This enables organization owners to share fine-tuned models with other projects
// in their organization.
func (r*FineTuningCheckpointPermissionService) New(ctx context.Context, fineTunedModelCheckpointstring, bodyFineTuningCheckpointPermissionNewParams, opts...option.RequestOption) (res*pagination.Page[FineTuningCheckpointPermissionNewResponse], errerror) {
varraw*http.Response
opts=append(r.Options[:], opts...)
opts=append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
iffineTunedModelCheckpoint=="" {
err=errors.New("missing required fine_tuned_model_checkpoint parameter")
return
}
path:=fmt.Sprintf("fine_tuning/checkpoints/%s/permissions", fineTunedModelCheckpoint)
cfg, err:=requestconfig.NewRequestConfig(ctx, http.MethodPost, path, body, &res, opts...)
iferr!=nil {
returnnil, err
}
err=cfg.Execute()
iferr!=nil {
returnnil, err
}
res.SetPageConfig(cfg, raw)
returnres, nil
}
// **NOTE:** Calling this endpoint requires an [admin API key](../admin-api-keys).
//
// This enables organization owners to share fine-tuned models with other projects
// in their organization.
func (r*FineTuningCheckpointPermissionService) NewAutoPaging(ctx context.Context, fineTunedModelCheckpointstring, bodyFineTuningCheckpointPermissionNewParams, opts...option.RequestOption) *pagination.PageAutoPager[FineTuningCheckpointPermissionNewResponse] {
returnpagination.NewPageAutoPager(r.New(ctx, fineTunedModelCheckpoint, body, opts...))
}
// **NOTE:** This endpoint requires an [admin API key](../admin-api-keys).
//
// Organization owners can use this endpoint to view all permissions for a
// fine-tuned model checkpoint.
func (r*FineTuningCheckpointPermissionService) Get(ctx context.Context, fineTunedModelCheckpointstring, queryFineTuningCheckpointPermissionGetParams, opts...option.RequestOption) (res*FineTuningCheckpointPermissionGetResponse, errerror) {
opts=append(r.Options[:], opts...)
iffineTunedModelCheckpoint=="" {
err=errors.New("missing required fine_tuned_model_checkpoint parameter")
return
}
path:=fmt.Sprintf("fine_tuning/checkpoints/%s/permissions", fineTunedModelCheckpoint)
err=requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
return
}
// **NOTE:** This endpoint requires an [admin API key](../admin-api-keys).
//
// Organization owners can use this endpoint to delete a permission for a
// fine-tuned model checkpoint.
func (r*FineTuningCheckpointPermissionService) Delete(ctx context.Context, fineTunedModelCheckpointstring, opts...option.RequestOption) (res*FineTuningCheckpointPermissionDeleteResponse, errerror) {
opts=append(r.Options[:], opts...)
iffineTunedModelCheckpoint=="" {
err=errors.New("missing required fine_tuned_model_checkpoint parameter")
return
}
path:=fmt.Sprintf("fine_tuning/checkpoints/%s/permissions", fineTunedModelCheckpoint)
err=requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return
}
// The `checkpoint.permission` object represents a permission for a fine-tuned
// model checkpoint.
typeFineTuningCheckpointPermissionNewResponsestruct {
// The permission identifier, which can be referenced in the API endpoints.
IDstring`json:"id,required"`
// The Unix timestamp (in seconds) for when the permission was created.
CreatedAtint64`json:"created_at,required"`
// The object type, which is always "checkpoint.permission".
Object constant.CheckpointPermission`json:"object,required"`
// The project identifier that the permission is for.
ProjectIDstring`json:"project_id,required"`
// Metadata for the response, check the presence of optional fields with the
// [resp.Field.IsPresent] method.
JSONstruct {
ID resp.Field
CreatedAt resp.Field
Object resp.Field
ProjectID resp.Field
ExtraFieldsmap[string]resp.Field
rawstring
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (rFineTuningCheckpointPermissionNewResponse) RawJSON() string { returnr.JSON.raw }
func (r*FineTuningCheckpointPermissionNewResponse) UnmarshalJSON(data []byte) error {
returnapijson.UnmarshalRoot(data, r)
}
typeFineTuningCheckpointPermissionGetResponsestruct {
Data []FineTuningCheckpointPermissionGetResponseData`json:"data,required"`
HasMorebool`json:"has_more,required"`
Object constant.List`json:"object,required"`
FirstIDstring`json:"first_id,nullable"`
LastIDstring`json:"last_id,nullable"`
// Metadata for the response, check the presence of optional fields with the
// [resp.Field.IsPresent] method.
JSONstruct {
Data resp.Field
HasMore resp.Field
Object resp.Field
FirstID resp.Field
LastID resp.Field
ExtraFieldsmap[string]resp.Field
rawstring
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (rFineTuningCheckpointPermissionGetResponse) RawJSON() string { returnr.JSON.raw }
func (r*FineTuningCheckpointPermissionGetResponse) UnmarshalJSON(data []byte) error {
returnapijson.UnmarshalRoot(data, r)
}
// The `checkpoint.permission` object represents a permission for a fine-tuned
// model checkpoint.
typeFineTuningCheckpointPermissionGetResponseDatastruct {
// The permission identifier, which can be referenced in the API endpoints.
IDstring`json:"id,required"`
// The Unix timestamp (in seconds) for when the permission was created.
CreatedAtint64`json:"created_at,required"`
// The object type, which is always "checkpoint.permission".
Object constant.CheckpointPermission`json:"object,required"`
// The project identifier that the permission is for.
ProjectIDstring`json:"project_id,required"`
// Metadata for the response, check the presence of optional fields with the
// [resp.Field.IsPresent] method.
JSONstruct {
ID resp.Field
CreatedAt resp.Field
Object resp.Field
ProjectID resp.Field
ExtraFieldsmap[string]resp.Field
rawstring
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (rFineTuningCheckpointPermissionGetResponseData) RawJSON() string { returnr.JSON.raw }
func (r*FineTuningCheckpointPermissionGetResponseData) UnmarshalJSON(data []byte) error {
returnapijson.UnmarshalRoot(data, r)
}
typeFineTuningCheckpointPermissionDeleteResponsestruct {
// The ID of the fine-tuned model checkpoint permission that was deleted.
IDstring`json:"id,required"`
// Whether the fine-tuned model checkpoint permission was successfully deleted.
Deletedbool`json:"deleted,required"`
// The object type, which is always "checkpoint.permission".
Object constant.CheckpointPermission`json:"object,required"`
// Metadata for the response, check the presence of optional fields with the
// [resp.Field.IsPresent] method.
JSONstruct {
ID resp.Field
Deleted resp.Field
Object resp.Field
ExtraFieldsmap[string]resp.Field
rawstring
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (rFineTuningCheckpointPermissionDeleteResponse) RawJSON() string { returnr.JSON.raw }
func (r*FineTuningCheckpointPermissionDeleteResponse) UnmarshalJSON(data []byte) error {
returnapijson.UnmarshalRoot(data, r)
}
typeFineTuningCheckpointPermissionNewParamsstruct {
// The project identifiers to grant access to.
ProjectIDs []string`json:"project_ids,omitzero,required"`
paramObj
}
// IsPresent returns true if the field's value is not omitted and not the JSON
// "null". To check if this field is omitted, use [param.IsOmitted].
func (fFineTuningCheckpointPermissionNewParams) IsPresent() bool {
return!param.IsOmitted(f) &&!f.IsNull()
}
func (rFineTuningCheckpointPermissionNewParams) MarshalJSON() (data []byte, errerror) {
typeshadowFineTuningCheckpointPermissionNewParams
returnparam.MarshalObject(r, (*shadow)(&r))
}
typeFineTuningCheckpointPermissionGetParamsstruct {
// Identifier for the last permission ID from the previous pagination request.
After param.Opt[string] `query:"after,omitzero" json:"-"`
// Number of permissions to retrieve.
Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
// The ID of the project to get permissions for.
ProjectID param.Opt[string] `query:"project_id,omitzero" json:"-"`
// The order in which to retrieve permissions.
//
// Any of "ascending", "descending".
OrderFineTuningCheckpointPermissionGetParamsOrder`query:"order,omitzero" json:"-"`
paramObj
}
// IsPresent returns true if the field's value is not omitted and not the JSON
// "null". To check if this field is omitted, use [param.IsOmitted].
func (fFineTuningCheckpointPermissionGetParams) IsPresent() bool {
return!param.IsOmitted(f) &&!f.IsNull()
}
// URLQuery serializes [FineTuningCheckpointPermissionGetParams]'s query parameters
// as `url.Values`.
func (rFineTuningCheckpointPermissionGetParams) URLQuery() (v url.Values, errerror) {
returnapiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatBrackets,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}
// The order in which to retrieve permissions.
typeFineTuningCheckpointPermissionGetParamsOrderstring
const (
FineTuningCheckpointPermissionGetParamsOrderAscendingFineTuningCheckpointPermissionGetParamsOrder="ascending"
FineTuningCheckpointPermissionGetParamsOrderDescendingFineTuningCheckpointPermissionGetParamsOrder="descending"
)