diff options
| author | Omar Magdy <99906646+omagdy7@users.noreply.github.com> | 2024-02-14 17:22:40 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-14 17:22:40 +0200 |
| commit | 4f1971020d43d0958973712212f17bd9d51a1834 (patch) | |
| tree | 3099bc4223d9c39062b6f4d077809bccb88c8219 | |
| parent | 842fcd159675c4091952277526844b1eebf6df18 (diff) | |
| parent | f07b00c527db2947f49d4ea592018902d391d55f (diff) | |
| download | ollama-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
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | src/App.tsx | 1 | ||||
| -rw-r--r-- | src/main.tsx | 7 | ||||
| -rw-r--r-- | src/ollama.tsx | 3 |
4 files changed, 12 insertions, 0 deletions
@@ -92,3 +92,4 @@ lerna-debug.log # System Files .DS_Store Thumbs.db +package-lock.json 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 = {} |
