Content
Chatbot
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
Name | Type | Description | Options |
---|---|---|---|
Conversation | Object | An array with messages or a writer.ai.Conversation object. | |
Assistant initials | Text | ||
User initials | Text | ||
Use Markdown | Text | If active, the output will be sanitized; unsafe elements will be removed. |
|
Enable file upload | Text |
| |
Placeholder | Text | ||
Assistant role | Color | ||
User role | Color | ||
Avatar | Color | ||
Avatar text | Color | ||
Accent | Color | ||
Container background | Color | ||
Primary text | Color | ||
Secondary text | Color | ||
Separator | Color | ||
Button | Color | ||
Button text | Color | ||
Custom CSS classes | Text | CSS 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