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).
-
Clone the Repository:
git clone https://github.com/yourusername/rich-chat-room.git cd rich-chat-room
-
Install Dependencies:
You can install the required dependency
richvia 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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rich_chat_room-0.1.0.tar.gz | 3.7 kB | Without provenance | Details for rich_chat_room-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rich_chat_room-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for rich_chat_room-0.1.0-py3-none-any.whl |
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
|
Security for rich-chat-room 0.1.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.