mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-18 00:02:28 +08:00
definitely don't need this
This commit is contained in:
parent
c716481ef8
commit
61eaf46a04
@ -458,6 +458,7 @@ export class ContextService {
|
||||
.filter(note => {
|
||||
// Filter out notes with no content or very minimal content
|
||||
const hasContent = note.content && note.content.trim().length > 10;
|
||||
log.info(`Note "${note.title}" (${note.noteId}) has content: ${hasContent} and content length: ${note.content ? note.content.length : 0} chars`);
|
||||
if (!hasContent) {
|
||||
log.info(`Filtering out empty/minimal note from combined results: "${note.title}" (${note.noteId})`);
|
||||
}
|
||||
@ -467,88 +468,6 @@ export class ContextService {
|
||||
|
||||
log.info(`Combined ${relevantNotes.length} notes from initial search with ${vectorSearchNotes.length} notes from vector search, resulting in ${combinedNotes.length} unique notes after filtering out empty notes`);
|
||||
|
||||
// Filter for Qu-related notes
|
||||
const quNotes = combinedNotes.filter(result =>
|
||||
result.title.toLowerCase().includes('qu') ||
|
||||
(result.content && result.content.toLowerCase().includes('qu'))
|
||||
);
|
||||
|
||||
if (quNotes.length > 0) {
|
||||
log.info(`Found ${quNotes.length} Qu-related notes out of ${combinedNotes.length} total notes`);
|
||||
quNotes.forEach((note, idx) => {
|
||||
if (idx < 3) { // Log just a sample to avoid log spam
|
||||
log.info(`Qu note ${idx+1}: "${note.title}" (similarity: ${Math.round(note.similarity * 100)}%), content length: ${note.content ? note.content.length : 0} chars`);
|
||||
}
|
||||
});
|
||||
|
||||
// Prioritize Qu notes first, then other notes by similarity
|
||||
const nonQuNotes = combinedNotes.filter(note => !quNotes.includes(note));
|
||||
const finalNotes = [...quNotes, ...nonQuNotes].slice(0, 30); // Take top 30 prioritized notes
|
||||
|
||||
log.info(`Selected ${finalNotes.length} notes for context, with ${quNotes.length} Qu-related notes prioritized`);
|
||||
|
||||
// Add the selected notes to the context
|
||||
if (finalNotes.length > 0) {
|
||||
agentContext += `## Relevant Information\n`;
|
||||
|
||||
for (const note of finalNotes) {
|
||||
agentContext += `### ${note.title}\n`;
|
||||
|
||||
// Add relationship information for the note
|
||||
try {
|
||||
const noteObj = becca.getNote(note.noteId);
|
||||
if (noteObj) {
|
||||
// Get parent notes
|
||||
const parentNotes = noteObj.getParentNotes();
|
||||
if (parentNotes && parentNotes.length > 0) {
|
||||
agentContext += `**Parent notes:** ${parentNotes.map((p: any) => p.title).join(', ')}\n`;
|
||||
}
|
||||
|
||||
// Get child notes
|
||||
const childNotes = noteObj.getChildNotes();
|
||||
if (childNotes && childNotes.length > 0) {
|
||||
agentContext += `**Child notes:** ${childNotes.map((c: any) => c.title).join(', ')}\n`;
|
||||
}
|
||||
|
||||
// Get attributes
|
||||
const attributes = noteObj.getAttributes();
|
||||
if (attributes && attributes.length > 0) {
|
||||
const filteredAttrs = attributes.filter((a: any) => !a.name.startsWith('_')); // Filter out system attributes
|
||||
if (filteredAttrs.length > 0) {
|
||||
agentContext += `**Attributes:** ${filteredAttrs.map((a: any) => `${a.name}=${a.value}`).join(', ')}\n`;
|
||||
}
|
||||
}
|
||||
|
||||
// Get backlinks/related notes through relation attributes
|
||||
const relationAttrs = attributes?.filter((a: any) =>
|
||||
a.name.startsWith('relation:') ||
|
||||
a.name.startsWith('label:')
|
||||
);
|
||||
|
||||
if (relationAttrs && relationAttrs.length > 0) {
|
||||
agentContext += `**Relationships:** ${relationAttrs.map((a: any) => {
|
||||
const targetNote = becca.getNote(a.value);
|
||||
const targetTitle = targetNote ? targetNote.title : a.value;
|
||||
return `${a.name.substring(a.name.indexOf(':') + 1)} → ${targetTitle}`;
|
||||
}).join(', ')}\n`;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
log.error(`Error getting relationship info for note ${note.noteId}: ${error}`);
|
||||
}
|
||||
|
||||
agentContext += '\n';
|
||||
|
||||
if (note.content) {
|
||||
// Extract relevant content instead of just taking first 2000 chars
|
||||
const relevantContent = await this.extractRelevantContent(note.content, query, 2000);
|
||||
agentContext += `${relevantContent}\n\n`;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.info(`No Qu-related notes found among the ${combinedNotes.length} combined notes`);
|
||||
|
||||
// Just take the top notes by similarity
|
||||
const finalNotes = combinedNotes.slice(0, 30); // Take top 30 notes
|
||||
|
||||
@ -610,7 +529,7 @@ export class ContextService {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add thinking process if requested
|
||||
if (showThinking) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user