aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgixita <kris.laermans@gmail.com>2024-02-10 15:03:39 +0100
committergixita <kris.laermans@gmail.com>2024-02-10 15:03:39 +0100
commitfe8403156aa664c8fb203bddc243eb6fc4448b1a (patch)
tree0b85aea29fe83abe0cb2aa3eae42c7710f97b57a
parentfc1d6985c9eb0c31b8ea05244e4a270d9ec8ffaa (diff)
downloadollama-logseq-fe8403156aa664c8fb203bddc243eb6fc4448b1a.tar.xz
ollama-logseq-fe8403156aa664c8fb203bddc243eb6fc4448b1a.zip
Move the custom prompt trigger on the block command
-rw-r--r--src/App.tsx2
-rw-r--r--src/components/OllamaCommandPallete.tsx6
-rw-r--r--src/main.tsx7
-rw-r--r--src/ollama.tsx17
4 files changed, 2 insertions, 30 deletions
diff --git a/src/App.tsx b/src/App.tsx
index 0fb9984..230bc80 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -15,7 +15,6 @@ const options = [
'Divide into subtasks',
'Summarize',
'Summarize Block',
- 'Custom prompt on block',
'Convert to flash card',
];
@@ -64,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/components/OllamaCommandPallete.tsx b/src/components/OllamaCommandPallete.tsx
index d721892..e8e9c42 100644
--- a/src/components/OllamaCommandPallete.tsx
+++ b/src/components/OllamaCommandPallete.tsx
@@ -6,7 +6,7 @@ import {
CommandItem,
CommandList,
} from "@/components/ui/command"
-import { convertToFlashCardCurrentBlock, DivideTaskIntoSubTasksCurrentBlock, summarize, summarizeBlock, customPromptBlock } from "@/ollama";
+import { convertToFlashCardCurrentBlock, DivideTaskIntoSubTasksCurrentBlock, summarize, summarizeBlock } from "@/ollama";
import { PromptAI } from "./PromptAI";
export function OllamaCommandPallete({ options, theme }: { options: string[], theme: string }) {
@@ -28,10 +28,6 @@ export function OllamaCommandPallete({ options, theme }: { options: string[], th
logseq.hideMainUI()
summarizeBlock()
break;
- case "custom prompt on block":
- logseq.hideMainUI()
- customPromptBlock()
- break;
case "convert to flash card":
logseq.hideMainUI()
convertToFlashCardCurrentBlock()
diff --git a/src/main.tsx b/src/main.tsx
index a544760..a78d85d 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -36,13 +36,6 @@ 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 4fe697f..e59c633 100644
--- a/src/ollama.tsx
+++ b/src/ollama.tsx
@@ -186,23 +186,6 @@ export async function summarizeBlock() {
}
}
-export async function customPromptBlock() {
- try {
- if (!logseq.settings) {
- throw new Error("Couldn't find ollama-logseq settings")
- }
-
- // TODO: Get contnet of current block and subblocks
- const currentBlock = await logseq.Editor.getCurrentBlock()
- let customPromptBlock = await logseq.Editor.insertBlock(currentBlock!.uuid, `⌛Apply custom prompt...`, { before: false })
- const customPrompt = await promptLLM(`${logseq.settings.custom_prompt_block} ${currentBlock!.content}`);
-
- await logseq.Editor.updateBlock(customPromptBlock!.uuid, `${customPrompt}`)
- } catch (e: any) {
- logseq.App.showMsg(e.toString(), 'warning')
- console.error(e)
- }
-}
async function getOllamaParametersFromBlockProperties(b: BlockEntity) {