From 7cc96e65d102a0ff5a0fcf189a25ef2e977ae33e Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Mon, 12 Jun 2023 02:39:49 -0700 Subject: [PATCH 1/6] Fix signature for trainings.create --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d0593ceb..2e345efb 100644 --- a/README.md +++ b/README.md @@ -328,12 +328,14 @@ const response = await replicate.predictions.list(); ### `replicate.trainings.create` ```js -const response = await replicate.trainings.create(options); +const response = await replicate.trainings.create(model_owner, model_name, version_id, options); ``` | name | type | description | | ------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------- | -| `options.version` | string | **Required**. The model version | +| `model_owner` | string | **Required**. The name of the user or organization that owns the model. | +| `model_name` | string | **Required**. The name of the model. | +| `version` | string | **Required**. The model version | | `options.destination` | string | **Required**. The destination for the trained version in the form `{username}/{model_name}` | | `options.input` | object | **Required**. An object with the model's inputs | | `options.webhook` | string | An HTTPS URL for receiving a webhook when the training has new output | From a4a29a88ea30dac48b8327bd3d8804792dc7e980 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Mon, 12 Jun 2023 02:43:26 -0700 Subject: [PATCH 2/6] Add entry for trainings.cancel --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index 2e345efb..60da8926 100644 --- a/README.md +++ b/README.md @@ -389,6 +389,37 @@ const response = await replicate.trainings.get(training_id); } ``` +### `replicate.trainings.cancel` + +```js +const response = await replicate.trainings.cancel(training_id); +``` + +| name | type | description | +| ------------- | ------ | ----------------------------- | +| `training_id` | number | **Required**. The training id | + +```jsonc +{ + "id": "zz4ibbonubfz7carwiefibzgga", + "version": "{version}", + "status": "canceled", + "input": { + "data": "..." + "param1": "..." + }, + "output": { + "version": "..." + }, + "error": null, + "logs": null, + "webhook_completed": null, + "started_at": "2023-03-28T21:47:58.566434Z", + "created_at": "2023-03-28T21:47:58.566434Z", + "completed_at": "2023-03-28T21:47:58.566434Z" +} +``` + ### `replicate.trainings.list` ```js From 07c827e433971f93d01baba8b95ae1967c1c5e33 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Mon, 12 Jun 2023 02:44:50 -0700 Subject: [PATCH 3/6] Replace {version} placeholder with id for flan-t5-xl --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 60da8926..34ffc6ba 100644 --- a/README.md +++ b/README.md @@ -344,7 +344,7 @@ const response = await replicate.trainings.create(model_owner, model_name, versi ```jsonc { "id": "zz4ibbonubfz7carwiefibzgga", - "version": "{version}", + "version": "3ae0799123a1fe11f8c89fd99632f843fc5f7a761630160521c4253149754523", "status": "starting", "input": { "text": "..." @@ -371,7 +371,7 @@ const response = await replicate.trainings.get(training_id); ```jsonc { "id": "zz4ibbonubfz7carwiefibzgga", - "version": "{version}", + "version": "3ae0799123a1fe11f8c89fd99632f843fc5f7a761630160521c4253149754523", "status": "succeeded", "input": { "data": "..." @@ -402,7 +402,7 @@ const response = await replicate.trainings.cancel(training_id); ```jsonc { "id": "zz4ibbonubfz7carwiefibzgga", - "version": "{version}", + "version": "3ae0799123a1fe11f8c89fd99632f843fc5f7a761630160521c4253149754523", "status": "canceled", "input": { "data": "..." From 86088fc6a3cf74681e6732289d0dab26f896df00 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Mon, 12 Jun 2023 02:46:09 -0700 Subject: [PATCH 4/6] Add entry for predictions.cancel --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/README.md b/README.md index 34ffc6ba..900c3fac 100644 --- a/README.md +++ b/README.md @@ -294,6 +294,38 @@ const response = await replicate.predictions.get(prediction_id); } ``` +### `replicate.predictions.cancel` + +```js +const response = await replicate.predictions.cancel(prediction_id); +``` + +| name | type | description | +| --------------- | ------ | ------------------------------- | +| `prediction_id` | number | **Required**. The prediction id | + +```jsonc +{ + "id": "ufawqhfynnddngldkgtslldrkq", + "version": "5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa", + "urls": { + "get": "https://api.replicate.com/v1/predictions/ufawqhfynnddngldkgtslldrkq", + "cancel": "https://api.replicate.com/v1/predictions/ufawqhfynnddngldkgtslldrkq/cancel" + }, + "created_at": "2022-04-26T22:13:06.224088Z", + "started_at": "2022-04-26T22:13:06.224088Z", + "completed_at": "2022-04-26T22:13:06.224088Z", + "status": "canceled", + "input": { + "text": "Alice" + }, + "output": null, + "error": null, + "logs": null, + "metrics": {} +} +``` + ### `replicate.predictions.list` ```js From 618be5bccff4f4c0231e0f0f3dde18e5a78aa6bd Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Mon, 12 Jun 2023 02:53:10 -0700 Subject: [PATCH 5/6] Update timestamps in example responses --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 900c3fac..2fa73bb4 100644 --- a/README.md +++ b/README.md @@ -415,9 +415,9 @@ const response = await replicate.trainings.get(training_id); "error": null, "logs": null, "webhook_completed": null, - "started_at": null, + "started_at": "2023-03-28T21:48:02.402755Z", "created_at": "2023-03-28T21:47:58.566434Z", - "completed_at": null + "completed_at": "2023-03-28T02:49:48.492023Z" } ``` @@ -446,9 +446,9 @@ const response = await replicate.trainings.cancel(training_id); "error": null, "logs": null, "webhook_completed": null, - "started_at": "2023-03-28T21:47:58.566434Z", + "started_at": "2023-03-28T21:48:02.402755Z", "created_at": "2023-03-28T21:47:58.566434Z", - "completed_at": "2023-03-28T21:47:58.566434Z" + "completed_at": "2023-03-28T02:49:48.492023Z" } ``` From bea7d08b004aa7cffeb9024d1feacaaedcdd7a67 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Mon, 12 Jun 2023 02:54:16 -0700 Subject: [PATCH 6/6] Reorder fields in JSON responses --- README.md | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 2fa73bb4..07457328 100644 --- a/README.md +++ b/README.md @@ -248,9 +248,6 @@ const response = await replicate.predictions.create(options); "get": "https://api.replicate.com/v1/predictions/ufawqhfynnddngldkgtslldrkq", "cancel": "https://api.replicate.com/v1/predictions/ufawqhfynnddngldkgtslldrkq/cancel" }, - "created_at": "2022-04-26T22:13:06.224088Z", - "started_at": null, - "completed_at": null, "status": "succeeded", "input": { "text": "Alice" @@ -258,7 +255,10 @@ const response = await replicate.predictions.create(options); "output": null, "error": null, "logs": null, - "metrics": {} + "metrics": {}, + "created_at": "2022-04-26T22:13:06.224088Z", + "started_at": null, + "completed_at": null } ``` @@ -280,9 +280,6 @@ const response = await replicate.predictions.get(prediction_id); "get": "https://api.replicate.com/v1/predictions/ufawqhfynnddngldkgtslldrkq", "cancel": "https://api.replicate.com/v1/predictions/ufawqhfynnddngldkgtslldrkq/cancel" }, - "created_at": "2022-04-26T22:13:06.224088Z", - "started_at": null, - "completed_at": null, "status": "starting", "input": { "text": "Alice" @@ -290,7 +287,10 @@ const response = await replicate.predictions.get(prediction_id); "output": null, "error": null, "logs": null, - "metrics": {} + "metrics": {}, + "created_at": "2022-04-26T22:13:06.224088Z", + "started_at": null, + "completed_at": null } ``` @@ -312,9 +312,6 @@ const response = await replicate.predictions.cancel(prediction_id); "get": "https://api.replicate.com/v1/predictions/ufawqhfynnddngldkgtslldrkq", "cancel": "https://api.replicate.com/v1/predictions/ufawqhfynnddngldkgtslldrkq/cancel" }, - "created_at": "2022-04-26T22:13:06.224088Z", - "started_at": "2022-04-26T22:13:06.224088Z", - "completed_at": "2022-04-26T22:13:06.224088Z", "status": "canceled", "input": { "text": "Alice" @@ -322,7 +319,10 @@ const response = await replicate.predictions.cancel(prediction_id); "output": null, "error": null, "logs": null, - "metrics": {} + "metrics": {}, + "created_at": "2022-04-26T22:13:06.224088Z", + "started_at": "2022-04-26T22:13:06.224088Z", + "completed_at": "2022-04-26T22:13:06.224088Z" } ``` @@ -346,11 +346,11 @@ const response = await replicate.predictions.list(); "get": "https://api.replicate.com/v1/predictions/jpzd7hm5gfcapbfyt4mqytarku", "cancel": "https://api.replicate.com/v1/predictions/jpzd7hm5gfcapbfyt4mqytarku/cancel" }, + "source": "web", + "status": "succeeded", "created_at": "2022-04-26T20:00:40.658234Z", "started_at": "2022-04-26T20:00:84.583803Z", - "completed_at": "2022-04-26T20:02:27.648305Z", - "source": "web", - "status": "succeeded" + "completed_at": "2022-04-26T20:02:27.648305Z" } /* ... */ ] @@ -472,11 +472,11 @@ const response = await replicate.trainings.list(); "get": "https://api.replicate.com/v1/trainings/jpzd7hm5gfcapbfyt4mqytarku", "cancel": "https://api.replicate.com/v1/trainings/jpzd7hm5gfcapbfyt4mqytarku/cancel" }, + "source": "web", + "status": "succeeded", "created_at": "2022-04-26T20:00:40.658234Z", "started_at": "2022-04-26T20:00:84.583803Z", - "completed_at": "2022-04-26T20:02:27.648305Z", - "source": "web", - "status": "succeeded" + "completed_at": "2022-04-26T20:02:27.648305Z" } /* ... */ ]