Registry / llm-agents / shinychat

shinychat

JSON →
library0.4.0pypypi✓ verified 85d ago

ShinyChat is a Python library that provides a Shiny toolkit for building generative AI applications like chatbots and streaming content directly within Shiny applications. It offers easy-to-use chat UI components that integrate seamlessly with various LLM frameworks. The library is actively maintained with frequent updates, currently at version 0.2.9.

pip install shinychat
INSTALL
IMPORT
SIG · SHINYCHAT
S
shinychat
llm-agentspythonv0.4.0
Install
10.0s avg
Import
3371ms
Disk
68MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.4.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.960 runs
installs and imports cleanly · install 0.0s · import 2.776s · 67.2MB
glibc
py 3.103.960 runs
installs and imports cleanly · install 10.0s · import 2.617s · 67MB
68MB installed
● package 68MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Chat
from shinychat.express import Chat
from shiny.ui import Chat
While `ui.Chat` also works if `shiny` is imported, `shinychat.express.Chat` is the direct path for `shinychat`'s primary quickstart. For `shiny.App` structure, `chat = ui.Chat()` is used within the `server` function, with `ui.chat_ui()` in `app_ui`.

This quickstart creates a simple ShinyChat application where the AI assistant acts as an echo bot, repeating whatever the user types. It demonstrates the basic setup of a `Chat` instance, displaying its UI, and handling user input with an asynchronous callback.

import os from shiny.express import ui from shinychat.express import Chat # Set some Shiny page options ui.page_opts( title="Hello ShinyChat Echo Bot", fillable=True, fillable_mobile=True, ) # Create a chat instance and display its UI chat = Chat(id="chat") chat.ui( messages=["Hello! I'm an echo bot. Type something and I'll repeat it!"] ) # Define a callback to run when the user submits a message @chat.on_user_submit async def handle_user_input(user_input: str): # Simply echo the user's input back to them await chat.append_message(f"You said: {user_input}") # To run this app, save it as `app.py` and execute: # `uv shiny run --reload app.py` (if using uv) # or `python -m shiny run --reload app.py` (if using pip/python)
Debug
Known issues
deprecatedSeveral `Chat` constructor parameters and related methods were deprecated in v0.2.0. This includes `Chat(messages=...)`, `Chat(tokenizer=...)`, all parameters to `.messages()`, and the `.transform_user_input` and `.transform_assistant_response` decorators.
fix
Initialize `Chat` without message-related parameters, and use `chat.ui(messages=...)` to set initial messages. Perform input/response transformations manually outside of `Chat` methods.
affects: >=0.2.0
gotcha`pydantic` is listed as a 'soft dependency' (optional, part of the `providers` extra) but can cause `ImportError` if not installed when using features like `chatlas.types.ToolResultDisplay`. This has been a recurring point of change across several minor versions.
fix
If encountering import errors related to `pydantic` or `chatlas` types, ensure `pydantic` is installed by running `pip install shinychat[providers]` or `pip install pydantic`.
affects: >=0.2.5
breakingShinychat now requires Python 3.10 or later. Running with older Python versions will result in a `RuntimeError` or `SyntaxError` depending on the code.
fix
Upgrade your Python environment to version 3.10 or newer.
affects: >=0.2.9
gotchaWhen integrating with LangChain, ensure `langchain` version 1.0.0 or newer is installed. Older versions may lead to compatibility issues.
fix
Install or upgrade LangChain using `pip install 'langchain>=1.0.0'` or `pip install shinychat[langchain]`.
affects: >=0.2.9
Errors
Common errors & fixes
ImportError: cannot import name 'ToolResultDisplay' from 'chatlas.types'
`pydantic` is a soft dependency for `shinychat`'s `providers` extra, and is required by `chatlas` types like `ToolResultDisplay`. If `pydantic` is not installed, this error occurs.
fix
Install `pydantic` by running `pip install pydantic` or `pip install shinychat[providers]`.
TypeError: Chat() got an unexpected keyword argument 'messages'
The `messages` parameter in the `Chat` constructor was deprecated in v0.2.0.
fix
Initialize `chat = Chat(id="chat")` without the `messages` argument, then pass initial messages to the `chat.ui()` method: `chat.ui(messages=["Your initial message"])`.
ModuleNotFoundError: No module named 'shiny.express' or 'ModuleNotFoundError: No module named 'shiny''
`shinychat` is built on top of `Shiny for Python`. If `shiny` is not installed, any imports from `shiny` or `shinychat.express` will fail.
fix
Install the `shiny` package: `pip install shiny`.
RuntimeError: Python version 3.9 or earlier is not supported by shinychat.
Shinychat v0.2.9 and later require Python 3.10 or newer.
fix
Upgrade your Python environment to version 3.10, 3.11, or 3.12.
Upgrade
Version history
0.4.0latest on PyPI · released May 27, 2026
Audit
Dependencies
shinyrequiredShinychat is a UI component for Shiny apps; basic functionality often relies on Shiny's ecosystem.
python>=3.10requiredRequired as of shinychat v0.2.9.
langchain>=1.0.0optionalOptional dependency for integrating with LangChain LLM providers.
chatlasoptionalHighly recommended for interacting with LLM providers, though not strictly required for the basic chat UI.
pydanticoptionalA soft dependency included in the `providers` extra, necessary for certain features (e.g., `chatlas.types.ToolResultDisplay`).
python-dotenvoptionalRecommended for securely loading environment variables like API keys.
Agent activity
15 hits · last 30 days
node
12
Amazon
1
OpenAI (training)
1
Resources
shinychat — pip install shinychat · libregistry