Metadata-Version: 2.4
Name: shinychat
Version: 0.2.8
Summary: An AI Chat interface for Shiny apps.
Project-URL: Homepage, https://posit-dev.github.io/shinychat/
Project-URL: Documentation, https://posit-dev.github.io/shinychat/py/
Project-URL: Repository, https://github.com/posit-dev/shinychat
Project-URL: Issues, https://github.com/posit-dev/shinychat/issues/
Project-URL: Changelog, https://github.com/posit-dev/shinychat/blob/main/pkg-py/CHANGELOG.md
Author-email: Joe Cheng <joe@posit.co>, Carson Sievert <carson@posit.co>, Garrick Aden-Buie <garrick@posit.co>
License: MIT
License-File: LICENSE
Requires-Python: >=3.9
Requires-Dist: htmltools>=0.6.0
Requires-Dist: shiny>=1.4.0
Provides-Extra: providers
Requires-Dist: anthropic; (python_version >= '3.11') and extra == 'providers'
Requires-Dist: chatlas[mcp]>=0.12.0; extra == 'providers'
Requires-Dist: google-generativeai; extra == 'providers'
Requires-Dist: langchain-core; extra == 'providers'
Requires-Dist: ollama>=0.4.0; extra == 'providers'
Requires-Dist: openai; extra == 'providers'
Requires-Dist: pydantic; extra == 'providers'
Requires-Dist: tokenizers; extra == 'providers'
Provides-Extra: test
Requires-Dist: coverage>=7.8.2; extra == 'test'
Requires-Dist: faicons; extra == 'test'
Requires-Dist: ipyleaflet; extra == 'test'
Requires-Dist: pandas; extra == 'test'
Requires-Dist: playwright>=1.43.0; extra == 'test'
Requires-Dist: plotly; extra == 'test'
Requires-Dist: pyright>=1.1.398; extra == 'test'
Requires-Dist: pytest-playwright>=0.3.0; extra == 'test'
Requires-Dist: pytest>=6.2.4; extra == 'test'
Requires-Dist: shinylive; extra == 'test'
Requires-Dist: shinywidgets; extra == 'test'
Requires-Dist: tox-uv>=1; extra == 'test'
Description-Content-Type: text/markdown

# shinychat

<a href="https://posit-dev.github.io/shinychat/py"><img src="https://posit-dev.github.io/shinychat/logo.svg" align="right" height="138" alt="shinychat for Python website" /></a>

Chat UI component for [Shiny for Python](https://shiny.posit.co/py/).

**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](https://shiny.posit.co/py/docs/genai-chatbots.html).

## Installation

You can install shinychat from PyPI with:

```bash
uv pip install shinychat
```

Or, install the development version of shinychat from [GitHub](https://github.com/posit-dev/shinychat) with:

```bash
uv pip install git+https://github.com/posit-dev/shinychat.git
```

## Example

```r
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())
```
