generated from silverbulletmd/silverbullet-plug-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from justyns/template-options
Additional insertAt options, add support for postprocessors to templated prompts
- Loading branch information
Showing
20 changed files
with
480 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
tags: | ||
- template | ||
- aiPrompt | ||
- meta | ||
|
||
description: "Split current todo into smaller manageable chunks." | ||
aiprompt: | ||
description: "Split current todo into smaller manageable chunks." | ||
slashCommand: aiSplitTodo | ||
chat: true | ||
enrichMessages: true | ||
insertAt: new-line-below | ||
postProcessors: | ||
- convertToBulletList | ||
- convertToTaskList | ||
- removeDuplicateStart | ||
- indentOneLevel | ||
--- | ||
|
||
**user**: [enrich:false] I’ll provide the note contents, and instructions. | ||
**assistant**: What is the note title? | ||
**user**: [enrich:true] {{@page.name}} | ||
**assistant**: What are the note contents? | ||
**user**: [enrich:true] | ||
{{@currentPageText}} | ||
**assistant**: What is the parent item the user is looking at? | ||
**user**: [enrich:true] {{@parentItemText}} | ||
**assistant**: What is the current item the user is looking at? Include the parent task if appropriate. | ||
**user**: [enrich:true] {{@currentItemText}} | ||
**assistant**: What are the instructions? | ||
**user**: [enrich:false] Split the current task into smaller, more manageable, and well-defined tasks. Return one task per line. Keep the list of new tasks small. DO NOT return any existing items. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ frontmatter: | |
|
||
**assistant**: Hello, how can I help you? | ||
|
||
**user**: |^| | ||
**user**: |^| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
tags: | ||
- spacescript | ||
- meta | ||
|
||
description: > | ||
This space script allows takes a string and converts each line to a bullet item in a list, if it is not already. | ||
--- | ||
|
||
|
||
```space-script | ||
silverbullet.registerFunction({ name: "convertToBulletList" }, async (data) => { | ||
const { response, lineBefore, lineAfter } = data; | ||
const lines = response.split('\n'); | ||
// Get the indentation level of the line before | ||
const indentationMatch = lineBefore.match(/^\s*/); | ||
const indentation = indentationMatch ? indentationMatch[0] : ''; | ||
const bulletLines = lines.map(line => { | ||
// Trim the line and add the indentation back | ||
const trimmedLine = `${indentation}${line.trim()}`; | ||
// Add a bullet if the line doesn't already start with one | ||
if (!trimmedLine.trim().startsWith('- ')) { | ||
return `- ${trimmedLine.trim()}`; | ||
} | ||
return trimmedLine; | ||
}); | ||
const result = bulletLines.join('\n'); | ||
return result; | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
tags: | ||
- spacescript | ||
- meta | ||
|
||
description: > | ||
This space script takes a string, and makes sure each line is a markdown task. | ||
--- | ||
|
||
```space-script | ||
silverbullet.registerFunction({ name: "convertToTaskList" }, async (data) => { | ||
const { response } = data; | ||
const lines = response.split('\n'); | ||
const result = lines.map(line => { | ||
if (/^\s*-\s*\[\s*[xX]?\s*\]/.test(line)) { | ||
// Already a task | ||
return line.trim(); | ||
} | ||
if (/^\s*-/.test(line)) { | ||
// bullet, but not a task | ||
return `- [ ] ${line.slice(1).trim()}`; | ||
} | ||
// everything else, should be a non list item | ||
return `- [ ] ${line.trim()}`; | ||
}).join('\n'); | ||
return result; | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
tags: | ||
- spacescript | ||
- meta | ||
|
||
description: > | ||
This space script allows takes a string and indents each line one level, compared to the lineBefore. | ||
--- | ||
|
||
```space-script | ||
silverbullet.registerFunction({ name: "indentOneLevel" }, async (data) => { | ||
const { response, lineBefore, lineCurrent } = data; | ||
console.log(data); | ||
// Function to determine the indentation of a line | ||
const getIndentation = (line) => line.match(/^\s*/)[0]; | ||
// Determine the maximum indentation of lineBefore and lineCurrent | ||
const maxIndentation = getIndentation(lineBefore).length > getIndentation(lineCurrent).length | ||
? getIndentation(lineBefore) | ||
: getIndentation(lineCurrent); | ||
// Define additional indentation level | ||
const additionalIndentation = ' '; | ||
// Compute new indentation | ||
const newIndentation = maxIndentation + additionalIndentation; | ||
// Apply new indentation to all lines in the response | ||
const indentedLines = response.split('\n').map(line => `${newIndentation}${line.trim()}`).join('\n'); | ||
console.log("indentedLines:", indentedLines); | ||
return indentedLines; | ||
}); | ||
``` |
25 changes: 25 additions & 0 deletions
25
docs/Library/AICore/Space Script/Remove Duplicate Start.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
tags: | ||
- spacescript | ||
- meta | ||
|
||
description: > | ||
This space script checks lineBefore against the first line of the response and deletes it if its a duplicate. | ||
--- | ||
|
||
|
||
```space-script | ||
silverbullet.registerFunction({ name: "removeDuplicateStart" }, async (data) => { | ||
console.log(data); | ||
const { response, lineBefore, lineCurrent } = data; | ||
const lines = response.split('\n'); | ||
// Check if the first line matches either the previous or current line, and remove it if it does | ||
if ((lines[0].trim() == lineBefore.trim()) || (lines[0].trim() == lineCurrent.trim())) { | ||
lines.shift(); | ||
} | ||
console.log(lines); | ||
return lines.join('\n'); | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.