diff options
Diffstat (limited to 'src/ollama.tsx')
| -rw-r--r-- | src/ollama.tsx | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/ollama.tsx b/src/ollama.tsx index ca493ac..38cb0f6 100644 --- a/src/ollama.tsx +++ b/src/ollama.tsx @@ -97,8 +97,7 @@ async function ollamaGenerate(prompt: string, parameters?: OllamaGenerateParamet throw new Error("Error in Ollama request: " + response.statusText) } const data = await response.json() - return data.response - + 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") @@ -205,9 +204,14 @@ export async function promptFromBlockEvent(b: IHookEvent) { const answerBlock = await logseq.Editor.insertBlock(currentBlock!.uuid, '🦙Generating ...', { before: false }) const params = await getOllamaParametersFromBlockProperties(currentBlock!) const prompt = currentBlock!.content.replace(/^.*::.*$/gm, '') // nasty hack to remove properties from block content - const response = await ollamaGenerate(prompt, params); + const result = await ollamaGenerate(prompt, params); + + console.log(result) - await logseq.Editor.updateBlock(answerBlock!.uuid, `${response}`) + if (params.usecontext) { + await logseq.Editor.upsertBlockProperty(currentBlock!.uuid, 'ollama-generate-context', result.context) + } + await logseq.Editor.updateBlock(answerBlock!.uuid, `${result.response}`) } catch (e: any) { logseq.UI.showMsg(e.toString(), 'warning') console.error(e) |
