wriftai 0.30.0 → 0.33.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
@@ -15,7 +15,7 @@ type SchemaIO = {
15
15
  output: Record<string, JsonValue>;
16
16
  };
17
17
  /**
18
- * Represents schemas of a version.
18
+ * Represents schemas of a model version.
19
19
  */
20
20
  type Schemas = {
21
21
  /**
@@ -24,30 +24,35 @@ type Schemas = {
24
24
  prediction: SchemaIO;
25
25
  };
26
26
  /**
27
- * Represents a version.
27
+ * Represents a model version.
28
28
  */
29
- interface Version {
29
+ interface ModelVersion {
30
30
  /**
31
- * Unique identifier for the version.
31
+ * The number of the model version.
32
32
  */
33
- id: string;
33
+ number: number;
34
34
  /**
35
35
  * Information about changes such as new features, bug fixes,
36
- * or optimizations in this version.
36
+ * or optimizations in this model version.
37
37
  */
38
38
  release_notes: string;
39
39
  /**
40
- * The time when the version was created.
40
+ * The time when the model version was created.
41
41
  */
42
42
  created_at: string;
43
43
  /**
44
- * The schemas of the model version.
44
+ * A sha256 hash digest of the model version's container image.
45
45
  */
46
- schemas: Schemas;
46
+ container_image_digest: string;
47
+ }
48
+ /**
49
+ * Represents a model version with details.
50
+ */
51
+ interface ModelVersionWithDetails extends ModelVersion {
47
52
  /**
48
- * A sha256 hash digest of the version's container image.
53
+ * The schemas of the model version.
49
54
  */
50
- container_image_digest: string;
55
+ schemas: Schemas;
51
56
  }
52
57
  /**
53
58
  * Represents a user.
@@ -65,6 +70,11 @@ interface User {
65
70
  * URL of the user's avatar.
66
71
  */
67
72
  avatar_url: string;
73
+ }
74
+ /**
75
+ * Represents a user with details.
76
+ */
77
+ interface UserWithDetails extends User {
68
78
  /**
69
79
  * The name of the user.
70
80
  */
@@ -154,10 +164,6 @@ interface Model {
154
164
  * The details of the owner of the model.
155
165
  */
156
166
  owner: User;
157
- /**
158
- * The details of the latest version of the model.
159
- */
160
- latest_version: Version | null;
161
167
  /**
162
168
  * The hardware used by the model.
163
169
  */
@@ -166,6 +172,10 @@ interface Model {
166
172
  * The total number of predictions created across all versions of the model.
167
173
  */
168
174
  predictions_count: number;
175
+ /**
176
+ * The categories associated with the model.
177
+ */
178
+ categories: ModelCategory[];
169
179
  }
170
180
  /** Pagination options interface */
171
181
  type PaginationOptions = {
@@ -194,6 +204,19 @@ declare enum SortDirection {
194
204
  asc = "asc",
195
205
  desc = "desc"
196
206
  }
207
+ /**
208
+ * Represents a model category.
209
+ */
210
+ interface ModelCategory {
211
+ /**
212
+ * Name of the model category.
213
+ */
214
+ name: string;
215
+ /**
216
+ * Slug of the model category.
217
+ */
218
+ slug: string;
219
+ }
197
220
 
198
221
  /**
199
222
  * Representation of an error from WriftAI's API.
@@ -244,46 +267,27 @@ declare class API {
244
267
  */
245
268
  request<T>(path: string, options: {
246
269
  method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
247
- params?: Record<string, string | number | boolean>;
270
+ params?: Record<string, string | number | boolean | string[]>;
248
271
  body?: JsonValue;
249
272
  headers?: Record<string, string>;
250
273
  signal?: AbortSignal;
251
274
  }): Promise<T>;
252
275
  }
253
276
 
254
- /**
255
- * Error thrown when a model reference is not in owner/name format.
256
- */
257
- declare class InvalidModelReferenceError extends Error {
258
- /**
259
- * Creates an instance of the error.
260
- * @param model The model reference.
261
- */
262
- constructor(model: string);
263
- }
264
277
  /**
265
278
  * Abstract base class for WriftAI API resources.
266
279
  */
267
280
  declare abstract class Resource {
268
281
  protected api: API;
269
282
  protected readonly MODELS_API_PREFIX = "/models";
270
- protected readonly VERSIONS_API_PREFIX = "/versions";
271
283
  protected readonly SEARCH_API_PREFIX = "/search";
284
+ protected readonly MODEL_VERSION_PATH = "/versions";
272
285
  /**
273
286
  * Create a new resource.
274
287
  * @param api API client instance used to
275
288
  * communicate with WriftAI's API.
276
289
  */
277
290
  constructor(api: API);
278
- /**
279
- * Parses model reference into owner and name.
280
- * @param model The model reference in owner/name format
281
- * (for example: deepseek-ai/deepseek-r1).
282
- * @returns A tuple containing owner and name of the model.
283
- * @throws {InvalidModelReferenceError} When the provided
284
- * model reference is not in owner/name format.
285
- */
286
- protected parseModel(model: string): [owner: string, name: string];
287
291
  }
288
292
 
289
293
  /**
@@ -310,6 +314,23 @@ interface TaskError {
310
314
  message: string;
311
315
  detail: JsonValue;
312
316
  }
317
+ /**
318
+ * Represents the prediction model.
319
+ */
320
+ interface PredictionModel {
321
+ /**
322
+ * Username of the model's owner.
323
+ */
324
+ owner: string;
325
+ /**
326
+ * Name of the model.
327
+ */
328
+ name: string;
329
+ /**
330
+ * Version number of the model.
331
+ */
332
+ version_number: number;
333
+ }
313
334
  /**
314
335
  * Represents a prediction.
315
336
  */
@@ -322,10 +343,6 @@ interface Prediction {
322
343
  * Unique identifier for the prediction.
323
344
  */
324
345
  id: string;
325
- /**
326
- * Identifier of the model version used.
327
- */
328
- version_id: string;
329
346
  /**
330
347
  * Timestamp when the prediction was created.
331
348
  */
@@ -351,13 +368,9 @@ interface Prediction {
351
368
  */
352
369
  execution_time: string | null;
353
370
  /**
354
- * Identifier of the hardware used for prediction.
355
- */
356
- hardware_id: string;
357
- /**
358
- * Error details if the prediction failed.
371
+ * The model of the prediction.
359
372
  */
360
- error: TaskError | null;
373
+ model: PredictionModel;
361
374
  }
362
375
  /**
363
376
  * Represents a prediction with I/O details.
@@ -379,6 +392,10 @@ interface PredictionWithIO extends Prediction {
379
392
  * Logs generated during setup.
380
393
  */
381
394
  setup_logs: string[] | null;
395
+ /**
396
+ * Error details if the prediction failed.
397
+ */
398
+ error: TaskError | null;
382
399
  }
383
400
  /**
384
401
  * Prediction creation parameters.
@@ -396,32 +413,12 @@ interface CreatePredictionParams {
396
413
  * Enable input validation against the schema before processing.
397
414
  */
398
415
  validate_input?: boolean;
399
- }
400
- /**
401
- * Options for creating a prediction using the latest version of a model.
402
- */
403
- type ModelOptions = {
404
416
  /**
405
- * The model reference in owner/name format
406
- * (for example: deepseek-ai/deepseek-r1).
417
+ * The model reference in either owner/name or owner/name:version-number
418
+ * format (for example: deepseek-ai/deepseek-r1 or deepseek-ai/deepseek-r1:1).
407
419
  */
408
420
  model: string;
409
- };
410
- /**
411
- * Options for creating a prediction using a specific version of a model.
412
- */
413
- type VersionOptions = {
414
- /**
415
- * Unique identifier of the model's version.
416
- */
417
- version_id: string;
418
- };
419
- /**
420
- * Union type for prediction creation options.
421
- * Accepts either model or a version_id,
422
- * along with prediction creation parameters.
423
- */
424
- type CreateOptions = (ModelOptions | VersionOptions) & CreatePredictionParams;
421
+ }
425
422
  /**
426
423
  * Options for customizing wait behaviour.
427
424
  */
@@ -442,12 +439,21 @@ interface WaitOptions {
442
439
  declare const DEFAULT_WAIT_OPTIONS: {
443
440
  pollInterval: number;
444
441
  };
442
+ /**
443
+ * Error thrown when a model reference is not in owner/name format.
444
+ */
445
+ declare class InvalidModelReferenceError extends Error {
446
+ /**
447
+ * Creates an instance of the error.
448
+ * @param model The model reference.
449
+ */
450
+ constructor(model: string);
451
+ }
445
452
  /**
446
453
  * Resource class for interacting with predictions.
447
454
  */
448
455
  declare class PredictionsResource extends Resource {
449
456
  private readonly PREDICTIONS_API_PREFIX;
450
- private readonly ERROR_MSG_INVALID_PREDICTION_PARAMS;
451
457
  /**
452
458
  * Get a prediction by its ID.
453
459
  * @param id The ID of the prediction to fetch.
@@ -455,14 +461,24 @@ declare class PredictionsResource extends Resource {
455
461
  * @returns The prediction object.
456
462
  */
457
463
  get(id: string, signal?: AbortSignal): Promise<PredictionWithIO>;
464
+ /**
465
+ * Parses model reference into owner, name, and version number.
466
+ * @param model The model reference in either owner/name or
467
+ * owner/name:version-number format (for example: deepseek-ai/deepseek-r1
468
+ * or deepseek-ai/deepseek-r1:1).
469
+ * @returns A tuple containing owner, name, and version number of the model.
470
+ * @throws {InvalidModelReferenceError} When the provided model
471
+ * reference is not in owner/name or owner/name:version-number format.
472
+ */
473
+ private parseModel;
458
474
  /**
459
475
  * Constructs the API path to create a prediction.
460
- * @param options Options for prediction creation.
476
+ * @param model The model reference in either owner/name or
477
+ * owner/name:version-number format (for example: deepseek-ai/deepseek-r1
478
+ * or deepseek-ai/deepseek-r1:1).
461
479
  * @returns The API path.
462
- * @throws {TypeError} When an invalid combination of version_id and
463
- * model is provided.
464
480
  * @throws {InvalidModelReferenceError} When the provided model
465
- * reference is not in owner/name format.
481
+ * reference is not in owner/name or owner/name:version_number format.
466
482
  */
467
483
  private predictionPath;
468
484
  /**
@@ -476,12 +492,10 @@ declare class PredictionsResource extends Resource {
476
492
  * {@link DEFAULT_WAIT_OPTIONS} are used.
477
493
  * @param signal Optional AbortSignal to cancel the request.
478
494
  * @returns The new prediction.
479
- * @throws {TypeError} When an invalid combination of version_id,
480
- * and model is provided.
481
495
  * @throws {InvalidModelReferenceError} When the provided model
482
- * reference is not in owner/name format.
496
+ * reference is not in owner/name or owner/name:version_number format.
483
497
  */
484
- create(options: CreateOptions, wait?: boolean, waitOptions?: WaitOptions, signal?: AbortSignal): Promise<PredictionWithIO>;
498
+ create(options: CreatePredictionParams, wait?: boolean, waitOptions?: WaitOptions, signal?: AbortSignal): Promise<PredictionWithIO>;
485
499
  /**
486
500
  * List predictions.
487
501
  * @param options Optional settings to control pagination behavior.
@@ -535,6 +549,14 @@ type UpdateModelParams = {
535
549
  * Paper url from where research info on the model can be found.
536
550
  */
537
551
  paper_url?: string | null;
552
+ /**
553
+ * The overview of the model.
554
+ */
555
+ overview?: string | null;
556
+ /**
557
+ * List of model category slugs.
558
+ */
559
+ category_slugs?: string[];
538
560
  };
539
561
  /**
540
562
  * Parameters for creating a model.
@@ -568,7 +590,28 @@ type CreateModelParams = {
568
590
  * Paper url from where research info on the model can be found.
569
591
  */
570
592
  paper_url?: string;
593
+ /**
594
+ * The overview of the model.
595
+ */
596
+ overview?: string | null;
597
+ /**
598
+ * List of model category slugs.
599
+ */
600
+ category_slugs?: string[];
571
601
  };
602
+ /**
603
+ * Represents a model with details.
604
+ */
605
+ interface ModelWithDetails extends Model {
606
+ /**
607
+ * The overview of the model.
608
+ */
609
+ overview: string | null;
610
+ /**
611
+ * The details of the latest version of the model.
612
+ */
613
+ latest_version: ModelVersionWithDetails | null;
614
+ }
572
615
  /**
573
616
  * Enumeration of possible sorting options for querying models.
574
617
  */
@@ -586,6 +629,10 @@ type ModelPaginationOptions = PaginationOptions & {
586
629
  * The sorting direction
587
630
  */
588
631
  sort_direction?: SortDirection;
632
+ /**
633
+ * The list of category slugs to filter models.
634
+ */
635
+ category_slugs?: string[];
589
636
  };
590
637
  /**
591
638
  * Resource for operations related to models.
@@ -604,7 +651,7 @@ declare class Models extends Resource {
604
651
  * @param signal Optional AbortSignal to cancel the request.
605
652
  * @returns The new model.
606
653
  */
607
- create(options: CreateModelParams, signal?: AbortSignal): Promise<Model>;
654
+ create(options: CreateModelParams, signal?: AbortSignal): Promise<ModelWithDetails>;
608
655
  /**
609
656
  * Get a model.
610
657
  * @param owner Username of the model's owner.
@@ -612,7 +659,7 @@ declare class Models extends Resource {
612
659
  * @param signal Optional AbortSignal to cancel the request.
613
660
  * @returns A model object.
614
661
  */
615
- get(owner: string, name: string, signal?: AbortSignal): Promise<Model>;
662
+ get(owner: string, name: string, signal?: AbortSignal): Promise<ModelWithDetails>;
616
663
  /**
617
664
  * Constructs the API path for listing models.
618
665
  * @param owner - Username of the model's owner to fetch models for.
@@ -637,7 +684,7 @@ declare class Models extends Resource {
637
684
  * @param signal Optional AbortSignal to cancel the request.
638
685
  * @returns The updated model.
639
686
  */
640
- update(owner: string, name: string, params: UpdateModelParams, signal?: AbortSignal): Promise<Model>;
687
+ update(owner: string, name: string, params: UpdateModelParams, signal?: AbortSignal): Promise<ModelWithDetails>;
641
688
  /**
642
689
  * Search models.
643
690
  * @param q The search query.
@@ -676,14 +723,14 @@ declare class Users extends Resource {
676
723
  * @param signal Optional AbortSignal to cancel the request.
677
724
  * @returns The user object.
678
725
  */
679
- get(username: string, signal?: AbortSignal): Promise<User>;
726
+ get(username: string, signal?: AbortSignal): Promise<UserWithDetails>;
680
727
  /**
681
728
  * List users.
682
729
  * @param options Optional settings to control pagination behavior.
683
730
  * @param signal Optional AbortSignal to cancel the request.
684
731
  * @returns Paginated response containing users and navigation metadata.
685
732
  */
686
- list(options?: UserPaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<User>>;
733
+ list(options?: UserPaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<UserWithDetails>>;
687
734
  /**
688
735
  * Search users.
689
736
  * @param q The search query.
@@ -691,7 +738,7 @@ declare class Users extends Resource {
691
738
  * @param signal Optional AbortSignal to cancel the request.
692
739
  * @returns Paginated response containing users and navigation metadata.
693
740
  */
694
- search(q: string, options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<User>>;
741
+ search(q: string, options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<UserWithDetails>>;
695
742
  }
696
743
 
697
744
  /**
@@ -722,13 +769,36 @@ declare class HardwareResource extends Resource {
722
769
  list(options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<Hardware>>;
723
770
  }
724
771
 
772
+ /**
773
+ * Represents a model category with details.
774
+ */
775
+ interface ModelCategoryWithDetails extends ModelCategory {
776
+ /**
777
+ * Description of the model category.
778
+ */
779
+ description: string;
780
+ }
781
+ /**
782
+ * Resource for operations related to model categories.
783
+ */
784
+ declare class ModelCategories extends Resource {
785
+ /**
786
+ * List model categories.
787
+ * @param options Optional settings to control pagiantion behavior.
788
+ * @param signal Optional AbortSignal to cancel request.
789
+ * @returns Paginated response containing model categories and
790
+ * navigation metadata.
791
+ */
792
+ list(options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<ModelCategoryWithDetails>>;
793
+ }
794
+
725
795
  /**
726
796
  * Parameters for creating a version of a model.
727
797
  */
728
- type CreateVersionParams = {
798
+ type CreateModelVersionParams = {
729
799
  /**
730
800
  * Information about changes such as new features,
731
- * bug fixes, or optimizations in this version.
801
+ * bug fixes, or optimizations in this model version.
732
802
  */
733
803
  release_notes: string;
734
804
  /**
@@ -736,45 +806,49 @@ type CreateVersionParams = {
736
806
  */
737
807
  schemas: Schemas;
738
808
  /**
739
- * A sha256 hash digest of the version's container image.
809
+ * A sha256 hash digest of the model version's container image.
740
810
  */
741
811
  container_image_digest: string;
742
812
  };
743
813
  /**
744
814
  * Resource class for interacting with model versions.
745
815
  */
746
- declare class Versions extends Resource {
816
+ declare class ModelVersions extends Resource {
747
817
  /**
748
- * Get a model version by its ID.
749
- * @param id The ID of the model version to retrieve.
818
+ * Get a model version by its owner, name, and version number.
819
+ * @param modelOwner Username of the model's owner.
820
+ * @param modelName Name of the model.
821
+ * @param number The number of the model version.
750
822
  * @param signal Optional AbortSignal to cancel the request.
751
823
  * @returns The model version object.
752
824
  */
753
- get(id: string, signal?: AbortSignal): Promise<Version>;
825
+ get(modelOwner: string, modelName: string, number: number, signal?: AbortSignal): Promise<ModelVersionWithDetails>;
754
826
  /**
755
827
  * Create a version of a model.
756
828
  * @param modelOwner The username of the model's owner.
757
829
  * @param modelName The name of the model.
758
- * @param params Version creation parameters.
830
+ * @param params Model version creation parameters.
759
831
  * @param signal Optional AbortSignal to cancel the request.
760
832
  * @returns The new version object.
761
833
  */
762
- create(modelOwner: string, modelName: string, params: CreateVersionParams, signal?: AbortSignal): Promise<Version>;
834
+ create(modelOwner: string, modelName: string, params: CreateModelVersionParams, signal?: AbortSignal): Promise<ModelVersionWithDetails>;
763
835
  /**
764
- * Delete a model version by its ID.
765
- * @param id The ID of the model version to delete.
836
+ * Delete a model version by its owner, name, and version number.
837
+ * @param modelOwner Username of the model's owner.
838
+ * @param modelName Name of the model.
839
+ * @param number The number of the model version.
766
840
  * @param signal Optional AbortSignal to cancel the request.
767
841
  */
768
- delete(id: string, signal?: AbortSignal): Promise<void>;
842
+ delete(modelOwner: string, modelName: string, number: number, signal?: AbortSignal): Promise<void>;
769
843
  /**
770
- * List versions.
844
+ * List model versions.
771
845
  * @param modelOwner Username of the model's owner.
772
846
  * @param modelName Name of the model.
773
847
  * @param options Pagination options.
774
848
  * @param signal Optional AbortSignal to cancel the request.
775
849
  * @returns A paginated response containing model versions.
776
850
  */
777
- list(modelOwner: string, modelName: string, options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<Version>>;
851
+ list(modelOwner: string, modelName: string, options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<ModelVersion>>;
778
852
  }
779
853
 
780
854
  /**
@@ -816,14 +890,14 @@ declare class AuthenticatedUser extends Resource {
816
890
  * @param signal - Optional AbortSignal to cancel the request.
817
891
  * @returns The user object.
818
892
  */
819
- get(signal?: AbortSignal): Promise<User>;
893
+ get(signal?: AbortSignal): Promise<UserWithDetails>;
820
894
  /**
821
895
  * Update the authenticated user.
822
896
  * @param params - The fields to update.
823
897
  * @param signal - Optional AbortSignal to cancel the request.
824
898
  * @returns The updated user object.
825
899
  */
826
- update(params: UpdateUserParams, signal?: AbortSignal): Promise<User>;
900
+ update(params: UpdateUserParams, signal?: AbortSignal): Promise<UserWithDetails>;
827
901
  /**
828
902
  * List models of the authenticated user.
829
903
  * @param options - Optional settings to control pagination behavior.
@@ -867,10 +941,10 @@ declare class WriftAI {
867
941
  */
868
942
  predictions: PredictionsResource;
869
943
  /**
870
- * Interface for accessing version related
944
+ * Interface for accessing model version related
871
945
  * resources and operations.
872
946
  */
873
- versions: Versions;
947
+ modelVersions: ModelVersions;
874
948
  /**
875
949
  * Interface for accessing user related
876
950
  * resources and operations.
@@ -887,6 +961,11 @@ declare class WriftAI {
887
961
  * resources and operations
888
962
  */
889
963
  hardware: HardwareResource;
964
+ /**
965
+ * Interface for accessing model categories related
966
+ * reources and operations.
967
+ */
968
+ modelCategories: ModelCategories;
890
969
  /**
891
970
  * Create an instance of the WriftAI client.
892
971
  * @param options Client options
@@ -904,4 +983,4 @@ declare class WriftAI {
904
983
  }
905
984
 
906
985
  export { DEFAULT_WAIT_OPTIONS, ErrorSource, InvalidModelReferenceError, ModelVisibility, ModelsSortBy, SortDirection, Status, UsersSortBy, WriftAI, WriftAIAPIError };
907
- export type { HardwareWithDetails, Model, PaginatedResponse, Prediction, PredictionWithIO, SchemaIO, Schemas, TaskError, User, Version, WriftAIClientOptions };
986
+ export type { HardwareWithDetails, Model, ModelCategory, ModelCategoryWithDetails, ModelVersion, ModelVersionWithDetails, ModelWithDetails, PaginatedResponse, Prediction, PredictionModel, PredictionWithIO, SchemaIO, Schemas, TaskError, User, UserWithDetails, WriftAIClientOptions };