Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
docs(user): improve documentation for the AI feature
Elian Dorand75dd311ab0d
diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI.htmlindex ef9952c176..3070f28911 100644--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI.html+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/AI.html@@ -25,11 +25,40 @@<ul><li>Chat-based interface with live streaming of the messages.</li><li>Provides the AI context with the note currently being looked at.</li>- <li>Tools to alter note content, create new notes, etc.</li>- <li>Statistics regarding context window use and pricing per message.</li>- <li>Optional MCP to allow external chat tools (e.g. Claude Code) to operate- on notes within Trilium.</li>+ <li+ >Tools to alter note content, create new notes, etc.</li>+ <li>Statistics regarding context window use and pricing per message.</li>+ <li+ >Attachments for multi-modal chat (images, text files, PDFs).</li>+ <li>Optional MCP to allow external chat tools (e.g. Claude Code) to operate+ on notes within Trilium.</li></ul>+<h2>Sample use-cases</h2>+<figure class="table" style="width:100%;">+ <table class="ck-table-resized">+ <colgroup>+ <col style="width:38.77%;">+ <col style="width:61.23%;">+ </colgroup>+ <thead>+ <tr>+ <th scope="col">Use case</th>+ <th scope="col">Sample prompt</th>+ </tr>+ </thead>+ <tbody>+ <tr>+ <td>Easily create a <a class="reference-link" href="#root/pOsGYCXsbNQG/KSZ04uQ2D1St/_help_HcABDtFCkbFN">Render Note</a>.</td>+ <td>+ <blockquote>+ <p><em>Create for me a render note which allows me to play tic-tac-toe. Make sure to use Preact instead of the legacy jQuery.</em>+ </p>+ </blockquote>+ </td>+ </tr>+ </tbody>+ </table>+</figure><h2>LLM Providers</h2><h3>Cloud providers</h3><p>Currently, only three cloud providers are supported:</p>@@ -49,13 +78,16 @@for a different cloud provider, make sure to discuss it over GitHub discussions.</p></aside><h3>Self-hosted providers</h3>-<p>You might have noticed that there are no self-hosted solutions supported- by the AI integration. The reasoning is that currently the self-hosted- alternatives require additional integrations (for example a web search- tool) or provide low-quality results (e.g. hallucinating tool calls) that- would otherwise degrade the experience of the chat.</p>-<aside class="admonition note">- <p>We do plan to support self-hosted AI solutions in future versions.</p>+<p>Since v0.104.0, self-hosted LLM providers are supported indirectly. Simply+ create an Anthropic, ChatGPT, or Gemini provider and select the appropriate+ base URL.</p>+<p>Model selection for self-hosted providers is not yet supported, but generally+ the default or the loaded one is used instead.</p>+<aside class="admonition warning">+ <p>When dealing with self-hosted LLM models, depending on the training and+ the size of the model, the quality of the output may vary. Before <a href="#root/pOsGYCXsbNQG/BgmBlOIl72jZ/_help_wy8So3yZZlH9">reporting issues</a> regarding+ the quality of the output (e.g. hallucinating tool calls), consider benchmarking+ the response against a cloud provider (Claude Sonnet is recommended).</p></aside><h2>Enabling the AI integration</h2><p>Because it is an experimental feature, enabling the AI integration is@@ -63,7 +95,8 @@<ol><li>Go to <a class="reference-link" href="#root/_help_4TIF1oA4VQRO">Options</a> → <em>Advanced</em> andcheck <em>AI / LLM Chat</em> in the <em>Experimental Options</em> section.</li>- <li>Go to <a class="reference-link" href="#root/_help_4TIF1oA4VQRO">Options</a> → <em>AI / LLM</em> and+ <li+ >Go to <a class="reference-link" href="#root/_help_4TIF1oA4VQRO">Options</a> → <em>AI / LLM</em> andconfigure a new provider.</li></ol><h2>Creating a new chat</h2>@@ -103,30 +136,203 @@longer conversations more comfortable to read.</p><p>Unlike the sidebar, the AI will not be aware of the current note it'sin.</p>-<h2>Web search</h2>+<h3>Templates</h3>+<p>Chat notes can be set as <a class="reference-link" href="#root/pOsGYCXsbNQG/tC7s2alapj8V/_help_KC1HB96bqqHX">Templates</a> to+ make them easily reusable. The entire conversation history is kept, allowing+ a basic form of specialization for the LLM with the existing chat acting+ like a system prompt. </p>+<h2>Features</h2>+<h3>Web search</h3><p>The AI can optionally search the web to find more information about aspecific topic. </p><p>This feature is on by default but it can easily be disabled by clickingon the model selector at the bottom of the chat and unchecking <em>Web search</em>.</p>-<h2>Tools</h2>-<p>Tools allow the agentic AI to understand and operate on notes directly- within your Trilium instance.</p>-<p>This feature is on by default but it can easily be disabled by clicking- on the model selector at the bottom of the chat and unchecking <em>Note access</em>.</p>-<h2>Alternative solutions (MCP)</h2>-<p>The following are alternatives to Trilium's built-in MCP feature. Since- Trilium's AI implementation is still experimental, its tooling might not- be as mature as external tools.</p>-<ul>- <li><a href="https://github.com/tan-yong-sheng/triliumnext-mcp">tan-yong-sheng/triliumnext-mcp</a>- </li>- <li><a href="https://github.com/perfectra1n/triliumnext-mcp">perfectra1n/triliumnext-mcp</a>- </li>- <li><a href="https://github.com/eliassoares/trilium-fastmcp">eliassoares/trilium-fastmcp</a>- </li>-</ul>-<aside class="admonition important">- <p>These solutions are third-party and thus not endorsed or supported directly- by the Trilium Notes team. Please address questions and issues on their- corresponding repository instead.</p>-</aside>\ No newline at end of file+<aside+class="admonition note">+ <p>Currently only the search native to the LLM provider is supported. External+ search providers such as Exa, Tavily & SearXNG are not yet supported.</p>+ </aside>+ <h3>Note access (tools)</h3>+ <p>Tools allow the agentic AI to understand and operate on notes directly+ within your Trilium instance.</p>+ <p>This feature is on by default but it can easily be disabled by clicking+ on the model selector at the bottom of the chat and unchecking <em>Note access</em>.</p>+ <p>Here are a few tools that Trilium provides for the LLM:</p>+ <ul>+ <li>At note level:+ <ul>+ <li>Search for notes</li>+ <li>Get the metadata or content of a note.</li>+ <li>Edit a note+ <ul>+ <li>There are multiple mechanism for the LLM to edit a note: completely by+ re-writing it, find/replace of a text sequence or append.</li>+ <li>Whenever the AI makes a change, a <a href="#root/pOsGYCXsbNQG/gh7bpGYxajRS/BFs8mudNFgCS/_help_vZWERwf8U3nx">revision</a> is+ saved to be able to revert any unwanted changes.</li>+ </ul>+ </li>+ <li>Create a new note</li>+ <li>Rename or delete a note.</li>+ </ul>+ </li>+ <li>At attribute level:+ <ul>+ <li>Get the full list of attributes, or a specific attribute.</li>+ <li>Set the value of an attribute.</li>+ <li>Delete an attribute.</li>+ </ul>+ </li>+ <li>At tree level:+ <ul>+ <li>Get the direct children of a note.</li>+ <li>Get the entire subtree of a note.</li>+ <li>Move or clone a note somewhere else.</li>+ </ul>+ </li>+ <li>For <a class="reference-link" href="#root/pOsGYCXsbNQG/gh7bpGYxajRS/BFs8mudNFgCS/_help_0vhv7lsOLy82">Attachments</a>:+ <ul>+ <li>Get metadata for an attachment.</li>+ <li>Get the content of an attachment.</li>+ </ul>+ </li>+ <li>Skills (see the dedicated section).</li>+ </ul>+ <aside class="admonition warning">+ <p>Currently there is <strong>no permission management</strong> implemented+ for note tools, meaning that the LLM could potentially remove existing+ notes or clutter the tree with notes. Generally most actions are easily+ reversible (deleting the notes, restoring deleted notes, reverting modifications+ to a note), but there are some that are harder to revert (e.g. setting+ an attribute because there is no attribute history).</p>+ </aside>+ <aside class="admonition note">+ <p>Gemini has a special case in which <em>Note access</em> and <em>Web search</em> can't+ be both enabled at the same time.</p>+ </aside>+ <h3>Attachments</h3>+ <p>Since Trilium v0.140.0, <a class="reference-link" href="#root/pOsGYCXsbNQG/gh7bpGYxajRS/BFs8mudNFgCS/_help_0vhv7lsOLy82">Attachments</a> allow+ for multi-modal chat:</p>+ <ul>+ <li>+ <p>Raster image (sent as vision input, except for SVGs) with the following+ supported formats: PNG, JPEG, GIF, WebP.</p>+ </li>+ <li>+ <p>PDFs, sent natively to the provider (supported by Anthropic, OpenAI and+ Google).</p>+ </li>+ <li>+ <p>SVG images (sent as raw HTML).</p>+ </li>+ <li>+ <p>Text files.</p>+ </li>+ </ul>+ <p>To upload an attachment:</p>+ <ul>+ <li>+ <p>Press the dedicated <em>Attach</em> button (paperclip icon) underneath the+ text box.</p>+ </li>+ <li>+ <p>Paste an image directly from clipboard using <kbd spellcheck="false">Ctrl</kbd>++ <kbd+ spellcheck="false">V</kbd>.</p>+ </li>+ </ul>+ <p>Once one or more attachments are uploaded, they will appear directly above+ the text box:</p>+ <ul>+ <li>+ <p>Images have a small thumbnail for easy identifications.</p>+ </li>+ <li>+ <p>Every attachment can be deleted by pressing their corresponding X button.</p>+ </li>+ </ul>+ <p>When an attachment is present, the LLM is instructed to consider the attachment+ with priority, even if it has access to the current note.</p>+ <aside class="admonition note">+ <p>Currently Trilium doesn't pre-process the attachments (e.g. via + <a+ class="reference-link" href="#root/pOsGYCXsbNQG/tC7s2alapj8V/_help_TiQbQDgP8L5t">Text Extraction (OCR)</a>) before sending them to the LLM provider.</p>+ </aside>+ <h3>Mentions</h3>+ <p>Mentions are a way to insert references to notes other than the current+ note, using the same mechanism as <a class="reference-link" href="#root/pOsGYCXsbNQG/KSZ04uQ2D1St/iPIMuisry3hd/QEAPj01N5f7w/_help_hrZ1D00cLbal">Internal (reference) links</a>.+ To refer to another note, simply type <kbd spellcheck="false">@</kbd> followed+ by the name of the note to reference.</p>+ <p>This feature is mostly helpful when note tools are enabled, otherwise+ the LLM will have no way to access the given note.</p>+ <h3>Skills</h3>+ <p>Skills in Trilium are specialized instruction sets that help the AI be+ more productive by understanding how Trilium.</p>+ <p>These skills are not loaded by default to avoid an increased consumption+ of tokens, but the AI can load them on-demand if <em>Note tools </em>are+ enabled.</p>+ <p>The following skills are built-in:</p>+ <ul>+ <li>+ <p>Search syntax: understands the full syntax of <a class="reference-link"+ href="#root/pOsGYCXsbNQG/gh7bpGYxajRS/wArbEsdSae6g/_help_eIg8jdvaoNNd">Search</a>.</p>+ </li>+ <li>+ <p>Backend scripting: to be able to write proper <a class="reference-link"+ href="#root/pOsGYCXsbNQG/CdNpE2pqjmI6/_help_SPirpZypehBG">Backend scripts</a>.</p>+ </li>+ <li>+ <p>Frontend scripting: to be able to write proper <a href="#root/pOsGYCXsbNQG/CdNpE2pqjmI6/_help_yIhgI5H7A2Sm">front-end scripts</a> (basic+ scripts, widgets, <a class="reference-link" href="#root/pOsGYCXsbNQG/KSZ04uQ2D1St/_help_HcABDtFCkbFN">Render Note</a>).</p>+ </li>+ </ul>+ <p>When <em>Note tools</em> are enabled the skills will automatically be made+ available to the AI, so no user interaction is required.</p>+ <aside class="admonition note">+ <p>Custom skills are currently not supported but they are planned.</p>+ </aside>+ <h3>MCP</h3>+ <p><a href="https://en.wikipedia.org/wiki/Model_Context_Protocol">Model Context Protocol</a> allows+ external chat applications such as Claude Code to have access to the Trilium+ database.</p>+ <h4>Built-in MCP</h4>+ <p>v0.103.0 comes with a built-in MCP server that is not active by default.+ To activate it, go to <a class="reference-link" href="#root/pOsGYCXsbNQG/gh7bpGYxajRS/Vc8PjrjAGuOp/_help_4TIF1oA4VQRO">Options</a> →+ AI/LLM and toggle the <em>MCP server</em> option.</p>+ <p>Once the MCP is active, simply add the MCP server to your AI assistant.+ The URL to use is displayed in the <em>Endpoint</em> <em>URL</em> information+ underneath the MCP toggle.</p>+ <p>Important aspects to consider:</p>+ <ul>+ <li>+ <p>Only the HTTP transport is supported, the <code spellcheck="false">stdio</code> method+ is not supported. If that is a blocker, consider using a third-party alternative+ listed below.</p>+ </li>+ <li>+ <p>The MCP does not have any authentication.</p>+ </li>+ <li>+ <p>The MCP is currently exposed only on <code spellcheck="false">localhost</code> to+ avoid potential security issues, especially given that there is no authentication+ present.</p>+ </li>+ </ul>+ <p>The tools exposed to the MCP are the same tools that are supported by+ the internal chat (see the <em>Note access</em> section).</p>+ <h4>Third-party alternatives</h4>+ <p>The following are alternatives to Trilium's built-in MCP feature. Since+ Trilium's AI implementation is still experimental, its tooling might not+ be as mature as external tools.</p>+ <ul>+ <li><a href="https://github.com/perfectra1n/triliumnext-mcp">perfectra1n/triliumnext-mcp</a>+ </li>+ <li><a href="https://github.com/tan-yong-sheng/triliumnext-mcp">tan-yong-sheng/triliumnext-mcp</a>+ </li>+ <li><a href="https://github.com/eliassoares/trilium-fastmcp">eliassoares/trilium-fastmcp</a>+ </li>+ </ul>+ <aside class="admonition important">+ <p>These solutions are third-party and thus not endorsed or supported directly+ by the Trilium Notes team. Please address questions and issues on their+ corresponding repository instead.</p>+ </aside>\ No newline at end of filediff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Markdown.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Markdown.htmlindex af567c0961..6a72568bd4 100644--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Markdown.html+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Markdown.html@@ -32,58 +32,68 @@<p>The following features are supported by Trilium's Markdown format andwill show up in the preview pane:</p><ul>- <li>All standard and GitHub-flavored syntax (basic formatting, tables, blockquotes).</li>- <li- >Basic HTML is also supported (e.g. collapsible blocks using <code spellcheck="false"><details></code> and- <code- spellcheck="false"><summary></code>).</li>- <li>Code blocks with syntax highlight.- <ul>- <li>The language must be specified for syntax highlight to be applied (e.g.- <code- spellcheck="false">```js</code>).</li>- <li>Code blocks will respect the text wrapping from the <a class="reference-link"- href="#root/_help_iPIMuisry3hd">Text</a> section in <a class="reference-link"- href="#root/_help_4TIF1oA4VQRO">Options</a>.</li>- </ul>- </li>- <li><a class="reference-link" href="#root/_help_NwBbFdNZ9h7O">Block quotes & admonitions</a>- </li>- <li><a class="reference-link" href="#root/_help_YfYAtQBcfo5V">Math Equations</a> (both- inline and block)</li>- <li><a class="reference-link" href="#root/_help_s1aBHPd79XYj">Mermaid Diagrams</a> using+ <li>+ <p>All standard and GitHub-flavored syntax (basic formatting, tables, blockquotes).</p>+ </li>+ <li>+ <p>Basic HTML is also supported (e.g. collapsible blocks using <code spellcheck="false"><details></code> and+ <code+ spellcheck="false"><summary></code>).</p>+ </li>+ <li>+ <p>Code blocks with syntax highlight.</p>+ <ul>+ <li>The language must be specified for syntax highlight to be applied (e.g.<code- spellcheck="false">```mermaid</code>- </li>- <li>- <p><a class="reference-link" href="#root/_help_nBAXQFj20hS1">Include Note</a> (no- built-in Markdown syntax, but HTML syntax works just fine):</p><pre><code class="language-text-html"><section class="include-note" data-note-id="vJDjQm0VK8Na" data-box-size="expandable">+ spellcheck="false">```js</code>).</li>+ <li>Code blocks will respect the text wrapping from the <a class="reference-link"+ href="#root/_help_iPIMuisry3hd">Text</a> section in <a class="reference-link"+ href="#root/_help_4TIF1oA4VQRO">Options</a>.</li>+ </ul>+ </li>+ <li>+ <p><a class="reference-link" href="#root/_help_NwBbFdNZ9h7O">Block quotes & admonitions</a>+ </p>+ </li>+ <li>+ <p><a class="reference-link" href="#root/_help_YfYAtQBcfo5V">Math Equations</a> (both+ inline and block)</p>+ </li>+ <li>+ <p><a class="reference-link" href="#root/_help_s1aBHPd79XYj">Mermaid Diagrams</a> using+ <code+ spellcheck="false">```mermaid</code>+ </p>+ </li>+ <li>+ <p><a class="reference-link" href="#root/_help_nBAXQFj20hS1">Include Note</a> (no+ built-in Markdown syntax, but HTML syntax works just fine):</p><pre><code class="language-text-html"><section class="include-note" data-note-id="vJDjQm0VK8Na" data-box-size="expandable">&nbsp;</section></code></pre>- <ul>- <li>These can also be quickly created via the <code spellcheck="false">/include</code> command- or via a dedicated keyboard shortcut (not assigned by default).</li>- </ul>- </li>- <li>- <p><a class="reference-link" href="#root/_help_hrZ1D00cLbal">Internal (reference) links</a> via- its HTML syntax, or through a <em>Wikilinks</em>-like format (only - <a- class="reference-link" href="#root/_help_m1lbrzyKDaRB">Note ID</a>):</p><pre><code class="language-text-x-trilium-auto">[[Hg8TS5ZOxti6]]</code></pre>- </li>- <li>- <p><a class="reference-link" href="#root/_help_AgjCISero73a">Footnotes</a> are- also supported via the corresponding Markdown syntax:</p><pre><code class="language-text-x-trilium-auto">This is [^1], while this is [^2].+ <ul>+ <li>These can also be quickly created via the <code spellcheck="false">/include</code> command+ or via a dedicated keyboard shortcut (not assigned by default).</li>+ </ul>+ </li>+ <li>+ <p><a class="reference-link" href="#root/_help_hrZ1D00cLbal">Internal (reference) links</a> via+ its HTML syntax, or through a <em>Wikilinks</em>-like format (only + <a+ class="reference-link" href="#root/_help_m1lbrzyKDaRB">Note ID</a>):</p><pre><code class="language-text-x-trilium-auto">[[Hg8TS5ZOxti6]]</code></pre>+ </li>+ <li>+ <p><a class="reference-link" href="#root/_help_AgjCISero73a">Footnotes</a> are+ also supported via the corresponding Markdown syntax:</p><pre><code class="language-text-x-trilium-auto">This is [^1], while this is [^2].[^1]: the first footnote[^2]: the second footnote</code></pre>- <ul>- <li>These can also be quickly created using the <code spellcheck="false">/footnote</code> command.</li>- </ul>- </li>- <li>- <p>Page breaks for <a class="reference-link" href="#root/jdjRLhLV3TtI/yeqU0zo0ZQ83/_help_W0msUwLxm40d">Printing and exporting to PDF</a>:</p><pre><code class="language-text-x-trilium-auto"><div class="page-break"></div></code></pre>- </li>+ <ul>+ <li>These can also be quickly created using the <code spellcheck="false">/footnote</code> command.</li>+ </ul>+ </li>+ <li>+ <p>Page breaks for <a class="reference-link" href="#root/jdjRLhLV3TtI/yeqU0zo0ZQ83/_help_W0msUwLxm40d">Printing and exporting to PDF</a>:</p><pre><code class="language-text-x-trilium-auto"><div class="page-break"></div></code></pre>+ </li></ul><h3>Links</h3><p>Multiple types of links are supported:</p>@@ -133,8 +143,7 @@<li>Drag & drop directly into the editor area.</li><li>Pasting an image from clipboard.</li><li>Pasting a reference to another <a href="#root/_help_0vhv7lsOLy82">attachment</a> (e.g. <em>Copy reference to clipboard</em> button).</li>- <li- >Use the <code spellcheck="false">/image</code> slash command.</li>+ <li>Use the <code spellcheck="false">/image</code> slash command.</li></ul><p>An image reference to an attachment looks like this:</p><pre><code class="language-text-x-trilium-auto"></code></pre><h3>Slash commands</h3>@@ -142,9 +151,8 @@Markdown notes support a selection of slash commands:</p><ul><li>Creating <a href="#root/_help_NwBbFdNZ9h7O">admonitions</a> (e.g. <code spellcheck="false">/tip</code>)</li>- <li- >Uploading images (<code spellcheck="false">/image</code>).</li>- <li>Inserting the current date & time (<code spellcheck="false">/date</code>).</li>+ <li>Uploading images (<code spellcheck="false">/image</code>).</li>+ <li>Inserting the current date & time (<code spellcheck="false">/date</code>).</li></ul><p>Note that slash commands only work outside of inline </p><h3>Other features</h3>@@ -169,8 +177,7 @@<ol><li>Create a new note (e.g. in the <a class="reference-link" href="#root/_help_oPVyFC7WL2Lp">Note Tree</a>)and select the type <em>Markdown</em>, just like all the other note types.</li>- <li- >Create a note of type <a class="reference-link" href="#root/_help_6f9hih2hXXZk">Code</a> and+ <li>Create a note of type <a class="reference-link" href="#root/_help_6f9hih2hXXZk">Code</a> andselect as the language either <em>Markdown</em> or <em>GitHub-Flavored Markdown</em>.This maintains compatibility with your existing notes prior to the introductionof this feature.</li>diff --git a/docs/Developer Guide/Developer Guide/Documentation.md b/docs/Developer Guide/Developer Guide/Documentation.mdindex 0b6483efdc..59ed193b32 100644--- a/docs/Developer Guide/Developer Guide/Documentation.md+++ b/docs/Developer Guide/Developer Guide/Documentation.md@@ -1,5 +1,5 @@# Documentation-There are multiple types of documentation for Trilium:<img class="image-style-align-right" src="api/images/9EFg0G8dUBHK/Documentation_image.png" width="205" height="162">+There are multiple types of documentation for Trilium:<img class="image-style-align-right" src="api/images/Ju4P3jNDhEVy/Documentation_image.png" width="205" height="162">* The _User Guide_ represents the user-facing documentation. This documentation can be browsed by users directly from within Trilium, by pressing <kbd>F1</kbd>.* The _Developer's Guide_ represents a set of Markdown documents that present the internals of Trilium, for developers.diff --git a/docs/User Guide/!!!meta.json b/docs/User Guide/!!!meta.jsonindex d530ae8f95..17451a3c31 100644--- a/docs/User Guide/!!!meta.json+++ b/docs/User Guide/!!!meta.json@@ -16771,6 +16771,76 @@"value": "bx bx-bot","isInheritable": false,"position": 30+ },+ {+ "type": "relation",+ "name": "internalLink",+ "value": "TiQbQDgP8L5t",+ "isInheritable": false,+ "position": 60+ },+ {+ "type": "relation",+ "name": "internalLink",+ "value": "hrZ1D00cLbal",+ "isInheritable": false,+ "position": 70+ },+ {+ "type": "relation",+ "name": "internalLink",+ "value": "0vhv7lsOLy82",+ "isInheritable": false,+ "position": 80+ },+ {+ "type": "relation",+ "name": "internalLink",+ "value": "eIg8jdvaoNNd",+ "isInheritable": false,+ "position": 90+ },+ {+ "type": "relation",+ "name": "internalLink",+ "value": "SPirpZypehBG",+ "isInheritable": false,+ "position": 100+ },+ {+ "type": "relation",+ "name": "internalLink",+ "value": "yIhgI5H7A2Sm",+ "isInheritable": false,+ "position": 110+ },+ {+ "type": "relation",+ "name": "internalLink",+ "value": "HcABDtFCkbFN",+ "isInheritable": false,+ "position": 120+ },+ {+ "type": "relation",+ "name": "internalLink",+ "value": "wy8So3yZZlH9",+ "isInheritable": false,+ "position": 130+ },+ {+ "type": "relation",+ "name": "internalLink",+ "value": "vZWERwf8U3nx",+ "isInheritable": false,+ "position": 140+ },+ {+ "type": "relation",+ "name": "internalLink",+ "value": "KC1HB96bqqHX",+ "isInheritable": false,+ "position": 150}],"format": "markdown",diff --git a/docs/User Guide/User Guide/AI.md b/docs/User Guide/User Guide/AI.mdindex 13b4079d78..e232573488 100644--- a/docs/User Guide/User Guide/AI.md+++ b/docs/User Guide/User Guide/AI.md@@ -24,8 +24,13 @@ One of the key changes that lead to the reimplementation is that now we are usin* Provides the AI context with the note currently being looked at.* Tools to alter note content, create new notes, etc.* Statistics regarding context window use and pricing per message.+* Attachments for multi-modal chat (images, text files, PDFs).* Optional MCP to allow external chat tools (e.g. Claude Code) to operate on notes within Trilium.+## Sample use-cases++<table class="ck-table-resized"><colgroup><col style="width:38.77%;"><col style="width:61.23%;"></colgroup><thead><tr><th scope="col">Use case</th><th scope="col">Sample prompt</th></tr></thead><tbody><tr><td>Easily create a <a class="reference-link" href="Note%20Types/Render%20Note.md">Render Note</a>.</td><td><blockquote><p><em>Create for me a render note which allows me to play tic-tac-toe. Make sure to use Preact instead of the legacy jQuery.</em></p></blockquote></td></tr></tbody></table>+## LLM Providers### Cloud providers@@ -43,10 +48,12 @@ For all the providers, an API key is needed. Note that this is charged separatel### Self-hosted providers-You might have noticed that there are no self-hosted solutions supported by the AI integration. The reasoning is that currently the self-hosted alternatives require additional integrations (for example a web search tool) or provide low-quality results (e.g. hallucinating tool calls) that would otherwise degrade the experience of the chat.+Since v0.104.0, self-hosted LLM providers are supported indirectly. Simply create an Anthropic, ChatGPT, or Gemini provider and select the appropriate base URL.-> [!NOTE]-> We do plan to support self-hosted AI solutions in future versions.+Model selection for self-hosted providers is not yet supported, but generally the default or the loaded one is used instead.++> [!WARNING]+> When dealing with self-hosted LLM models, depending on the training and the size of the model, the quality of the output may vary. Before [reporting issues](Troubleshooting/Reporting%20issues.md) regarding the quality of the output (e.g. hallucinating tool calls), consider benchmarking the response against a cloud provider (Claude Sonnet is recommended).## Enabling the AI integration@@ -82,24 +89,127 @@ The dedicated chat note is similar to the sidebar interface, but it makes longerUnlike the sidebar, the AI will not be aware of the current note it's in.-## Web search+### Templates++Chat notes can be set as <a class="reference-link" href="Advanced%20Usage/Templates.md">Templates</a> to make them easily reusable. The entire conversation history is kept, allowing a basic form of specialization for the LLM with the existing chat acting like a system prompt.++## Features++### Web searchThe AI can optionally search the web to find more information about a specific topic.This feature is on by default but it can easily be disabled by clicking on the model selector at the bottom of the chat and unchecking _Web search_.-## Tools+> [!NOTE]+> Currently only the search native to the LLM provider is supported. External search providers such as Exa, Tavily & SearXNG are not yet supported.++### Note access (tools)Tools allow the agentic AI to understand and operate on notes directly within your Trilium instance.This feature is on by default but it can easily be disabled by clicking on the model selector at the bottom of the chat and unchecking _Note access_.-## Alternative solutions (MCP)+Here are a few tools that Trilium provides for the LLM:++* At note level:+ * Search for notes+ * Get the metadata or content of a note.+ * Edit a note+ * There are multiple mechanism for the LLM to edit a note: completely by re-writing it, find/replace of a text sequence or append.+ * Whenever the AI makes a change, a [revision](Basic%20Concepts%20and%20Features/Notes/Note%20Revisions.md) is saved to be able to revert any unwanted changes.+ * Create a new note+ * Rename or delete a note.+* At attribute level:+ * Get the full list of attributes, or a specific attribute.+ * Set the value of an attribute.+ * Delete an attribute.+* At tree level:+ * Get the direct children of a note.+ * Get the entire subtree of a note.+ * Move or clone a note somewhere else.+* For <a class="reference-link" href="Basic%20Concepts%20and%20Features/Notes/Attachments.md">Attachments</a>:+ * Get metadata for an attachment.+ * Get the content of an attachment.+* Skills (see the dedicated section).++> [!WARNING]+> Currently there is **no permission management** implemented for note tools, meaning that the LLM could potentially remove existing notes or clutter the tree with notes. Generally most actions are easily reversible (deleting the notes, restoring deleted notes, reverting modifications to a note), but there are some that are harder to revert (e.g. setting an attribute because there is no attribute history).++> [!NOTE]+> Gemini has a special case in which _Note access_ and _Web search_ can't be both enabled at the same time.++### Attachments++Since Trilium v0.140.0, <a class="reference-link" href="Basic%20Concepts%20and%20Features/Notes/Attachments.md">Attachments</a> allow for multi-modal chat:++* Raster image (sent as vision input, except for SVGs) with the following supported formats: PNG, JPEG, GIF, WebP.+* PDFs, sent natively to the provider (supported by Anthropic, OpenAI and Google).+* SVG images (sent as raw HTML).+* Text files.++To upload an attachment:++* Press the dedicated _Attach_ button (paperclip icon) underneath the text box.+* Paste an image directly from clipboard using <kbd spellcheck="false">Ctrl</kbd>+<kbd spellcheck="false">V</kbd>.++Once one or more attachments are uploaded, they will appear directly above the text box:++* Images have a small thumbnail for easy identifications.+* Every attachment can be deleted by pressing their corresponding X button.++When an attachment is present, the LLM is instructed to consider the attachment with priority, even if it has access to the current note.++> [!NOTE]+> Currently Trilium doesn't pre-process the attachments (e.g. via <a class="reference-link" href="Advanced%20Usage/Text%20Extraction%20(OCR).md">Text Extraction (OCR)</a>) before sending them to the LLM provider.++### Mentions++Mentions are a way to insert references to notes other than the current note, using the same mechanism as <a class="reference-link" href="Note%20Types/Text/Links/Internal%20(reference)%20links.md">Internal (reference) links</a>. To refer to another note, simply type <kbd spellcheck="false">@</kbd> followed by the name of the note to reference.++This feature is mostly helpful when note tools are enabled, otherwise the LLM will have no way to access the given note.++### Skills++Skills in Trilium are specialized instruction sets that help the AI be more productive by understanding how Trilium.++These skills are not loaded by default to avoid an increased consumption of tokens, but the AI can load them on-demand if _Note tools_ are enabled.++The following skills are built-in:++* Search syntax: understands the full syntax of <a class="reference-link" href="Basic%20Concepts%20and%20Features/Navigation/Search.md">Search</a>.+* Backend scripting: to be able to write proper <a class="reference-link" href="Scripting/Backend%20scripts.md">Backend scripts</a>.+* Frontend scripting: to be able to write proper [front-end scripts](Scripting/Frontend%20Basics.md) (basic scripts, widgets, <a class="reference-link" href="Note%20Types/Render%20Note.md">Render Note</a>).++When _Note tools_ are enabled the skills will automatically be made available to the AI, so no user interaction is required.++> [!NOTE]+> Custom skills are currently not supported but they are planned.++### MCP++[Model Context Protocol](https://en.wikipedia.org/wiki/Model_Context_Protocol) allows external chat applications such as Claude Code to have access to the Trilium database.++#### Built-in MCP++v0.103.0 comes with a built-in MCP server that is not active by default. To activate it, go to <a class="reference-link" href="Basic%20Concepts%20and%20Features/UI%20Elements/Options.md">Options</a> → AI/LLM and toggle the _MCP server_ option.++Once the MCP is active, simply add the MCP server to your AI assistant. The URL to use is displayed in the _Endpoint_ _URL_ information underneath the MCP toggle.++Important aspects to consider:++* Only the HTTP transport is supported, the `stdio` method is not supported. If that is a blocker, consider using a third-party alternative listed below.+* The MCP does not have any authentication.+* The MCP is currently exposed only on `localhost` to avoid potential security issues, especially given that there is no authentication present.++The tools exposed to the MCP are the same tools that are supported by the internal chat (see the _Note access_ section).++#### Third-party alternativesThe following are alternatives to Trilium's built-in MCP feature. Since Trilium's AI implementation is still experimental, its tooling might not be as mature as external tools.-* [tan-yong-sheng/triliumnext-mcp](https://github.com/tan-yong-sheng/triliumnext-mcp)* [perfectra1n/triliumnext-mcp](https://github.com/perfectra1n/triliumnext-mcp)+* [tan-yong-sheng/triliumnext-mcp](https://github.com/tan-yong-sheng/triliumnext-mcp)* [eliassoares/trilium-fastmcp](https://github.com/eliassoares/trilium-fastmcp)> [!IMPORTANT]diff --git a/docs/User Guide/User Guide/Note Types/Markdown.md b/docs/User Guide/User Guide/Note Types/Markdown.mdindex 03f9d38da0..30d73064ef 100644--- a/docs/User Guide/User Guide/Note Types/Markdown.md+++ b/docs/User Guide/User Guide/Note Types/Markdown.md@@ -27,6 +27,7 @@ The following features are supported by Trilium's Markdown format and will show* All standard and GitHub-flavored syntax (basic formatting, tables, blockquotes).* Basic HTML is also supported (e.g. collapsible blocks using `<details>` and `<summary>`).* Code blocks with syntax highlight.+* The language must be specified for syntax highlight to be applied (e.g. ` ```js `).* Code blocks will respect the text wrapping from the <a class="reference-link" href="Text.md">Text</a> section in <a class="reference-link" href="../Basic%20Concepts%20and%20Features/UI%20Elements/Options.md">Options</a>.* <a class="reference-link" href="Text/Block%20quotes%20%26%20admonitions.md">Block quotes & admonitions</a>