aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package.json2
-rw-r--r--src/App.tsx23
-rw-r--r--src/ollama.tsx15
3 files changed, 18 insertions, 22 deletions
diff --git a/package.json b/package.json
index 93d0d6e..05fd10e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "ollama-logseq",
- "version": "1.0.8",
+ "version": "1.0.9",
"main": "dist/index.html",
"scripts": {
"dev": "vite",
diff --git a/src/App.tsx b/src/App.tsx
index b6b6918..0a32968 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -45,20 +45,19 @@ function App() {
return
}
-logseq.Editor.getPageBlocksTree("ollama-logseq-config").then((blocks) => {
- blocks!.forEach((block) => {
- logseq.Editor.getBlockProperty(block.uuid, "ollama-context-menu-title").then((title) => {
- logseq.Editor.getBlockProperty(block.uuid, "ollama-prompt-prefix").then((prompt_prefix) => {
- logseq.Editor.registerBlockContextMenuItem(title, promptFromBlockEventClosure(prompt_prefix))
+ logseq.Editor.getPageBlocksTree("ollama-logseq-config").then((blocks) => {
+ blocks!.forEach((block) => {
+ logseq.Editor.getBlockProperty(block.uuid, "ollama-context-menu-title").then((title) => {
+ logseq.Editor.getBlockProperty(block.uuid, "ollama-prompt-prefix").then((prompt_prefix) => {
+ logseq.Editor.registerBlockContextMenuItem(title, promptFromBlockEventClosure(prompt_prefix))
+ })
+ }).catch((reason) => {
+ })
})
}).catch((reason) => {
+ console.error("Can not find the configuration page named 'ollama-logseq-config'", reason)
})
- })
-}).catch((reason) => {
- console.log("Can not find the configuration page named 'ollama-logseq-config'")
- console.log(reason)
-})
-
+
logseq.Editor.registerSlashCommand("ollama", ollamaUI)
logseq.Editor.registerBlockContextMenuItem("Ollama: Create a flash card", convertToFlashCardFromEvent)
@@ -70,7 +69,7 @@ logseq.Editor.getPageBlocksTree("ollama-logseq-config").then((blocks) => {
logseq.App.registerCommandShortcut(
{ "binding": logseq.settings.shortcut },
ollamaUI
- );
+ );
}, [])
if (visible) {
diff --git a/src/ollama.tsx b/src/ollama.tsx
index 5ba47ab..9d925db 100644
--- a/src/ollama.tsx
+++ b/src/ollama.tsx
@@ -199,32 +199,29 @@ async function getOllamaParametersFromBlockProperties(b: BlockEntity) {
}
async function getOllamaParametersFromBlockAndParentProperties(b: BlockEntity) {
- let p_params: OllamaGenerateParameters = {}
+ let ollamaParentProperties: OllamaGenerateParameters = {}
if (b.parent) {
let parentBlock = await logseq.Editor.getBlock(b.parent.id)
if (parentBlock)
- p_params = await getOllamaParametersFromBlockProperties(parentBlock)
+ ollamaParentProperties = await getOllamaParametersFromBlockProperties(parentBlock)
}
- const b_params = await getOllamaParametersFromBlockProperties(b)
- return {...p_params, ...b_params}
+ const ollamaBlockProperties = await getOllamaParametersFromBlockProperties(b)
+ return { ...ollamaParentProperties, ...ollamaBlockProperties }
}
async function promptFromBlock(block: BlockEntity, prefix?: string) {
const answerBlock = await logseq.Editor.insertBlock(block!.uuid, '🦙Generating ...', { before: false })
const params = await getOllamaParametersFromBlockAndParentProperties(block!)
- console.log("ollama params", params)
let prompt = block!.content.replace(/^.*::.*$/gm, '') // hack to remove properties from block content
if (prefix) {
prompt = prefix + " " + prompt
}
- console.log("prompt", prompt)
const result = await ollamaGenerate(prompt, params);
-
- console.log("ollama response", result)
- if (params.usecontext) { //FIXME: work out the best way to story context
+ //FIXME: work out the best way to story context
+ if (params.usecontext) {
await logseq.Editor.upsertBlockProperty(block!.uuid, 'ollama-generate-context', result.context)
}