You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+40-41Lines changed: 40 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,21 @@
2
2
3
3
This is a Python client for [Replicate](https://replicate.com). It lets you run models from your Python code or Jupyter notebook, and do various other things on Replicate.
4
4
5
+
## Breaking Changes in 1.0.0
6
+
7
+
The 1.0.0 release contains breaking changes:
8
+
9
+
- The `replicate.run()` method now returns `FileObject`s instead of URL strings by default for models that output files. `FileObject` implements an iterable interface similar to `httpx.Response`, making it easier to work with files efficiently.
10
+
11
+
To revert to the previous behavior, you can opt out of `FileObject` by passing `use_file_output=False` to `replicate.run()`:
In most cases, updating existing applications to call `output.url()` should resolve any issues.
18
+
19
+
> [!TIP]
5
20
> **👋** Check out an interactive version of this tutorial on [Google Colab](https://colab.research.google.com/drive/1K91q4p-OhL96FHBAVLsv9FlwFdu6Pn3c).
6
21
>
7
22
> [](https://colab.research.google.com/drive/1K91q4p-OhL96FHBAVLsv9FlwFdu6Pn3c)
@@ -30,17 +45,18 @@ We recommend not adding the token directly to your source code, because you don'
30
45
31
46
## Run a model
32
47
33
-
Create a new Python file and add the following code,
34
-
replacing the model identifier and input with your own:
48
+
Create a new Python file and add the following code, replacing the model identifier and input with your own:
Is a file-like object returned from the `replicate.run()` method that makes it easier to work with models
299
-
that output files. It implements `Iterator` and `AsyncIterator` for reading the file data in chunks as well
300
-
as `read` and `aread()` to read the entire file into memory.
301
-
302
-
Lastly, the underlying datasource is available on the `url` attribute.
303
-
304
-
> [!NOTE]
305
-
> The `url` attribute can vary between a remote URL and a data-uri depending on whether the server has
306
-
> optimized the request. For small files <5mb using the syncronous API data-uris will be returned to
307
-
> remove the need to make subsequent requests for the file data. To disable this pass `wait=false`
308
-
> to the replicate.run() function.
316
+
Is a file-like object returned from the `replicate.run()` method that makes it easier to work with models that output files. It implements `Iterator` and `AsyncIterator` for reading the file data in chunks as well as `read` and `aread()` to read the entire file into memory.
309
317
310
-
To access the file URL:
318
+
Lastly, the URL of the underlying data source is available on the `url` attribute.
311
319
312
320
```python
313
321
print(output.url) #=> "data:image/png;base64,xyz123..." or "https://delivery.replicate.com/..."
@@ -439,13 +447,9 @@ Here's how to list of all the available hardware for running models on Replicate
439
447
440
448
## Fine-tune a model
441
449
442
-
Use the [training API](https://replicate.com/docs/fine-tuning)
443
-
to fine-tune models to make them better at a particular task.
444
-
To see what **language models** currently support fine-tuning,
445
-
check out Replicate's [collection of trainable language models](https://replicate.com/collections/trainable-language-models).
450
+
Use the [training API](https://replicate.com/docs/fine-tuning) to fine-tune models to make them better at a particular task. To see what **language models** currently support fine-tuning, check out Replicate's [collection of trainable language models](https://replicate.com/collections/trainable-language-models).
446
451
447
-
If you're looking to fine-tune **image models**,
448
-
check out Replicate's [guide to fine-tuning image models](https://replicate.com/docs/guides/fine-tune-an-image-model).
452
+
If you're looking to fine-tune **image models**, check out Replicate's [guide to fine-tuning image models](https://replicate.com/docs/guides/fine-tune-an-image-model).
449
453
450
454
Here's how to fine-tune a model on Replicate:
451
455
@@ -467,24 +471,19 @@ training = replicate.trainings.create(
467
471
468
472
## Customize client behavior
469
473
470
-
The `replicate` package exports a default shared client.
471
-
This client is initialized with an API token
472
-
set by the `REPLICATE_API_TOKEN` environment variable.
474
+
The `replicate` package exports a default shared client. This client is initialized with an API token set by the `REPLICATE_API_TOKEN` environment variable.
473
475
474
-
You can create your own client instance to
475
-
pass a different API token value,
476
-
add custom headers to requests,
477
-
or control the behavior of the underlying [HTTPX client](https://www.python-httpx.org/api/#client):
476
+
You can create your own client instance to pass a different API token value, add custom headers to requests, or control the behavior of the underlying [HTTPX client](https://www.python-httpx.org/api/#client):
0 commit comments