find_related
Discover semantically related documents in Outline wiki to expand research or find connected content.
Instructions
Find documents semantically related to a specific document.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| documentId | Yes | ||
| limit | No |
Implementation Reference
- src/lib/handlers/smart.ts:159-188 (handler)The core handler function for the 'find_related' tool. Fetches the target document content, performs semantic search using brain.search on title + first 500 chars of text, filters out the source document by ID prefix, and returns document info with list of related docs including title, url, and excerpt.async find_related(args: { documentId: string; limit?: number }) { if (!brain.isEnabled()) { return { error: ERROR_MESSAGES.SMART_FEATURES_DISABLED }; } // Fetch document const { data } = await apiCall(() => apiClient.post<OutlineDocument>('/documents.info', { id: args.documentId }) ); if (!data.text) { return { error: ERROR_MESSAGES.NO_CONTENT_TO_ANALYZE }; } // Search for similar documents const results = await brain.search(data.title + ' ' + data.text.substring(0, 500), args.limit || 5); // Filter out the source document const related = results.filter((r) => !r.id.startsWith(args.documentId)); return { documentId: data.id, title: data.title, related: related.map((r) => ({ title: r.title, url: r.url, excerpt: r.text.substring(0, 200) + '...', })), }; },
- src/lib/schemas.ts:159-162 (schema)Zod input schema for find_related tool: requires 'documentId' string and optional 'limit' number (defaults to 5, min 1 max 100).export const findRelatedSchema = z.object({ documentId, limit: limit.default(5).optional(), });
- src/lib/schemas.ts:159-162 (registration)Schema registered in toolSchemas map at line 248: find_related: findRelatedSchemaexport const findRelatedSchema = z.object({ documentId, limit: limit.default(5).optional(), });
- src/lib/tools.ts:220-224 (registration)Tool definition registered in allTools array, specifying name 'find_related', description, and schema reference 'find_related' (which maps to findRelatedSchema).createTool( 'find_related', 'Find documents semantically related to a specific document.', 'find_related' ),