gradio-multichat


Namegradio-multichat JSON
Version 0.0.6 PyPI version JSON
download
home_page
SummaryA Gradio Chatbot variant for handling multiple characters with customizable profiles, pictures, and CSS. Ideal for diverse tasks like multi-entity conversations and role-playing scenarios.
upload_time2024-03-04 06:21:25
maintainer
docs_urlNone
authorgr1336
requires_python>=3.8
license
keywords actors agents characters chat chatbot entities gradio gradio-custom-component gradio-template-chatbot multi multiple roleplay roleplaying
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# `gradio_multichat`
<a href="https://pypi.org/project/gradio_multichat/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_multichat"></a>  

A Gradio Chatbot variant for handling multiple characters with customizable profiles, pictures, and CSS. Ideal for diverse tasks like multi-entity conversations and role-playing scenarios.

## Installation

```bash
pip install gradio_multichat
```

## Usage

```python
import os
import time
import gradio as gr
from random import choice
from typing import Literal, Optional
from gradio_multichat import MultiChat as mc


def print_like_dislike(x: gr.LikeData):
    print(x.index, x.value, x.liked)


# Setup some custom CSS styles that will be used by some of the characters
css = """
.char-style-a {
  color: #0e0e0e;
  background: #8084eb;
  font-size: 22px;
  font-weight: 800;
}
.char-style-b {
  color: #10f1f2;
  background: #666666;
}
.char-style-c {
  background: #a42727;
  font-weight: 600;
}
"""


class MessageControl:
    def __init__(self, characters: Optional[list[dict[str, None]]]) -> None:
        self.characters = []
        self.participants = []
        if characters:
            [self.process_character(**x) for x in characters]

    def process_character(
        self,
        role: str,
        position: Literal["bot", "user"] | None = None,
        avatar: str | None | os.PathLike = None,
        style: str | None = None,
    ):
        position = (
            "bot"
            if not isinstance(position, str) or position not in ["bot", "user"]
            else position
        )
        self.characters.append(
            {
                "role": role,
                "position": position,
                "avatar": avatar,
                "style": style if isinstance(style, str) and style.strip() else None,
            }
        )
        if role not in self.participants:
            self.participants.append(role)
        return (
            gr.update(choices=self.participants),
            gr.update(characters=self.characters),
            gr.update(characters=self.characters),
        )

    def add_message(self, role: str, message: str):
        return {"role": role, "content": message}

    def clear_history(self):
        return None

    def generate(self, value, participants: list[str], history:list[dict]):
        if not participants:
            participants = self.participants
        history = history["messages"]
        history.append({"role":"user", "content":value})
        yield history
        time.sleep(1)
        history.append({"role":"bot", "content":value})
        yield history
        for character in participants:
            history.append({"role":character, "content":""})
            for char in choice(RANDOM_CHAT):
                history[-1]["content"] += char
                time.sleep(0.015)
                yield history


# Characters for this demo
characters = [
    {"role": "user", "position": "user", "avatar": "demo/User.png"},
    {"role": "bot", "position": "bot", "avatar": "demo/Assistant.png"},
    {"role": "Carl", "position": "user", "style": "char-style-b"},
    {"role": "Klaus", "position": "bot", "avatar": "demo/Klaus.png"},
    {
        "role": "Mark",
        "position": "bot",
        "avatar": "demo/Mark.png",
        "style": "char-style-c",
    },
    {
        "role": "John",
        "position": "user",
        "avatar": "demo/John.png",
        "style": "char-style-a",
    },
]
# Random speech lines for testing:
RANDOM_CHAT = [
    "Did you know that pineapples wear sunglasses during winter?",
    "I tried teaching my pet rock algebra, but it kept rolling away.",
    "In a parallel universe, marshmallows are the currency.",
    "My toaster and I have deep philosophical discussions about life.",
    "Yesterday, I saw a giraffe playing the saxophone in the park.",
    "I'm thinking of starting a dance crew for synchronized swimming.",
    "Bananas have secret meetings at midnight to discuss their peelings.",
    "I have a collection of invisible paintings – they're quite rare.",
    "I communicate with my plants through interpretive dance.",
    "I once raced a snail. It was intense, but I lost... eventually.",
    "I speak fluent penguin – it's a highly underrated skill.",
    "I'm training my pet rock to participate in the next rock Olympics.",
    "Have you ever tried square-shaped watermelons? They taste cubic.",
    "I have a conspiracy theory that trees are just really slow dancers.",
]

with gr.Blocks(css=css, title="Demo gradio_multichat") as demo:
    msg = MessageControl(characters)
    msg.history = [
        {"role": "user", "content": choice(RANDOM_CHAT)},
        {"role": "bot", "content": choice(RANDOM_CHAT)},
        {"role": "Mark", "content": choice(RANDOM_CHAT)},
        {"role": "John", "content": choice(RANDOM_CHAT)},
    ]

    chatbot = mc(
        value=msg.history,
        label="MultiChatbot",
        characters=msg.characters,
        layout="bubble",
        height=600,
        likeable=True,
        show_copy_button=True,
    )

    with gr.Row():
        with gr.Column(scale=999):
            text_input = gr.Textbox(
                interactive=True,
                placeholder="Write here your message.",
                container=False,
                lines=7,
                max_lines=7,
            )
        with gr.Group():
            send_button = gr.Button("Send", variant="primary")
            clear_btn = gr.Button("Clear")
            delete_last_btn = gr.Button("Delete Last Entry", variant="stop")
            edit_last_btn = gr.Button("Edit Last Entry")

    with gr.Row():
        chatstyle_menu = gr.Dropdown(
            choices=["bubble", "panel"],
            value="bubble",
            interactive=True,
            label="MultiChat Style",
            allow_custom_value=True,
        )
        participants_menu = gr.Dropdown(
            choices=msg.participants,
            interactive=True,
            label="Participants",
            max_choices=32,
            multiselect=True,
            allow_custom_value=True,
        )
    with gr.Accordion("Create Character"):
        with gr.Row():
            char_name = gr.Textbox(
                interactive=True,
                label="Character's Name",
                placeholder="Insert the character's name here",
            )
            char_position = gr.Dropdown(
                ["user", "bot"],
                value="bot",
                interactive=True,
                label="Character's position",
            )
        with gr.Row():
            char_picture = gr.Textbox(
                interactive=True,
                label="Character Profile Picture (Optional)",
                placeholder="Url or Path to image to be used as profile picture.",
            )
            char_style = gr.Textbox(
                interactive=True,
                label="CSS Style Template (Optional)",
                placeholder="CSS Style here.",
            )
        with gr.Row():
            btn_addchat = gr.Button("Add Character", variant="primary")
            chat_print = gr.Button("Print Content from chat")

    def ccf():
        return None, None, None, None

    btn_addchat.click(
        msg.process_character,
        [char_name, char_position, char_picture, char_style],
        [participants_menu, chatbot],
    ).then(
        ccf,
        outputs=[char_name, char_position, char_picture, char_style],
    )

    chat_print.click(lambda x: print(x), chatbot)
    chatstyle_menu.change(lambda x: gr.update(layout=x), chatstyle_menu, chatbot)
    gr.on(
        [send_button.click, text_input.submit],
        msg.generate,
        [text_input, participants_menu, chatbot],
        [chatbot],
    )

    clear_btn.click(lambda: None, outputs=[chatbot])

    chatbot.like(print_like_dislike, None, None)


if __name__ == "__main__":
    demo.launch()

```

## `MultiChat`

### Initialization

<table>
<thead>
<tr>
<th align="left">name</th>
<th align="left" style="width: 25%;">type</th>
<th align="left">default</th>
<th align="left">description</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left"><code>value</code></td>
<td align="left" style="width: 25%;">

```python
list[dict[str, str | None]] | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>characters</code></td>
<td align="left" style="width: 25%;">

```python
list[dict] | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>label</code></td>
<td align="left" style="width: 25%;">

```python
str | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>every</code></td>
<td align="left" style="width: 25%;">

```python
float | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>show_label</code></td>
<td align="left" style="width: 25%;">

```python
bool | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">if True, will display label. Defaults to None.</td>
</tr>

<tr>
<td align="left"><code>container</code></td>
<td align="left" style="width: 25%;">

```python
bool
```

</td>
<td align="left"><code>True</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>scale</code></td>
<td align="left" style="width: 25%;">

```python
int | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>min_width</code></td>
<td align="left" style="width: 25%;">

```python
int
```

</td>
<td align="left"><code>160</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>visible</code></td>
<td align="left" style="width: 25%;">

```python
bool
```

</td>
<td align="left"><code>True</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>elem_id</code></td>
<td align="left" style="width: 25%;">

```python
str | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>elem_classes</code></td>
<td align="left" style="width: 25%;">

```python
list[str] | str | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>render</code></td>
<td align="left" style="width: 25%;">

```python
bool
```

</td>
<td align="left"><code>True</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>height</code></td>
<td align="left" style="width: 25%;">

```python
int | str | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>latex_delimiters</code></td>
<td align="left" style="width: 25%;">

```python
list[dict[str, str | bool]] | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>rtl</code></td>
<td align="left" style="width: 25%;">

```python
bool
```

</td>
<td align="left"><code>False</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>show_copy_button</code></td>
<td align="left" style="width: 25%;">

```python
bool
```

</td>
<td align="left"><code>False</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>sanitize_html</code></td>
<td align="left" style="width: 25%;">

```python
bool
```

</td>
<td align="left"><code>True</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>render_markdown</code></td>
<td align="left" style="width: 25%;">

```python
bool
```

</td>
<td align="left"><code>True</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>bubble_full_width</code></td>
<td align="left" style="width: 25%;">

```python
bool
```

</td>
<td align="left"><code>True</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>line_breaks</code></td>
<td align="left" style="width: 25%;">

```python
bool
```

</td>
<td align="left"><code>True</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>likeable</code></td>
<td align="left" style="width: 25%;">

```python
bool
```

</td>
<td align="left"><code>False</code></td>
<td align="left">None</td>
</tr>

<tr>
<td align="left"><code>layout</code></td>
<td align="left" style="width: 25%;">

```python
"panel" | "bubble" | None
```

</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>
</tbody></table>


### Events

| name | description |
|:-----|:------------|
| `change` | Triggered when the value of the MultiChat changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input. |
| `select` | Event listener for when the user selects or deselects the MultiChat. Uses event data gradio.SelectData to carry `value` referring to the label of the MultiChat, and `selected` to refer to state of the MultiChat. See EventData documentation on how to use this event data |
| `like` | This listener is triggered when the user likes/dislikes from within the MultiChat. This event has EventData of type gradio.LikeData that carries information, accessible through LikeData.index and LikeData.value. See EventData documentation on how to use this event data. |



### User function

The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).

- When used as an Input, the component only impacts the input signature of the user function.
- When used as an output, the component only impacts the return signature of the user function.

The code snippet below is accurate in cases where the component is used as both an input and an output.

- **As output:** Is passed, a list of dictionaries that contain ready to deploy messages, or None.
- **As input:** Should return, receives a list of dictionaries containing dictionaries with both "role" and "content" in each, the "role" can be registred in characters, there is a default "user" and "bot" profile in there if its needed.

 ```python
 def predict(
     value: list[
        dict[str, str | gradio.data_classes.FileData | None]
    ]
    | None
 ) -> list[dict[str, str | list | None]] | None:
     return value
 ```
 

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "gradio-multichat",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "actors,agents,characters,chat,chatbot,entities,gradio,gradio-custom-component,gradio-template-Chatbot,multi,multiple,roleplay,roleplaying",
    "author": "gr1336",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/3f/31/7aa904c16e6548fda616077e2c1c5ea2bdd5691ded23563bb7259bb8bd0a/gradio_multichat-0.0.6.tar.gz",
    "platform": null,
    "description": "\n# `gradio_multichat`\n<a href=\"https://pypi.org/project/gradio_multichat/\" target=\"_blank\"><img alt=\"PyPI - Version\" src=\"https://img.shields.io/pypi/v/gradio_multichat\"></a>  \n\nA Gradio Chatbot variant for handling multiple characters with customizable profiles, pictures, and CSS. Ideal for diverse tasks like multi-entity conversations and role-playing scenarios.\n\n## Installation\n\n```bash\npip install gradio_multichat\n```\n\n## Usage\n\n```python\nimport os\nimport time\nimport gradio as gr\nfrom random import choice\nfrom typing import Literal, Optional\nfrom gradio_multichat import MultiChat as mc\n\n\ndef print_like_dislike(x: gr.LikeData):\n    print(x.index, x.value, x.liked)\n\n\n# Setup some custom CSS styles that will be used by some of the characters\ncss = \"\"\"\n.char-style-a {\n  color: #0e0e0e;\n  background: #8084eb;\n  font-size: 22px;\n  font-weight: 800;\n}\n.char-style-b {\n  color: #10f1f2;\n  background: #666666;\n}\n.char-style-c {\n  background: #a42727;\n  font-weight: 600;\n}\n\"\"\"\n\n\nclass MessageControl:\n    def __init__(self, characters: Optional[list[dict[str, None]]]) -> None:\n        self.characters = []\n        self.participants = []\n        if characters:\n            [self.process_character(**x) for x in characters]\n\n    def process_character(\n        self,\n        role: str,\n        position: Literal[\"bot\", \"user\"] | None = None,\n        avatar: str | None | os.PathLike = None,\n        style: str | None = None,\n    ):\n        position = (\n            \"bot\"\n            if not isinstance(position, str) or position not in [\"bot\", \"user\"]\n            else position\n        )\n        self.characters.append(\n            {\n                \"role\": role,\n                \"position\": position,\n                \"avatar\": avatar,\n                \"style\": style if isinstance(style, str) and style.strip() else None,\n            }\n        )\n        if role not in self.participants:\n            self.participants.append(role)\n        return (\n            gr.update(choices=self.participants),\n            gr.update(characters=self.characters),\n            gr.update(characters=self.characters),\n        )\n\n    def add_message(self, role: str, message: str):\n        return {\"role\": role, \"content\": message}\n\n    def clear_history(self):\n        return None\n\n    def generate(self, value, participants: list[str], history:list[dict]):\n        if not participants:\n            participants = self.participants\n        history = history[\"messages\"]\n        history.append({\"role\":\"user\", \"content\":value})\n        yield history\n        time.sleep(1)\n        history.append({\"role\":\"bot\", \"content\":value})\n        yield history\n        for character in participants:\n            history.append({\"role\":character, \"content\":\"\"})\n            for char in choice(RANDOM_CHAT):\n                history[-1][\"content\"] += char\n                time.sleep(0.015)\n                yield history\n\n\n# Characters for this demo\ncharacters = [\n    {\"role\": \"user\", \"position\": \"user\", \"avatar\": \"demo/User.png\"},\n    {\"role\": \"bot\", \"position\": \"bot\", \"avatar\": \"demo/Assistant.png\"},\n    {\"role\": \"Carl\", \"position\": \"user\", \"style\": \"char-style-b\"},\n    {\"role\": \"Klaus\", \"position\": \"bot\", \"avatar\": \"demo/Klaus.png\"},\n    {\n        \"role\": \"Mark\",\n        \"position\": \"bot\",\n        \"avatar\": \"demo/Mark.png\",\n        \"style\": \"char-style-c\",\n    },\n    {\n        \"role\": \"John\",\n        \"position\": \"user\",\n        \"avatar\": \"demo/John.png\",\n        \"style\": \"char-style-a\",\n    },\n]\n# Random speech lines for testing:\nRANDOM_CHAT = [\n    \"Did you know that pineapples wear sunglasses during winter?\",\n    \"I tried teaching my pet rock algebra, but it kept rolling away.\",\n    \"In a parallel universe, marshmallows are the currency.\",\n    \"My toaster and I have deep philosophical discussions about life.\",\n    \"Yesterday, I saw a giraffe playing the saxophone in the park.\",\n    \"I'm thinking of starting a dance crew for synchronized swimming.\",\n    \"Bananas have secret meetings at midnight to discuss their peelings.\",\n    \"I have a collection of invisible paintings \u2013 they're quite rare.\",\n    \"I communicate with my plants through interpretive dance.\",\n    \"I once raced a snail. It was intense, but I lost... eventually.\",\n    \"I speak fluent penguin \u2013 it's a highly underrated skill.\",\n    \"I'm training my pet rock to participate in the next rock Olympics.\",\n    \"Have you ever tried square-shaped watermelons? They taste cubic.\",\n    \"I have a conspiracy theory that trees are just really slow dancers.\",\n]\n\nwith gr.Blocks(css=css, title=\"Demo gradio_multichat\") as demo:\n    msg = MessageControl(characters)\n    msg.history = [\n        {\"role\": \"user\", \"content\": choice(RANDOM_CHAT)},\n        {\"role\": \"bot\", \"content\": choice(RANDOM_CHAT)},\n        {\"role\": \"Mark\", \"content\": choice(RANDOM_CHAT)},\n        {\"role\": \"John\", \"content\": choice(RANDOM_CHAT)},\n    ]\n\n    chatbot = mc(\n        value=msg.history,\n        label=\"MultiChatbot\",\n        characters=msg.characters,\n        layout=\"bubble\",\n        height=600,\n        likeable=True,\n        show_copy_button=True,\n    )\n\n    with gr.Row():\n        with gr.Column(scale=999):\n            text_input = gr.Textbox(\n                interactive=True,\n                placeholder=\"Write here your message.\",\n                container=False,\n                lines=7,\n                max_lines=7,\n            )\n        with gr.Group():\n            send_button = gr.Button(\"Send\", variant=\"primary\")\n            clear_btn = gr.Button(\"Clear\")\n            delete_last_btn = gr.Button(\"Delete Last Entry\", variant=\"stop\")\n            edit_last_btn = gr.Button(\"Edit Last Entry\")\n\n    with gr.Row():\n        chatstyle_menu = gr.Dropdown(\n            choices=[\"bubble\", \"panel\"],\n            value=\"bubble\",\n            interactive=True,\n            label=\"MultiChat Style\",\n            allow_custom_value=True,\n        )\n        participants_menu = gr.Dropdown(\n            choices=msg.participants,\n            interactive=True,\n            label=\"Participants\",\n            max_choices=32,\n            multiselect=True,\n            allow_custom_value=True,\n        )\n    with gr.Accordion(\"Create Character\"):\n        with gr.Row():\n            char_name = gr.Textbox(\n                interactive=True,\n                label=\"Character's Name\",\n                placeholder=\"Insert the character's name here\",\n            )\n            char_position = gr.Dropdown(\n                [\"user\", \"bot\"],\n                value=\"bot\",\n                interactive=True,\n                label=\"Character's position\",\n            )\n        with gr.Row():\n            char_picture = gr.Textbox(\n                interactive=True,\n                label=\"Character Profile Picture (Optional)\",\n                placeholder=\"Url or Path to image to be used as profile picture.\",\n            )\n            char_style = gr.Textbox(\n                interactive=True,\n                label=\"CSS Style Template (Optional)\",\n                placeholder=\"CSS Style here.\",\n            )\n        with gr.Row():\n            btn_addchat = gr.Button(\"Add Character\", variant=\"primary\")\n            chat_print = gr.Button(\"Print Content from chat\")\n\n    def ccf():\n        return None, None, None, None\n\n    btn_addchat.click(\n        msg.process_character,\n        [char_name, char_position, char_picture, char_style],\n        [participants_menu, chatbot],\n    ).then(\n        ccf,\n        outputs=[char_name, char_position, char_picture, char_style],\n    )\n\n    chat_print.click(lambda x: print(x), chatbot)\n    chatstyle_menu.change(lambda x: gr.update(layout=x), chatstyle_menu, chatbot)\n    gr.on(\n        [send_button.click, text_input.submit],\n        msg.generate,\n        [text_input, participants_menu, chatbot],\n        [chatbot],\n    )\n\n    clear_btn.click(lambda: None, outputs=[chatbot])\n\n    chatbot.like(print_like_dislike, None, None)\n\n\nif __name__ == \"__main__\":\n    demo.launch()\n\n```\n\n## `MultiChat`\n\n### Initialization\n\n<table>\n<thead>\n<tr>\n<th align=\"left\">name</th>\n<th align=\"left\" style=\"width: 25%;\">type</th>\n<th align=\"left\">default</th>\n<th align=\"left\">description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td align=\"left\"><code>value</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nlist[dict[str, str | None]] | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>characters</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nlist[dict] | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>label</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nstr | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>every</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nfloat | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>show_label</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">if True, will display label. Defaults to None.</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>container</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>scale</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nint | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>min_width</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nint\n```\n\n</td>\n<td align=\"left\"><code>160</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>visible</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>elem_id</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nstr | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>elem_classes</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nlist[str] | str | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>render</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>height</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nint | str | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>latex_delimiters</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nlist[dict[str, str | bool]] | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>rtl</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>False</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>show_copy_button</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>False</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>sanitize_html</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>render_markdown</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>bubble_full_width</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>line_breaks</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>True</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>likeable</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\nbool\n```\n\n</td>\n<td align=\"left\"><code>False</code></td>\n<td align=\"left\">None</td>\n</tr>\n\n<tr>\n<td align=\"left\"><code>layout</code></td>\n<td align=\"left\" style=\"width: 25%;\">\n\n```python\n\"panel\" | \"bubble\" | None\n```\n\n</td>\n<td align=\"left\"><code>None</code></td>\n<td align=\"left\">None</td>\n</tr>\n</tbody></table>\n\n\n### Events\n\n| name | description |\n|:-----|:------------|\n| `change` | Triggered when the value of the MultiChat changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input. |\n| `select` | Event listener for when the user selects or deselects the MultiChat. Uses event data gradio.SelectData to carry `value` referring to the label of the MultiChat, and `selected` to refer to state of the MultiChat. See EventData documentation on how to use this event data |\n| `like` | This listener is triggered when the user likes/dislikes from within the MultiChat. This event has EventData of type gradio.LikeData that carries information, accessible through LikeData.index and LikeData.value. See EventData documentation on how to use this event data. |\n\n\n\n### User function\n\nThe impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).\n\n- When used as an Input, the component only impacts the input signature of the user function.\n- When used as an output, the component only impacts the return signature of the user function.\n\nThe code snippet below is accurate in cases where the component is used as both an input and an output.\n\n- **As output:** Is passed, a list of dictionaries that contain ready to deploy messages, or None.\n- **As input:** Should return, receives a list of dictionaries containing dictionaries with both \"role\" and \"content\" in each, the \"role\" can be registred in characters, there is a default \"user\" and \"bot\" profile in there if its needed.\n\n ```python\n def predict(\n     value: list[\n        dict[str, str | gradio.data_classes.FileData | None]\n    ]\n    | None\n ) -> list[dict[str, str | list | None]] | None:\n     return value\n ```\n \n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A Gradio Chatbot variant for handling multiple characters with customizable profiles, pictures, and CSS. Ideal for diverse tasks like multi-entity conversations and role-playing scenarios.",
    "version": "0.0.6",
    "project_urls": null,
    "split_keywords": [
        "actors",
        "agents",
        "characters",
        "chat",
        "chatbot",
        "entities",
        "gradio",
        "gradio-custom-component",
        "gradio-template-chatbot",
        "multi",
        "multiple",
        "roleplay",
        "roleplaying"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b711d0a4982f04ca788251a87d57b513e5d7d5c1f1220737c7405d140a91b030",
                "md5": "24526ff608a2bd9e6e076a787a607d3c",
                "sha256": "ee62c34eeed2754a950eedd79efd176e7e3c1894aafb39221085b91042c2e6ca"
            },
            "downloads": -1,
            "filename": "gradio_multichat-0.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "24526ff608a2bd9e6e076a787a607d3c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 1141822,
            "upload_time": "2024-03-04T06:21:23",
            "upload_time_iso_8601": "2024-03-04T06:21:23.433345Z",
            "url": "https://files.pythonhosted.org/packages/b7/11/d0a4982f04ca788251a87d57b513e5d7d5c1f1220737c7405d140a91b030/gradio_multichat-0.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3f317aa904c16e6548fda616077e2c1c5ea2bdd5691ded23563bb7259bb8bd0a",
                "md5": "05f239c0ee6824ad995a292462ae68d1",
                "sha256": "e2845a9103f43f7ea83bd3ff5724206cade681ecb4c44afa1fbf4faa9fc0c313"
            },
            "downloads": -1,
            "filename": "gradio_multichat-0.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "05f239c0ee6824ad995a292462ae68d1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 3566161,
            "upload_time": "2024-03-04T06:21:25",
            "upload_time_iso_8601": "2024-03-04T06:21:25.812810Z",
            "url": "https://files.pythonhosted.org/packages/3f/31/7aa904c16e6548fda616077e2c1c5ea2bdd5691ded23563bb7259bb8bd0a/gradio_multichat-0.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-04 06:21:25",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "gradio-multichat"
}
        
Elapsed time: 0.19456s