diff --git a/index.d.ts b/index.d.ts index 4801654..78457e0 100644 --- a/index.d.ts +++ b/index.d.ts @@ -297,6 +297,7 @@ declare module "replicate" { model?: string; version?: string; input: object; + /** @deprecated */ stream?: boolean; webhook?: string; webhook_events_filter?: WebhookEventType[]; diff --git a/index.js b/index.js index f2c3e1e..f0d3e75 100644 --- a/index.js +++ b/index.js @@ -318,13 +318,11 @@ class Replicate { prediction = await this.predictions.create({ ...data, version: identifier.version, - stream: true, }); } else if (identifier.owner && identifier.name) { prediction = await this.predictions.create({ ...data, model: `${identifier.owner}/${identifier.name}`, - stream: true, }); } else { throw new Error("Invalid model version identifier"); diff --git a/index.test.ts b/index.test.ts index 5ca3e54..08fbf7c 100644 --- a/index.test.ts +++ b/index.test.ts @@ -357,7 +357,6 @@ describe("Replicate client", () => { prompt: "Tell me a story", data, }, - stream: true, }); expect(actual?.input.data).toEqual(expected); @@ -385,7 +384,6 @@ describe("Replicate client", () => { prompt: "Tell me a story", data, }, - stream: true, }); }).rejects.toThrowError( expect.objectContaining({ @@ -396,24 +394,6 @@ describe("Replicate client", () => { } ); - test("Passes stream parameter to API endpoint", async () => { - nock(BASE_URL) - .post("/predictions") - .reply(201, (_uri, body) => { - expect((body as any).stream).toBe(true); - return body; - }); - - await client.predictions.create({ - version: - "5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa", - input: { - prompt: "Tell me a story", - }, - stream: true, - }); - }); - test("Throws an error if webhook URL is invalid", async () => { await expect(async () => { await client.predictions.create({ diff --git a/lib/predictions.js b/lib/predictions.js index c290d40..88bed32 100644 --- a/lib/predictions.js +++ b/lib/predictions.js @@ -9,11 +9,11 @@ const { transformFileInputs } = require("./util"); * @param {object} options.input - Required. An object with the model inputs * @param {string} [options.webhook] - An HTTPS URL for receiving a webhook when the prediction has new output * @param {string[]} [options.webhook_events_filter] - You can change which events trigger webhook requests by specifying webhook events (`start`|`output`|`logs`|`completed`) - * @param {boolean} [options.stream] - Whether to stream the prediction output. Defaults to false + * @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 * @returns {Promise} Resolves with the created prediction */ async function createPrediction(options) { - const { model, version, stream, input, ...data } = options; + const { model, version, input, ...data } = options; if (data.webhook) { try { @@ -36,7 +36,6 @@ async function createPrediction(options) { this.fileEncodingStrategy ), version, - stream, }, }); } else if (model) { @@ -49,7 +48,6 @@ async function createPrediction(options) { input, this.fileEncodingStrategy ), - stream, }, }); } else {