-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.go
More file actions
372 lines (333 loc) · 14.7 KB
/
Copy pathtypes.go
File metadata and controls
372 lines (333 loc) · 14.7 KB
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
package api
import (
"encoding/json"
"time"
"github.com/google/uuid"
)
// RunOptions configures the behaviour of Client.Run.
type RunOptions struct {
// TaskType overrides the task type detected from the model schema.
// Required when the schema is unavailable or does not encode a task type.
TaskType string
// DeliveryMethod overrides the delivery method resolved from the model schema.
// Accepted values: "sync", "async". Empty means resolve from schema or payload.
DeliveryMethod string
// PollInterval is the interval between getResponse polls when delivery is async.
// Defaults to 2 seconds when zero.
PollInterval time.Duration
// OnProgress is called with the reported progress percentage (0–100) during async
// polling. It may be nil.
OnProgress func(int)
// OnSubmit is called with the generated task UUID after the initial request is
// submitted but before async polling begins. It may be nil.
OnSubmit func(taskUUID uuid.UUID)
// Validate enables client-side validation of required and conditional
// constraints against the model schema. Off by default so the API remains the
// source of truth for requirements (the fetched schema can disagree with the
// live API — see RUN-10584).
Validate bool
}
// ImageInferenceRequest contains fields for the imageInference task type.
type ImageInferenceRequest struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
PositivePrompt string `json:"positivePrompt"`
NegativePrompt string `json:"negativePrompt,omitempty"`
Model string `json:"model"`
Width int `json:"width"`
Height int `json:"height"`
Steps int `json:"steps,omitempty"`
NumberResults int `json:"numberResults"`
CFGScale float64 `json:"CFGScale,omitempty"`
Scheduler string `json:"scheduler,omitempty"`
Seed int64 `json:"seed,omitempty"`
OutputFormat OutputFormat `json:"outputFormat,omitempty"`
InputImage string `json:"inputImage,omitempty"`
Strength float64 `json:"strength,omitempty"`
MaskImage string `json:"maskImage,omitempty"`
}
// ImageInferenceResult is a single image result from the API.
type ImageInferenceResult struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
ImageUUID uuid.UUID `json:"imageUUID"`
ImageURL string `json:"imageURL"`
Seed int64 `json:"seed"`
}
// ImageUploadRequest is the request payload for the imageUpload task.
type ImageUploadRequest struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
Image string `json:"image"`
}
// ImageUploadResult is the response from an imageUpload task. ImageUUID is the
// stored asset identifier, reusable as input for other tasks.
type ImageUploadResult struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
ImageUUID uuid.UUID `json:"imageUUID"`
}
// PingRequest is the request payload for the ping task.
type PingRequest struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
}
// PingResult is the response from a ping task.
type PingResult struct {
TaskType TaskType `json:"taskType"`
Pong bool `json:"pong"`
}
// AccountManagementRequest is the request payload for the accountManagement task.
type AccountManagementRequest struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
Operation string `json:"operation"`
}
// AccountResult is the response from accountManagement getDetails.
type AccountResult struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
OrganizationUUID uuid.UUID `json:"organizationUUID"`
OrganizationName string `json:"organizationName"`
AIRSource string `json:"AIRSource,omitempty"`
Balance float64 `json:"balance"`
Team []TeamMember `json:"team,omitempty"`
APIKeys []APIKeyInfo `json:"apiKeys,omitempty"`
Usage AccountUsage `json:"usage"`
}
// TeamMember is a member of the organization.
type TeamMember struct {
Name string `json:"name"`
Email string `json:"email"`
Roles []string `json:"roles"`
JoinedAt time.Time `json:"joinedAt,omitempty"`
}
// APIKeyInfo describes a single API key on the account.
type APIKeyInfo struct {
Name string `json:"name"`
APIKey string `json:"apiKey"`
Description string `json:"description,omitempty"`
Enabled bool `json:"enabled"`
CreatedAt time.Time `json:"createdAt"`
LastUsedAt time.Time `json:"lastUsedAt,omitempty"`
Requests int `json:"requests,omitempty"`
}
type AccountUsage struct {
Total UsagePeriod `json:"total"`
Today UsagePeriod `json:"today"`
Last7Days UsagePeriod `json:"last7Days"`
Last30Days UsagePeriod `json:"last30Days"`
}
type UsagePeriod struct {
Credits float64 `json:"credits"`
Requests int `json:"requests"`
}
// VideoInferenceRequest contains fields for the videoInference task type.
type VideoInferenceRequest struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
Model string `json:"model"`
PositivePrompt string `json:"positivePrompt,omitempty"`
NegativePrompt string `json:"negativePrompt,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
Duration float64 `json:"duration,omitempty"`
Steps int `json:"steps,omitempty"`
CFGScale float64 `json:"CFGScale,omitempty"`
Seed int64 `json:"seed,omitempty"`
NumberResults int `json:"numberResults,omitempty"`
OutputFormat OutputFormat `json:"outputFormat,omitempty"`
DeliveryMethod DeliveryMethod `json:"deliveryMethod,omitempty"`
FrameImages []FrameImage `json:"frameImages,omitempty"`
IncludeCost bool `json:"includeCost,omitempty"`
}
// FrameImage constrains a specific frame with an input image.
type FrameImage struct {
InputImage string `json:"inputImage"`
Frame any `json:"frame"` // "first", "last", or int
}
// VideoInferenceResult is a single video result from the API.
type VideoInferenceResult struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
Status string `json:"status,omitempty"`
VideoUUID uuid.UUID `json:"videoUUID"`
VideoURL string `json:"videoURL,omitempty"`
MediaUUID uuid.UUID `json:"mediaUUID"`
MediaURL string `json:"mediaURL,omitempty"`
Seed int64 `json:"seed,omitempty"`
Cost float64 `json:"cost,omitempty"`
}
// GetResponseRequest is used to poll for async task results.
type GetResponseRequest struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
}
// pollResponseItem is the minimal shape of each item returned by a getResponse
// poll call. Status is "success", "processing", or "error"; Progress is the
// completion percentage reported for "processing" items.
type pollResponseItem struct {
Status string `json:"status"`
Progress int `json:"progress"`
Code string `json:"code"`
Message string `json:"message"`
}
// AudioInferenceRequest contains fields for the audioInference task type.
type AudioInferenceRequest struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
Model string `json:"model"`
PositivePrompt string `json:"positivePrompt,omitempty"`
Duration float64 `json:"duration"`
NumberResults int `json:"numberResults"`
OutputFormat OutputFormat `json:"outputFormat,omitempty"`
DeliveryMethod DeliveryMethod `json:"deliveryMethod,omitempty"`
IncludeCost bool `json:"includeCost,omitempty"`
AudioSettings *AudioSettings `json:"audioSettings,omitempty"`
}
// AudioSettings configures technical audio quality parameters.
type AudioSettings struct {
SampleRate int `json:"sampleRate,omitempty"`
Bitrate int `json:"bitrate,omitempty"`
}
// AudioInferenceResult is a single audio result from the API.
type AudioInferenceResult struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
Status string `json:"status,omitempty"`
AudioUUID uuid.UUID `json:"audioUUID"`
AudioURL string `json:"audioURL,omitempty"`
Cost float64 `json:"cost,omitempty"`
}
// Message represents a single message in a text inference conversation.
type Message struct {
Role string `json:"role"`
Content string `json:"content"`
}
// TextInferenceRequest contains fields for the textInference task type.
type TextInferenceRequest struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
Model string `json:"model"`
Messages []Message `json:"messages"`
MaxTokens int `json:"maxTokens,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
TopP float64 `json:"topP,omitempty"`
TopK int `json:"topK,omitempty"`
Seed int64 `json:"seed,omitempty"`
StopSequences []string `json:"stopSequences,omitempty"`
NumberResults int `json:"numberResults,omitempty"`
SystemPrompt string `json:"systemPrompt,omitempty"`
OutputFormat OutputFormat `json:"outputFormat,omitempty"`
IncludeCost bool `json:"includeCost,omitempty"`
}
// TextInferenceUsage contains token usage statistics.
type TextInferenceUsage struct {
InputTokens int `json:"inputTokens,omitempty"`
OutputTokens int `json:"outputTokens,omitempty"`
TotalTokens int `json:"totalTokens,omitempty"`
}
// TextInferenceResult is a single text result from the API.
type TextInferenceResult struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
Text string `json:"text"`
FinishReason string `json:"finishReason,omitempty"`
Usage TextInferenceUsage `json:"usage"`
Cost float64 `json:"cost,omitempty"`
}
// ModelSearchRequest contains fields for the modelSearch task type.
type ModelSearchRequest struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
Search string `json:"search,omitempty"`
Tags []string `json:"tags,omitempty"`
Category string `json:"category,omitempty"`
Type string `json:"type,omitempty"`
Architecture string `json:"architecture,omitempty"`
Conditioning string `json:"conditioning,omitempty"`
Visibility string `json:"visibility,omitempty"`
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
}
// ModelSearchResponse is the response wrapper from modelSearch.
type ModelSearchResponse struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
Results []ModelResult `json:"results"`
TotalResults int `json:"totalResults"`
}
// ModelResult is a single model from the search results.
type ModelResult struct {
Name string `json:"name"`
AIR string `json:"air"`
Tags []string `json:"tags"`
ImageURL string `json:"imageURL"`
ThumbnailURL string `json:"thumbnailURL"`
Category string `json:"category"`
Private bool `json:"private"`
BaseModel string `json:"baseModel,omitempty"`
Version string `json:"version"`
Architecture string `json:"architecture"`
NSFWLevel int `json:"nsfwLevel"`
Type string `json:"type,omitempty"`
DefaultWeight float64 `json:"defaultWeight,omitempty"`
DefaultWidth int `json:"defaultWidth,omitempty"`
DefaultHeight int `json:"defaultHeight,omitempty"`
DefaultSteps int `json:"defaultSteps,omitempty"`
DefaultScheduler string `json:"defaultScheduler,omitempty"`
DefaultCFG float64 `json:"defaultCFG,omitempty"`
DefaultStrength float64 `json:"defaultStrength,omitempty"`
PositiveTriggerWords string `json:"positiveTriggerWords,omitempty"`
NegativeTriggerWords string `json:"negativeTriggerWords,omitempty"`
Primary bool `json:"primary,omitempty"`
}
// ModelUploadRequest contains fields for the modelUpload task type.
// Optional non-string fields are pointers so they are omitted from the payload
// unless explicitly set.
type ModelUploadRequest struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
Category string `json:"category"`
Name string `json:"name"`
Version string `json:"version"`
DownloadURL string `json:"downloadURL"`
Architecture string `json:"architecture"`
Format string `json:"format,omitempty"`
Type string `json:"type,omitempty"`
AIR string `json:"air,omitempty"`
UniqueIdentifier string `json:"uniqueIdentifier,omitempty"`
HeroImageURL string `json:"heroImageURL,omitempty"`
Tags []string `json:"tags,omitempty"`
ShortDescription string `json:"shortDescription,omitempty"`
Comment string `json:"comment,omitempty"`
Private *bool `json:"private,omitempty"`
DefaultCFG *float64 `json:"defaultCFG,omitempty"`
DefaultSteps *int `json:"defaultSteps,omitempty"`
DefaultScheduler string `json:"defaultScheduler,omitempty"`
DefaultStrength *float64 `json:"defaultStrength,omitempty"`
DefaultWeight *float64 `json:"defaultWeight,omitempty"`
PositiveTriggerWords string `json:"positiveTriggerWords,omitempty"`
}
// ModelUploadResult is a single status/result frame from the modelUpload
// pipeline. Status progresses validated → downloaded → optimized → stored →
// ready, or terminates with a failure status such as "failed" or "error downloading".
type ModelUploadResult struct {
TaskType TaskType `json:"taskType"`
TaskUUID uuid.UUID `json:"taskUUID"`
Status string `json:"status"`
Message string `json:"message,omitempty"`
AIR string `json:"air,omitempty"`
}
// ModelUploadOptions configures the behaviour of Client.ModelUpload.
type ModelUploadOptions struct {
// OnStatus is called for each intermediate pipeline status
// (validated, downloaded, optimized, stored). It may be nil.
OnStatus func(status, message string)
}
// ModelSchema is the response from the schema resolve endpoint.
type ModelSchema struct {
RequestSchema json.RawMessage `json:"requestSchema"`
ResponseSchema json.RawMessage `json:"responseSchema"`
Documentation string `json:"documentation"`
}