diff --git a/core/llm/llms/Ollama.ts b/core/llm/llms/Ollama.ts index 6b6a356f3..d54e0d8fd 100644 --- a/core/llm/llms/Ollama.ts +++ b/core/llm/llms/Ollama.ts @@ -183,12 +183,16 @@ class Ollama extends BaseLLM { stream: true, }); - for await (const chunk of response) { - if (!chunk?.message?.content) continue; - yield { - role: "assistant", - content: chunk.message.content, - }; + try { + for await (const chunk of response) { + if (!chunk?.message?.content) continue; + yield { + role: "assistant", + content: chunk.message.content, + }; + } + } finally { + client.abort(); } } diff --git a/gui/package-lock.json b/gui/package-lock.json index 08c1df33d..339105e89 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -84,6 +84,7 @@ "llm-code-highlighter": "^0.0.3", "node-fetch": "^3.3.2", "node-html-markdown": "^1.3.0", + "ollama": "^0.4.6", "openai": "^4.20.1", "replicate": "^0.23.0", "socket.io-client": "^4.7.3",