1
1
type Identifier = `${string } /${string } :${string } `;
2
- type WebhookEventType = " start" | " output" | " logs" | " completed" ;
2
+ type WebhookEventType = ' start' | ' output' | ' logs' | ' completed' ;
3
3
4
- declare module "replicate" {
5
- export interface ReplicateOptions {
6
- auth : string ;
7
- userAgent ?: string ;
8
- baseUrl ?: string ;
9
- }
4
+ interface Page < T > {
5
+ previous ?: string ;
6
+ next ?: string ;
7
+ results : T [ ] ;
8
+ }
10
9
10
+ declare module 'replicate' {
11
11
export interface Collection {
12
12
id : string ;
13
13
name : string ;
@@ -43,39 +43,17 @@ declare module "replicate" {
43
43
updated : string ;
44
44
}
45
45
46
- export interface CollectionsGetOptions {
47
- collection_slug : string ;
48
- }
49
-
50
- export interface ModelsGetOptions {
51
- model_owner : string ;
52
- model_name : string ;
53
- }
54
-
55
- export interface ModelsVersionsListOptions {
56
- model_owner : string ;
57
- model_name : string ;
58
- }
46
+ export default class Replicate {
47
+ constructor ( options : {
48
+ auth : string ;
49
+ userAgent ?: string ;
50
+ baseUrl ?: string ;
51
+ } ) ;
59
52
60
- export interface ModelsVersionsGetOptions {
61
- model_owner : string ;
62
- model_name : string ;
63
- id : string ;
64
- }
65
-
66
- export interface PredictionsCreateOptions {
67
- version : string ;
68
- input : any ;
69
- webhook ?: string ;
70
- webhook_events_filter ?: WebhookEventType [ ] ;
71
- }
72
-
73
- export interface PredictionsGetOptions {
74
- predictionId : string ;
75
- }
76
-
77
- export class Replicate {
78
- constructor ( options : ReplicateOptions ) ;
53
+ auth : string ;
54
+ userAgent ?: string ;
55
+ baseUrl ?: string ;
56
+ private instance : any ;
79
57
80
58
run (
81
59
identifier : Identifier ,
@@ -87,7 +65,7 @@ declare module "replicate" {
87
65
}
88
66
) : Promise < object > ;
89
67
request ( route : string , parameters : any ) : Promise < any > ;
90
- paginate < T > ( endpoint : ( ) => Promise < T > ) : AsyncGenerator < T [ ] > ;
68
+ paginate < T > ( endpoint : ( ) => Promise < Page < T > > ) : AsyncGenerator < [ T ] > ;
91
69
wait (
92
70
prediction : Prediction ,
93
71
options : {
@@ -97,23 +75,30 @@ declare module "replicate" {
97
75
) : Promise < Prediction > ;
98
76
99
77
collections : {
100
- get ( options : CollectionsGetOptions ) : Promise < Collection > ;
78
+ get ( collection_slug : string ) : Promise < Collection > ;
101
79
} ;
102
80
103
81
models : {
104
- get ( options : ModelsGetOptions ) : Promise < Model > ;
82
+ get ( model_owner : string , model_name : string ) : Promise < Model > ;
105
83
versions : {
106
- list ( options : ModelsVersionsListOptions ) : Promise < ModelVersion [ ] > ;
107
- get ( options : ModelsVersionsGetOptions ) : Promise < ModelVersion > ;
84
+ list ( model_owner : string , model_name : string ) : Promise < ModelVersion [ ] > ;
85
+ get (
86
+ model_owner : string ,
87
+ model_name : string ,
88
+ version_id : string
89
+ ) : Promise < ModelVersion > ;
108
90
} ;
109
91
} ;
110
92
111
93
predictions : {
112
- create ( options : PredictionsCreateOptions ) : Promise < Prediction > ;
113
- get ( options : PredictionsGetOptions ) : Promise < Prediction > ;
114
- list ( ) : Promise < Prediction [ ] > ;
94
+ create ( options : {
95
+ version : string ;
96
+ input : any ;
97
+ webhook ?: string ;
98
+ webhook_events_filter ?: WebhookEventType [ ] ;
99
+ } ) : Promise < Prediction > ;
100
+ get ( prediction_id : string ) : Promise < Prediction > ;
101
+ list ( ) : Promise < Page < Prediction > > ;
115
102
} ;
116
103
}
117
-
118
- export default Replicate ;
119
104
}
0 commit comments