shinychat0.2.8
shinychat0.2.8
Published
An AI Chat interface for Shiny apps.
pip install shinychat
Package Downloads
Project URLs
Requires Python
>=3.9
Dependencies
- htmltools
>=0.6.0
- shiny
>=1.4.0
- anthropic
; python_version >= "3.11" and extra == "providers"
- chatlas
[mcp]>=0.12.0; extra == "providers"
- google-generativeai
; extra == "providers"
- langchain-core
; extra == "providers"
- ollama
>=0.4.0; extra == "providers"
- openai
; extra == "providers"
- pydantic
; extra == "providers"
- tokenizers
; extra == "providers"
- coverage
>=7.8.2; extra == "test"
- faicons
; extra == "test"
- ipyleaflet
; extra == "test"
- pandas
; extra == "test"
- playwright
>=1.43.0; extra == "test"
- plotly
; extra == "test"
- pyright
>=1.1.398; extra == "test"
- pytest-playwright
>=0.3.0; extra == "test"
- pytest
>=6.2.4; extra == "test"
- shinylive
; extra == "test"
- shinywidgets
; extra == "test"
- tox-uv
>=1; extra == "test"
shinychat
Chat UI component for Shiny for Python.
Note: shinychat is automatically installed with Shiny for Python and available as shiny.ui.Chat
and shiny.express.ui.Chat
. For complete instructions about creating chatbots please see the Shiny for Python documentation.
Installation
You can install shinychat from PyPI with:
uv pip install shinychat
Or, install the development version of shinychat from GitHub with:
uv pip install git+https://github.com/posit-dev/shinychat.git
Example
from shiny.express import render, ui
from shinychat.express import Chat
# Set some Shiny page options
ui.page_opts(title="Hello Chat")
# Create a chat component, with an initial message
chat = Chat(
id="chat",
messages=[
{"content": "Hello! How can I help you today?", "role": "assistant"},
],
)
# Display the chat
chat.ui()
# Define a callback to run when the user submits a message
@chat.on_user_submit
async def handle_user_input(user_input: str):
await chat.append_message(f"You said: {user_input}")
"Message state:"
@render.code
def message_state():
return str(chat.messages())