wriftai 0.48.0 → 0.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -13,6 +13,10 @@ type SchemaIO = {
13
13
  * Schema for output, following JSON Schema Draft 2020-12 standards.
14
14
  */
15
15
  output: Record<string, JsonValue>;
16
+ /**
17
+ * Schema for streaming output, following JSON Schema Draft 2020-12 standards.
18
+ */
19
+ stream_output?: Record<string, JsonValue>;
16
20
  };
17
21
  /**
18
22
  * Represents schemas of a model version.
@@ -153,15 +157,6 @@ declare enum ModelVisibility {
153
157
  public = "public",
154
158
  restricted = "restricted"
155
159
  }
156
- /**
157
- * Represents a hardware item.
158
- */
159
- interface Hardware {
160
- /** The name of the hardware. */
161
- name: string;
162
- /** The identifier of the hardware. */
163
- identifier: string;
164
- }
165
160
  /**
166
161
  * Represents a model.
167
162
  */
@@ -194,10 +189,6 @@ interface Model {
194
189
  * The details of the owner of the model.
195
190
  */
196
191
  owner: BaseUser;
197
- /**
198
- * The hardware used by the model.
199
- */
200
- hardware: Hardware;
201
192
  /**
202
193
  * The total number of predictions created across all versions of the model.
203
194
  */
@@ -222,10 +213,6 @@ interface PaginatedResponse<T> {
222
213
  next_cursor: string | null;
223
214
  /** Cursor pointing to the previous page */
224
215
  previous_cursor: string | null;
225
- /** URL to fetch the next page */
226
- next_url: string | null;
227
- /** URL to fetch the previous page */
228
- previous_url: string | null;
229
216
  }
230
217
  /**
231
218
  * Enumeration of possible sorting options.
@@ -265,6 +252,7 @@ declare class WriftAIAPIError extends Error {
265
252
  }
266
253
  /**
267
254
  * Client for WriftAI's API.
255
+ * @internal
268
256
  */
269
257
  declare class API {
270
258
  private baseUrl;
@@ -609,6 +597,19 @@ declare class PredictionsResource extends Resource {
609
597
  wait(predictionID: string, options?: WaitOptions, signal?: AbortSignal): Promise<PredictionWithIO>;
610
598
  }
611
599
 
600
+ /**
601
+ * Configuration for the model version
602
+ */
603
+ type ModelVersionConfiguration = {
604
+ /**
605
+ * The identifier of the hardware used by the model version.
606
+ */
607
+ hardware_identifier: string;
608
+ /**
609
+ * A list of variable keys for the model version.
610
+ */
611
+ variable_keys: string[];
612
+ };
612
613
  /**
613
614
  * Parameters for creating a version of a model.
614
615
  */
@@ -631,6 +632,11 @@ type CreateModelVersionParams = {
631
632
  * supported by the version.
632
633
  */
633
634
  compatibilities?: Partial<Compatibilities>;
635
+ /**
636
+ * Configuration for the model version.
637
+ * Omit to inherit configuration from the previous version.
638
+ */
639
+ configuration?: ModelVersionConfiguration;
634
640
  };
635
641
  /**
636
642
  * Error thrown when a model version identifier is not in
@@ -643,10 +649,34 @@ declare class InvalidModelVersionIdentifierError extends Error {
643
649
  */
644
650
  constructor(identifier: string);
645
651
  }
652
+ /**
653
+ * Parameters for updating the configuration of a model version.
654
+ */
655
+ type UpdateModelVersionConfigurationParams = {
656
+ /**
657
+ * The identifier of the hardware used by the model version.
658
+ */
659
+ hardware_identifier?: string;
660
+ /**
661
+ * The new list of variable keys to attach to the model version.
662
+ * Replaces all current variable keys.
663
+ */
664
+ variable_keys?: string[];
665
+ };
666
+ /**
667
+ * Represents a model version with it's details and configuration.
668
+ */
669
+ interface ModelVersionWithDetailsAndConfiguration extends ModelVersionWithDetails {
670
+ /**
671
+ * Configuration for the model version.
672
+ */
673
+ configuration: ModelVersionConfiguration;
674
+ }
646
675
  /**
647
676
  * Resource class for interacting with model versions.
648
677
  */
649
678
  declare class ModelVersions extends Resource {
679
+ private readonly CONFIGURATION_PATH;
650
680
  /**
651
681
  * Parses model version identifier into owner, name, and version number.
652
682
  * @param identifier The model version identifier in owner/name:version-number
@@ -673,7 +703,7 @@ declare class ModelVersions extends Resource {
673
703
  * @param signal Optional AbortSignal to cancel the request.
674
704
  * @returns The new version object.
675
705
  */
676
- create(identifier: string, params: CreateModelVersionParams, signal?: AbortSignal): Promise<ModelVersionWithDetails>;
706
+ create(identifier: string, params: CreateModelVersionParams, signal?: AbortSignal): Promise<ModelVersionWithDetailsAndConfiguration>;
677
707
  /**
678
708
  * Delete a model version.
679
709
  * @param identifier The model version identifier in owner/name:version-number
@@ -690,6 +720,23 @@ declare class ModelVersions extends Resource {
690
720
  * @returns A paginated response containing model versions.
691
721
  */
692
722
  list(identifier: string, options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<ModelVersion>>;
723
+ /**
724
+ * Update the configuration of a model version.
725
+ * @param identifier The model version identifier in owner/name:version-number
726
+ * format (for example: deepseek-ai/deepseek-r1:1).
727
+ * @param params Parameters for updating the configuration.
728
+ * @param signal Optional AbortSignal to cancel the request.
729
+ * @returns The updated model version configuration.
730
+ */
731
+ updateConfiguration(identifier: string, params: UpdateModelVersionConfigurationParams, signal?: AbortSignal): Promise<ModelVersionConfiguration>;
732
+ /**
733
+ * Get the configuration of a model version.
734
+ * @param identifier The model version identifier in owner/name:version-number
735
+ * format (for example: deepseek-ai/deepseek-r1:1).
736
+ * @param signal Optional AbortSignal to cancel the request.
737
+ * @returns The model version configuration.
738
+ */
739
+ getConfiguration(identifier: string, signal?: AbortSignal): Promise<ModelVersionConfiguration>;
693
740
  }
694
741
 
695
742
  /**
@@ -708,10 +755,6 @@ type UpdateModelParams = {
708
755
  * The visibility of the model.
709
756
  */
710
757
  visibility?: ModelVisibility;
711
- /**
712
- * The identifier of the hardware used by the model.
713
- */
714
- hardware_identifier?: string;
715
758
  /**
716
759
  * Source url from where the model's code can be referenced.
717
760
  */
@@ -745,10 +788,6 @@ type CreateModelParams = {
745
788
  * The visibility of the model.
746
789
  */
747
790
  visibility?: ModelVisibility;
748
- /**
749
- * The identifier of the hardware used by the model.
750
- */
751
- hardware_identifier: string;
752
791
  /**
753
792
  * Description of the model.
754
793
  */
@@ -929,9 +968,13 @@ declare class Users extends Resource {
929
968
  }
930
969
 
931
970
  /**
932
- * Represents a hardware item with more details.
971
+ * Represents a hardware item.
933
972
  */
934
- interface HardwareWithDetails extends Hardware {
973
+ interface Hardware {
974
+ /**The name of the hardware.*/
975
+ name: string;
976
+ /**The identifier of the hardware.*/
977
+ identifier: string;
935
978
  /** Number of GPUs available on the hardware. */
936
979
  gpus: number;
937
980
  /** Number of CPUs available on the hardware. */
@@ -983,6 +1026,10 @@ declare class ModelCategories extends Resource {
983
1026
 
984
1027
  /** Resource a file is related to. */
985
1028
  type FileResource = 'prediction';
1029
+ /**
1030
+ * Represents contents of a file.
1031
+ */
1032
+ type FileContent = File | Blob | Uint8Array;
986
1033
  /**
987
1034
  * Generated file urls.
988
1035
  */
@@ -1029,13 +1076,150 @@ type CreateFileUrlsParams = {
1029
1076
  * Resource for operations related to files.
1030
1077
  */
1031
1078
  declare class Files extends Resource {
1079
+ private fetchImpl;
1080
+ private headers;
1081
+ /**
1082
+ * Create a new Files resource.
1083
+ * @param fetchImpl Fetch implementation to use.
1084
+ * @param headers Additional headers to send with file upload requests.
1085
+ * @param api API client instance used to
1086
+ * communicate with WriftAI's API.
1087
+ */
1088
+ constructor(fetchImpl: typeof fetch, headers: Record<string, string>, api: API);
1032
1089
  /**
1033
1090
  * Generate urls to upload and download a file for a resource.
1091
+ * This is a low-level method. Most callers should use
1092
+ * {@link upload} instead, which handles reading, streaming,
1093
+ * and uploading the file contents.
1034
1094
  * @param params Parameters for url generation.
1035
1095
  * @param signal Optional AbortSignal to cancel the request.
1036
1096
  * @returns The generated urls.
1037
1097
  */
1038
1098
  createUrls(params: CreateFileUrlsParams, signal?: AbortSignal): Promise<FileUrls>;
1099
+ /**
1100
+ * Upload a file.
1101
+ * The upload is streamed, but the underlying data may already be
1102
+ * in memory depending on how `file` was constructed.
1103
+ * For example, a browser `File` from an `<input>` or Node's
1104
+ * `openAsBlob()` stream from disk, while `new Blob([buffer])` or
1105
+ * `Uint8Array` require the data to already be in memory.
1106
+ * @param file Contents of the file to upload.
1107
+ * @param resource The resource this file relates to.
1108
+ * @param name Display name including extension (e.g. "report.pdf").
1109
+ * When omitted, inferred from `File.name`. Required when file is a `Blob`
1110
+ * or `Uint8Array`.
1111
+ * @param signal Optional AbortSignal to cancel the request.
1112
+ * @returns The download url for the uploaded file.
1113
+ * @throws {TypeError} If `name` is not provided and `file` is not a
1114
+ * `File` instance.
1115
+ */
1116
+ upload(file: FileContent, resource: FileResource, name?: string, signal?: AbortSignal): Promise<string>;
1117
+ /**
1118
+ * Resolves the display name for a file.
1119
+ * @param file Contents of the file.
1120
+ * @param name Display name including extension (e.g. "report.pdf").
1121
+ * @returns The resolved mime type.
1122
+ * @throws {TypeError} When `name` is not provided and `file` is not
1123
+ * a `File` instance.
1124
+ */
1125
+ private resolveFileName;
1126
+ /**
1127
+ * Guesses the MIME type.
1128
+ * Prefers the file's own type, while falling back to
1129
+ * extension lookup.
1130
+ * @param file Contents of the file.
1131
+ * @param name Display name including extension (e.g. "report.pdf").
1132
+ * @returns The resolved mime type.
1133
+ */
1134
+ private resolveMimeType;
1135
+ }
1136
+
1137
+ /**
1138
+ * Represents a variable
1139
+ */
1140
+ interface Variable {
1141
+ /**
1142
+ * The unique key that identifies the variable.
1143
+ */
1144
+ key: string;
1145
+ /**
1146
+ * The value of the variable.
1147
+ * This is an empty string if the variable is a secret.
1148
+ */
1149
+ value: string;
1150
+ /**
1151
+ * Indicates whether this variable is a secret.
1152
+ */
1153
+ secret: boolean;
1154
+ /**
1155
+ * The timestamp when the variable was created.
1156
+ */
1157
+ created_at: string;
1158
+ /**
1159
+ * The timestamp when the variable was last updated.
1160
+ */
1161
+ updated_at: string | null;
1162
+ }
1163
+ /**
1164
+ * Parameters for creating a variable.
1165
+ */
1166
+ type CreateVariableParams = {
1167
+ /**
1168
+ * The unique key that identifies the variable.
1169
+ */
1170
+ key: string;
1171
+ /**
1172
+ * The value of the variable.
1173
+ */
1174
+ value: string;
1175
+ /**
1176
+ * Represents whether the variable's value should be treated
1177
+ * as a secret. The values of secrets are not returned.
1178
+ */
1179
+ secret: boolean;
1180
+ };
1181
+ /**
1182
+ * Parameters for updating a variable.
1183
+ */
1184
+ type UpdateVariableParams = {
1185
+ /**
1186
+ * The new value of the variable.
1187
+ */
1188
+ value?: string;
1189
+ };
1190
+ /**
1191
+ * Resource for operations related to variables.
1192
+ */
1193
+ declare class Variables extends Resource {
1194
+ private readonly VARIABLES_API_PREFIX;
1195
+ /**
1196
+ * Create a new variable.
1197
+ * @param params Parameters for creating the variable.
1198
+ * @param signal Optional abort signal.
1199
+ * @returns The created variable.
1200
+ */
1201
+ create(params: CreateVariableParams, signal?: AbortSignal): Promise<Variable>;
1202
+ /**
1203
+ * Delete a variable.
1204
+ * @param key The unique key that identifies the variable to be deleted.
1205
+ * @param signal Optional abort signal.
1206
+ */
1207
+ delete(key: string, signal?: AbortSignal): Promise<void>;
1208
+ /**
1209
+ * Update a variable.
1210
+ * @param key The unique key that identifies the variable to be updated.
1211
+ * @param params The parameters for updating the variable.
1212
+ * @param signal Optional abort signal.
1213
+ * @returns The updated variable.
1214
+ */
1215
+ update(key: string, params: UpdateVariableParams, signal?: AbortSignal): Promise<Variable>;
1216
+ /**
1217
+ * List variables.
1218
+ * @param options Optional settings to control pagination behavior.
1219
+ * @param signal Optional abort signal.
1220
+ * @returns Paginated response containing variables and navigation metadata.
1221
+ */
1222
+ list(options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<Variable>>;
1039
1223
  }
1040
1224
 
1041
1225
  /**
@@ -1102,6 +1286,83 @@ declare class WebhookTimestampOutsideToleranceError extends WebhookSignatureVeri
1102
1286
  */
1103
1287
  declare function verify(payload: Uint8Array, signature: string, secret: string, tolerance?: number, scheme?: string, keyCacheSize?: number): Promise<void>;
1104
1288
 
1289
+ /**
1290
+ * Represents an upload.
1291
+ */
1292
+ interface Upload {
1293
+ /**
1294
+ * The urls used to upload the file.
1295
+ */
1296
+ urls: string[];
1297
+ /**
1298
+ * The identifier for the upload.
1299
+ */
1300
+ id: string;
1301
+ /**
1302
+ * The size, in bytes, of each part. All parts
1303
+ * are this size except the last one, which may be
1304
+ * smaller. If the upload consists of a single part,
1305
+ * this value equals the total file size.
1306
+ */
1307
+ part_size: number;
1308
+ }
1309
+ /**
1310
+ * Parameters for creating an upload.
1311
+ */
1312
+ type CreateUploadParams = {
1313
+ /**
1314
+ * The size of the file to upload in bytes.
1315
+ * This should be the exact size of the file.
1316
+ * Any mismatch will result in an error or a corrupt file being uploaded.
1317
+ */
1318
+ size: number;
1319
+ /**
1320
+ * The MIME type of the file.
1321
+ */
1322
+ mime_type: string;
1323
+ };
1324
+ /**
1325
+ * Parameters for completing an upload.
1326
+ */
1327
+ type CompleteUploadParams = {
1328
+ /**
1329
+ * The list of etags of the uploaded parts
1330
+ * matching the ordering of urls.
1331
+ */
1332
+ etags: string[];
1333
+ };
1334
+ /**
1335
+ * Represents the result of a completed upload.
1336
+ */
1337
+ interface UploadCompletionResult {
1338
+ /**
1339
+ * A time-limited signed URL for downloading the file.
1340
+ * No additional authentication is required.
1341
+ */
1342
+ download_url: string;
1343
+ }
1344
+ /**
1345
+ * Resource for operations related to uploads.
1346
+ */
1347
+ declare class Uploads extends Resource {
1348
+ private readonly UPLOADS_API_PREFIX;
1349
+ /**
1350
+ * Create an upload.
1351
+ * @param params Upload creation parameters.
1352
+ * @param signal Optional AbortSignal to cancel the request.
1353
+ * @returns The new upload.
1354
+ */
1355
+ create(params: CreateUploadParams, signal?: AbortSignal): Promise<Upload>;
1356
+ /**
1357
+ * Complete an upload.
1358
+ * @param id The unique identifier of the upload.
1359
+ * @param params Parameters to complete an upload.
1360
+ * @param signal Optional AbortSignal to cancel the request.
1361
+ * @returns The completion result.
1362
+ */
1363
+ complete(id: string, params: CompleteUploadParams, signal?: AbortSignal): Promise<UploadCompletionResult>;
1364
+ }
1365
+
1105
1366
  /**
1106
1367
  * Parameters for updating a user.
1107
1368
  */
@@ -1187,10 +1448,7 @@ interface WriftAIClientOptions {
1187
1448
  * Client for WriftAI.
1188
1449
  */
1189
1450
  declare class WriftAI {
1190
- /**
1191
- * The client used to interact with WriftAI's API.
1192
- */
1193
- api: API;
1451
+ private api;
1194
1452
  /**
1195
1453
  * Interface for accessing prediction related
1196
1454
  * resources and operations.
@@ -1227,6 +1485,16 @@ declare class WriftAI {
1227
1485
  * resources and operations.
1228
1486
  */
1229
1487
  files: Files;
1488
+ /**
1489
+ * Interface for accessing variables related
1490
+ * resources and options
1491
+ */
1492
+ variables: Variables;
1493
+ /**
1494
+ * Interface for accessing uploads related
1495
+ * resources and operations
1496
+ */
1497
+ uploads: Uploads;
1230
1498
  /**
1231
1499
  * Create an instance of the WriftAI client.
1232
1500
  * @param options Client options
@@ -1247,4 +1515,4 @@ declare class WriftAI {
1247
1515
  }
1248
1516
 
1249
1517
  export { DEFAULT_WAIT_OPTIONS, ErrorSource, InvalidIdentifierError, InvalidModelIdentifierError, InvalidModelVersionIdentifierError, ModelVisibility, ModelsSortBy, SortDirection, Status, UsersSortBy, WebhookNoSignatureError, WebhookNoTimestampError, WebhookSignatureMismatchError, WebhookSignatureVerificationError, WebhookTimestampOutsideToleranceError, WriftAI, WriftAIAPIError, verify as verifyWebhook };
1250
- export type { BaseUser, Compatibilities, FileUrls, HardwareWithDetails, Model, ModelCategory, ModelCategoryWithDetails, ModelVersion, ModelVersionWithDetails, ModelWithDetails, PaginatedResponse, Prediction, PredictionModel, PredictionWithIO, SchemaIO, Schemas, TaskError, User, UserWithDetails, WriftAIClientOptions };
1518
+ export type { BaseUser, Compatibilities, FileUrls, Hardware, Model, ModelCategory, ModelCategoryWithDetails, ModelVersion, ModelVersionConfiguration, ModelVersionWithDetails, ModelVersionWithDetailsAndConfiguration, ModelWithDetails, PaginatedResponse, Prediction, PredictionModel, PredictionWithIO, SchemaIO, Schemas, TaskError, Upload, UploadCompletionResult, User, UserWithDetails, Variable, WriftAIClientOptions };