github posit-dev/py-shiny v1.3.0
shiny 1.3.0

one day ago

New features

  • Added a new ui.MarkdownStream() component for performantly streaming in chunks of markdown/html strings into the UI. This component is primarily useful for text-based generative AI where responses are received incrementally. (#1782)

  • The ui.Chat() component now supports input suggestion links. This feature is useful for providing users with clickable suggestions that can be used to quickly input text into the chat. This can be done in 2 different ways (see #1845 for more details):

    • By adding a .suggestion CSS class to an HTML element (e.g., <span class="suggestion">A suggestion</span>)
    • Add a data-suggestion attribute to an HTML element, and set the value to the input suggestion text (e.g., <span data-suggestion="Suggestion value">Suggestion link</span>)
    • To auto-submit the suggestion when clicked by the user, include the .submit class or the data-suggestion-submit="true" attribute on the HTML element. Alternatively, use Cmd/Ctrl + click to auto-submit any suggestion or Alt/Opt + click to apply any suggestion to the chat input without submitting.
  • The ui.Chat() component also gains the following:

    • The .on_user_submit() decorator method now passes the user input to the decorated function. This makes it a bit easier to access the user input. See the new templates (mentioned below) for examples. (#1801)
    • The assistant icon is now configurable via ui.chat_ui() (or the ui.Chat.ui() method in Shiny Express) or for individual messages in the .append_message() and .append_message_stream() methods of ui.Chat(). (#1853)
    • A new latest_message_stream property was added for an easy way to reactively read the stream's status, result, and also cancel an in progress stream. (#1846)
    • The .append_message_stream() method now returns the reactive.extended_task instance that it launches. (#1846)
    • The ui.Chat() component's .update_user_input() method gains submit and focus options that allow you to submit the input on behalf of the user and to choose whether the input receives focus after the update. (#1851)
  • shiny create includes new and improved ui.Chat() template options. Most of these templates leverage the new {chatlas} package, our opinionated approach to interfacing with various LLM. (#1806)

  • Client data values (e.g., url info, output sizes/styles, etc.) can now be accessed in the server-side Python code via session.clientdata. For example, session.clientdata.url_search() reactively reads the URL search parameters. (#1832)

  • Available input ids can now be listed via dir(input). This also works on the new session.clientdata object. (#1832)

  • ui.input_text(), ui.input_text_area(), ui.input_numeric() and ui.input_password() all gain an update_on option. update_on="change" is the default and previous behavior, where the input value updates immediately whenever the value changes. With update_on="blur", the input value will update only when the text input loses focus or when the user presses Enter (or Cmd/Ctrl + Enter for ui.input_text_area()). (#1874)

  • Added a new .add_sass_layer_file() method to ui.Theme that supports reading a Sass file with layer boundary comments, e.g. /*-- scss:defaults --*/. This format is supported by Quarto and makes it easier to store Sass rules and declarations that need to be woven into Shiny's Sass Bootstrap files. (#1790)

  • Added a new expect_max_height() method to the Valuebox controllers to check the maximum height of a value box (#1816)

  • shiny.pytest.create_app_fixture(app) gained support for multiple app file paths when creating your test fixture. If multiple file paths are given, it will behave as a parameterized fixture value and execute the test for each app path. (#1869)

Breaking changes

  • The navbar-related style options of ui.page_navbar() and ui.navset_bar() have been consolidated into a single navbar_options argument that pairs with a new ui.navbar_options() helper. Using the direct position, bg, inverse, collapsible, and underline arguments will continue to work with a deprecation message.

    Related to this change, ui.navset_bar() now defaults to using underline=True so that it uses the same set of default ui.navbar_options() as the page variant. In ui.navbar_options(), inverse is replaced by theme, which takes values "light" (dark text on a light background), "dark" (light text on a dark background), or "auto" (follow page settings).

  • The Shiny Core component shiny.ui.Chat() no longer has a .ui() method. This method
    was never intended to be used in Shiny Core (in that case, use shiny.ui.chat_ui()) to create the UI element. Note that the shiny.express.ui.Chat() class still has a .ui() method. (#1840)

Bug fixes

  • ui.Chat() now correctly handles new ollama.chat() return value introduced in ollama v0.4. (#1787)

  • Updated expect_height() for Valuebox controllers to check the height property instead of max-height. (#1816)

Don't miss a new py-shiny release

NewReleases is sending notifications on new releases.