Skip to main content

A chat room build in python rich.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rich_chat_room-0.1.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rich_chat_room-0.1.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file rich_chat_room-0.1.0.tar.gz.

File metadata

  • Download URL: rich_chat_room-0.1.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.8 Darwin/24.2.0

File hashes

Hashes for rich_chat_room-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ff4f4f2ffa2845f161352baf1376fbfdc28ef8e59399fc394504787124cfe54d
MD5 900713e20ca208375a1b162697c3ed52
BLAKE2b-256 201ec9bc85f2af69a3bbd9667469e9ad3174f5288c931d10871d447f3c14e77e

See more details on using hashes here.

File details

Details for the file rich_chat_room-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rich_chat_room-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.8 Darwin/24.2.0

File hashes

Hashes for rich_chat_room-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3fa493993d247f22e0d61af39c2510640c06b9d320e5135022d8aa50867038f3
MD5 3f071a015a5a58696e751f7c4f523693
BLAKE2b-256 6ef1b40595a5352f9525598d985ea6e33596afaba191497c610633c50718e77e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page