forked from nicholascelestin/replicate-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreplicate.d.ts
59 lines (59 loc) · 2.24 KB
/
replicate.d.ts
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
export declare type PredictionStatus = "starting" | "processing" | "succeeded" | "failed" | "canceled";
export declare type PredictionInput = string | Record<string, any> | any[];
export declare type PredictionOutput = PredictionInput;
export interface ReplicateInputProps {
token?: string;
baseUrl?: string;
proxyUrl?: string;
httpClient?: HTTPClient;
pollingInterval?: number;
}
export interface Replicate extends ReplicateInputProps {
}
export declare class Replicate {
models: {
get: (path: string, version?: string) => Promise<Model>;
};
constructor({ token, proxyUrl, httpClient, pollingInterval }?: ReplicateInputProps);
getModel(path: string): Promise<any>;
getPrediction(id: string): Promise<any>;
startPrediction(modelVersion: string, input: PredictionInput): Promise<any>;
protected callHttpClient({ url, method, event, body }: HTTPClientRequest): Promise<any>;
}
export interface ModelInputProps {
path: string;
version: string;
replicate?: any;
modelDetails?: any;
}
export interface Model extends ModelInputProps {
}
export declare class Model {
static fetch(options: ModelInputProps): Promise<Model>;
constructor({ path, version, replicate }: ModelInputProps);
getModelDetails(): Promise<void>;
predictor(input: PredictionInput): AsyncGenerator<any, void, unknown>;
predict(input?: PredictionInput): Promise<any>;
}
export interface HTTPClientRequest {
url: string;
method: "get" | "post";
event: "getModel" | "startPrediction" | "getPrediction";
body?: Record<string, any>;
}
interface HTTPClientAuthenticatedRequest extends HTTPClientRequest {
token: string;
}
export interface HTTPClient {
get: (request: HTTPClientAuthenticatedRequest) => Promise<any>;
post: (request: HTTPClientAuthenticatedRequest) => Promise<any>;
}
export declare class DefaultFetchHTTPClient implements HTTPClient {
headers: Record<string, string>;
constructor(token: string);
importFetch(): Promise<void>;
get({ url }: HTTPClientAuthenticatedRequest): Promise<any>;
post({ url, body }: HTTPClientAuthenticatedRequest): Promise<any>;
}
export default Replicate;
//# sourceMappingURL=replicate.d.ts.map