diff --git a/package.json b/package.json index ed703f6..3d26f65 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ollama-logseq", - "version": "1.1.2", + "version": "1.1.3", "main": "dist/index.html", "scripts": { "dev": "vite", diff --git a/src/ollama.tsx b/src/ollama.tsx index c0c27e2..2c70685 100644 --- a/src/ollama.tsx +++ b/src/ollama.tsx @@ -37,7 +37,7 @@ async function getTreeContent(b: BlockEntity) { includeChildren: true, }); if (childBlock) { - content += await getTreeContent(childBlock); + content += "\n" + await getTreeContent(childBlock); } } } @@ -93,14 +93,14 @@ async function ollamaGenerate(prompt: string, parameters?: OllamaGenerateParamet body: JSON.stringify(params) }) if (!response.ok) { - logseq.UI.showMsg("Coudln't fulfull request make sure that ollama service is running and make sure there is no typo in host or model name") + logseq.UI.showMsg("Coudln't fulfill request make sure that ollama service is running and make sure there is no typo in host or model name") throw new Error("Error in Ollama request: " + response.statusText) } const data = await response.json() return data } catch (e: any) { console.error("ERROR: ", e) - logseq.App.showMsg("Coudln't fulfull request make sure that ollama service is running and make sure there is no typo in host or model name") + logseq.App.showMsg("Coudln't fulfill request make sure that ollama service is running and make sure there is no typo in host or model name") } } @@ -121,7 +121,7 @@ async function promptLLM(prompt: string) { }), }) if (!response.ok) { - logseq.App.showMsg("Coudln't fulfull request make sure that ollama service is running and make sure there is no typo in host or model name") + logseq.App.showMsg("Coudln't fulfill request make sure that ollama service is running and make sure there is no typo in host or model name") throw new Error("Error in Ollama request: " + response.statusText) } const data = await response.json(); @@ -129,7 +129,7 @@ async function promptLLM(prompt: string) { return data.response; } catch (e: any) { console.error("ERROR: ", e) - logseq.App.showMsg("Coudln't fulfull request make sure that ollama service is running and make sure there is no typo in host or model name") + logseq.App.showMsg("Coudln't fulfill request make sure that ollama service is running and make sure there is no typo in host or model name") } } @@ -221,10 +221,13 @@ async function getOllamaParametersFromBlockAndParentProperties(b: BlockEntity) { async function promptFromBlock(block: BlockEntity, prefix?: string) { const answerBlock = await logseq.Editor.insertBlock(block!.uuid, '🦙Generating ...', { before: false }) const params = await getOllamaParametersFromBlockAndParentProperties(block!) + const blockContent = await getTreeContent(block); - let prompt = block!.content.replace(/^.*::.*$/gm, '') // hack to remove properties from block content + // let prompt = block!.content.replace(/^.*::.*$/gm, '') // hack to remove properties from block content + + let prompt = blockContent; if (prefix) { - prompt = prefix + " " + prompt + prompt = prefix + "\n" + prompt } const result = await ollamaGenerate(prompt, params);