wriftai 0.30.0 → 0.32.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
  */
@@ -251,39 +257,20 @@ declare class API {
251
257
  }): Promise<T>;
252
258
  }
253
259
 
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
260
  /**
265
261
  * Abstract base class for WriftAI API resources.
266
262
  */
267
263
  declare abstract class Resource {
268
264
  protected api: API;
269
265
  protected readonly MODELS_API_PREFIX = "/models";
270
- protected readonly VERSIONS_API_PREFIX = "/versions";
271
266
  protected readonly SEARCH_API_PREFIX = "/search";
267
+ protected readonly MODEL_VERSION_PATH = "/versions";
272
268
  /**
273
269
  * Create a new resource.
274
270
  * @param api API client instance used to
275
271
  * communicate with WriftAI's API.
276
272
  */
277
273
  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
274
  }
288
275
 
289
276
  /**
@@ -310,6 +297,23 @@ interface TaskError {
310
297
  message: string;
311
298
  detail: JsonValue;
312
299
  }
300
+ /**
301
+ * Represents the prediction model.
302
+ */
303
+ interface PredictionModel {
304
+ /**
305
+ * Username of the model's owner.
306
+ */
307
+ owner: string;
308
+ /**
309
+ * Name of the model.
310
+ */
311
+ name: string;
312
+ /**
313
+ * Version number of the model.
314
+ */
315
+ version_number: number;
316
+ }
313
317
  /**
314
318
  * Represents a prediction.
315
319
  */
@@ -322,10 +326,6 @@ interface Prediction {
322
326
  * Unique identifier for the prediction.
323
327
  */
324
328
  id: string;
325
- /**
326
- * Identifier of the model version used.
327
- */
328
- version_id: string;
329
329
  /**
330
330
  * Timestamp when the prediction was created.
331
331
  */
@@ -351,13 +351,9 @@ interface Prediction {
351
351
  */
352
352
  execution_time: string | null;
353
353
  /**
354
- * Identifier of the hardware used for prediction.
354
+ * The model of the prediction.
355
355
  */
356
- hardware_id: string;
357
- /**
358
- * Error details if the prediction failed.
359
- */
360
- error: TaskError | null;
356
+ model: PredictionModel;
361
357
  }
362
358
  /**
363
359
  * Represents a prediction with I/O details.
@@ -379,6 +375,10 @@ interface PredictionWithIO extends Prediction {
379
375
  * Logs generated during setup.
380
376
  */
381
377
  setup_logs: string[] | null;
378
+ /**
379
+ * Error details if the prediction failed.
380
+ */
381
+ error: TaskError | null;
382
382
  }
383
383
  /**
384
384
  * Prediction creation parameters.
@@ -396,32 +396,12 @@ interface CreatePredictionParams {
396
396
  * Enable input validation against the schema before processing.
397
397
  */
398
398
  validate_input?: boolean;
399
- }
400
- /**
401
- * Options for creating a prediction using the latest version of a model.
402
- */
403
- type ModelOptions = {
404
399
  /**
405
- * The model reference in owner/name format
406
- * (for example: deepseek-ai/deepseek-r1).
400
+ * The model reference in either owner/name or owner/name:version-number
401
+ * format (for example: deepseek-ai/deepseek-r1 or deepseek-ai/deepseek-r1:1).
407
402
  */
408
403
  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;
404
+ }
425
405
  /**
426
406
  * Options for customizing wait behaviour.
427
407
  */
@@ -442,12 +422,21 @@ interface WaitOptions {
442
422
  declare const DEFAULT_WAIT_OPTIONS: {
443
423
  pollInterval: number;
444
424
  };
425
+ /**
426
+ * Error thrown when a model reference is not in owner/name format.
427
+ */
428
+ declare class InvalidModelReferenceError extends Error {
429
+ /**
430
+ * Creates an instance of the error.
431
+ * @param model The model reference.
432
+ */
433
+ constructor(model: string);
434
+ }
445
435
  /**
446
436
  * Resource class for interacting with predictions.
447
437
  */
448
438
  declare class PredictionsResource extends Resource {
449
439
  private readonly PREDICTIONS_API_PREFIX;
450
- private readonly ERROR_MSG_INVALID_PREDICTION_PARAMS;
451
440
  /**
452
441
  * Get a prediction by its ID.
453
442
  * @param id The ID of the prediction to fetch.
@@ -455,14 +444,24 @@ declare class PredictionsResource extends Resource {
455
444
  * @returns The prediction object.
456
445
  */
457
446
  get(id: string, signal?: AbortSignal): Promise<PredictionWithIO>;
447
+ /**
448
+ * Parses model reference into owner, name, and version number.
449
+ * @param model The model reference in either owner/name or
450
+ * owner/name:version-number format (for example: deepseek-ai/deepseek-r1
451
+ * or deepseek-ai/deepseek-r1:1).
452
+ * @returns A tuple containing owner, name, and version number of the model.
453
+ * @throws {InvalidModelReferenceError} When the provided model
454
+ * reference is not in owner/name or owner/name:version-number format.
455
+ */
456
+ private parseModel;
458
457
  /**
459
458
  * Constructs the API path to create a prediction.
460
- * @param options Options for prediction creation.
459
+ * @param model The model reference in either owner/name or
460
+ * owner/name:version-number format (for example: deepseek-ai/deepseek-r1
461
+ * or deepseek-ai/deepseek-r1:1).
461
462
  * @returns The API path.
462
- * @throws {TypeError} When an invalid combination of version_id and
463
- * model is provided.
464
463
  * @throws {InvalidModelReferenceError} When the provided model
465
- * reference is not in owner/name format.
464
+ * reference is not in owner/name or owner/name:version_number format.
466
465
  */
467
466
  private predictionPath;
468
467
  /**
@@ -476,12 +475,10 @@ declare class PredictionsResource extends Resource {
476
475
  * {@link DEFAULT_WAIT_OPTIONS} are used.
477
476
  * @param signal Optional AbortSignal to cancel the request.
478
477
  * @returns The new prediction.
479
- * @throws {TypeError} When an invalid combination of version_id,
480
- * and model is provided.
481
478
  * @throws {InvalidModelReferenceError} When the provided model
482
- * reference is not in owner/name format.
479
+ * reference is not in owner/name or owner/name:version_number format.
483
480
  */
484
- create(options: CreateOptions, wait?: boolean, waitOptions?: WaitOptions, signal?: AbortSignal): Promise<PredictionWithIO>;
481
+ create(options: CreatePredictionParams, wait?: boolean, waitOptions?: WaitOptions, signal?: AbortSignal): Promise<PredictionWithIO>;
485
482
  /**
486
483
  * List predictions.
487
484
  * @param options Optional settings to control pagination behavior.
@@ -535,6 +532,10 @@ type UpdateModelParams = {
535
532
  * Paper url from where research info on the model can be found.
536
533
  */
537
534
  paper_url?: string | null;
535
+ /**
536
+ * The overview of the model.
537
+ */
538
+ overview?: string | null;
538
539
  };
539
540
  /**
540
541
  * Parameters for creating a model.
@@ -568,7 +569,24 @@ type CreateModelParams = {
568
569
  * Paper url from where research info on the model can be found.
569
570
  */
570
571
  paper_url?: string;
572
+ /**
573
+ * The overview of the model.
574
+ */
575
+ overview?: string | null;
571
576
  };
577
+ /**
578
+ * Represents a model with details.
579
+ */
580
+ interface ModelWithDetails extends Model {
581
+ /**
582
+ * The overview of the model.
583
+ */
584
+ overview: string | null;
585
+ /**
586
+ * The details of the latest version of the model.
587
+ */
588
+ latest_version: ModelVersionWithDetails | null;
589
+ }
572
590
  /**
573
591
  * Enumeration of possible sorting options for querying models.
574
592
  */
@@ -604,7 +622,7 @@ declare class Models extends Resource {
604
622
  * @param signal Optional AbortSignal to cancel the request.
605
623
  * @returns The new model.
606
624
  */
607
- create(options: CreateModelParams, signal?: AbortSignal): Promise<Model>;
625
+ create(options: CreateModelParams, signal?: AbortSignal): Promise<ModelWithDetails>;
608
626
  /**
609
627
  * Get a model.
610
628
  * @param owner Username of the model's owner.
@@ -612,7 +630,7 @@ declare class Models extends Resource {
612
630
  * @param signal Optional AbortSignal to cancel the request.
613
631
  * @returns A model object.
614
632
  */
615
- get(owner: string, name: string, signal?: AbortSignal): Promise<Model>;
633
+ get(owner: string, name: string, signal?: AbortSignal): Promise<ModelWithDetails>;
616
634
  /**
617
635
  * Constructs the API path for listing models.
618
636
  * @param owner - Username of the model's owner to fetch models for.
@@ -637,7 +655,7 @@ declare class Models extends Resource {
637
655
  * @param signal Optional AbortSignal to cancel the request.
638
656
  * @returns The updated model.
639
657
  */
640
- update(owner: string, name: string, params: UpdateModelParams, signal?: AbortSignal): Promise<Model>;
658
+ update(owner: string, name: string, params: UpdateModelParams, signal?: AbortSignal): Promise<ModelWithDetails>;
641
659
  /**
642
660
  * Search models.
643
661
  * @param q The search query.
@@ -676,14 +694,14 @@ declare class Users extends Resource {
676
694
  * @param signal Optional AbortSignal to cancel the request.
677
695
  * @returns The user object.
678
696
  */
679
- get(username: string, signal?: AbortSignal): Promise<User>;
697
+ get(username: string, signal?: AbortSignal): Promise<UserWithDetails>;
680
698
  /**
681
699
  * List users.
682
700
  * @param options Optional settings to control pagination behavior.
683
701
  * @param signal Optional AbortSignal to cancel the request.
684
702
  * @returns Paginated response containing users and navigation metadata.
685
703
  */
686
- list(options?: UserPaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<User>>;
704
+ list(options?: UserPaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<UserWithDetails>>;
687
705
  /**
688
706
  * Search users.
689
707
  * @param q The search query.
@@ -691,7 +709,7 @@ declare class Users extends Resource {
691
709
  * @param signal Optional AbortSignal to cancel the request.
692
710
  * @returns Paginated response containing users and navigation metadata.
693
711
  */
694
- search(q: string, options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<User>>;
712
+ search(q: string, options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<UserWithDetails>>;
695
713
  }
696
714
 
697
715
  /**
@@ -722,13 +740,44 @@ declare class HardwareResource extends Resource {
722
740
  list(options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<Hardware>>;
723
741
  }
724
742
 
743
+ /**
744
+ * Represents a model category.
745
+ */
746
+ interface ModelCategory {
747
+ /**
748
+ * Name of the model category.
749
+ */
750
+ name: string;
751
+ /**
752
+ * Slug of the model category.
753
+ */
754
+ slug: string;
755
+ /**
756
+ * Description of the model category.
757
+ */
758
+ description: string;
759
+ }
760
+ /**
761
+ * Resource for operations related to model categories.
762
+ */
763
+ declare class ModelCategories extends Resource {
764
+ /**
765
+ * List model categories.
766
+ * @param options Optional settings to control pagiantion behavior.
767
+ * @param signal Optional AbortSignal to cancel request.
768
+ * @returns Paginated response containing model categories and
769
+ * navigation metadata.
770
+ */
771
+ list(options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<ModelCategory>>;
772
+ }
773
+
725
774
  /**
726
775
  * Parameters for creating a version of a model.
727
776
  */
728
- type CreateVersionParams = {
777
+ type CreateModelVersionParams = {
729
778
  /**
730
779
  * Information about changes such as new features,
731
- * bug fixes, or optimizations in this version.
780
+ * bug fixes, or optimizations in this model version.
732
781
  */
733
782
  release_notes: string;
734
783
  /**
@@ -736,45 +785,49 @@ type CreateVersionParams = {
736
785
  */
737
786
  schemas: Schemas;
738
787
  /**
739
- * A sha256 hash digest of the version's container image.
788
+ * A sha256 hash digest of the model version's container image.
740
789
  */
741
790
  container_image_digest: string;
742
791
  };
743
792
  /**
744
793
  * Resource class for interacting with model versions.
745
794
  */
746
- declare class Versions extends Resource {
795
+ declare class ModelVersions extends Resource {
747
796
  /**
748
- * Get a model version by its ID.
749
- * @param id The ID of the model version to retrieve.
797
+ * Get a model version by its owner, name, and version number.
798
+ * @param modelOwner Username of the model's owner.
799
+ * @param modelName Name of the model.
800
+ * @param number The number of the model version.
750
801
  * @param signal Optional AbortSignal to cancel the request.
751
802
  * @returns The model version object.
752
803
  */
753
- get(id: string, signal?: AbortSignal): Promise<Version>;
804
+ get(modelOwner: string, modelName: string, number: number, signal?: AbortSignal): Promise<ModelVersionWithDetails>;
754
805
  /**
755
806
  * Create a version of a model.
756
807
  * @param modelOwner The username of the model's owner.
757
808
  * @param modelName The name of the model.
758
- * @param params Version creation parameters.
809
+ * @param params Model version creation parameters.
759
810
  * @param signal Optional AbortSignal to cancel the request.
760
811
  * @returns The new version object.
761
812
  */
762
- create(modelOwner: string, modelName: string, params: CreateVersionParams, signal?: AbortSignal): Promise<Version>;
813
+ create(modelOwner: string, modelName: string, params: CreateModelVersionParams, signal?: AbortSignal): Promise<ModelVersionWithDetails>;
763
814
  /**
764
- * Delete a model version by its ID.
765
- * @param id The ID of the model version to delete.
815
+ * Delete a model version by its owner, name, and version number.
816
+ * @param modelOwner Username of the model's owner.
817
+ * @param modelName Name of the model.
818
+ * @param number The number of the model version.
766
819
  * @param signal Optional AbortSignal to cancel the request.
767
820
  */
768
- delete(id: string, signal?: AbortSignal): Promise<void>;
821
+ delete(modelOwner: string, modelName: string, number: number, signal?: AbortSignal): Promise<void>;
769
822
  /**
770
- * List versions.
823
+ * List model versions.
771
824
  * @param modelOwner Username of the model's owner.
772
825
  * @param modelName Name of the model.
773
826
  * @param options Pagination options.
774
827
  * @param signal Optional AbortSignal to cancel the request.
775
828
  * @returns A paginated response containing model versions.
776
829
  */
777
- list(modelOwner: string, modelName: string, options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<Version>>;
830
+ list(modelOwner: string, modelName: string, options?: PaginationOptions, signal?: AbortSignal): Promise<PaginatedResponse<ModelVersion>>;
778
831
  }
779
832
 
780
833
  /**
@@ -816,14 +869,14 @@ declare class AuthenticatedUser extends Resource {
816
869
  * @param signal - Optional AbortSignal to cancel the request.
817
870
  * @returns The user object.
818
871
  */
819
- get(signal?: AbortSignal): Promise<User>;
872
+ get(signal?: AbortSignal): Promise<UserWithDetails>;
820
873
  /**
821
874
  * Update the authenticated user.
822
875
  * @param params - The fields to update.
823
876
  * @param signal - Optional AbortSignal to cancel the request.
824
877
  * @returns The updated user object.
825
878
  */
826
- update(params: UpdateUserParams, signal?: AbortSignal): Promise<User>;
879
+ update(params: UpdateUserParams, signal?: AbortSignal): Promise<UserWithDetails>;
827
880
  /**
828
881
  * List models of the authenticated user.
829
882
  * @param options - Optional settings to control pagination behavior.
@@ -867,10 +920,10 @@ declare class WriftAI {
867
920
  */
868
921
  predictions: PredictionsResource;
869
922
  /**
870
- * Interface for accessing version related
923
+ * Interface for accessing model version related
871
924
  * resources and operations.
872
925
  */
873
- versions: Versions;
926
+ modelVersions: ModelVersions;
874
927
  /**
875
928
  * Interface for accessing user related
876
929
  * resources and operations.
@@ -887,6 +940,11 @@ declare class WriftAI {
887
940
  * resources and operations
888
941
  */
889
942
  hardware: HardwareResource;
943
+ /**
944
+ * Interface for accessing model categories related
945
+ * reources and operations.
946
+ */
947
+ modelCategories: ModelCategories;
890
948
  /**
891
949
  * Create an instance of the WriftAI client.
892
950
  * @param options Client options
@@ -904,4 +962,4 @@ declare class WriftAI {
904
962
  }
905
963
 
906
964
  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 };
965
+ export type { HardwareWithDetails, Model, ModelCategory, ModelVersion, ModelVersionWithDetails, ModelWithDetails, PaginatedResponse, Prediction, PredictionModel, PredictionWithIO, SchemaIO, Schemas, TaskError, User, UserWithDetails, WriftAIClientOptions };