aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOmar Magdy <99906646+omagdy7@users.noreply.github.com>2024-02-14 17:22:40 +0200
committerGitHub <noreply@github.com>2024-02-14 17:22:40 +0200
commit4f1971020d43d0958973712212f17bd9d51a1834 (patch)
tree3099bc4223d9c39062b6f4d077809bccb88c8219 /src
parent842fcd159675c4091952277526844b1eebf6df18 (diff)
parentf07b00c527db2947f49d4ea592018902d391d55f (diff)
downloadollama-logseq-4f1971020d43d0958973712212f17bd9d51a1834.tar.xz
ollama-logseq-4f1971020d43d0958973712212f17bd9d51a1834.zip
Merge pull request #16 from gixita/master
feat: Add custom prompt defined in configuration to apply on block
Diffstat (limited to 'src')
-rw-r--r--src/App.tsx1
-rw-r--r--src/main.tsx7
-rw-r--r--src/ollama.tsx3
3 files changed, 11 insertions, 0 deletions
diff --git a/src/App.tsx b/src/App.tsx
index 0a32968..230bc80 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -63,6 +63,7 @@ function App() {
logseq.Editor.registerBlockContextMenuItem("Ollama: Create a flash card", convertToFlashCardFromEvent)
logseq.Editor.registerBlockContextMenuItem("Ollama: Divide into subtasks", DivideTaskIntoSubTasksFromEvent)
logseq.Editor.registerBlockContextMenuItem("Ollama: Prompt from Block", promptFromBlockEventClosure())
+ logseq.Editor.registerBlockContextMenuItem("Ollama: Custom prompt on Block", promptFromBlockEventClosure(logseq.settings.custom_prompt_block))
logseq.Editor.registerBlockContextMenuItem("Ollama: Summarize block", promptFromBlockEventClosure("Summarize: "))
logseq.Editor.registerBlockContextMenuItem("Ollama: Expand Block", promptFromBlockEventClosure("Expand: "))
diff --git a/src/main.tsx b/src/main.tsx
index a78d85d..a544760 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -36,6 +36,13 @@ let settings: SettingSchemaDesc[] = [
description: "Shortcut to open plugin command pallete",
default: "mod+shift+o"
},
+ {
+ key: "custom_prompt_block",
+ type: "string",
+ title: "Custom prompt block",
+ description: "Define your custom prompt and use a block as context",
+ default: "Translate in French : "
+ },
]
diff --git a/src/ollama.tsx b/src/ollama.tsx
index 9d925db..e59c633 100644
--- a/src/ollama.tsx
+++ b/src/ollama.tsx
@@ -178,6 +178,7 @@ export async function summarizeBlock() {
const currentBlock = await logseq.Editor.getCurrentBlock()
let summaryBlock = await logseq.Editor.insertBlock(currentBlock!.uuid, `⌛Summarizing Block...`, { before: false })
const summary = await promptLLM(`Summarize the following ${currentBlock!.content}`);
+
await logseq.Editor.updateBlock(summaryBlock!.uuid, `Summary: ${summary}`)
} catch (e: any) {
logseq.App.showMsg(e.toString(), 'warning')
@@ -185,6 +186,8 @@ export async function summarizeBlock() {
}
}
+
+
async function getOllamaParametersFromBlockProperties(b: BlockEntity) {
const properties = await logseq.Editor.getBlockProperties(b.uuid);
const ollamaParameters: OllamaGenerateParameters = {}