Skip to content

Commit cce4d65

Browse files
committed
update api ref pages; fix links
1 parent 8d58d6f commit cce4d65

9 files changed

Lines changed: 59 additions & 30 deletions

File tree

chatkit/widgets.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,7 @@ def from_file(cls, file_path: str) -> WidgetTemplate:
11711171
def build(
11721172
self, data: dict[str, Any] | BaseModel | None = None
11731173
) -> DynamicWidgetRoot:
1174+
"""Build a widget from the template and data."""
11741175
rendered = self.template.render(**self._normalize_data(data))
11751176
widget_dict = json.loads(rendered)
11761177
return DynamicWidgetRoot.model_validate(widget_dict)

docs/api/chatkit/index.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Chatkit Python API Reference
2+
3+
What you'll find here:
4+
5+
- **Core server API**: [`chatkit.server`](server.md)`ChatKitServer` and related helpers for receiving messages, streaming responses, and wiring up tools and widgets.
6+
- **Store integration**: [`chatkit.store`](store.md) – interfaces and utilities for persisting threads, items, and metadata.
7+
- **Agents integration helpers**: [`chatkit.agents`](agents.md) – helpers and utilities for using ChatKit together with the Agents SDK.
8+
- **Data models and types**: [`chatkit.types`](types.md) – Pydantic models for threads, items, events, and other shared types.
9+
- **Errors**: [`chatkit.errors`](errors.md) – structured error types your ChatKit integration can raise so ChatKit can emit consistent `ErrorEvent`s to the client.
10+
- **Widgets**: [`chatkit.widgets`](widgets.md) – models and helpers such as `WidgetTemplate`, `DynamicWidgetRoot`, and `BasicRoot` for building rich UI responses.

docs/concepts/entities.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Entities can be used as cited sources in assistant responses.
1616

1717
**References:**
1818

19-
- The [EntitySource](../../api/chatkit/types/#chatkit.types.EntitySource) Pydantic model definition
19+
- The [EntitySource](../api/chatkit/types.md#chatkit.types.EntitySource) Pydantic model definition
2020
- [Add annotations in assistant messages](../guides/add-annotations.md#annotating-with-custom-entities).
2121

2222
## Entity tags as @-mentions in user messages
@@ -26,5 +26,5 @@ Users can tag your entities in the composer using @-mentions.
2626
**References**:
2727

2828
- The [Entity](https://openai.github.io/chatkit-js/api/openai/chatkit-react/type-aliases/entity/) TypeScript type definition
29-
- The [UserMessageTagContent](../../api/chatkit/types/#chatkit.types.UserMessageTagContent) Pydantic model definition
29+
- The [UserMessageTagContent](../api/chatkit/types.md#chatkit.types.UserMessageTagContent) Pydantic model definition
3030
- [Accept rich user input](../guides/accept-rich-user-input.md#-mentions-tag-entities-in-user-messages).

docs/concepts/thread-stream-events.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
11
# Thread stream events
22

3-
[`ThreadStreamEvent`](../../api/chatkit/types/#chatkit.types.ThreadStreamEvent)s are the Server-Sent Event (SSE) payloads streamed by ChatKitServer while responding to a user message or action. They keep the client UI in sync with server-side processing and drive persistence in your store.
3+
[`ThreadStreamEvent`](../api/chatkit/types.md#chatkit.types.ThreadStreamEvent)s are the Server-Sent Event (SSE) payloads streamed by ChatKitServer while responding to a user message or action. They keep the client UI in sync with server-side processing and drive persistence in your store.
44

55
## Thread metadata updates
66

77
ChatKitServer emits these after it creates a thread or notices metadata changes (title, status, etc.) so the UI stays in sync.
88

9-
- [`ThreadCreatedEvent`](../../api/chatkit/types/#chatkit.types.ThreadCreatedEvent): introduce a new thread
10-
- [`ThreadUpdatedEvent`](../../api/chatkit/types/#chatkit.types.ThreadUpdatedEvent): update the current thread metadata such as title or status
9+
- [`ThreadCreatedEvent`](../api/chatkit/types.md#chatkit.types.ThreadCreatedEvent): introduce a new thread
10+
- [`ThreadUpdatedEvent`](../api/chatkit/types.md#chatkit.types.ThreadUpdatedEvent): update the current thread metadata such as title or status
1111

1212
## Thread item events
1313

1414
Thread item events drive the conversation state. ChatKitServer processes these events to persist conversation state before streaming them back to the client.
1515

16-
- [`ThreadItemAddedEvent`](../../api/chatkit/types/#chatkit.types.ThreadItemAddedEvent): introduce a new item (message, tool call, workflow, widget, etc).
17-
- [`ThreadItemUpdatedEvent`](../../api/chatkit/types/#chatkit.types.ThreadItemUpdatedEvent): mutate a pending item (e.g., stream text deltas, workflow task updates).
18-
- [`ThreadItemDoneEvent`](../../api/chatkit/types/#chatkit.types.ThreadItemDoneEvent): mark an item complete and persist it.
19-
- [`ThreadItemRemovedEvent`](../../api/chatkit/types/#chatkit.types.ThreadItemRemovedEvent): delete an item by id.
20-
- [`ThreadItemReplacedEvent`](../../api/chatkit/types/#chatkit.types.ThreadItemReplacedEvent): swap an item in place.
16+
- [`ThreadItemAddedEvent`](../api/chatkit/types.md#chatkit.types.ThreadItemAddedEvent): introduce a new item (message, tool call, workflow, widget, etc).
17+
- [`ThreadItemUpdatedEvent`](../api/chatkit/types.md#chatkit.types.ThreadItemUpdatedEvent): mutate a pending item (e.g., stream text deltas, workflow task updates).
18+
- [`ThreadItemDoneEvent`](../api/chatkit/types.md#chatkit.types.ThreadItemDoneEvent): mark an item complete and persist it.
19+
- [`ThreadItemRemovedEvent`](../api/chatkit/types.md#chatkit.types.ThreadItemRemovedEvent): delete an item by id.
20+
- [`ThreadItemReplacedEvent`](../api/chatkit/types.md#chatkit.types.ThreadItemReplacedEvent): swap an item in place.
2121

2222
Note: `ThreadItemAddedEvent` does not persist the item. `ChatKitServer` saves on `ThreadItemDoneEvent`/`ThreadItemReplacedEvent`, tracks pending items in between, and handles store writes for all `ThreadItem*Event`s.
2323

2424
## Errors
2525

26-
Stream [`ErrorEvent`](../../api/chatkit/types/#chatkit.types.ErrorEvent)s for user-facing errors in the chat UI. You can configure a custom message and whether a retry button is shown to the user.
26+
Stream [`ErrorEvent`](../api/chatkit/types.md#chatkit.types.ErrorEvent)s for user-facing errors in the chat UI. You can configure a custom message and whether a retry button is shown to the user.
2727

2828
## Progress updates
2929

30-
Stream [`ProgressUpdateEvent`](../../api/chatkit/types/#chatkit.types.ProgressUpdateEvent)s to show the user transient status while work is in flight.
30+
Stream [`ProgressUpdateEvent`](../api/chatkit/types.md#chatkit.types.ProgressUpdateEvent)s to show the user transient status while work is in flight.
3131

3232
See [Show progress while tools run](../guides/update-client-during-response.md#show-progress-while-tools-run) for more info.
3333

3434
## Client effects
3535

36-
Use [`ClientEffectEvent`](../../api/chatkit/types/#chatkit.types.ClientEffectEvent) to trigger fire-and-forget behavior on the client such as opening a dialog or pushing updates.
36+
Use [`ClientEffectEvent`](../api/chatkit/types.md#chatkit.types.ClientEffectEvent) to trigger fire-and-forget behavior on the client such as opening a dialog or pushing updates.
3737

3838
See [Trigger client-side effects without blocking](../guides/update-client-during-response.md#trigger-client-side-effects-without-blocking) for more info.
3939

4040
## Stream options
4141

42-
[`StreamOptionsEvent`](../../api/chatkit/types/#chatkit.types.StreamOptionsEvent) configures runtime stream behavior (for example, allowing user cancellation). `ChatKitServer` emits one at the start of every stream using `get_stream_options`; override that method to change defaults such as `allow_cancel`.
42+
[`StreamOptionsEvent`](../api/chatkit/types.md#chatkit.types.StreamOptionsEvent) configures runtime stream behavior (for example, allowing user cancellation). `ChatKitServer` emits one at the start of every stream using `get_stream_options`; override that method to change defaults such as `allow_cancel`.
4343

4444

4545
## Related guides

docs/concepts/threads.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Thread items serve two primary purposes in ChatKit:
4141

4242
### Model input
4343

44-
Your server's [`respond`](../../api/chatkit/server/#chatkit.server.ChatKitServer.respond) logic reads thread items to construct input for the model input. This ensures the model sees the full conversational context both during an active response and when a user resumes a past thread.
44+
Your server's [`respond`](../api/chatkit/server.md#chatkit.server.ChatKitServer.respond) logic reads thread items to construct input for the model input. This ensures the model sees the full conversational context both during an active response and when a user resumes a past thread.
4545

4646
See [Respond to a user message](../guides/respond-to-user-message.md) for a full walkthrough.
4747

@@ -53,7 +53,7 @@ On the client, ChatKit.js renders items incrementally as they stream in for the
5353

5454
### User messages
5555

56-
[`UserMessageItem`](../../api/chatkit/types/#chatkit.types.UserMessageItem)s represent end-user input. They may include:
56+
[`UserMessageItem`](../api/chatkit/types.md#chatkit.types.UserMessageItem)s represent end-user input. They may include:
5757

5858
- Plain text entered by the user
5959
- Optional `quoted_text` for reply-style UIs
@@ -65,7 +65,7 @@ User text is not Markdown-rendered, but it may contain [@-mentions](../guides/ac
6565

6666
### Assistant messages
6767

68-
[`AssistantMessageItem`](../../api/chatkit/types/#chatkit.types.AssistantMessageItem)s represent assistant output. Their content can include:
68+
[`AssistantMessageItem`](../api/chatkit/types.md#chatkit.types.AssistantMessageItem)s represent assistant output. Their content can include:
6969

7070
- Markdown-rendered text
7171
- Tool call outputs
@@ -92,9 +92,9 @@ Hidden context items are included in model input but are not rendered in the cha
9292

9393
Typical use cases include recording widget actions, selection state, or system signals.
9494

95-
- **[`HiddenContextItem`](../../api/chatkit/types/#chatkit.types.HiddenContextItem)**: Integration-defined hidden context. You control its schema and how it is converted for the model.
95+
- **[`HiddenContextItem`](../api/chatkit/types.md#chatkit.types.HiddenContextItem)**: Integration-defined hidden context. You control its schema and how it is converted for the model.
9696

97-
- **[`SDKHiddenContextItem`](../../api/chatkit/types/#chatkit.types.SDKHiddenContextItem)**: Hidden context inserted by the ChatKit Python SDK for its own internal operations. Most applications do not need to modify this unless overriding conversion behavior.
97+
- **[`SDKHiddenContextItem`](../api/chatkit/types.md#chatkit.types.SDKHiddenContextItem)**: Hidden context inserted by the ChatKit Python SDK for its own internal operations. Most applications do not need to modify this unless overriding conversion behavior.
9898

9999
## Thread item actions
100100

@@ -104,7 +104,7 @@ Actions are configured client-side using the [threadItemActions option](https://
104104

105105
## Converting items to model input
106106

107-
[`ThreadItemConverter`](../../api/chatkit/agents/#chatkit.agents.ThreadItemConverter) translates stored thread items into model-ready input items. The default converter understands common ChatKit item types such as messages, widgets, workflows, and tasks.
107+
[`ThreadItemConverter`](../api/chatkit/agents.md#chatkit.agents.ThreadItemConverter) translates stored thread items into model-ready input items. The default converter understands common ChatKit item types such as messages, widgets, workflows, and tasks.
108108

109109
You can override the converter when you need custom behavior. For example:
110110

docs/concepts/widgets.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ Here’s how a widget is represented from design time through runtime streaming.
1010
| --- | --- |
1111
| Working definition | [Widget UI language](#widget-ui-language) plus a schema (Zod/JSON) and example data you author in <https://widgets.chatkit.studio>. |
1212
| Published definition | The exported [`.widget` file](#widget-files) bundling the layout, schema, and sample data. |
13-
| Server runtime (definition only) | [`WidgetTemplate`](../../api/chatkit/widgets/#chatkit.widgets.WidgetTemplate) instance loaded from the `.widget` file. |
14-
| Server runtime (hydrated) | [`DynamicWidgetRoot`](../../api/chatkit/widgets/#chatkit.widgets.DynamicWidgetRoot) or [`BasicRoot`](../../api/chatkit/widgets/#chatkit.widgets.BasicRoot) Pydantic model instance built from the template and real data. |
15-
| Streamed to the client | The hydrated root serialized to JSON and included inside a [`WidgetItem`](../../api/chatkit/types/#chatkit.types.WidgetItem) streamed by `ChatKitServer`. |
13+
| Server runtime (definition only) | [`WidgetTemplate`](../api/chatkit/widgets.md#chatkit.widgets.WidgetTemplate) instance loaded from the `.widget` file. |
14+
| Server runtime (hydrated) | [`DynamicWidgetRoot`](../api/chatkit/widgets.md#chatkit.widgets.DynamicWidgetRoot) or [`BasicRoot`](../api/chatkit/widgets.md#chatkit.widgets.BasicRoot) Pydantic model instance built from the template and real data. |
15+
| Streamed to the client | The hydrated root serialized to JSON and included inside a [`WidgetItem`](../api/chatkit/types.md#chatkit.types.WidgetItem) streamed by `ChatKitServer`. |
1616
| Rendered by the client | ChatKit.js deserializes the JSON into typed widget objects (for example, [`Card`](https://openai.github.io/chatkit-js/api/openai/chatkit-react/namespaces/widgets/type-aliases/card/) or [`ListView`](https://openai.github.io/chatkit-js/api/openai/chatkit/namespaces/widgets/type-aliases/listview/)) and renders them; entity previews use [`BasicRoot`](https://openai.github.io/chatkit-js/api/openai/chatkit-react/namespaces/widgets/type-aliases/basicroot/) returned from [`entities.onRequestPreview`](#entity-previews). |
17-
| Sent as model input | A Responses API `Message` produced from a [`WidgetItem`](../../api/chatkit/types/#chatkit.types.WidgetItem) via [`ThreadItemConverter.widget_to_input`](../../api/chatkit/agents/#chatkit.agents.ThreadItemConverter.widget_to_input). |
17+
| Sent as model input | A Responses API `Message` produced from a [`WidgetItem`](../api/chatkit/types.md#chatkit.types.WidgetItem) via [`ThreadItemConverter.widget_to_input`](../api/chatkit/agents.md#chatkit.agents.ThreadItemConverter.widget_to_input). |
1818

1919

2020
## Widget UI language
@@ -35,7 +35,7 @@ Exported `.widget` files are JSON blobs that include the widget template, the ex
3535

3636
## WidgetItem
3737

38-
[`WidgetItem`](../../api/chatkit/types/#chatkit.types.WidgetItem) represents a widget rendered as a [thread item](threads.md#what-are-thread-items) in the chat UI. In addition to a reference to the widget instance, it contains a `copy_text` field that represents the text value copied to the clipboard when the user clicks the copy button below the response.
38+
[`WidgetItem`](../api/chatkit/types.md#chatkit.types.WidgetItem) represents a widget rendered as a [thread item](threads.md#what-are-thread-items) in the chat UI. In addition to a reference to the widget instance, it contains a `copy_text` field that represents the text value copied to the clipboard when the user clicks the copy button below the response.
3939

4040
## Entity previews
4141

docs/gen_ref_pages.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
for path in SRC_ROOT.rglob("*.py"):
2727
if path.name.startswith("_"):
2828
continue
29-
if path.name in {"version.py", "logger.py"}:
29+
if path.name in {"version.py", "logger.py", "actions.py"}:
3030
continue
3131

3232
module_path = path.with_suffix("").relative_to(SRC_ROOT)
@@ -40,4 +40,19 @@
4040
mkdocs_gen_files.set_edit_path(doc_path, path)
4141
with mkdocs_gen_files.open(doc_path, "w") as f:
4242
f.write(f"# {path.stem}\n\n")
43-
f.write(f"::: {identifier}\n")
43+
44+
# For the widgets module, keep the module-level directive but only include
45+
# a curated set of public members so we preserve nice headings.
46+
if identifier == "chatkit.widgets":
47+
f.write(f"::: {identifier}\n")
48+
f.write(" options:\n")
49+
f.write(" members:\n")
50+
for symbol in (
51+
"WidgetTemplate",
52+
"DynamicWidgetRoot",
53+
"BasicRoot",
54+
"DynamicWidgetComponent",
55+
):
56+
f.write(f" - {symbol}\n")
57+
else:
58+
f.write(f"::: {identifier}\n")

docs/guides/respond-to-user-message.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,12 @@ async def load_document(ctx: RunContextWrapper[AgentContext], document_id: str):
269269

270270
- [Let users browse past threads](browse-past-threads.md)
271271
- [Accept rich user input](accept-rich-user-input.md)
272+
- [Let users pick tools and models](let-users-pick-tools-and-models.md)
273+
- [Pass extra app context to your model](pass-extra-app-context-to-your-model.md)
272274
- [Update the client during a response](update-client-during-response.md)
273275
- [Build interactive responses with widgets](build-interactive-responses-with-widgets.md)
274-
- [Handle feedback](handle-feedback.md)
275-
- [Allow @-mentions in user messages](accept-rich-user-input.md#-mentions-tag-entities-in-user-messages)
276276
- [Add annotations in assistant messages](add-annotations.md)
277+
- [Keep your app in sync with ChatKit](keep-your-app-in-sync-with-chatkit.md)
278+
- [Let your app draft and send messages](let-your-app-draft-and-send-messages.md)
279+
- [Handle feedback](handle-feedback.md)
280+
- [Prepare your app for production](prepare-your-app-for-production.md)

mkdocs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ nav:
6262
- API Reference:
6363
- Overview: api/chatkit/index.md
6464
- Modules:
65-
- actions: api/chatkit/actions.md
6665
- agents: api/chatkit/agents.md
6766
- errors: api/chatkit/errors.md
6867
- server: api/chatkit/server.md

0 commit comments

Comments
 (0)