Skip to content

Commit edbac16

Browse files
authored
Update usage documentation in README (replicate#83)
* Fix signature for trainings.create * Add entry for trainings.cancel * Replace {version} placeholder with id for flan-t5-xl * Add entry for predictions.cancel * Update timestamps in example responses * Reorder fields in JSON responses
1 parent 8c8bcd9 commit edbac16

File tree

1 file changed

+84
-19
lines changed

1 file changed

+84
-19
lines changed

README.md

Lines changed: 84 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -248,17 +248,17 @@ const response = await replicate.predictions.create(options);
248248
"get": "https://api.replicate.com/v1/predictions/ufawqhfynnddngldkgtslldrkq",
249249
"cancel": "https://api.replicate.com/v1/predictions/ufawqhfynnddngldkgtslldrkq/cancel"
250250
},
251-
"created_at": "2022-04-26T22:13:06.224088Z",
252-
"started_at": null,
253-
"completed_at": null,
254251
"status": "succeeded",
255252
"input": {
256253
"text": "Alice"
257254
},
258255
"output": null,
259256
"error": null,
260257
"logs": null,
261-
"metrics": {}
258+
"metrics": {},
259+
"created_at": "2022-04-26T22:13:06.224088Z",
260+
"started_at": null,
261+
"completed_at": null
262262
}
263263
```
264264

@@ -280,17 +280,49 @@ const response = await replicate.predictions.get(prediction_id);
280280
"get": "https://api.replicate.com/v1/predictions/ufawqhfynnddngldkgtslldrkq",
281281
"cancel": "https://api.replicate.com/v1/predictions/ufawqhfynnddngldkgtslldrkq/cancel"
282282
},
283+
"status": "starting",
284+
"input": {
285+
"text": "Alice"
286+
},
287+
"output": null,
288+
"error": null,
289+
"logs": null,
290+
"metrics": {},
283291
"created_at": "2022-04-26T22:13:06.224088Z",
284292
"started_at": null,
285-
"completed_at": null,
286-
"status": "starting",
293+
"completed_at": null
294+
}
295+
```
296+
297+
### `replicate.predictions.cancel`
298+
299+
```js
300+
const response = await replicate.predictions.cancel(prediction_id);
301+
```
302+
303+
| name | type | description |
304+
| --------------- | ------ | ------------------------------- |
305+
| `prediction_id` | number | **Required**. The prediction id |
306+
307+
```jsonc
308+
{
309+
"id": "ufawqhfynnddngldkgtslldrkq",
310+
"version": "5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
311+
"urls": {
312+
"get": "https://api.replicate.com/v1/predictions/ufawqhfynnddngldkgtslldrkq",
313+
"cancel": "https://api.replicate.com/v1/predictions/ufawqhfynnddngldkgtslldrkq/cancel"
314+
},
315+
"status": "canceled",
287316
"input": {
288317
"text": "Alice"
289318
},
290319
"output": null,
291320
"error": null,
292321
"logs": null,
293-
"metrics": {}
322+
"metrics": {},
323+
"created_at": "2022-04-26T22:13:06.224088Z",
324+
"started_at": "2022-04-26T22:13:06.224088Z",
325+
"completed_at": "2022-04-26T22:13:06.224088Z"
294326
}
295327
```
296328

@@ -314,11 +346,11 @@ const response = await replicate.predictions.list();
314346
"get": "https://api.replicate.com/v1/predictions/jpzd7hm5gfcapbfyt4mqytarku",
315347
"cancel": "https://api.replicate.com/v1/predictions/jpzd7hm5gfcapbfyt4mqytarku/cancel"
316348
},
349+
"source": "web",
350+
"status": "succeeded",
317351
"created_at": "2022-04-26T20:00:40.658234Z",
318352
"started_at": "2022-04-26T20:00:84.583803Z",
319-
"completed_at": "2022-04-26T20:02:27.648305Z",
320-
"source": "web",
321-
"status": "succeeded"
353+
"completed_at": "2022-04-26T20:02:27.648305Z"
322354
}
323355
/* ... */
324356
]
@@ -328,12 +360,14 @@ const response = await replicate.predictions.list();
328360
### `replicate.trainings.create`
329361

330362
```js
331-
const response = await replicate.trainings.create(options);
363+
const response = await replicate.trainings.create(model_owner, model_name, version_id, options);
332364
```
333365

334366
| name | type | description |
335367
| ------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------- |
336-
| `options.version` | string | **Required**. The model version |
368+
| `model_owner` | string | **Required**. The name of the user or organization that owns the model. |
369+
| `model_name` | string | **Required**. The name of the model. |
370+
| `version` | string | **Required**. The model version |
337371
| `options.destination` | string | **Required**. The destination for the trained version in the form `{username}/{model_name}` |
338372
| `options.input` | object | **Required**. An object with the model's inputs |
339373
| `options.webhook` | string | An HTTPS URL for receiving a webhook when the training has new output |
@@ -342,7 +376,7 @@ const response = await replicate.trainings.create(options);
342376
```jsonc
343377
{
344378
"id": "zz4ibbonubfz7carwiefibzgga",
345-
"version": "{version}",
379+
"version": "3ae0799123a1fe11f8c89fd99632f843fc5f7a761630160521c4253149754523",
346380
"status": "starting",
347381
"input": {
348382
"text": "..."
@@ -369,7 +403,7 @@ const response = await replicate.trainings.get(training_id);
369403
```jsonc
370404
{
371405
"id": "zz4ibbonubfz7carwiefibzgga",
372-
"version": "{version}",
406+
"version": "3ae0799123a1fe11f8c89fd99632f843fc5f7a761630160521c4253149754523",
373407
"status": "succeeded",
374408
"input": {
375409
"data": "..."
@@ -381,9 +415,40 @@ const response = await replicate.trainings.get(training_id);
381415
"error": null,
382416
"logs": null,
383417
"webhook_completed": null,
384-
"started_at": null,
418+
"started_at": "2023-03-28T21:48:02.402755Z",
385419
"created_at": "2023-03-28T21:47:58.566434Z",
386-
"completed_at": null
420+
"completed_at": "2023-03-28T02:49:48.492023Z"
421+
}
422+
```
423+
424+
### `replicate.trainings.cancel`
425+
426+
```js
427+
const response = await replicate.trainings.cancel(training_id);
428+
```
429+
430+
| name | type | description |
431+
| ------------- | ------ | ----------------------------- |
432+
| `training_id` | number | **Required**. The training id |
433+
434+
```jsonc
435+
{
436+
"id": "zz4ibbonubfz7carwiefibzgga",
437+
"version": "3ae0799123a1fe11f8c89fd99632f843fc5f7a761630160521c4253149754523",
438+
"status": "canceled",
439+
"input": {
440+
"data": "..."
441+
"param1": "..."
442+
},
443+
"output": {
444+
"version": "..."
445+
},
446+
"error": null,
447+
"logs": null,
448+
"webhook_completed": null,
449+
"started_at": "2023-03-28T21:48:02.402755Z",
450+
"created_at": "2023-03-28T21:47:58.566434Z",
451+
"completed_at": "2023-03-28T02:49:48.492023Z"
387452
}
388453
```
389454

@@ -407,11 +472,11 @@ const response = await replicate.trainings.list();
407472
"get": "https://api.replicate.com/v1/trainings/jpzd7hm5gfcapbfyt4mqytarku",
408473
"cancel": "https://api.replicate.com/v1/trainings/jpzd7hm5gfcapbfyt4mqytarku/cancel"
409474
},
475+
"source": "web",
476+
"status": "succeeded",
410477
"created_at": "2022-04-26T20:00:40.658234Z",
411478
"started_at": "2022-04-26T20:00:84.583803Z",
412-
"completed_at": "2022-04-26T20:02:27.648305Z",
413-
"source": "web",
414-
"status": "succeeded"
479+
"completed_at": "2022-04-26T20:02:27.648305Z"
415480
}
416481
/* ... */
417482
]

0 commit comments

Comments
 (0)