Skip to main content

jupyter-chat-widget

A simple chat UI widget for Jupyter notebooks with streaming response support, designed to integrate easily with LLM APIs.

Note: this widget uses ipywidgets<8.0.0 for compatibility with Colab.

CI Docs PyPI version Python versions

Installation

pip install jupyter-chat-widget

Quick Start

from jupyter_chat_widget import ChatUI

# Create the chat widget
chat = ChatUI()

# Define a handler for user messages
def handle_message(message: str) -> None:
    # Stream a response token by token
    for word in message.split():
        chat.append(word + " ")

# Connect the handler
chat.connect(handle_message)

Documentation

See the live documentation or the example notebook in examples/.

API Reference

ChatUI

The main chat widget class.

Methods

Method Description
connect(callback) Connect a callback function to handle user messages
append(token) Append text to the current assistant response (streaming)
rewrite(text) Replace the entire assistant response
clear() Clear all chat history and current response

Example: Streaming Responses

from jupyter_chat_widget import ChatUI
from time import sleep

chat = ChatUI()

def slow_echo(message: str) -> None:
    """Echo back the message word by word."""
    for word in message.split():
        sleep(0.5)  # Simulate processing time
        chat.append(word + " ")
    chat.rewrite(f"You said: {message}")

chat.connect(slow_echo)

Example: Integration with LLM

from jupyter_chat_widget import ChatUI

chat = ChatUI()

def llm_handler(message: str) -> None:
    """Stream responses from an LLM API."""
    # Replace with your LLM API call
    for token in your_llm_api.stream(message):
        chat.append(token)

chat.connect(llm_handler)

Development

# Clone the repository
git clone https://github.com/zansara/jupyter-chat-widget.git
cd jupyter-chat-widget

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run linting
ruff check src tests
ruff format src tests

# Build the package
python -m build

Pre-commit Hooks

# Install pre-commit hooks
pre-commit install

# Run hooks on all files
pre-commit run --all-files

License

MIT License - see LICENSE for details.

Metadata

Release files for jupyter-chat-widget 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jupyter-chat-widget 0.4.0
File Size Uploaded Provenance
jupyter_chat_widget-0.4.0.tar.gz 5.4 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for jupyter-chat-widget 0.4.0
File Interpreter ABI Platform
jupyter_chat_widget-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.2 kB

Release files / jupyter_chat_widget-0.4.0.tar.gz

Download URL jupyter_chat_widget-0.4.0.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4878fe8e5f8ee99af6eb1fe23338ac46f04ab6afdd6e08f05404fa8afc4975e2
BLAKE2b-256 checksum
How to use checksums
cb9aa8de6503fa239b2d6e7221dddf79436a2b6e6f21f773723e1b586b6c7c52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 17, 2026.

Transparency log

Release files / jupyter_chat_widget-0.4.0-py3-none-any.whl

Download URL jupyter_chat_widget-0.4.0-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a3250fe25e93ecaaa53e5956f7ed57b55f91e9dbbaa4274a1fd914094fd9554f
BLAKE2b-256 checksum
How to use checksums
d95bf602a6836b30367a781274de607699b6091784e01fbce1170f9cddc7a1cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 17, 2026.

Transparency log

Security for jupyter-chat-widget 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for jupyter_chat_widget-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page