AISummary
- Last Updated: May 5, 2026
- 3 minute read
- MarkLogic Server
- Documentation
The AISummary widget displays a response returned by an AI model and optionally shows citations or sources corresponding to that response. The widget supports Markdown formatting and customizable source display.
AISummary widget features
-
Renders Markdown-formatted summary text using
react-markdownandremark-gfm. -
Optionally displays a list of sources/citations below the summary.
-
Offers customizable title and container styling.
-
Handles empty responses gracefully.
AISummary example rendering
![]() |
AISummary example configuration
The following example uses the default field names that the SourceList component expects (sourceId and sourceLabel). No idPath or labelPath configuration is required in this case:
import { AISummary } from 'ml-fasttrack';
const response = {
summary: "There have been multiple **cybercrimes** reported in **San Francisco** in the past month.[1][2]",
sources: [
{ sourceId: "/doc1.json", sourceLabel: "[1] - Cybercrime at 268 Bay Boulevard" },
{ sourceId: "/doc2.json", sourceLabel: "[2] - Cybercrime at 226 Meadow Avenue" }
]
};
<AISummary
data={response}
title={<h4>AI Response</h4>}
sourcesPath={{ path: 'sources' }}
SourceListProps={{
onClick: (e, src) => console.log("Source clicked: ", src),
style: { color: 'blue', cursor: 'pointer' }
}}
noResponseMessage="No response returned."
/>
If the response object uses different field names, use summaryPath, idPath, and labelPath to map to the correct fields:
const response = {
text: "There have been multiple **cybercrimes** reported in **San Francisco**.[1][2]",
citations: [
{ citationId: "/doc1.json", citationLabel: "[1] - Cybercrime at 268 Bay Boulevard" },
{ citationId: "/doc2.json", citationLabel: "[2] - Cybercrime at 226 Meadow Avenue" }
]
};
<AISummary
data={response}
title={<h4>AI Response</h4>}
summaryPath={{ path: 'text' }}
sourcesPath={{ path: 'citations' }}
SourceListProps={{
idPath: { path: 'citationId' },
labelPath: { path: 'citationLabel' },
onClick: (e, src) => console.log("Source clicked: ", src),
style: { color: 'blue', cursor: 'pointer' }
}}
/>
Code explanation
-
datais the AI response object. Whendatais empty ornull, the widget displaysnoResponseMessageinstead of the summary. -
summaryPathspecifies the path withindatato the summary text (using a PathConfig object). If omitted, the component readsdata.summaryby default. -
sourcesPathspecifies the path withindatato the sources array. If omitted, no source list is rendered. -
SourceListPropsconfigures the source citation list. UseidPathandlabelPathto map custom field names within each source object. If omitted, the source list readssourceIdandsourceLabelfrom each entry. -
titleaccepts anyReactNode. If omitted, the widget renders a default "AI Summary" heading with a sparkle icon.
AISummary API
Prop |
Type |
Description |
|---|---|---|
data (required) |
any |
The AI response object containing the summary text and optional source references. When empty or |
title |
ReactNode |
Optional title to display above the summary text. If omitted, a default "AI Summary" heading with a sparkle icon is rendered. |
containerStyle |
CSSProperties |
Inline CSS styles applied to the outermost container element. |
summaryPath |
Path within |
|
sourcesPath |
Path within |
|
SourceListProps |
ISourceListProps |
Configuration for the source citation list rendered below the summary. See SourceListProps API below. The |
noResponseMessage |
string |
Text displayed when |
SourceListProps API
Prop |
Type |
Description |
|---|---|---|
onClick |
((e: MouseEvent, sourceId: string) => void) |
Callback triggered when a source item is clicked. Receives the mouse event and the resolved source ID. |
idPath |
Path within each source object to extract the source ID. If omitted, reads |
|
labelPath |
Path within each source object to extract the display label. If omitted, reads |
|
truncateAfter |
number |
Maximum number of characters to display for each source label before truncating with an ellipsis. Default: |
style |
CSSProperties |
Inline CSS styles applied to each source item. |
