Skip to content

Commit 6646f83

Browse files
committed
Updated annotations doc
1 parent 2e7a147 commit 6646f83

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

docs/guides/add-annotations.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,14 @@ yield ThreadItemDoneEvent(
5858

5959
## Annotating with custom entities
6060

61-
Inline annotations are not yet supported for entity sources, but you can still attach `EntitySource` items as annotations so they appear in the Sources list below the message.
61+
You can attach `EntitySource` items as annotations to show entity references inline in assistant text and in the **Sources** list below the message.
62+
63+
Entity annotations support a few UI-focused fields:
64+
65+
- `icon`: Controls the icon shown for the entity in the default inline/hover UI.
66+
- `label`: Customizes what's shown in the default entity hover header (when you are not rendering a custom preview).
67+
- `inline_label`: Shows a label inline instead of an icon.
68+
- `interactive=True`: Wires the annotation to client-side callbacks (`ChatKitOptions.entities.onClick` and `ChatKitOptions.entities.onRequestPreview`).
6269

6370
```python
6471
from datetime import datetime
@@ -70,15 +77,22 @@ from chatkit.types import (
7077
ThreadItemDoneEvent,
7178
)
7279

80+
text = "Here are the ACME account details for reference."
81+
7382
annotations = [
7483
Annotation(
7584
source=EntitySource(
7685
id="customer_123",
7786
title="ACME Corp",
7887
description="Enterprise plan · 500 seats",
7988
icon="suitcase",
89+
label="Customer",
90+
interactive=True,
91+
# Free-form data object passed to your client-side entity callbacks
8092
data={"href": "https://crm.example.com/customers/123"},
81-
)
93+
),
94+
# `index` controls where the inline marker is placed in the text.
95+
index=text.index("ACME") + len("ACME"),
8296
)
8397
]
8498

@@ -89,12 +103,12 @@ yield ThreadItemDoneEvent(
89103
created_at=datetime.now(),
90104
content=[
91105
AssistantMessageContent(
92-
text="Here are the ACME account details for reference.",
106+
text=text,
93107
annotations=annotations,
94108
)
95109
],
96110
)
97111
)
98112
```
99113

100-
Provide richer previews and navigation by handling [`entities.onRequestPreview`](https://openai.github.io/chatkit-js/api/openai/chatkit/type-aliases/entitiesoption/#onrequestpreview) and [`entities.onClick`](https://openai.github.io/chatkit-js/api/openai/chatkit/type-aliases/entitiesoption/#onclick) in ChatKit.js, using the `data` payload to pass entity information and deep link into your app.
114+
Provide richer previews and navigation by handling [`entities.onRequestPreview`](https://openai.github.io/chatkit-js/api/openai/chatkit/type-aliases/entitiesoption/#onrequestpreview) and [`entities.onClick`](https://openai.github.io/chatkit-js/api/openai/chatkit/type-aliases/entitiesoption/#onclick) in ChatKit.js. These callbacks are only invoked for entity annotations with `interactive=True`; use the `data` payload to pass entity information and deep link into your app.

0 commit comments

Comments
 (0)