mirror of
https://github.com/open-webui/docs
synced 2025-06-16 11:28:36 +00:00
Update index.mdx
This commit is contained in:
parent
e8b2de229e
commit
5a07b5553e
@ -102,131 +102,250 @@ Below is a comprehensive table of **all supported `type` values** for events, al
|
|||||||
- You can define your own types and handle them at the UI layer (or use upcoming event-extension mechanisms).
|
- You can define your own types and handle them at the UI layer (or use upcoming event-extension mechanisms).
|
||||||
|
|
||||||
### ❗ Details on Specific Event Types
|
### ❗ Details on Specific Event Types
|
||||||
|
### `status`
|
||||||
|
|
||||||
#### `status`
|
Show a status/progress update in the UI:
|
||||||
|
|
||||||
Show an updating status/history block for a message (e.g., progress).
|
|
||||||
**Data Example:**
|
|
||||||
```python
|
```python
|
||||||
{
|
await __event_emitter__(
|
||||||
|
{
|
||||||
|
"type": "status",
|
||||||
|
"data": {
|
||||||
"description": "Step 1/3: Fetching data...",
|
"description": "Step 1/3: Fetching data...",
|
||||||
"done": False,
|
"done": False,
|
||||||
"hidden": False
|
"hidden": False,
|
||||||
}
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `chat:message:delta` or `message`
|
---
|
||||||
|
|
||||||
Append text to the message in progress (streaming output).
|
### `chat:message:delta` or `message`
|
||||||
|
|
||||||
|
**Streaming output** (append text):
|
||||||
|
|
||||||
```python
|
```python
|
||||||
{
|
await __event_emitter__(
|
||||||
"content": "Partial text"
|
{
|
||||||
}
|
"type": "chat:message:delta", # or simply "message"
|
||||||
|
"data": {
|
||||||
|
"content": "Partial text, "
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Later, as you generate more:
|
||||||
|
await __event_emitter__(
|
||||||
|
{
|
||||||
|
"type": "chat:message:delta",
|
||||||
|
"data": {
|
||||||
|
"content": "next chunk of response."
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `chat:message` or `replace`
|
---
|
||||||
|
|
||||||
Set or replace the entire message content.
|
### `chat:message` or `replace`
|
||||||
|
|
||||||
|
**Set (or replace) the entire message content:**
|
||||||
|
|
||||||
```python
|
```python
|
||||||
{
|
await __event_emitter__(
|
||||||
"content": "Final complete response."
|
{
|
||||||
}
|
"type": "chat:message", # or "replace"
|
||||||
|
"data": {
|
||||||
|
"content": "Final, complete response."
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `files` or `chat:message:files`
|
---
|
||||||
|
|
||||||
Set or update the array of files for a message (useful for file uploads or response with files):
|
### `files` or `chat:message:files`
|
||||||
|
|
||||||
|
**Attach or update files:**
|
||||||
|
|
||||||
```python
|
```python
|
||||||
{
|
await __event_emitter__(
|
||||||
|
{
|
||||||
|
"type": "files", # or "chat:message:files"
|
||||||
|
"data": {
|
||||||
"files": [
|
"files": [
|
||||||
{ "name": "file.txt", "url": "https://..." }
|
# Open WebUI File Objects
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `chat:title`
|
---
|
||||||
|
|
||||||
Update the conversation title or trigger UI to refresh titles.
|
### `chat:title`
|
||||||
|
|
||||||
|
**Update the chat's title:**
|
||||||
|
|
||||||
```python
|
```python
|
||||||
{
|
await __event_emitter__(
|
||||||
"title": "New conversation subject"
|
{
|
||||||
}
|
"type": "chat:title",
|
||||||
|
"data": {
|
||||||
|
"title": "Market Analysis Bot Session"
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `chat:tags`
|
---
|
||||||
|
|
||||||
Update tags on the current chat session.
|
### `chat:tags`
|
||||||
|
|
||||||
|
**Update the chat's tags:**
|
||||||
|
|
||||||
```python
|
```python
|
||||||
{
|
await __event_emitter__(
|
||||||
"tags": ["work", "openai", "todo"]
|
{
|
||||||
}
|
"type": "chat:tags",
|
||||||
|
"data": {
|
||||||
|
"tags": ["finance", "AI", "daily-report"]
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `source` or `citation` (and code execution)
|
---
|
||||||
|
|
||||||
Append a source reference, or—if `type: code_execution` inside `data`—track code execution state for the message.
|
### `source` or `citation` (and code execution)
|
||||||
|
|
||||||
|
**Add a reference/citation:**
|
||||||
|
|
||||||
```python
|
```python
|
||||||
{
|
await __event_emitter__(
|
||||||
"type": "code_execution",
|
{
|
||||||
"id": "unique-id-abc",
|
"type": "source", # or "citation"
|
||||||
"status": "running" | "done" | "error",
|
"data": {
|
||||||
"output": "...",
|
# Open WebUI Source (Citation) Object
|
||||||
...
|
}
|
||||||
}
|
}
|
||||||
```
|
)
|
||||||
If not code, ordinary reference/citation data is added to message `.sources`.
|
|
||||||
|
|
||||||
#### `notification`
|
|
||||||
|
|
||||||
Show a UI "toast" for the user.
|
|
||||||
|
|
||||||
```python
|
|
||||||
{
|
|
||||||
"type": "success", # or "error", "info", "warning"
|
|
||||||
"content": "Successfully completed action!"
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `confirmation` (**requires** `await __event_call__`)
|
**For code execution (track execution state):**
|
||||||
|
|
||||||
Presents an OK/Cancel/Yes/No confirmation dialog to the user, returns user response.
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
{
|
await __event_emitter__(
|
||||||
|
{
|
||||||
|
"type": "source",
|
||||||
|
"data": {
|
||||||
|
# Open WebUI Code Source (Citation) Object
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### `notification`
|
||||||
|
|
||||||
|
**Show a toast notification:**
|
||||||
|
|
||||||
|
```python
|
||||||
|
await __event_emitter__(
|
||||||
|
{
|
||||||
|
"type": "notification",
|
||||||
|
"data": {
|
||||||
|
"type": "info", # "success", "warning", "error"
|
||||||
|
"content": "The operation completed successfully!"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### `confirmation` (**requires** `__event_call__`)
|
||||||
|
|
||||||
|
**Show a confirm dialog and get user response:**
|
||||||
|
|
||||||
|
```python
|
||||||
|
result = await __event_call__(
|
||||||
|
{
|
||||||
|
"type": "confirmation",
|
||||||
|
"data": {
|
||||||
"title": "Are you sure?",
|
"title": "Are you sure?",
|
||||||
"message": "Do you want to continue?",
|
"message": "Do you really want to proceed?"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
if result: # or check result contents
|
||||||
|
await __event_emitter__({
|
||||||
|
"type": "notification",
|
||||||
|
"data": {"type": "success", "content": "User confirmed operation."}
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
await __event_emitter__({
|
||||||
|
"type": "notification",
|
||||||
|
"data": {"type": "warning", "content": "User cancelled."}
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `input` (**requires** `await __event_call__`)
|
---
|
||||||
|
|
||||||
Prompts user for simple text input (modal input box).
|
### `input` (**requires** `__event_call__`)
|
||||||
|
|
||||||
|
**Prompt user for text input:**
|
||||||
|
|
||||||
```python
|
```python
|
||||||
{
|
result = await __event_call__(
|
||||||
"title": "Enter your email",
|
{
|
||||||
"message": "We'll send you a receipt.",
|
"type": "input",
|
||||||
"placeholder": "user@example.com"
|
"data": {
|
||||||
}
|
"title": "Enter your name",
|
||||||
|
"message": "We need your name to proceed.",
|
||||||
|
"placeholder": "Your full name"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
user_input = result
|
||||||
|
await __event_emitter__(
|
||||||
|
{
|
||||||
|
"type": "notification",
|
||||||
|
"data": {"type": "info", "content": f"You entered: {user_input}"}
|
||||||
|
}
|
||||||
|
)
|
||||||
```
|
```
|
||||||
Returns `{value: ...}`.
|
|
||||||
|
|
||||||
#### `execute` (**requires** `await __event_call__`)
|
---
|
||||||
|
|
||||||
Evaluates code client-side (dangerous!). Used for specialized scenarios.
|
### `execute` (**requires** `__event_call__`)
|
||||||
|
|
||||||
|
**Run code dynamically on the user's side:**
|
||||||
|
|
||||||
```python
|
```python
|
||||||
{
|
result = await __event_call__(
|
||||||
"code": "return 2 + 2;"
|
{
|
||||||
}
|
"type": "execute",
|
||||||
|
"data": {
|
||||||
|
"code": "print(40 + 2);",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
await __event_emitter__(
|
||||||
|
{
|
||||||
|
"type": "notification",
|
||||||
|
"data": {
|
||||||
|
"type": "info",
|
||||||
|
"content": f"Code executed, result: {result}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
```
|
```
|
||||||
Returns the result of evaluation.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user