Skip to content
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
6 changes: 2 additions & 4 deletions pkg-r/R/client_state.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ method(client_get_state, S7::new_S3_class(c("Chat", "R6"))) <-
# Instead, save only the `turns` information
recorded_turns <- lapply(
client$get_turns(),
ellmer::contents_record,
chat = client
ellmer::contents_record
)

if (is_url_bookmarkstore()) {
Expand Down Expand Up @@ -74,8 +73,7 @@ method(client_set_state, S7::new_S3_class(c("Chat", "R6"))) <-

replayed_turns <- lapply(
recorded_turns,
ellmer::contents_replay,
chat = client
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to pass in tools = client$get_tools()

(Or something similar.)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpsievert @schloerke Did y'all end up resolving this? Or is this currently broken?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like maybe some of the changes in 19a206c (#80) should make it into main?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR #79 gets bookmarking working (without tool calling). Those changes in #80 get bookmarking working with tool calling.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you remember if that changed worked for you as-is? I'm trying to re-apply the patch and the call to chat_enable_bookmarking() in chat_mod_server() leads to

Error in chat_enable_bookmarking("chat", client, session = session) : 
  Error: Shiny bookmarking is not enabled. Please enable bookmarking in your
  Shiny app either by calling `shiny::enableBookmarking("server")` or by
  setting the parameter in `shiny::shinyApp(enableBookmarking = "server")`

And if I add shiny::enableBookmarking("server") to the server function of chat_app() or chat_mod_server(), I'm getting

Error in session$onBookmarked(fun) : 
  onBookmarked() can't be used in a module.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh hmm, yea. I don't think I had tested yet with the module approach. I think the way go about it properly would be to first check if bookmarking is enabled?

if (!is.null(shiny::getShinyOption("bookmarkStore"))) {
   chat_enable_bookmarking("chat", client, session = session)
}

ellmer::contents_replay
)

client$set_turns(replayed_turns)
Expand Down
Loading