mirror of
https://github.com/zadam/trilium.git
synced 2025-11-05 04:45:47 +01:00
better note names to LLM?
This commit is contained in:
@@ -425,9 +425,9 @@ function buildContextFromNotes(sources: NoteSource[], query: string): string {
|
|||||||
|
|
||||||
const noteContexts = sources
|
const noteContexts = sources
|
||||||
.filter(source => source.content) // Only include sources with content
|
.filter(source => source.content) // Only include sources with content
|
||||||
.map((source, index) => {
|
.map((source) => {
|
||||||
// Format each note as a section in the context
|
// Format each note with its title as a natural heading
|
||||||
return `[NOTE ${index + 1}: ${source.title}]\n${source.content || 'No content available'}`;
|
return `### ${source.title}\n${source.content || 'No content available'}`;
|
||||||
})
|
})
|
||||||
.join('\n\n');
|
.join('\n\n');
|
||||||
|
|
||||||
@@ -436,12 +436,14 @@ function buildContextFromNotes(sources: NoteSource[], query: string): string {
|
|||||||
return query || '';
|
return query || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build a complete context prompt
|
// Build a complete context prompt with clearer instructions
|
||||||
return `I'll provide you with relevant notes from my knowledge base to help answer the question. Please use this information when responding:
|
return `I'll provide you with relevant information from my notes to help answer your question.
|
||||||
|
|
||||||
${noteContexts}
|
${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.";
|
"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) => {
|
sources.forEach((source) => {
|
||||||
context += `--- NOTE ${index + 1}: ${source.title} ---\n`;
|
// 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) {
|
if (source.content) {
|
||||||
// Clean up HTML content before adding it to the context
|
// 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 += "\n";
|
||||||
});
|
});
|
||||||
|
|
||||||
context += "--- END OF NOTES ---\n\n";
|
// Add clear instructions about how to reference the notes
|
||||||
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.";
|
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;
|
return context;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user