diff options
| author | David Li <taweili@gmail.com> | 2023-12-03 21:36:26 +0800 |
|---|---|---|
| committer | David Li <taweili@gmail.com> | 2023-12-03 21:36:26 +0800 |
| commit | ec89527bec8727ca8a6f897c449751cd6856d859 (patch) | |
| tree | 8ae50641558f707e716aabb7bcb5e32b6e114631 /src/ollama.tsx | |
| parent | c6b9988e027f186262a1b65700edbec1ed6ed7d1 (diff) | |
| parent | 5b671c04685acd36b49a20d0104829f6f91e728f (diff) | |
| download | ollama-logseq-ec89527bec8727ca8a6f897c449751cd6856d859.tar.xz ollama-logseq-ec89527bec8727ca8a6f897c449751cd6856d859.zip | |
Merge branch 'master' into ollama-context
Diffstat (limited to 'src/ollama.tsx')
| -rw-r--r-- | src/ollama.tsx | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/ollama.tsx b/src/ollama.tsx index a59b03b..38cb0f6 100644 --- a/src/ollama.tsx +++ b/src/ollama.tsx @@ -73,7 +73,6 @@ type OllamaGenerateParameters = { } async function ollamaGenerate(prompt: string, parameters?: OllamaGenerateParameters) { - if (!logseq.settings) { throw new Error("Couldn't find ollama-logseq settings") } @@ -85,8 +84,6 @@ async function ollamaGenerate(prompt: string, parameters?: OllamaGenerateParamet params.prompt = prompt params.stream = false - console.log(params) - try { const response = await fetch(`http://${logseq.settings.host}/api/generate`, { method: 'POST', @@ -96,16 +93,14 @@ async function ollamaGenerate(prompt: string, parameters?: OllamaGenerateParamet body: JSON.stringify(params) }) if (!response.ok) { - console.log("Error in Ollama request: " + response.statusText) - logseq.UI.showMsg("Error in Ollama request") + 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") throw new Error("Error in Ollama request: " + response.statusText) } const data = await response.json() - return data } catch (e: any) { - console.log(e) - logseq.UI.showMsg("Error in Ollama request") + 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") } } @@ -126,9 +121,8 @@ async function promptLLM(prompt: string) { }), }) if (!response.ok) { - console.log("Error: couldn't fulfill request") 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") - throw new Error('Network response was not ok'); + throw new Error("Error in Ollama request: " + response.statusText) } const data = await response.json(); |
