Source Transformation
Copy page
Transform source content before it's used by the AI assistant.
Scenario
In this guide, we'll explore how to customize the display of source information. This includes modifying source icons, titles, URLs, breadcrumbs, the tabs where search results appear, and other metadata for search results and chat references.
Type Signature
The transformSource function is defined in the InkeepBaseSettings interface and allows you to modify how source information appears in different contexts:
| Parameter | Type | Description |
|---|---|---|
source | SourceItem | The original source data containing title, URL, description, etc. |
type | 'chatSourceItem' | 'searchResultItem' | 'intelligentFormSource' | Context where the source is being displayed |
opts | { organizationDisplayName?: string; tabs?: (string | SearchTab)[] } | Additional options including organization name and configured tabs |
The function should return a TransformedSource object that defines how the source should be displayed. This gives you control over:
- Title and description formatting
- URL modifications and parameters
- Breadcrumb trails
- Tab categorization
- Icons and visual elements
- Link behavior (new tab vs same window)
- Additional metadata and tags
Common use cases include:
- Adding organization branding to titles
- Truncating long descriptions
- Categorizing content into tabs
- Adding tracking parameters to URLs
- Customizing navigation behavior
- Setting context-specific icons
Examples
Basic source transformation
This example sets the title of all sources to include the organization name, and uses the book icon for all sources.
Advanced source transformation
This example shows how to transform the source data based on whether the source is a search result or a chat source.
Add a documentation tab
Let's have a "Documentation" tab that shows the sources that come from your docs. Assuming you have other sources aside docs.
You first want to define a Documentation tab:
More info on tabs can be found in the Search and Chat guide.
Then you'd need to update the transformSource function to add qualifying sources to the Documentation tab:
Hide breadcrumb in matching tab.
Say you're in a Blog tab, and a blog post has a breadcrumb of Blog > Announcement > My Post. You may want to hide the Blog breadcrumb when the user is in the Blog tab.
Well when setting a tab for a source, you can also decide the breadcrumbs to show in that tab for that source.