fix: include tags in vault context sent to AI and update system prompt

- chat-view.ts: include 'Tags: ...' prefix in vault context when tags exist
- chat-view.ts: update system prompt to instruct AI to pay attention to tags
  when organizing or categorizing notes
This commit is contained in:
2026-05-20 01:13:40 +02:00
parent a8d8936b11
commit f09e134948
2 changed files with 22 additions and 3 deletions
+11 -2
View File
@@ -9260,6 +9260,8 @@ var ChatView = class extends import_obsidian3.ItemView {
buildMessages(userMessageContent, tools) { buildMessages(userMessageContent, tools) {
const systemContent = `You are an assistant that can help answer questions using the contents of a vault. const systemContent = `You are an assistant that can help answer questions using the contents of a vault.
The user can ask questions about their vault contents, and you should provide helpful responses based on the files. The user can ask questions about their vault contents, and you should provide helpful responses based on the files.
Vault context includes note titles, content, and any tags (shown as "Tags: ..." at the top of a note entry).
When organizing or categorizing notes, pay attention to tags as they reflect the note's topics and categories.
When a user asks for information, try to find relevant files using the search_vault_files tool and read their contents with the read_vault_file tool. When a user asks for information, try to find relevant files using the search_vault_files tool and read their contents with the read_vault_file tool.
Only use the tools if you need to access vault content that is not already in the context.`; Only use the tools if you need to access vault content that is not already in the context.`;
const systemMessage = { const systemMessage = {
@@ -9355,8 +9357,15 @@ var ChatView = class extends import_obsidian3.ItemView {
userMessage, userMessage,
this.settings.vaultSearchLimit this.settings.vaultSearchLimit
); );
const context = entries.map((entry) => `${entry.title} const context = entries.map((entry) => {
${entry.content}`).join("\n\n").slice(0, MAX_CONTEXT_LENGTH); const parts = [];
if (entry.tags) {
parts.push(`Tags: ${entry.tags}`);
}
parts.push(entry.title);
parts.push(entry.content);
return parts.join("\n");
}).join("\n\n").slice(0, MAX_CONTEXT_LENGTH);
const userMessageWithContext = context ? `Relevant vault context: const userMessageWithContext = context ? `Relevant vault context:
${context} ${context}
+11 -1
View File
@@ -356,6 +356,8 @@ export class ChatView extends ItemView {
buildMessages(userMessageContent: string, tools?: OllamaTool[]): OllamaMessage[] { buildMessages(userMessageContent: string, tools?: OllamaTool[]): OllamaMessage[] {
const systemContent = `You are an assistant that can help answer questions using the contents of a vault. const systemContent = `You are an assistant that can help answer questions using the contents of a vault.
The user can ask questions about their vault contents, and you should provide helpful responses based on the files. The user can ask questions about their vault contents, and you should provide helpful responses based on the files.
Vault context includes note titles, content, and any tags (shown as "Tags: ..." at the top of a note entry).
When organizing or categorizing notes, pay attention to tags as they reflect the note's topics and categories.
When a user asks for information, try to find relevant files using the search_vault_files tool and read their contents with the read_vault_file tool. When a user asks for information, try to find relevant files using the search_vault_files tool and read their contents with the read_vault_file tool.
Only use the tools if you need to access vault content that is not already in the context.`; Only use the tools if you need to access vault content that is not already in the context.`;
const systemMessage: OllamaMessage = { const systemMessage: OllamaMessage = {
@@ -478,7 +480,15 @@ export class ChatView extends ItemView {
this.settings.vaultSearchLimit this.settings.vaultSearchLimit
); );
const context = entries const context = entries
.map((entry) => `${entry.title}\n${entry.content}`) .map((entry) => {
const parts: string[] = [];
if (entry.tags) {
parts.push(`Tags: ${entry.tags}`);
}
parts.push(entry.title);
parts.push(entry.content);
return parts.join('\n');
})
.join('\n\n') .join('\n\n')
.slice(0, MAX_CONTEXT_LENGTH); .slice(0, MAX_CONTEXT_LENGTH);
const userMessageWithContext = context const userMessageWithContext = context