Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganize and reword discussion of streaming language models #319

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ We recommend not adding the token directly to your source code, because you don'

## Run a model

Create a new Python file and add the following code, replacing the model identifier and input with your own:
Create a new Python file and add the following code,
replacing the model identifier and input with your own:

```python
>>> import replicate
Expand All @@ -42,18 +43,6 @@ Create a new Python file and add the following code, replacing the model identif
['https://replicate.com/api/models/stability-ai/stable-diffusion/files/50fcac81-865d-499e-81ac-49de0cb79264/out-0.png']
```

Some models, particularly language models, may not require the version string. Refer to the API documentation for the model for more on the specifics:

```python
replicate.run(
"meta/meta-llama-3-70b-instruct",
input={
"prompt": "Can you write a poem about open source machine learning?",
"system_prompt": "You are a helpful, respectful and honest assistant.",
},
)
```

> [!TIP]
> You can also use the Replicate client asynchronously by prepending `async_` to the method name.
>
Expand Down Expand Up @@ -110,13 +99,17 @@ for event in replicate.stream(
print(str(event), end="")
```

> [!TIP]
> Some models, like [meta/meta-llama-3-70b-instruct](https://replicate.com/meta/meta-llama-3-70b-instruct),
> don't require a version string.
> You can always refer to the API documentation on the model page for specifics.

You can also stream the output of a prediction you create.
This is helpful when you want the ID of the prediction separate from its output.

```python
version = "02e509c789964a7ea8736978a43525956ef40397be9033abf9fd2badfe68c9e3"
prediction = replicate.predictions.create(
version=version,
model="meta/meta-llama-3-70b-instruct"
input={"prompt": "Please write a haiku about llamas."},
stream=True,
)
Expand Down
Loading