From 834d535ac703bbcb04a162dedda4e5ab033a1fe6 Mon Sep 17 00:00:00 2001 From: Yuki Date: Mon, 6 May 2024 11:14:55 +0800 Subject: [PATCH] Ollama FAQ add solutions zh-cn&en (#68) * FAQ add solutions * FAQ add solutions --- en/tutorials/model-configuration/ollama.md | 9 +++++++++ zh_CN/guides/model-configuration/ollama.md | 22 +++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/en/tutorials/model-configuration/ollama.md b/en/tutorials/model-configuration/ollama.md index 06a0d48..cdfdf05 100644 --- a/en/tutorials/model-configuration/ollama.md +++ b/en/tutorials/model-configuration/ollama.md @@ -87,6 +87,15 @@ If Ollama is run as a macOS application, environment variables should be set usi 2. Restart Ollama application. +3. If the above steps are ineffective, you can use the following method: + + The issue lies within Docker itself, and to access the Docker host. + you should connect to `host.docker.internal`. Therefore, replacing `localhost` with `host.docker.internal` in the service will make it work effectively. + + ```bash + http://host.docker.internal:11434 + ``` + ### Setting environment variables on Linux If Ollama is run as a systemd service, environment variables should be set using `systemctl`: diff --git a/zh_CN/guides/model-configuration/ollama.md b/zh_CN/guides/model-configuration/ollama.md index 81c9af8..2eec54a 100644 --- a/zh_CN/guides/model-configuration/ollama.md +++ b/zh_CN/guides/model-configuration/ollama.md @@ -65,7 +65,7 @@ Dify 支持接入 Ollama 部署的大型语言模型推理和 embedding 能力 ## FAQ -### ⚠️ If you are using docker to deploy Dify and Ollama, you may encounter the following error: +### ⚠️ 如果您使用Docker部署Dify和Ollama,您可能会遇到以下错误: ``` httpconnectionpool(host=127.0.0.1, port=11434): max retries exceeded with url:/cpi/chat (Caused by NewConnectionError(': fail to establish a new connection:[Errno 111] Connection refused')) @@ -75,6 +75,26 @@ httpconnectionpool(host=localhost, port=11434): max retries exceeded with url:/c 这个错误是因为 Docker 容器无法访问 Ollama 服务。localhost 通常指的是容器本身,而不是主机或其他容器。要解决此问题,您需要将 Ollama 服务暴露给网络。 +### 在Mac上设置环境变量 + +如果 `Ollama` 作为 `macOS` 应用程序运行,则应使用以下命令设置环境变量`launchctl`: + +1. 通过调用`launchctl setenv`设置环境变量: + + ```bash + launchctl setenv OLLAMA_HOST "0.0.0.0" + ``` + +2. 重启Ollama应用程序。 + +3. 如果以上步骤无效,可以使用以下方法: + + 问题是在docker内部,你应该连接到`host.docker.internal`,才能访问docker的主机,所以将`localhost`替换为`host.docker.internal`服务就可以生效了: + + ```bash + http://host.docker.internal:11434 + ``` + ### 在Linux上设置环境变量 如果Ollama作为systemd服务运行,应该使用`systemctl`设置环境变量: