Skip to content

Commit f51c0be

Browse files
committed
Rename parameters back to bookmark_store and bookmark_on
1 parent df344b1 commit f51c0be

File tree

8 files changed

+25
-22
lines changed

8 files changed

+25
-22
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
chat.ui()
3030

3131
# Store chat state in the url when an "assistant" response occurs
32-
chat.enable_bookmarking(chat_client, store="url")
32+
chat.enable_bookmarking(chat_client, bookmark_store="url")
3333

3434

3535
# Define a callback to run when the user submits a message

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
chat.ui()
3535

3636
# Store chat state in the url when an "assistant" response occurs
37-
chat.enable_bookmarking(chat_client, store="url")
37+
chat.enable_bookmarking(chat_client, bookmark_store="url")
3838

3939

4040
# Define a callback to run when the user submits a message

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
chat.ui()
3535

3636
# Store chat state in the url when an "assistant" response occurs
37-
chat.enable_bookmarking(chat_client, store="url")
37+
chat.enable_bookmarking(chat_client, bookmark_store="url")
3838

3939

4040
# Generate a response when the user submits a message

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
chat.ui()
3131

3232
# Store chat state in the url when an "assistant" response occurs
33-
chat.enable_bookmarking(chat_client, store="url")
33+
chat.enable_bookmarking(chat_client, bookmark_store="url")
3434

3535

3636
# Generate a response when the user submits a message

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
chat.ui()
3636

3737
# Store chat state in the url when an "assistant" response occurs
38-
chat.enable_bookmarking(chat_client, store="url")
38+
chat.enable_bookmarking(chat_client, bookmark_store="url")
3939

4040

4141
# Define a callback to run when the user submits a message

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
chat.ui()
2727

2828
# Store chat state in the url when an "assistant" response occurs
29-
chat.enable_bookmarking(chat_client, store="url")
29+
chat.enable_bookmarking(chat_client, bookmark_store="url")
3030

3131

3232
# Generate a response when the user submits a message

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
chat.ui()
3535

3636
# Store chat state in the url when an "assistant" response occurs
37-
chat.enable_bookmarking(chat_client, store="url")
37+
chat.enable_bookmarking(chat_client, bookmark_store="url")
3838

3939

4040
# Generate a response when the user submits a message

shiny/ui/_chat.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,7 @@ def enable_bookmarking(
14161416
client: ClientWithState | chatlas.Chat[Any, Any],
14171417
/,
14181418
*,
1419-
on: Optional[Literal["response"]] = "response",
1419+
bookmark_on: Optional[Literal["response"]] = "response",
14201420
) -> CancelCallback:
14211421
"""
14221422
Enable bookmarking for the chat instance.
@@ -1432,11 +1432,11 @@ def enable_bookmarking(
14321432
The chat client instance to use for bookmarking. This can be a Chat model
14331433
provider from [chatlas](https://posit-dev.github.io/chatlas/), or more
14341434
generally, an instance following the `ClientWithState` protocol.
1435-
on
1435+
bookmark_on
14361436
The event to trigger the bookmarking on. Supported values include:
14371437
1438-
- `"response"` (the default): a bookmark is triggered when the assistant is done responding.
1439-
- `None`: no bookmark is triggered
1438+
- `"response"` (the default): a bookmark is triggered when the assistant is done responding.
1439+
- `None`: no bookmark is triggered
14401440
14411441
When this method triggers a bookmark, it also updates the URL query string to reflect the bookmarked state.
14421442
@@ -1516,14 +1516,14 @@ async def set_chatlas_state(value: Jsonifiable) -> None:
15161516
root_session = session.root_scope()
15171517
root_session.bookmark.exclude.append(self.id + "_user_input")
15181518

1519-
if on is not None:
1519+
if bookmark_on is not None:
15201520

15211521
# When ever the bookmark is requested, update the query string (indep of store type)
15221522
@root_session.bookmark.on_bookmarked
15231523
async def _(url: str):
15241524
await session.bookmark.update_query_string(url)
15251525

1526-
if on == "response":
1526+
if bookmark_on == "response":
15271527

15281528
@reactive.effect
15291529
@reactive.event(lambda: self.messages(format=MISSING), ignore_init=True)
@@ -1538,6 +1538,9 @@ async def _():
15381538
if last_message.get("role") == "assistant":
15391539
await session.bookmark()
15401540

1541+
###############
1542+
# On Bookmark
1543+
15411544
@root_session.bookmark.on_bookmark
15421545
async def _on_bookmark_client(state: BookmarkState):
15431546
if resolved_bookmark_id_str in state.values:
@@ -1670,8 +1673,8 @@ def enable_bookmarking(
16701673
client: ClientWithState | chatlas.Chat[Any, Any],
16711674
/,
16721675
*,
1673-
store: Optional[BookmarkStore] = None,
1674-
on: Optional[Literal["response"]] = "response",
1676+
bookmark_store: Optional[BookmarkStore] = None,
1677+
bookmark_on: Optional[Literal["response"]] = "response",
16751678
) -> CancelCallback:
16761679
"""
16771680
Enable bookmarking for the chat instance.
@@ -1687,15 +1690,15 @@ def enable_bookmarking(
16871690
The chat client instance to use for bookmarking. This can be a Chat model
16881691
provider from [chatlas](https://posit-dev.github.io/chatlas/), or more
16891692
generally, an instance following the `ClientWithState` protocol.
1690-
store
1693+
bookmark_store
16911694
A convenience parameter to set the `shiny.express.app_opts(bookmark_store=)`
16921695
which is required for bookmarking (and `.enable_bookmarking()`). If `None`,
16931696
no value will be set.
1694-
on
1697+
bookmark_on
16951698
The event to trigger the bookmarking on. Supported values include:
16961699
1697-
- `"response"` (the default): a bookmark is triggered when the assistant is done responding.
1698-
- `None`: no bookmark is triggered
1700+
- `"response"` (the default): a bookmark is triggered when the assistant is done responding.
1701+
- `None`: no bookmark is triggered
16991702
17001703
When this method triggers a bookmark, it also updates the URL query string to reflect the bookmarked state.
17011704
@@ -1705,12 +1708,12 @@ def enable_bookmarking(
17051708
If the Shiny App does have bookmarking enabled.
17061709
"""
17071710

1708-
if store is not None:
1711+
if bookmark_store is not None:
17091712
from ..express import app_opts
17101713

1711-
app_opts(bookmark_store=store)
1714+
app_opts(bookmark_store=bookmark_store)
17121715

1713-
return super().enable_bookmarking(client, on=on)
1716+
return super().enable_bookmarking(client, bookmark_on=bookmark_on)
17141717

17151718

17161719
@add_example(ex_dir="../api-examples/Chat")

0 commit comments

Comments
 (0)