Просмотр исходного кода

refactor(suggest-path): improve candidate evaluation prompt for taxonomy-aware path proposals

Replace mechanical parent/subdirectory/sibling pattern instructions with
taxonomy-based reasoning. The AI now reads wiki path hierarchy as a content
classification system and proposes paths based on where content naturally
fits, leading to more accurate sibling directory suggestions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
tomoyuki-t 1 месяц назад
Родитель
Сommit
34b1521c33
1 измененных файлов с 21 добавлено и 9 удалено
  1. 21 9
      apps/app/src/server/routes/apiv3/ai-tools/evaluate-candidates.ts

+ 21 - 9
apps/app/src/server/routes/apiv3/ai-tools/evaluate-candidates.ts

@@ -15,14 +15,26 @@ import type {
 const SYSTEM_PROMPT = [
   'You are a page save location evaluator for a wiki system. ',
   'Given content to be saved, its analysis (keywords and information type), and a list of search candidate pages, ',
-  "evaluate each candidate's suitability as a save location and propose optimal directory paths.\n\n",
-  '## Path Proposal Patterns\n',
-  'For each suitable candidate, propose a save location using ONE of three structural patterns:\n',
-  '(a) **Parent directory**: The parent directory of the matching page (e.g., candidate `/tech/React/hooks` → propose `/tech/React/`)\n',
-  '(b) **Subdirectory**: A subdirectory under the matching page (e.g., candidate `/tech/React/hooks` → propose `/tech/React/hooks/advanced/`)\n',
-  '(c) **Sibling directory**: A new directory alongside the matching page at the SAME hierarchy level ',
-  '(e.g., candidate `/tech/React/hooks` → propose `/tech/React/performance/`). ',
-  'The generated path MUST be at the same depth as the candidate page.\n\n',
+  'propose optimal directory paths for saving the content.\n\n',
+  '## How to Read Wiki Paths\n',
+  'Treat the wiki path hierarchy as a content classification taxonomy. ',
+  'Each path segment represents a category or topic at a certain level of abstraction.\n',
+  'Example: `/engineering/frontend/react-testing-patterns`\n',
+  '- `engineering` = broad domain\n',
+  '- `frontend` = topic category within that domain\n',
+  '- `react-testing-patterns` = specific article\n\n',
+  'When proposing a save location, determine which level of the taxonomy the content belongs to ',
+  'and what category name best describes it. The proposed path should reflect where the content ',
+  'naturally fits in the existing classification structure.\n\n',
+  '## Path Proposal\n',
+  'For each suitable candidate, propose a directory path for the content. The proposed path may be:\n',
+  '- An existing directory in the candidate path hierarchy\n',
+  '- A new directory at the appropriate level of the taxonomy\n\n',
+  'Examples given candidate `/engineering/frontend/react-testing-patterns`:\n',
+  '- Content about React components → `/engineering/frontend/` (same topic category)\n',
+  '- Content about CSS architecture → `/engineering/frontend/css-architecture/` (sub-topic)\n',
+  '- Content about Express API design → `/engineering/backend/` (different topic at the same category level)\n\n',
+  'Only propose candidates that are genuinely suitable. Skip candidates where the content has no meaningful relationship.\n\n',
   '## Flow/Stock Information Type\n',
   instructionsForInformationTypes,
   '\n\n',
@@ -30,7 +42,7 @@ const SYSTEM_PROMPT = [
   '## Output Format\n',
   'Return a JSON array of suggestion objects, ranked by content-destination fit (best first).\n',
   'Each object must have:\n',
-  '- "path": Directory path with trailing slash (e.g., "/tech/React/")\n',
+  '- "path": Directory path with trailing slash (e.g., "/engineering/backend/")\n',
   '- "label": Short display label for the suggestion\n',
   '- "description": Explanation of why this location is suitable, considering content relevance and flow/stock alignment\n\n',
   'Return an empty array `[]` if no candidates are suitable.\n',