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:
@@ -9260,6 +9260,8 @@ var ChatView = class extends import_obsidian3.ItemView {
|
||||
buildMessages(userMessageContent, tools) {
|
||||
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.
|
||||
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.
|
||||
Only use the tools if you need to access vault content that is not already in the context.`;
|
||||
const systemMessage = {
|
||||
@@ -9355,8 +9357,15 @@ var ChatView = class extends import_obsidian3.ItemView {
|
||||
userMessage,
|
||||
this.settings.vaultSearchLimit
|
||||
);
|
||||
const context = entries.map((entry) => `${entry.title}
|
||||
${entry.content}`).join("\n\n").slice(0, MAX_CONTEXT_LENGTH);
|
||||
const context = entries.map((entry) => {
|
||||
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:
|
||||
${context}
|
||||
|
||||
|
||||
+11
-1
@@ -356,6 +356,8 @@ export class ChatView extends ItemView {
|
||||
buildMessages(userMessageContent: string, tools?: OllamaTool[]): OllamaMessage[] {
|
||||
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.
|
||||
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.
|
||||
Only use the tools if you need to access vault content that is not already in the context.`;
|
||||
const systemMessage: OllamaMessage = {
|
||||
@@ -478,7 +480,15 @@ export class ChatView extends ItemView {
|
||||
this.settings.vaultSearchLimit
|
||||
);
|
||||
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')
|
||||
.slice(0, MAX_CONTEXT_LENGTH);
|
||||
const userMessageWithContext = context
|
||||
|
||||
Reference in New Issue
Block a user