Implementation:Evidentlyai Evidently Legacy Widget Models
| Knowledge Sources | |
|---|---|
| Domains | ML Monitoring, Visualization, Data Models |
| Last Updated | 2026-02-14 12:00 GMT |
Overview
Legacy Widget Models defines the Pydantic data models used to represent dashboard widgets, alerts, insights, and graph information in the Evidently legacy reporting system.
Description
This module provides the core data model classes for the legacy widget rendering system. The key classes are:
TriggeredAlertStats -- contains alert counts for a period and the last 24 hours.
AlertStats -- holds the number of active alerts and a TriggeredAlertStats instance.
Insight -- represents a dashboard insight with a title, severity level (info, warning, error, success), and descriptive text.
Alert -- represents an individual alert with a value, state, short text, and long text.
AdditionalGraphInfo -- a model for additional graph metadata with an ID and params dict. Configured with extra = "forbid".
PlotlyGraphInfo -- stores Plotly graph data and layout dicts, with an auto-generated UUID7 ID.
WidgetType (Enum) -- defines supported widget types: COUNTER, TABLE, BIG_TABLE, GROUP, BIG_GRAPH, RICH_DATA, TABBED_GRAPH, and TABS.
BaseWidgetInfo -- the central widget model containing:
- Basic fields:
type,title,size, auto-generatedid - Optional display fields:
details,alertsPosition,alertStats,params - Collections:
insights,additionalGraphs,alerts,tabs,widgets(nested) - Pagination:
pageSize(default 5) - Fingerprinting:
source_fingerprintandlinked_metrics - A method
get_additional_graphs()that recursively collects graphs from nested widgets
TabInfo -- represents a tab within a tabbed widget, containing an ID, title, and a BaseWidgetInfo.
The module also provides two utility functions:
- link_metric -- links widget(s) to a metric source via fingerprints
- set_source_fingerprint -- sets the source fingerprint on widget(s) and also calls
link_metric
Forward references are resolved at the end with BaseWidgetInfo.update_forward_refs().
Usage
Use these models when building custom renderers or widgets for Evidently reports. They form the data contract between metric calculation logic and the HTML rendering layer.
Code Reference
Source Location
- Repository: Evidentlyai_Evidently
- File:
src/evidently/legacy/model/widget.py
Signature
class TriggeredAlertStats(BaseModel):
period: int
last_24h: int
class AlertStats(BaseModel):
active: int
triggered: TriggeredAlertStats
class Insight(BaseModel):
title: str
severity: str
text: str
class Alert(BaseModel):
value: Union[str, int, float]
state: str
text: str
longText: str
class AdditionalGraphInfo(BaseModel):
id: str
params: dict
class PlotlyGraphInfo(BaseModel):
data: dict
layout: dict
id: str = Field(default_factory=lambda: str(uuid6.uuid7()))
class WidgetType(Enum):
COUNTER = "counter"
TABLE = "table"
BIG_TABLE = "big_table"
GROUP = "group"
BIG_GRAPH = "big_graph"
RICH_DATA = "rich_data"
TABBED_GRAPH = "tabbed_graph"
TABS = "tabs"
class BaseWidgetInfo(BaseModel):
type: str
title: str
size: int
id: str = Field(default_factory=lambda: str(uuid6.uuid7()))
details: str = ""
alertsPosition: Optional[str] = None
alertStats: Optional[AlertStats] = None
params: Any = None
insights: List[Insight] = Field(default_factory=list)
additionalGraphs: List[Union[AdditionalGraphInfo, "BaseWidgetInfo", PlotlyGraphInfo]] = Field(default_factory=list)
alerts: List[Alert] = Field(default_factory=list)
tabs: List["TabInfo"] = Field(default_factory=list)
widgets: List["BaseWidgetInfo"] = Field(default_factory=list)
pageSize: int = 5
source_fingerprint: Optional[Fingerprint] = None
linked_metrics: Optional[List[Fingerprint]] = None
def get_additional_graphs(self) -> List[Union[AdditionalGraphInfo, PlotlyGraphInfo, "BaseWidgetInfo"]]:
...
class TabInfo(BaseModel):
id: str
title: str
widget: BaseWidgetInfo
def link_metric(widgets, source):
...
def set_source_fingerprint(widgets, source):
...
Import
from evidently.legacy.model.widget import BaseWidgetInfo
from evidently.legacy.model.widget import WidgetType
from evidently.legacy.model.widget import Alert, AlertStats, Insight
from evidently.legacy.model.widget import PlotlyGraphInfo, AdditionalGraphInfo
from evidently.legacy.model.widget import TabInfo
from evidently.legacy.model.widget import link_metric, set_source_fingerprint
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| type | str |
Yes | Widget type identifier (e.g., "counter", "table"). |
| title | str |
Yes | Display title of the widget. |
| size | int |
Yes | Widget size indicator (typically 1 for half, 2 for full). |
| params | Any |
No | Widget-specific parameters (typically a dict). |
| insights | List[Insight] |
No | List of insight objects to display. |
| alerts | List[Alert] |
No | List of alert objects to display. |
| widgets | List[BaseWidgetInfo] |
No | Nested child widgets for composite layouts. |
| tabs | List[TabInfo] |
No | Tabs for tabbed widget layouts. |
Outputs
| Name | Type | Description |
|---|---|---|
| BaseWidgetInfo | BaseWidgetInfo |
A Pydantic model instance representing a complete widget with all its data, suitable for serialization and HTML rendering. |
Usage Examples
from evidently.legacy.model.widget import BaseWidgetInfo, WidgetType
# Create a simple counter widget
widget = BaseWidgetInfo(
type=WidgetType.COUNTER.value,
title="Accuracy",
size=2,
params={"counters": [{"value": "0.95", "label": "Accuracy"}]},
)
# Link a widget to a metric source fingerprint
from evidently.legacy.model.widget import set_source_fingerprint
set_source_fingerprint(widget, some_metric)