Skip to content
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

Add ui.MarkdownStream #1782

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Add ui.MarkdownStream #1782

wants to merge 5 commits into from

Conversation

cpsievert
Copy link
Collaborator

@cpsievert cpsievert commented Nov 21, 2024

This PR extracts the streaming markdown capabilities of ui.Chat() into another component: ui.MarkdownStream(). See the new files for example usage:

  • shiny/api-examples/MarkdownStream/app-express.py
  • shiny/api-examples/MarkdownStream/app-core.py

By pulling out the markdown rendering aspect of chat.ts into a more reusable web component, it not only allows us to fairly easily support an additional component, but I can also re-use it for chatlas, which will be a big improvement over the rich console for a web-based settings.

TODO

  • Fix streaming context with ui.Chat()
  • Does it make sense to replace server-side logic with ui.MarkdownStream()
    • If we do, we'll need an R equivalent for shinychat.
  • shinychat will need to be updated to pull in additional JS/CSS files

from shiny import App, ui

app_ui = ui.page_fluid(
ui.markdown_stream_ui("shiny-readme"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would ui.output_markdown_stream be more consistent with our past naming, perhaps? (I think of Chat as a special case because it's equal parts output and input)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah yes, agreed, thanks.

@cpsievert cpsievert force-pushed the markdown-stream-component branch from 026867b to ba86904 Compare November 26, 2024 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants