fastchat.serve.gradio_patch
Adopted from https://github.com/gradio-app/gradio/blob/main/gradio/components.py Fix a markdown render problem.
Module Contents
Classes
Displays a chatbot output showing both user submitted messages and responses. Supports a subset of Markdown including bold, italics, code, and images. |
- class fastchat.serve.gradio_patch.Chatbot(value: List[Tuple[str | None, str | None]] | Callable | None = None, color_map: Dict[str, str] | None = None, *, label: str | None = None, every: float | None = None, show_label: bool = True, visible: bool = True, elem_id: str | None = None, elem_classes: List[str] | str | None = None, **kwargs)[source]
Displays a chatbot output showing both user submitted messages and responses. Supports a subset of Markdown including bold, italics, code, and images. Preprocessing: this component does not accept input. Postprocessing: expects function to return a {List[Tuple[str | None | Tuple, str | None | Tuple]]}, a list of tuples with user message and response messages. Messages should be strings, tuples, or Nones. If the message is a string, it can include Markdown. If it is a tuple, it should consist of (string filepath to image/video/audio, [optional string alt text]). Messages that are None are not displayed.
Demos: chatbot_simple, chatbot_multimodal
- select: EventListenerMethod[source]
Event listener for when the user selects message from Chatbot. Uses event data gradio.SelectData to carry value referring to text of selected message, and index tuple to refer to [message, participant] index. See EventData documentation on how to use this event data.
- postprocess(y: List[Tuple[str | Tuple | List | Dict | None, str | Tuple | List | Dict | None]]) List[Tuple[str | Dict | None, str | Dict | None]][source]
- Parameters:
y – List of tuples representing the message and response pairs. Each message and response should be a string, which may be in Markdown format. It can also be a tuple whose first element is a string filepath or URL to an image/video/audio, and second (optional) element is the alt text, in which case the media file is displayed. It can also be None, in which case that message is not displayed.
- Returns:
List of tuples representing the message and response. Each message and response will be a string of HTML, or a dictionary with media information.