Skip to content

Commit

Permalink
Merge pull request #70 from justyns/template-options
Browse files Browse the repository at this point in the history
Remove duplicate description field in aiPrompt templates
  • Loading branch information
justyns authored Sep 11, 2024
2 parents c4a8612 + e785c58 commit fe4d560
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 16 deletions.
1 change: 1 addition & 0 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion docs/Library/AICore/AIPrompt/AI Create Space Script.md
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
1 change: 0 additions & 1 deletion docs/Library/AICore/AIPrompt/AI Rewrite - Grammar.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion docs/Library/AICore/AIPrompt/AI Rewrite - Professional.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion docs/Library/AICore/AIPrompt/AI Split Task.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion docs/Library/AICore/AIPrompt/AI Summarize Note - Chat.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion docs/Library/AICore/AIPrompt/AI Summarize Note.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ tags:
- template
- aiPrompt

description: "Generate a summary of the current page."
aiprompt:
description: "Generate a summary of the current page."
---
Expand Down
2 changes: 0 additions & 2 deletions docs/Templated Prompts.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -189,7 +188,6 @@ tags:
- aiPrompt
- meta

description: "Generate a random pet name"
aiprompt:
description: "Generate a random pet name."
slashCommand: aiGeneratePetName
Expand Down
13 changes: 5 additions & 8 deletions src/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]/plugs/template/api.ts";
import type {
CompleteEvent,
Expand All @@ -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!;
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit fe4d560

Please sign in to comment.