You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add minimal documentation for the @Ngaf 0.0.21 citations release across all adapter libraries and changelog.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: libs/ag-ui/README.md
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,3 +20,29 @@ export class App {
20
20
protectedreadonly agent =inject(AG_UI_AGENT);
21
21
}
22
22
```
23
+
24
+
## Citations
25
+
26
+
The `bridgeCitationsState()` function populates `Message.citations` from AG-UI STATE_DELTA events. Citations are located at JSON Pointer `/citations/{messageId}`.
27
+
28
+
### Example: AG-UI citations state shape
29
+
30
+
```json
31
+
{
32
+
"state": {
33
+
"citations": {
34
+
"msg-123": [
35
+
{
36
+
"id": "src1",
37
+
"index": 1,
38
+
"title": "Example Source",
39
+
"url": "https://example.com",
40
+
"snippet": "Relevant excerpt from the source..."
41
+
}
42
+
]
43
+
}
44
+
}
45
+
}
46
+
```
47
+
48
+
Each citation object in the array supports `id`, `index`, `title`, `url`, `snippet`, and custom `extra` fields. The messageId key matches the corresponding message in the chat history.
Copy file name to clipboardExpand all lines: libs/chat/README.md
+49Lines changed: 49 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,3 +12,52 @@ Chat primitives consume a runtime-neutral `Agent` contract. Two adapters ship to
12
12
Custom backends can implement `Agent` directly with no library dependency.
13
13
14
14
See the capability matrix in the docs site for which primitives require which runtime capabilities.
15
+
16
+
## Citations
17
+
18
+
Chat messages can include citations to sources. The `Citation` interface provides structured metadata for each source:
19
+
20
+
```ts
21
+
interfaceCitation {
22
+
id:string; // Unique identifier for the citation
23
+
index?:number; // Display index (1-based) for inline markers
24
+
title?:string; // Source title
25
+
url?:string; // Source URL
26
+
snippet?:string; // Quoted excerpt
27
+
extra?:unknown; // Custom fields per adapter
28
+
}
29
+
```
30
+
31
+
### Message citations
32
+
33
+
Adapters populate `Message.citations?: Citation[]` from their respective backends. Messages are rendered with the `<chat-citations [message]="message" />` primitive, which displays a collapsible sources panel under assistant messages.
34
+
35
+
### Rendering sources
36
+
37
+
Use the `<chat-citations>` component to render a sources panel. Customize the card layout with the optional `chatCitationCard` ng-template:
Markdown rendering registers `chat-md-citation-reference` in the markdown view registry. Citation indices are rendered as superscript markers inline with the message text. The markers link to the corresponding citation in the sources panel.
55
+
56
+
### Adapter integration
57
+
58
+
Each runtime adapter extracts citations into the `Message.citations` array:
59
+
60
+
-**LangGraph** — reads from `message.additional_kwargs.citations` (preferred) or `message.additional_kwargs.sources` (fallback)
61
+
-**AG-UI** — reads from STATE_DELTA at JSON Pointer `/citations/{messageId}`
62
+
63
+
The `CitationsResolverService` is provided to query citations in message-first or markdown-fallback order.
This library was generated with [Nx](https://nx.dev).
3
+
Adapter that wraps a LangGraph agent into the runtime-neutral `Agent` contract from `@ngaf/chat`.
4
+
5
+
## Citations
6
+
7
+
The `extractCitations()` function populates `Message.citations` from LangGraph message metadata. It reads from `additional_kwargs.citations` (preferred) or `additional_kwargs.sources` (fallback).
0 commit comments