aboutsummaryrefslogtreecommitdiff
path: root/src/ollama.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/ollama.tsx')
-rw-r--r--src/ollama.tsx24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/ollama.tsx b/src/ollama.tsx
index f5eaae7..945d2cb 100644
--- a/src/ollama.tsx
+++ b/src/ollama.tsx
@@ -149,6 +149,30 @@ export async function summarizeBlock() {
}
}
+export async function promptFromBlockEvent(b: IHookEvent) {
+ try {
+ const currentBlock = await logseq.Editor.getBlock(b.uuid)
+ const answerBlock = await logseq.Editor.insertBlock(currentBlock!.uuid, '⌛Generating ...', { before: false })
+ const response = await promptLLM(`${currentBlock!.content}`);
+ await logseq.Editor.updateBlock(answerBlock!.uuid, `${response}`)
+ } catch (e: any) {
+ logseq.UI.showMsg(e.toString(), 'warning')
+ console.error(e)
+ }
+}
+
+export async function expandBlockEvent(b: IHookEvent) {
+ try {
+ const currentBlock = await logseq.Editor.getBlock(b.uuid)
+ const answerBlock = await logseq.Editor.insertBlock(currentBlock!.uuid, '⌛Generating ...', { before: false })
+ const response = await promptLLM(`Expand: ${currentBlock!.content}`);
+ await logseq.Editor.updateBlock(answerBlock!.uuid, `${response}`)
+ } catch(e: any) {
+ logseq.UI.showMsg(e.toString(), 'warning')
+ console.error(e)
+ }
+}
+
export async function askAI(prompt: string, context: string) {
await delay(300)
try {