Skip to main content

rich-chat-room

rich-chat-room is a modern, dynamic chat interface built using Python and the Rich library. It provides a visually appealing command-line interface that displays chat messages in a structured and colorful layout.

Overview

This project demonstrates how to leverage the Rich library to create a chat room experience in the terminal. It supports features like:

  • Dynamic Layout: Automatically splits the terminal into header and chat areas.
  • Message Bubbles: Displays messages with distinct styles based on the sender.
  • Adaptive Rendering: Only renders the most recent messages that fit within the visible terminal window.

Installation

Ensure you are using Python 3.9 or later (but less than 4.0).

  1. Clone the Repository:

    git clone https://github.com/yourusername/rich-chat-room.git
    cd rich-chat-room
    
  2. Install Dependencies:

    You can install the required dependency rich via pip:

    pip install rich
    

    Alternatively, if you prefer using Poetry:

    poetry install
    

Usage

To integrate and use the chat room in your application, import the module and call the render_chat_room function with a list of messages. For example:

from rich_chat_room import render_chat_room
from rich.console import Console

console = Console()

# Example messages
messages = [
    {"role": "user", "content": "Hello, how are you?"},
    {"role": "assistant", "content": "I'm doing great, thanks for asking!"}
]

# Render the chat room layout
layout = render_chat_room(messages)

# Clear the terminal and display the layout
console.clear()
console.print(layout)

This snippet will render a chat room with a header and the provided messages, automatically aligning user and assistant messages appropriately.

Testing

Tests for the chat room functionality are included using pytest. To run the tests, simply execute:

pytest

Contributing

Contributions are welcome! If you have ideas for improvements, bug fixes, or additional features, feel free to open an issue or submit a pull request.

License

rich-chat-room is open-source software released under the MIT License.

Metadata

Release files for rich-chat-room 0.1.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 rich-chat-room 0.1.0
File Size Uploaded
rich_chat_room-0.1.0.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rich-chat-room 0.1.0
File Interpreter ABI Platform
rich_chat_room-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.2 kB

Release files / rich_chat_room-0.1.0.tar.gz

Download URL rich_chat_room-0.1.0.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ff4f4f2ffa2845f161352baf1376fbfdc28ef8e59399fc394504787124cfe54d
BLAKE2b-256 checksum
How to use checksums
201ec9bc85f2af69a3bbd9667469e9ad3174f5288c931d10871d447f3c14e77e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.12.8 Darwin/24.2.0

Release files / rich_chat_room-0.1.0-py3-none-any.whl

Download URL rich_chat_room-0.1.0-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3fa493993d247f22e0d61af39c2510640c06b9d320e5135022d8aa50867038f3
BLAKE2b-256 checksum
How to use checksums
6ef1b40595a5352f9525598d985ea6e33596afaba191497c610633c50718e77e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.12.8 Darwin/24.2.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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