-
Notifications
You must be signed in to change notification settings - Fork 21
feat!(pkg-r): new QueryChat API
#109
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
Conversation
QueryChat() APIQueryChat API
|
@gadenbuie ideally we'd also address the data source plugin API (which is a bit of a mess), but I'm gonna punt on that for now #110 |
gadenbuie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really nice, going to be a great overall improvement to the package!
Co-authored-by: Garrick Aden-Buie <[email protected]>
Co-authored-by: Garrick Aden-Buie <[email protected]>
8fe0bd1 to
be0ddda
Compare
…ide of active session
|
Thanks for the detailed feedback @gadenbuie. Just FYI, I'm likely going to merge this by EOD Wed to unblock Veerle. |
|
Also, one thing I realized while addressing feedback is that it's not currently possible to access the app object underlying |
pkg-r/R/QueryChat.R
Outdated
| app <- self$app_obj(..., bookmark_store = bookmark_store) | ||
| tryCatch(shiny::runGadget(app), interrupt = function(cnd) NULL) | ||
| invisible(private$server_values$chat) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I missed this in the first review. The advantage of calling runGadget() is so that we can return the chat object. Is there another way to expose the session-specific chat clients?
Thinking about that, will our current approach work in apps with simultaneous users?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm conflicted on this; I personally find it helpful that shinychat::chat_app() (and ellmer::live_browser() by extension) returns the session chat client, but I'm not sure how many other people use this feature and it'd be a lot easier to just return the app object here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Man I feel silly for not catching this earlier. I think we're gonna have to go back to $server() returning a list of reactives
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, if stopApp() is passed a value, runGadget() will return it. I also think it's pretty neat that you can get at the most-recent query, so now I'm returning all the session-specific values.
…handle fallout and address feedback
This PR introduces a major API redesign for the R package, replacing the functional API with a simpler R6 class-based approach. These changes are in part motivated by the recent changes made to the Python package (#101 and #108), where the class-based approach is much more idiomatic to Python and Shiny Express.
Summary
The previous API required users to juggle multiple function calls (
querychat_init(),querychat_sidebar(),querychat_server()), explicitly create data sources withquerychat_data_source(), and route output/input values into the proper locations. The newQueryChatR6 class consolidates all this functionality into a single object.API Comparison
Before:
After:
Key Changes
New QueryChat R6 Class
QueryChat$new(data_source, table_name, ...)accepts data frames or database connections directly$sidebar(),$ui()create chat interface components$server()initializes server logic (must be called within Shiny server function)$app()generates a ready-to-run Shiny app with sensible defaults$generate_greeting()creates reusable greeting messages$cleanup()closes data source resourcesHard Deprecations
All previous functional API functions now throw errors with helpful migration messages:
querychat_init()→QueryChat$new()querychat_app()→QueryChat$app()querychat_sidebar()→QueryChat$sidebar()querychat_ui()→QueryChat$ui()querychat_server()→QueryChat$server()querychat_greeting()→QueryChat$generate_greeting()querychat_data_source()→QueryChat$new()(data sources now created internally)Internal Refactoring
querychat_data_source()toas_querychat_data_source()- now exported as an internal developer extension point onlycategorical_thresholdfrom data source creation (moved toQueryChat$new())Migration Guide
Users upgrading from the old API will receive clear error messages with side-by-side code comparisons showing exactly how to migrate. The new API is more intuitive and requires less code in most cases.
Documentation Updates