gpt4 book ai didi

python - 运行 Rasa Stack 时超出最大重试次数并出现连接拒绝错误

转载 作者:太空宇宙 更新时间:2023-11-03 20:52:22 25 4
gpt4 key购买 nike

Rasa版本:Core = 0.14.4,Core-sdk = 0.14.0,NLU = 0.15.0

Python版本:3.6.7

操作系统(windows、osx...):Ubuntu 18.04.2 LTS

问题:我一直在使用 Rasa Stack 入门包 ( https://github.com/RasaHQ/starter-pack-rasa-stack ),除了我将 python 实例更改为 python3 的 Makefile 之外,其中的文件保持不变。我尝试使用 RestInput channel 让 Rasa Stack 作为服务器工作,如 https://rasa.com/docs/core/connectors/#rest-channels 中所述。 。我使用示例通过运行脚本连接其余输入 channel :

python3 -m rasa_core.run -d models/current/dialogue -u models/current/nlu --port 5002 --credential credentials.yml

这最初有效,但我尝试使用以下代码发布消息:

import requests

URL = 'http://localhost:5010/webhooks/rest/webhook/'
PARAMS = {'sender': "ola", 'message': "how are you"}

r = requests.get(URL)

data = r.json()
print(data)

由于 url 超出最大重试次数和连接拒绝而导致错误。问题是从那时起,无论有没有命令行界面,我都无法启动并运行服务器。当我尝试按上述方式连接其余输入 channel 时,出现以下错误:

r/lib/python3.6/runpy.py:125: RuntimeWarning: 'rasa_core.run' found in sys.modules after import of package 'rasa_core', but prior to execution of 'rasa_core.run'; this may result in unpredictable behaviour
warn(RuntimeWarning(msg))
2019-05-21 08:38:27 INFO root - Rasa process starting
2019-05-21 08:38:45 INFO rasa_nlu.components - Added 'SpacyNLP' to component cache. Key 'SpacyNLP-en'.
Traceback (most recent call last):
File "/home/thales/.local/lib/python3.6/site-packages/urllib3/connection.py", line 160, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "/home/thales/.local/lib/python3.6/site-packages/urllib3/util/connection.py", line 80, in create_connection
raise err
File "/home/thales/.local/lib/python3.6/site-packages/urllib3/util/connection.py", line 70, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/thales/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 603, in urlopen
chunked=chunked)
File "/home/thales/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 355, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
self.send(msg)
File "/usr/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/home/thales/.local/lib/python3.6/site-packages/urllib3/connection.py", line 183, in connect
conn = self._new_conn()
File "/home/thales/.local/lib/python3.6/site-packages/urllib3/connection.py", line 169, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f58af883ba8>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/thales/.local/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/home/thales/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 641, in urlopen
_stacktrace=sys.exc_info()[2])
File "/home/thales/.local/lib/python3.6/site-packages/urllib3/util/retry.py", line 399, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=5002): Max retries exceeded with url: /webhooks/rest/webhook/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f58af883ba8>: Failed to establish a new connection: [Errno 111] Connection refused',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.6/dist-packages/rasa_core/run.py", line 204, in <module>
endpoints=_endpoints)
File "/usr/local/lib/python3.6/dist-packages/rasa_core/run.py", line 157, in load_agent
from rasa_core import agent
File "/usr/local/lib/python3.6/dist-packages/rasa_core/agent.py", line 14, in <module>
from rasa_core.channels import UserMessage, OutputChannel, InputChannel
File "/usr/local/lib/python3.6/dist-packages/rasa_core/channels/__init__.py", line 23, in <module>
from rasa_core.channels.telegram import TelegramInput # nopep8
File "/usr/local/lib/python3.6/dist-packages/rasa_core/channels/telegram.py", line 4, in <module>
from telegram import (
File "/home/thales/.local/lib/python3.6/site-packages/telegram/__init__.py", line 46, in <module>
from .files.file import File
File "/home/thales/.local/lib/python3.6/site-packages/telegram/files/file.py", line 23, in <module>
from future.backports.urllib import parse as urllib_parse
File "/home/thales/.local/lib/python3.6/site-packages/future/backports/__init__.py", line 14, in <module>
import_top_level_modules()
File "/home/thales/.local/lib/python3.6/site-packages/future/standard_library/__init__.py", line 810, in import_top_level_modules
with exclude_local_folder_imports(*TOP_LEVEL_MODULES):
File "/home/thales/.local/lib/python3.6/site-packages/future/standard_library/__init__.py", line 781, in __enter__
module = __import__(m, level=0)
File "/home/thales/ola/starter-pack-rasa-stack/test.py", line 6, in <module>
r = requests.post(URL, data = PARAMS)
File "/home/thales/.local/lib/python3.6/site-packages/requests/api.py", line 116, in post
return request('post', url, data=data, json=json, **kwargs)
File "/home/thales/.local/lib/python3.6/site-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/home/thales/.local/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/home/thales/.local/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/home/thales/.local/lib/python3.6/site-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=5002): Max retries exceeded with url: /webhooks/rest/webhook/ (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f58af883ba8>: Failed to establish a new connection: [Errno 111] Connection refused',))

提到端口的错误部分似乎取决于我的帖子消息 python 脚本中的端口。命令行参数中的端口似乎被忽略。我尝试调试 run.py 文件,发现它在第 157 行“来自 rasa_core import agent”处崩溃了,这没有什么意义,因为该导入在 python 终端中可以正常工作。

“make cmdline”命令会产生与“make train-core”命令相同的错误。

我应该注意,我仍然可以为其他事情创建操作服务器和本地服务器。

配置文件(config.yml)的内容:

language: "en"
pipeline: spacy_sklearn

最佳答案

您提供的电报凭据似乎有误。请查看文档here如果您错过了什么。

如果您使用包含 localhost 的 URL 指定 Webhook URL:如果 Telegram 尝试将用户消息转发到机器人,则可以访问此 URL,因为此 URL 是内部的。你可以例如使用ngrok使该网址公开。

关于python - 运行 Rasa Stack 时超出最大重试次数并出现连接拒绝错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56234533/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com