Skip to content

Commit

Permalink
async
Browse files Browse the repository at this point in the history
  • Loading branch information
lindbrook authored Dec 19, 2024
1 parent 9d6e24b commit 26474c9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions vignettes/streaming-async.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ coro::loop(for (chunk in stream) {
#> THESE USES MAKE R A POWERFUL TOOL FOR DATA SCIENTISTS, STATISTICIANS, AND RESEARCHERS.
```

## Asynchronous use
## Async usage

ellmer also supports asynchronous use. This is useful when you want to run multiple, concurrent chat sessions. This is particularly important for Shiny applications where using the methods described above would block the Shiny app for other users for the duration of each response.
ellmer also supports async usage. This is useful when you want to run multiple, concurrent chat sessions. This is particularly important for Shiny applications where using the methods described above would block the Shiny app for other users for the duration of each response.

To use asynchronous chat, call `chat_async()`/`stream_async()` instead of `chat()`/`stream()`. The `_async` variants take the same arguments for construction but return a promise instead of the actual response.
To use asyn chat, call `chat_async()`/`stream_async()` instead of `chat()`/`stream()`. The `_async` variants take the same arguments for construction but return a promise instead of the actual response.

Remember that chat objects are stateful; they preserve the conversation history as you interact with it. This means that it doesn't make sense to issue multiple, concurrent chat/stream operations on the same chat object because the conversation history can become corrupted with interleaved conversation fragments. If you need to run concurrent chat sessions, create multiple chat objects.

Expand Down

0 comments on commit 26474c9

Please sign in to comment.