From e785c58d9cfdaa6d8b400341668d9b5cd2ac8aa9 Mon Sep 17 00:00:00 2001 From: Justyn Shull Date: Wed, 11 Sep 2024 00:55:54 -0500 Subject: [PATCH] Remove duplicate description field in aiPrompt templates --- docs/Changelog.md | 1 + .../AICore/AIPrompt/AI Create Space Script.md | 1 - .../Library/AICore/AIPrompt/AI Rewrite - Grammar.md | 1 - .../AICore/AIPrompt/AI Rewrite - Professional.md | 1 - docs/Library/AICore/AIPrompt/AI Split Task.md | 1 - .../AICore/AIPrompt/AI Summarize Note - Chat.md | 1 - docs/Library/AICore/AIPrompt/AI Summarize Note.md | 1 - docs/Templated Prompts.md | 2 -- src/prompts.ts | 13 +++++-------- 9 files changed, 6 insertions(+), 16 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index f146669..7d7dfa0 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -28,6 +28,7 @@ This page is a brief overview of each version. - **replace-smart**: Intelligently replaces content based on context (selected text, current item, or current paragraph). - AICore Library: Add `aiSplitTodo` slash command and [[^Library/AICore/AIPrompt/AI Split Task]] templated prompt to split a task into smaller subtasks. - AICore Library: Add template prompts for rewriting text, mostly as a demo for the `replace-smart` insertAt option. +- Remove need for duplicate `description` frontmatter field for templated prompts. --- ## 0.3.2 diff --git a/docs/Library/AICore/AIPrompt/AI Create Space Script.md b/docs/Library/AICore/AIPrompt/AI Create Space Script.md index d5b6a9f..7ec2edb 100644 --- a/docs/Library/AICore/AIPrompt/AI Create Space Script.md +++ b/docs/Library/AICore/AIPrompt/AI Create Space Script.md @@ -3,7 +3,6 @@ tags: - template - aiPrompt -description: "Describe the space script functionality you want and generate it" aiprompt: description: "Describe the space script functionality you want and generate it" system: "You are an expert javascript developer. Help the user develop new functionality for their personal note taking tool." diff --git a/docs/Library/AICore/AIPrompt/AI Rewrite - Grammar.md b/docs/Library/AICore/AIPrompt/AI Rewrite - Grammar.md index 9929cfb..dba5a39 100644 --- a/docs/Library/AICore/AIPrompt/AI Rewrite - Grammar.md +++ b/docs/Library/AICore/AIPrompt/AI Rewrite - Grammar.md @@ -4,7 +4,6 @@ tags: - aiPrompt - meta -description: "Rewrite current paragraph or selected text to fix and improve grammar." aiprompt: description: "Rewrite current paragraph or selected text to fix and improve grammar." chat: true diff --git a/docs/Library/AICore/AIPrompt/AI Rewrite - Professional.md b/docs/Library/AICore/AIPrompt/AI Rewrite - Professional.md index 3a9a46e..327daa6 100644 --- a/docs/Library/AICore/AIPrompt/AI Rewrite - Professional.md +++ b/docs/Library/AICore/AIPrompt/AI Rewrite - Professional.md @@ -4,7 +4,6 @@ tags: - aiPrompt - meta -description: "Rewrite current paragraph or selected text to be more professional" aiprompt: description: "Rewrite current paragraph or selected text to be more professional" chat: true diff --git a/docs/Library/AICore/AIPrompt/AI Split Task.md b/docs/Library/AICore/AIPrompt/AI Split Task.md index 3e6f915..3aab2a4 100644 --- a/docs/Library/AICore/AIPrompt/AI Split Task.md +++ b/docs/Library/AICore/AIPrompt/AI Split Task.md @@ -4,7 +4,6 @@ tags: - aiPrompt - meta -description: "Split current todo into smaller manageable chunks." aiprompt: description: "Split current todo into smaller manageable chunks." slashCommand: aiSplitTodo diff --git a/docs/Library/AICore/AIPrompt/AI Summarize Note - Chat.md b/docs/Library/AICore/AIPrompt/AI Summarize Note - Chat.md index 39c7d8e..a57a90b 100644 --- a/docs/Library/AICore/AIPrompt/AI Summarize Note - Chat.md +++ b/docs/Library/AICore/AIPrompt/AI Summarize Note - Chat.md @@ -3,7 +3,6 @@ tags: - template - aiPrompt -description: "Generate a summary of the current page using chat." aiprompt: description: "Generate a summary of the current page using chat." system: You are an AI Note Summary bot. Help the user create useful and accurate summaries. diff --git a/docs/Library/AICore/AIPrompt/AI Summarize Note.md b/docs/Library/AICore/AIPrompt/AI Summarize Note.md index b2787ea..0dc9827 100644 --- a/docs/Library/AICore/AIPrompt/AI Summarize Note.md +++ b/docs/Library/AICore/AIPrompt/AI Summarize Note.md @@ -3,7 +3,6 @@ tags: - template - aiPrompt -description: "Generate a summary of the current page." aiprompt: description: "Generate a summary of the current page." --- diff --git a/docs/Templated Prompts.md b/docs/Templated Prompts.md index dbf8cf3..24fa784 100644 --- a/docs/Templated Prompts.md +++ b/docs/Templated Prompts.md @@ -126,7 +126,6 @@ tags: - template - aiPrompt -description: "Generate a summary of the current page." aiprompt: description: "Generate a summary of the current page." system: You are an AI Note Summary bot. Help the user create useful and accurate summaries. @@ -189,7 +188,6 @@ tags: - aiPrompt - meta -description: "Generate a random pet name" aiprompt: description: "Generate a random pet name." slashCommand: aiGeneratePetName diff --git a/src/prompts.ts b/src/prompts.ts index 5ff49f9..2726fa6 100644 --- a/src/prompts.ts +++ b/src/prompts.ts @@ -5,7 +5,7 @@ import { space, system, } from "@silverbulletmd/silverbullet/syscalls"; -import { queryObjects } from "./utils.ts"; +import { query } from "./utils.ts"; import { renderTemplate } from "https://deno.land/x/silverbullet@0.9.4/plugs/template/api.ts"; import type { CompleteEvent, @@ -28,9 +28,9 @@ export async function aiPromptSlashComplete( if (!supportsPlugSlashComplete()) { return; } - const allTemplates = await queryObjects("template", { - filter: ["attr", ["attr", "aiprompt"], "slashCommand"], - }, 5); + const allTemplates = await query( + "template where aiprompt and aiprompt.slashCommand", + ); return { options: allTemplates.map((template) => { const aiPromptTemplate = template.aiprompt!; @@ -58,10 +58,7 @@ export async function insertAiPromptFromTemplate( let selectedTemplate; if (!SlashCompletions || !SlashCompletions.templatePage) { - // TODO: I don't really understand how this filter works. I'd rather have it check for a #aiPrompt tag instead of an aiprompt.description property - const aiPromptTemplates = await queryObjects("template", { - filter: ["attr", ["attr", "aiprompt"], "description"], - }); + const aiPromptTemplates = await query("template where aiprompt"); selectedTemplate = await editor.filterBox( "Prompt Template",