A chatbot component to build human-to-AI interactions.

Connect it to an LLM by handling the wf-chatbot-message event, which is triggered every time the user sends a message.

You can add actions to messages, which are buttons that trigger the wf-chatbot-action-click.

See the stubs for more details.

Fields

NameTypeDescriptionOptions
ConversationObjectAn array with messages or a writer.ai.Conversation object.-
Assistant initialsText--
User initialsText--
Use MarkdownBooleanIf active, the output will be sanitized; unsafe elements will be removed.
  1. Yes
  2. No
Enable file uploadText-
  1. Single file
  2. Multiple files
  3. No
PlaceholderText--
Assistant roleColor--
User roleColor--
AvatarColor--
Avatar textColor--
AccentColor--
Container backgroundColor--
Primary textColor--
Secondary textColor--
SeparatorColor--
ButtonColor--
Button textColor--
Custom CSS classesTextCSS classes, separated by spaces. You can define classes in custom stylesheets.-

Events

Low code usage

This component can be declared directly in Python, using backend-driven UI.

ui.Chatbot(content={
        "conversation": {}, # Union[Dict, str] 
        "assistantInitials": "", # str 
        "userInitials": "", # str 
        "useMarkdown": "no", # str [yes, no]
        "enableFileUpload": "no", # str [single, multiple, no]
        "placeholder": "", # str 
        "assistantRoleColor": "", # str 
        "userRoleColor": "", # str 
        "avatarBackgroundColor": "", # str 
        "avatarTextColor": "", # str 
        "accentColor": "", # str 
        "containerBackgroundColor": "", # str 
        "primaryTextColor": "", # str 
        "secondaryTextColor": "", # str 
        "separatorColor": "", # str 
        "buttonColor": "", # str 
        "buttonTextColor": "", # str 
        "cssClasses": "", # str 
    },
    handlers={
        "wf-chatbot-message": handle_event,
        "wf-chatbot-action-click": handle_event,
        "wf-file-change": handle_event,
    }
)

A function, in this example handle_event, should be implemented in your code to handle events.

def handle_event(state, payload, context, ui):
  pass

Reference