From 154d2905fa37d8c09ccc7ad86ef05fccd43c4d2b Mon Sep 17 00:00:00 2001 From: perf3ct Date: Tue, 1 Apr 2025 18:51:37 +0000 Subject: [PATCH] actually undo translations in hierarchy.ts for now --- .../llm/constants/hierarchy_constants.ts | 32 +++++++++---------- src/services/llm/context/hierarchy.ts | 18 +++++------ translations/en/server.json | 18 ----------- 3 files changed, 24 insertions(+), 44 deletions(-) diff --git a/src/services/llm/constants/hierarchy_constants.ts b/src/services/llm/constants/hierarchy_constants.ts index 0b577ee02..40cbedd1f 100644 --- a/src/services/llm/constants/hierarchy_constants.ts +++ b/src/services/llm/constants/hierarchy_constants.ts @@ -1,37 +1,35 @@ /** * Hierarchy Context Constants * - * This file centralizes all translatable strings used in the note hierarchy context + * This file centralizes all strings used in the note hierarchy context * functionality. These strings are used when displaying information about parent-child * relationships and note relations in the LLM context building process. */ -import { t } from 'i18next'; - export const HIERARCHY_STRINGS = { // Parent context strings PARENT_CONTEXT: { - NO_PARENT_CONTEXT: () => t('llm.hierarchy.no_parent_context', 'No parent context available.'), - CURRENT_NOTE: (title: string) => t('llm.hierarchy.current_note', '{{title}} (current note)', { title }), + NO_PARENT_CONTEXT: 'No parent context available.', + CURRENT_NOTE: (title: string) => `${title} (current note)`, }, // Child context strings CHILD_CONTEXT: { - NO_CHILD_NOTES: () => t('llm.hierarchy.no_child_notes', 'No child notes.'), - CHILD_NOTES_HEADER: (count: number) => t('llm.hierarchy.child_notes_header', 'Child notes ({{count}} total)', { count }), - CHILD_SUMMARY_PREFIX: () => t('llm.hierarchy.child_summary_prefix', 'Summary: '), - MORE_CHILDREN: (count: number) => t('llm.hierarchy.more_children', '... and {{count}} more child notes not shown', { count }), - ERROR_RETRIEVING: () => t('llm.hierarchy.error_retrieving_children', 'Error retrieving child notes.') + NO_CHILD_NOTES: 'No child notes.', + CHILD_NOTES_HEADER: (count: number) => `Child notes (${count} total)`, + CHILD_SUMMARY_PREFIX: 'Summary: ', + MORE_CHILDREN: (count: number) => `... and ${count} more child notes not shown`, + ERROR_RETRIEVING: 'Error retrieving child notes.' }, // Linked notes context strings LINKED_NOTES: { - NO_LINKED_NOTES: () => t('llm.hierarchy.no_linked_notes', 'No linked notes.'), - OUTGOING_RELATIONS_HEADER: (count: number) => t('llm.hierarchy.outgoing_relations_header', 'Outgoing relations ({{count}} total)', { count }), - INCOMING_RELATIONS_HEADER: (count: number) => t('llm.hierarchy.incoming_relations_header', 'Incoming relations ({{count}} total)', { count }), - DEFAULT_RELATION: () => t('llm.hierarchy.default_relation', 'relates to'), - MORE_OUTGOING: (count: number) => t('llm.hierarchy.more_outgoing', '... and {{count}} more outgoing relations not shown', { count }), - MORE_INCOMING: (count: number) => t('llm.hierarchy.more_incoming', '... and {{count}} more incoming relations not shown', { count }), - ERROR_RETRIEVING: () => t('llm.hierarchy.error_retrieving_linked', 'Error retrieving linked notes.') + NO_LINKED_NOTES: 'No linked notes.', + OUTGOING_RELATIONS_HEADER: (count: number) => `Outgoing relations (${count} total)`, + INCOMING_RELATIONS_HEADER: (count: number) => `Incoming relations (${count} total)`, + DEFAULT_RELATION: 'relates to', + MORE_OUTGOING: (count: number) => `... and ${count} more outgoing relations not shown`, + MORE_INCOMING: (count: number) => `... and ${count} more incoming relations not shown`, + ERROR_RETRIEVING: 'Error retrieving linked notes.' } }; diff --git a/src/services/llm/context/hierarchy.ts b/src/services/llm/context/hierarchy.ts index d2985b08c..4ed4d5e6d 100644 --- a/src/services/llm/context/hierarchy.ts +++ b/src/services/llm/context/hierarchy.ts @@ -98,7 +98,7 @@ export async function getParentContext( } if (!context) { - return HIERARCHY_STRINGS.PARENT_CONTEXT.NO_PARENT_CONTEXT(); + return HIERARCHY_STRINGS.PARENT_CONTEXT.NO_PARENT_CONTEXT; } return context; @@ -123,7 +123,7 @@ export async function getChildContext( const childNotes = note.getChildNotes(); if (!childNotes || childNotes.length === 0) { - return HIERARCHY_STRINGS.CHILD_CONTEXT.NO_CHILD_NOTES(); + return HIERARCHY_STRINGS.CHILD_CONTEXT.NO_CHILD_NOTES; } let context = `${HIERARCHY_STRINGS.CHILD_CONTEXT.CHILD_NOTES_HEADER(childNotes.length)}\n`; @@ -146,7 +146,7 @@ export async function getChildContext( .replace(/\n/g, ' '); if (truncatedContent) { - context += ` ${HIERARCHY_STRINGS.CHILD_CONTEXT.CHILD_SUMMARY_PREFIX()}${truncatedContent}${truncatedContent.length >= 100 ? '...' : ''}\n`; + context += ` ${HIERARCHY_STRINGS.CHILD_CONTEXT.CHILD_SUMMARY_PREFIX}${truncatedContent}${truncatedContent.length >= 100 ? '...' : ''}\n`; } } catch (e) { // Silently skip content errors @@ -162,7 +162,7 @@ export async function getChildContext( return context; } catch (error) { console.error(`Error getting child context for ${noteId}:`, error); - return HIERARCHY_STRINGS.CHILD_CONTEXT.ERROR_RETRIEVING(); + return HIERARCHY_STRINGS.CHILD_CONTEXT.ERROR_RETRIEVING; } } @@ -184,7 +184,7 @@ export async function getLinkedNotesContext( const relations = note.getRelations(); if (!relations || relations.length === 0) { - return HIERARCHY_STRINGS.LINKED_NOTES.NO_LINKED_NOTES(); + return HIERARCHY_STRINGS.LINKED_NOTES.NO_LINKED_NOTES; } // Get incoming relations as well @@ -202,7 +202,7 @@ export async function getLinkedNotesContext( for (const relation of limitedRelations) { const targetNote = becca.getNote(relation.value || ""); if (targetNote) { - const relationName = relation.name || HIERARCHY_STRINGS.LINKED_NOTES.DEFAULT_RELATION(); + const relationName = relation.name || HIERARCHY_STRINGS.LINKED_NOTES.DEFAULT_RELATION; context += `- ${relationName} → ${targetNote.title}\n`; } } @@ -225,7 +225,7 @@ export async function getLinkedNotesContext( for (const relation of limitedIncoming) { const sourceNote = becca.getNote(relation.value || ""); if (sourceNote) { - const relationName = relation.name || HIERARCHY_STRINGS.LINKED_NOTES.DEFAULT_RELATION(); + const relationName = relation.name || HIERARCHY_STRINGS.LINKED_NOTES.DEFAULT_RELATION; context += `- ${sourceNote.title} → ${relationName}\n`; } } @@ -236,9 +236,9 @@ export async function getLinkedNotesContext( } } - return context || HIERARCHY_STRINGS.LINKED_NOTES.NO_LINKED_NOTES(); + return context || HIERARCHY_STRINGS.LINKED_NOTES.NO_LINKED_NOTES; } catch (error) { console.error(`Error getting linked notes context for ${noteId}:`, error); - return HIERARCHY_STRINGS.LINKED_NOTES.ERROR_RETRIEVING(); + return HIERARCHY_STRINGS.LINKED_NOTES.ERROR_RETRIEVING; } } diff --git a/translations/en/server.json b/translations/en/server.json index a6c3d0dbb..be6cb488d 100644 --- a/translations/en/server.json +++ b/translations/en/server.json @@ -196,24 +196,6 @@ "theme_group_light": "Light themes", "theme_group_dark": "Dark themes" }, - "llm": { - "hierarchy": { - "no_parent_context": "No parent context available.", - "current_note": "{{title}} (current note)", - "no_child_notes": "No child notes.", - "child_notes_header": "Child notes ({{count}} total)", - "child_summary_prefix": "Summary: ", - "more_children": "... and {{count}} more child notes not shown", - "error_retrieving_children": "Error retrieving child notes.", - "no_linked_notes": "No linked notes.", - "outgoing_relations_header": "Outgoing relations ({{count}} total)", - "incoming_relations_header": "Incoming relations ({{count}} total)", - "default_relation": "relates to", - "more_outgoing": "... and {{count}} more outgoing relations not shown", - "more_incoming": "... and {{count}} more incoming relations not shown", - "error_retrieving_linked": "Error retrieving linked notes." - } - }, "test_sync": { "not-configured": "Sync server host is not configured. Please configure sync first.", "successful": "Sync server handshake has been successful, sync has been started."