mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-11-04 15:11:31 +08:00 
			
		
		
		
	better note names to LLM?
This commit is contained in:
		
							parent
							
								
									1f661e4c90
								
							
						
					
					
						commit
						6ce3f1c355
					
				@ -425,9 +425,9 @@ function buildContextFromNotes(sources: NoteSource[], query: string): string {
 | 
			
		||||
 | 
			
		||||
    const noteContexts = sources
 | 
			
		||||
        .filter(source => source.content) // Only include sources with content
 | 
			
		||||
        .map((source, index) => {
 | 
			
		||||
            // Format each note as a section in the context
 | 
			
		||||
            return `[NOTE ${index + 1}: ${source.title}]\n${source.content || 'No content available'}`;
 | 
			
		||||
        .map((source) => {
 | 
			
		||||
            // Format each note with its title as a natural heading
 | 
			
		||||
            return `### ${source.title}\n${source.content || 'No content available'}`;
 | 
			
		||||
        })
 | 
			
		||||
        .join('\n\n');
 | 
			
		||||
 | 
			
		||||
@ -436,12 +436,14 @@ function buildContextFromNotes(sources: NoteSource[], query: string): string {
 | 
			
		||||
        return query || '';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Build a complete context prompt
 | 
			
		||||
    return `I'll provide you with relevant notes from my knowledge base to help answer the question. Please use this information when responding:
 | 
			
		||||
    // Build a complete context prompt with clearer instructions
 | 
			
		||||
    return `I'll provide you with relevant information from my notes to help answer your question.
 | 
			
		||||
 | 
			
		||||
${noteContexts}
 | 
			
		||||
 | 
			
		||||
Now, based on the above notes, please answer: ${query}`;
 | 
			
		||||
When referring to information from these notes in your response, please cite them by their titles (e.g., "According to your note on [Title]...") rather than using labels like "Note 1" or "Note 2".
 | 
			
		||||
 | 
			
		||||
Now, based on the above information, please answer: ${query}`;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 | 
			
		||||
@ -346,10 +346,16 @@ Example: ["exact topic mentioned", "related concept 1", "related concept 2"]`;
 | 
			
		||||
                   "with general knowledge about Trilium or other topics you're interested in.";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        let context = `The following are relevant notes from your knowledge base that may help answer the query: "${query}"\n\n`;
 | 
			
		||||
        let context = `I've found some relevant information in your notes that may help answer: "${query}"\n\n`;
 | 
			
		||||
 | 
			
		||||
        sources.forEach((source, index) => {
 | 
			
		||||
            context += `--- NOTE ${index + 1}: ${source.title} ---\n`;
 | 
			
		||||
        sources.forEach((source) => {
 | 
			
		||||
            // Use the note title as a meaningful heading
 | 
			
		||||
            context += `### ${source.title}\n`;
 | 
			
		||||
 | 
			
		||||
            // Add relationship context if available
 | 
			
		||||
            if (source.parentTitle) {
 | 
			
		||||
                context += `Part of: ${source.parentTitle}\n`;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (source.content) {
 | 
			
		||||
                // Clean up HTML content before adding it to the context
 | 
			
		||||
@ -369,8 +375,11 @@ Example: ["exact topic mentioned", "related concept 1", "related concept 2"]`;
 | 
			
		||||
            context += "\n";
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        context += "--- END OF NOTES ---\n\n";
 | 
			
		||||
        context += "Please use the information above to help answer the query. If the information doesn't contain what you need, just say so and use your general knowledge instead.";
 | 
			
		||||
        // Add clear instructions about how to reference the notes
 | 
			
		||||
        context += "When referring to information from these notes in your response, please cite them by their titles " +
 | 
			
		||||
                  "(e.g., \"According to your note on [Title]...\") rather than using labels like \"Note 1\" or \"Note 2\".\n\n";
 | 
			
		||||
 | 
			
		||||
        context += "If the information doesn't contain what you need, just say so and use your general knowledge instead.";
 | 
			
		||||
 | 
			
		||||
        return context;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user