shinychat for Python website

shinychat provides a Shiny toolkit for building generative AI applications like chatbots and streaming content. It works best with chatlas, but also works great with other LLM frameworks such as LangChain, Pydantic AI, and more.

Installation

shinychat is a dependency of the shiny package, so in most cases, you’ll want to just install shiny with:

uv pip install shiny

However, you can also install shinychat separately 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

Starter example

With shiny installed, you’re ready to run your first shinychat app. Create a new file named app.py with the following content:

from shinychat.express import Chat

# Create a chat instance and display it
chat = Chat(id="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):
    # Simply echo the user's input back to them
    await chat.append_message(f"You said: {user_input}")

To run the app, execute the following command in your terminal (or via the Shiny extension):

uv shiny run --reload app.py

Learn more

The official shiny website offers the best starting point for learning about shinychat: