> ## Documentation Index
> Fetch the complete documentation index at: https://alibi.itsdote.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# alibi_sdk.plugin

> Plugin contract — generated from python/alibi_sdk source.

Plugin contract: snapshot · observe · diff · restore.

*Source:* [`python/alibi_sdk/alibi_sdk/plugin.py`](https://github.com/valid22/alibi-ai/blob/main/python/alibi_sdk/alibi_sdk/plugin.py)

## `SnapshotHandle`

**Attributes**

| Name | Type |
| - | - |
| `plugin` | `str` |
| `ref` | `str` |
| `created_at` | `str` |
| `data` | `Optional[dict[str, Any]]` |

### `empty_observe`

```python theme={null}
def empty_observe() -> dict[str, Any]
```

**Returns**

`dict[str, Any]`

## `PluginProtocol`

**Bases:** `Protocol`

**Attributes**

| Name | Type |
| - | - |
| `name` | `str` |

#### `snapshot`

```python theme={null}
async def snapshot(span: SpanContext) -> SnapshotHandle
```

**Parameters**

| Name | Type |
| - | - |
| `span` | `SpanContext` |

**Returns**

`SnapshotHandle`

#### `observe`

```python theme={null}
async def observe(span: SpanContext) -> dict[str, Any]
```

**Parameters**

| Name | Type |
| - | - |
| `span` | `SpanContext` |

**Returns**

`dict[str, Any]`

#### `diff`

```python theme={null}
async def diff(span: SpanContext, expected: dict[str, Any], actual: dict[str, Any]) -> dict[str, Any]
```

**Parameters**

| Name | Type |
| - | - |
| `span` | `SpanContext` |
| `expected` | `dict[str, Any]` |
| `actual` | `dict[str, Any]` |

**Returns**

`dict[str, Any]`

#### `restore`

```python theme={null}
async def restore(span: SpanContext, handle: SnapshotHandle) -> None
```

**Parameters**

| Name | Type |
| - | - |
| `span` | `SpanContext` |
| `handle` | `SnapshotHandle` |

**Returns**

`None`

## `Plugin`

Base plugin. Subclasses implement real snapshot/observe/diff/restore.

**Attributes**

| Name | Type |
| - | - |
| `name` | `str` |

#### `snapshot`

```python theme={null}
async def snapshot(span: SpanContext) -> SnapshotHandle
```

**Parameters**

| Name | Type |
| - | - |
| `span` | `SpanContext` |

**Returns**

`SnapshotHandle`

#### `observe`

```python theme={null}
async def observe(span: SpanContext) -> dict[str, Any]
```

Drain in-span observations for this plugin from the context buffer.

**Parameters**

| Name | Type |
| - | - |
| `span` | `SpanContext` |

**Returns**

`dict[str, Any]`

#### `diff`

```python theme={null}
async def diff(span: SpanContext, expected: dict[str, Any], actual: dict[str, Any]) -> dict[str, Any]
```

**Parameters**

| Name | Type |
| - | - |
| `span` | `SpanContext` |
| `expected` | `dict[str, Any]` |
| `actual` | `dict[str, Any]` |

**Returns**

`dict[str, Any]`

#### `restore`

```python theme={null}
async def restore(span: SpanContext, handle: SnapshotHandle) -> None
```

**Parameters**

| Name | Type |
| - | - |
| `span` | `SpanContext` |
| `handle` | `SnapshotHandle` |

**Returns**

`None`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.