State Inspectors
March 3, 2025 ยท View on GitHub
Overview
State inspectors provide a way to visualize and interact with an assistant's internal state. Each assistant can have multiple state inspectors, with the config editor being a required inspector for all assistants.
State inspectors can be used for:
- Debugging assistant behavior
- Monitoring internal state changes
- Providing interactive interfaces for modifying assistant state
- Exposing data and attachments for user inspection
Accessing State Inspectors
State inspectors are available in the assistant's conversation view. To access them:
- Join a conversation with an assistant
- Click the
Show Inspectorsbutton in the conversation interface - A tabbed view will appear with each tab representing a different state
Rendering Methods
The inspector view will render state based on its content:
-
Content-based Rendering: If the state's
dataproperty contains acontentkey with a string value, it will be rendered as:- Markdown for formatted text
- HTML for rich content
- Plain text for simple content
-
Schema-based Rendering: If the state includes a
JsonSchemaproperty, a custom UI will be generated based on the schema:- Form elements will be created for each schema property
- If a
UISchemaproperty is provided, it will customize the UI appearance - Validation will follow the schema rules
-
JSON Fallback: If neither of the above applies, the state will be rendered as formatted JSON.
Interactive State Editing
When a state includes a JsonSchema property, the inspector provides editing capabilities:
- An edit button will appear in the inspector
- Clicking it opens a dialog with form elements based on the schema
- Users can modify values and save changes
- Changes are sent to the assistant, which is notified of the update
Attachments Support
State inspectors can include file attachments:
- If a state contains
attachmentsdata, files will be displayed with download options - Users can download attachments for local inspection
- Common file types may have preview capabilities
Implementing State Inspectors
Assistants can implement state inspectors by:
- Defining data models with appropriate JSON schemas
- Exposing state through the assistant service API
- Handling state change notifications from the user interface
- Updating state in response to internal events
Example Schema
{
"JsonSchema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Name"
},
"enabled": {
"type": "boolean",
"title": "Enabled"
},
"settings": {
"type": "object",
"properties": {
"threshold": {
"type": "number",
"title": "Threshold",
"minimum": 0,
"maximum": 1
}
}
}
}
},
"UISchema": {
"settings": {
"ui:expandable": true
}
},
"data": {
"name": "My Assistant",
"enabled": true,
"settings": {
"threshold": 0.7
}
}
}
State inspectors provide powerful debugging and interaction capabilities for both developers and users of the Semantic Workbench platform.