Skip to content

Commit ac47fb4

Browse files
authored
Deprecate stream parameter for predictions.create (#291)
1 parent eb9adfd commit ac47fb4

File tree

4 files changed

+3
-26
lines changed

4 files changed

+3
-26
lines changed

index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ declare module "replicate" {
297297
model?: string;
298298
version?: string;
299299
input: object;
300+
/** @deprecated */
300301
stream?: boolean;
301302
webhook?: string;
302303
webhook_events_filter?: WebhookEventType[];

index.js

-2
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,11 @@ class Replicate {
318318
prediction = await this.predictions.create({
319319
...data,
320320
version: identifier.version,
321-
stream: true,
322321
});
323322
} else if (identifier.owner && identifier.name) {
324323
prediction = await this.predictions.create({
325324
...data,
326325
model: `${identifier.owner}/${identifier.name}`,
327-
stream: true,
328326
});
329327
} else {
330328
throw new Error("Invalid model version identifier");

index.test.ts

-20
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,6 @@ describe("Replicate client", () => {
357357
prompt: "Tell me a story",
358358
data,
359359
},
360-
stream: true,
361360
});
362361

363362
expect(actual?.input.data).toEqual(expected);
@@ -385,7 +384,6 @@ describe("Replicate client", () => {
385384
prompt: "Tell me a story",
386385
data,
387386
},
388-
stream: true,
389387
});
390388
}).rejects.toThrowError(
391389
expect.objectContaining({
@@ -396,24 +394,6 @@ describe("Replicate client", () => {
396394
}
397395
);
398396

399-
test("Passes stream parameter to API endpoint", async () => {
400-
nock(BASE_URL)
401-
.post("/predictions")
402-
.reply(201, (_uri, body) => {
403-
expect((body as any).stream).toBe(true);
404-
return body;
405-
});
406-
407-
await client.predictions.create({
408-
version:
409-
"5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
410-
input: {
411-
prompt: "Tell me a story",
412-
},
413-
stream: true,
414-
});
415-
});
416-
417397
test("Throws an error if webhook URL is invalid", async () => {
418398
await expect(async () => {
419399
await client.predictions.create({

lib/predictions.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ const { transformFileInputs } = require("./util");
99
* @param {object} options.input - Required. An object with the model inputs
1010
* @param {string} [options.webhook] - An HTTPS URL for receiving a webhook when the prediction has new output
1111
* @param {string[]} [options.webhook_events_filter] - You can change which events trigger webhook requests by specifying webhook events (`start`|`output`|`logs`|`completed`)
12-
* @param {boolean} [options.stream] - Whether to stream the prediction output. Defaults to false
12+
* @param {boolean} [options.stream] - Whether to stream the prediction output. Defaults to false. Streaming is now enabled by default for all predictions. For more information, see https://replicate.com/changelog/2024-07-15-streams-always-available-stream-parameter-deprecated
1313
* @returns {Promise<object>} Resolves with the created prediction
1414
*/
1515
async function createPrediction(options) {
16-
const { model, version, stream, input, ...data } = options;
16+
const { model, version, input, ...data } = options;
1717

1818
if (data.webhook) {
1919
try {
@@ -36,7 +36,6 @@ async function createPrediction(options) {
3636
this.fileEncodingStrategy
3737
),
3838
version,
39-
stream,
4039
},
4140
});
4241
} else if (model) {
@@ -49,7 +48,6 @@ async function createPrediction(options) {
4948
input,
5049
this.fileEncodingStrategy
5150
),
52-
stream,
5351
},
5452
});
5553
} else {

0 commit comments

Comments
 (0)