Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Ollama连接错误? #939

Closed
safe049 opened this issue Dec 1, 2024 · 13 comments
Closed

[Bug]: Ollama连接错误? #939

safe049 opened this issue Dec 1, 2024 · 13 comments
Labels
bug? Bug或Bug修复相关 低活跃度 因主要参与者不再回复而处于不活跃状态,这些issue将很快被关闭

Comments

@safe049
Copy link

safe049 commented Dec 1, 2024

消息平台适配器

aiocqhttp(使用 OneBot 协议接入的)

运行环境

Docker

LangBot 版本

v3.4.0.2

异常情况

任何时候使用ollama进行大模型聊天都会产生Connection error错误,使用!ollama会产生Connection refused错误
我的ollama部署在Docker中
日志:

[12-01 14:58:22.522] manager.py (79) - [INFO] : 初始化平台适配器 0: aiocqhttp
[12-01 14:58:24.163] app.py (170) - [INFO] : =======================================
[12-01 14:58:24.163] app.py (170) - [INFO] : ✨ 您可通过以下方式访问管理面板
[12-01 14:58:24.163] app.py (170) - [INFO] : 
[12-01 14:58:24.163] app.py (170) - [INFO] : 🏠 本地地址:http://172.22.0.2:5300/
[12-01 14:58:24.163] app.py (170) - [INFO] : 🌐 公网地址:http://118.79.109.246:5300/
[12-01 14:58:24.163] app.py (170) - [INFO] : 
[12-01 14:58:24.163] app.py (170) - [INFO] : 📌 如果您在容器中运行此程序,请确保容器的 5300 端口已对外暴露
[12-01 14:58:24.164] app.py (170) - [INFO] : 🔗 若要使用公网地址访问,请阅读以下须知[12-01 14:58:24.164] app.py (170) - [INFO] :    1. 公网地址仅供参考,请以您的主机公网 IP 为准;
[12-01 14:58:24.164] app.py (170) - [INFO] :    2. 要使用公网地址访问,请确保您的主机具有公网 IP,并且系统防火墙已放行 5300 端口;
[12-01 14:58:24.164] app.py (170) - [INFO] : 
[12-01 14:58:24.164] app.py (170) - [INFO] : 🤯 WebUI 仍处于 Beta 测试阶段,如有问题或建议请反馈到 https://github.com/RockChinQ/LangBot/issues
[12-01 14:58:24.164] app.py (170) - [INFO] : =======================================[12-01 14:58:34.198] process.py (42) - [INFO] : 处理 person_1329261154 的请求(0): 你好[12-01 14:58:35.460] chat.py (94) - [ERROR] : 对话(0)请求失败: 模型请求失败: 请求错误: Connection error.[12-01 14:58:41.258] controller.py (98) - [ERROR] : 模型请求失败: 请求错误: Connection error.[12-01 14:58:48.841] process.py (42) - [INFO] : 处理 person_1329261154 的请求(1): !ollama
[12-01 14:58:48.842] controller.py (188) - [ERROR] : 处理请求时出错 query_id=1 stage=MessageProcessor : [Errno 111] Connection refused[12-01 15:02:18.150] process.py (42) - [INFO] : 处理 person_1329261154 的请求(2): !versions
[12-01 15:02:18.150] command.py (85) - [INFO] : 命令(2)报错: 未知命令: versions[12-01 15:02:25.929] process.py (42) - [INFO] : 处理 person_1329261154 的请求(3): !version
[12-01 15:02:26.747] command.py (112) - [INFO] : 命令返回: 当前版本: ...

docker ps:

CONTAINER ID   IMAGE                                    COMMAND                   CREATED          STATUS                 PORTS                                                                                   NAMES
bb240a18b6bb   rockchin/langbot:latest                  "python main.py"          23 minutes ago   Up 6 minutes           0.0.0.0:2280-2290->2280-2290/tcp, 0.0.0.0:5300->5300/tcp, :::2280-2290->2280-2290/tcp   langbot_lxs7-langbot_LXS7-1
e5bf7aa1471b   dockerpull.org/ollama/ollama:rocm        "/bin/ollama serve"       24 hours ago     Up 2 hours             0.0.0.0:11434->11434/tcp, :::11434->11434/tcp                                           ollama
1e10332d1a2a   9472fd378a1c                             "bash start.sh"           33 hours ago     Up 2 hours (healthy)                                                                                           open-webui
7c247ce22237   ghcr.io/sillytavern/sillytavern:latest   "tini -- ./docker-en…"   3 months ago     Up 2 hours             0.0.0.0:8000->8000/tcp, :::8000->8000/tcp   

直接访问ollama的api地址没有问题

启用的插件

无插件

@safe049 safe049 added the bug? Bug或Bug修复相关 label Dec 1, 2024
@RockChinQ
Copy link
Owner

看你platform.json怎么填的

@safe049
Copy link
Author

safe049 commented Dec 1, 2024

platform.json:

{
  "at-sender": true,
  "force-delay": {
    "max": 0,
    "min": 0
  },
  "hide-exception-info": true,
  "long-text-process": {
    "font-path": "",
    "strategy": "forward",
    "threshold": 256
  },
  "platform-adapters": [
    {
      "adapter": "nakuru",
      "enable": false,
      "host": "127.0.0.1",
      "http_port": 5700,
      "token": "",
      "ws_port": 8080
    },
    {
      "access-token": "",
      "adapter": "aiocqhttp",
      "enable": true,
      "host": "0.0.0.0",
      "port": 2280
    },
    {
      "adapter": "qq-botpy",
      "appid": "",
      "enable": false,
      "intents": [
        "public_guild_messages",
        "direct_message"
      ],
      "secret": ""
    },
    {
      "adapter": "nakuru",
      "enable": false,
      "host": "127.0.0.1",
      "http_port": 5700,
      "token": "",
      "ws_port": 8080
    }
  ],
  "quote-origin": false,
  "track-function-calls": true
}

顺带,lagrange的appsettings.json:

{
    "Logging": {
        "LogLevel": {
            "Default": "Information",
            "Microsoft": "Warning",
            "Microsoft.Hosting.Lifetime": "Information"
        }
    },
    "SignServerUrl": "",
    "SignProxyUrl": "",
    "MusicSignServerUrl": "",
    "Account": {
        "Uin":1,
        "Password": "",
        "Protocol": "Linux",
        "AutoReconnect": true,
        "GetOptimumServer": true
    },
    "Message": {
        "IgnoreSelf": true,
        "StringPost": false
    },
    "QrCode": {
        "ConsoleCompatibilityMode": false
    },
    "Implementations": [
        {
            "Type": "ReverseWebSocket",
            "Host": "127.0.0.1",
            "Port": 2280,
            "Suffix": "/ws",
            "ReconnectInterval": 5000,
            "HeartBeatInterval": 5000,
            "AccessToken": ""
        }
    ]
}

@RockChinQ
Copy link
Owner

说错了,是provider.json。

@safe049
Copy link
Author

safe049 commented Dec 1, 2024

{
  "enable-chat": true,
  "enable-vision": true,
  "keys": {
    "anthropic": [
      "sk-1234567890"
    ],
    "deepseek": [
      "sk-1234567890"
    ],
    "gitee": [],
    "gitee-ai": [
      "XXXXX"
    ],
    "moonshot": [
      "sk-1234567890"
    ],
    "openai": [
      "sk-1234567890"
    ]
  },
  "model": "ollama",
  "prompt": {
    "default": ""
  },
  "prompt-mode": "normal",
  "requester": {
    "anthropic-messages": {
      "args": {
        "max_tokens": 1024
      },
      "base-url": "https://api.anthropic.com",
      "timeout": 120
    },
    "deepseek-chat-completions": {
      "args": {},
      "base-url": "https://api.deepseek.com",
      "timeout": 120
    },
    "gitee-ai-chat-completions": {
      "args": {},
      "base-url": "https://ai.gitee.com/v1",
      "timeout": 120
    },
    "moonshot-chat-completions": {
      "args": {},
      "base-url": "https://api.moonshot.cn/v1",
      "timeout": 120
    },
    "ollama-chat": {
      "args": {},
      "base-url": "http://127.0.0.1:11434",
      "timeout": 600
    },
    "openai-chat-completions": {
      "args": {},
      "base-url": "https://api.openai.com/v1",
      "timeout": 120
    }
  },
  "runner": "local-agent"
}

@RockChinQ
Copy link
Owner

跨容器不能用127.0.0.1作为主机名连接。可以去网上看看多个docker容器网络互联的配置方式。

@safe049
Copy link
Author

safe049 commented Dec 1, 2024

我的langbot在宝塔使用docker部署,而lagrange则是本地部署的

@RockChinQ
Copy link
Owner

这是ollama连接的问题,跟消息平台没关系。

@safe049
Copy link
Author

safe049 commented Dec 1, 2024

哦,懂了,我去把ollama容器和langbot互联一下

@safe049
Copy link
Author

safe049 commented Dec 1, 2024

我把ollama容器和langbot容器互联到了langbot-network网络,但是lagrange连不到langbot了

info: Lagrange.OneBot.Core.Network.Service.ReverseWSService[1002]
      [ReverseWSService] Reconnecting 0ed88958-071b-4764-b3fb-bde043e21b2a at interval of 5000
info: Lagrange.OneBot.Core.Network.Service.ReverseWSService[1002]
      [ReverseWSService] Reconnecting 0ed88958-071b-4764-b3fb-bde043e21b2a at interval of 5000
info: Lagrange.OneBot.Core.Network.Service.ReverseWSService[1002]
      [ReverseWSService] Reconnecting 0ed88958-071b-4764-b3fb-bde043e21b2a at interval of 5000

@safe049
Copy link
Author

safe049 commented Dec 1, 2024

重启了一下可以了,但是ollama和langbot虽然在一个网络,但还是connection refused?

@safe049
Copy link
Author

safe049 commented Dec 1, 2024

这是目前的network inspect:

[
    {
        "Name": "langbot_langbot-network",
        "Id": "d94238624270b943f413ff445a965ec2d16cd6a9576b8ba8f53cff6abb103f2d",
        "Created": "2024-12-02T01:45:27.192377687+08:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.24.0.0/16",
                    "Gateway": "172.24.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "2d6cbe0b85880e09af4f127997bddbf0a9f72357599d3d09b65bfdcb2dfd4fc2": {
                "Name": "ollama",
                "EndpointID": "65ee21be327edc06919f81e3728593817791dfa07deb582cbbea17e0480ee5ee",
                "MacAddress": "02:42:ac:18:00:02",
                "IPv4Address": "172.24.0.2/16",
                "IPv6Address": ""
            },
            "f3a52243375559dace3286dcb653e3284459aeec1705983cc1e117ef188f93d2": {
                "Name": "langbot",
                "EndpointID": "d0b8443b8385ed230cb6a7d12765662cc26e35b5bae961fb4fe471a59ba36876",
                "MacAddress": "02:42:ac:18:00:03",
                "IPv4Address": "172.24.0.3/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {
            "com.docker.compose.config-hash": "2ffce403a840c7cd8ab564c4e1e39a2b321b4f03f99d836cc83be2b2f7708799",
            "com.docker.compose.network": "langbot-network",
            "com.docker.compose.project": "langbot",
            "com.docker.compose.version": "2.31.0"
        }
    }
]

provider.json:

{
  "enable-chat": true,
  "enable-vision": true,
  "keys": {
    "anthropic": [
      "sk-1234567890"
    ],
    "deepseek": [
      "sk-1234567890"
    ],
    "gitee": [],
    "gitee-ai": [
      "XXXXX"
    ],
    "moonshot": [
      "sk-1234567890"
    ],
    "openai": [
      "sk-1234567890"
    ]
  },
  "model": "ollama",
  "prompt": {
    "default": ""
  },
  "prompt-mode": "normal",
  "requester": {
    "anthropic-messages": {
      "args": {
        "max_tokens": 1024
      },
      "base-url": "https://api.anthropic.com",
      "timeout": 120
    },
    "deepseek-chat-completions": {
      "args": {},
      "base-url": "https://api.deepseek.com",
      "timeout": 120
    },
    "gitee-ai-chat-completions": {
      "base-url": "https://ai.gitee.com/v1",
      "timeout": 120
    },
    "moonshot-chat-completions": {
      "args": {},
      "base-url": "https://api.moonshot.cn/v1",
      "timeout": 120
    },
    "ollama-chat": {
      "base-url": "http://172.24.0.2:11434",
      "timeout": 600
    },
    "openai-chat-completions": {
      "args": {},
      "base-url": "https://api.openai.com/v1",
      "timeout": 120
    }
  },
  "runner": "local-agent"
}

日志:

[12-01 17:56:19.482] manager.py (79) - [INFO] : 初始化平台适配器 0: aiocqhttp
[12-01 17:56:21.195] app.py (170) - [INFO] : =======================================
[12-01 17:56:21.196] app.py (170) - [INFO] : ✨ 您可通过以下方式访问管理面板
[12-01 17:56:21.196] app.py (170) - [INFO] : 
[12-01 17:56:21.196] app.py (170) - [INFO] : 🏠 本地地址:http://172.24.0.3:5300/
[12-01 17:56:21.196] app.py (170) - [INFO] : 🌐 公网地址:http://118.79.109.246:5300/
[12-01 17:56:21.196] app.py (170) - [INFO] : 
[12-01 17:56:21.196] app.py (170) - [INFO] : 📌 如果您在容器中运行此程序,请确保容器的 5300 端口已对外暴露
[12-01 17:56:21.197] app.py (170) - [INFO] : 🔗 若要使用公网地址访问,请阅读以下须知
[12-01 17:56:21.197] app.py (170) - [INFO] :    1. 公网地址仅供参考,请以您的主机公网 IP 为准;
[12-01 17:56:21.197] app.py (170) - [INFO] :    2. 要使用公网地址访问,请确保您的主机具有公网 IP,并且系统防火墙已放行 5300 端口;
[12-01 17:56:21.197] app.py (170) - [INFO] : 
[12-01 17:56:21.197] app.py (170) - [INFO] : 🤯 WebUI 仍处于 Beta 测试阶段,如有问题或建议请反馈到 https://github.com/RockChinQ/LangBot/issues
[12-01 17:56:21.198] app.py (170) - [INFO] : =======================================
[12-01 17:56:28.390] process.py (42) - [INFO] : 处理 person_1329261154 的请求(0): !ollama
[12-01 17:56:28.405] controller.py (188) - [ERROR] : 处理请求时出错 query_id=0 stage=MessageProcessor : [Errno 111] Connection refused

@RockChinQ
Copy link
Owner

用ollama容器名作为连接的主机名。

@RockChinQ RockChinQ added the 低活跃度 因主要参与者不再回复而处于不活跃状态,这些issue将很快被关闭 label Dec 4, 2024
@safe049
Copy link
Author

safe049 commented Dec 6, 2024

还是不太行,我干脆用了LM Studio的openai兼容api

@safe049 safe049 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug? Bug或Bug修复相关 低活跃度 因主要参与者不再回复而处于不活跃状态,这些issue将很快被关闭
Projects
None yet
Development

No branches or pull requests

2 participants