Skip to content

Commit 6c5ae7e

Browse files
authored
feat(bookmarking): Add support for ui.Chat bookmarking (#1951)
1 parent dc0761b commit 6c5ae7e

File tree

15 files changed

+570
-4
lines changed

15 files changed

+570
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
## New features
1111

12+
* Added support for bookmarking Shiny applications. Bookmarking allows users to save the current state of an application and return to it later. This feature is available in both Shiny Core and Shiny Express. (#1870, #1915, #1919, #1920, #1922, #1934, #1938, #1945)
13+
* To enable bookmarking in Express mode, set `shiny.express.app_opts(bookmark_store=)` during the app's initial construction.
14+
* To enable bookmarking in Core mode, set `shiny.App(bookmark_store=)` when constructing the `app` object.
15+
16+
* Added a new `.enable_bookmarking(client)` method to `ui.Chat()`. This method will attach bookmark hooks to save and restore the chat's messages and client state. (#1951)
17+
1218
* Both `ui.Chat()` and `ui.MarkdownStream()` now support arbirary Shiny UI elements inside of messages. This allows for gathering input from the user (e.g., `ui.input_select()`), displaying of rich output (e.g., `render.DataGrid()`), and more. (#1868)
1319

1420
* Added a new `.message_stream_context()` method to `ui.Chat()`. This context manager is a useful alternative to `.append_message_stream()` when you want to: (1) Nest a stream within another and/or

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ dev = [
120120
"langsmith<0.3",
121121
"openai",
122122
"ollama",
123+
"chatlas>=0.6.1",
123124
"tokenizers",
124125
"aiohttp",
125126
"beautifulsoup4",

shiny/templates/chat/llm-enterprise/aws-bedrock-anthropic/app.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
chat = ui.Chat(id="chat")
2929
chat.ui()
3030

31+
# Store chat state in the url when an "assistant" response occurs
32+
chat.enable_bookmarking(chat_client, bookmark_store="url")
33+
3134

3235
# Define a callback to run when the user submits a message
3336
@chat.on_user_submit

shiny/templates/chat/llm-enterprise/azure-openai/app.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
)
3434
chat.ui()
3535

36+
# Store chat state in the url when an "assistant" response occurs
37+
chat.enable_bookmarking(chat_client, bookmark_store="url")
38+
3639

3740
# Define a callback to run when the user submits a message
3841
@chat.on_user_submit

shiny/templates/chat/llms/anthropic/app.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
)
3434
chat.ui()
3535

36+
# Store chat state in the url when an "assistant" response occurs
37+
chat.enable_bookmarking(chat_client, bookmark_store="url")
38+
3639

3740
# Generate a response when the user submits a message
3841
@chat.on_user_submit

shiny/templates/chat/llms/google/app.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
chat = ui.Chat(id="chat")
3030
chat.ui()
3131

32+
# Store chat state in the url when an "assistant" response occurs
33+
chat.enable_bookmarking(chat_client, bookmark_store="url")
34+
3235

3336
# Generate a response when the user submits a message
3437
@chat.on_user_submit

shiny/templates/chat/llms/langchain/app.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
)
3535
chat.ui()
3636

37+
# Store chat state in the url when an "assistant" response occurs
38+
chat.enable_bookmarking(chat_client, bookmark_store="url")
39+
3740

3841
# Define a callback to run when the user submits a message
3942
@chat.on_user_submit

shiny/templates/chat/llms/ollama/app.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
)
2626
chat.ui()
2727

28+
# Store chat state in the url when an "assistant" response occurs
29+
chat.enable_bookmarking(chat_client, bookmark_store="url")
30+
2831

2932
# Generate a response when the user submits a message
3033
@chat.on_user_submit

shiny/templates/chat/llms/openai/app.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
)
3434
chat.ui()
3535

36+
# Store chat state in the url when an "assistant" response occurs
37+
chat.enable_bookmarking(chat_client, bookmark_store="url")
38+
3639

3740
# Generate a response when the user submits a message
3841
@chat.on_user_submit

0 commit comments

Comments
 (0)