Skip to content

Commit 849ecc0

Browse files
committed
Fixup types
1 parent 42c673b commit 849ecc0

File tree

2 files changed

+40
-6
lines changed

2 files changed

+40
-6
lines changed

example.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const Replicate = require("./");
2+
const replicate = new Replicate({ useFileOutput: true });
3+
4+
(async function () {
5+
const input = {
6+
prompt:
7+
'black forest gateau cake spelling out the words "FLUX SCHNELL", tasty, food photography, dynamic shot',
8+
go_fast: true,
9+
megapixels: "1",
10+
num_outputs: 1,
11+
aspect_ratio: "1:1",
12+
output_format: "webp",
13+
output_quality: 80,
14+
};
15+
16+
const start = performance.now();
17+
const output = await replicate.run("black-forest-labs/flux-schnell", {
18+
wait: 0.0001,
19+
input,
20+
});
21+
22+
const blob = await output[0].blob();
23+
console.log(
24+
"output",
25+
blob,
26+
"url",
27+
output[0].url(),
28+
"duration",
29+
performance.now() - start
30+
);
31+
})().catch((err) => {
32+
console.error(err);
33+
process.exit(1);
34+
});

index.d.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ declare module "replicate" {
9393
model: string;
9494
version: string;
9595
input: object;
96-
output?: any;
96+
output?: any; // TODO: this should be `unknown`
9797
source: "api" | "web";
98-
error?: any;
98+
error?: unknown;
9999
logs?: string;
100100
metrics?: {
101101
predict_time?: number;
@@ -156,13 +156,13 @@ declare module "replicate" {
156156
identifier: `${string}/${string}` | `${string}/${string}:${string}`,
157157
options: {
158158
input: object;
159-
wait?: boolean | number | { mode?: "poll"; interval?: number };
159+
wait?: boolean | number | { mode: "poll"; interval?: number };
160160
webhook?: string;
161161
webhook_events_filter?: WebhookEventType[];
162162
signal?: AbortSignal;
163163
},
164164
progress?: (prediction: Prediction) => void
165-
): Promise<Prediction | any>;
165+
): Promise<unknown>;
166166

167167
stream(
168168
identifier: `${string}/${string}` | `${string}/${string}:${string}`,
@@ -217,7 +217,7 @@ declare module "replicate" {
217217
webhook_events_filter?: WebhookEventType[];
218218
wait?: boolean | number | { mode?: "poll"; interval?: number };
219219
}
220-
): Promise<Prediction | any>;
220+
): Promise<Prediction>;
221221
};
222222
get(
223223
deployment_owner: string,
@@ -306,7 +306,7 @@ declare module "replicate" {
306306
webhook_events_filter?: WebhookEventType[];
307307
wait?: boolean | number | { mode?: "poll"; interval?: number };
308308
} & ({ version: string } | { model: string })
309-
): Promise<Prediction | any>;
309+
): Promise<Prediction>;
310310
get(prediction_id: string): Promise<Prediction>;
311311
cancel(prediction_id: string): Promise<Prediction>;
312312
list(): Promise<Page<Prediction>>;

0 commit comments

Comments
 (0)