首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用RASA的API (rasa.core.processor -遇到异常)的正确方法是什么?

使用RASA的API (rasa.core.processor -遇到异常)的正确方法是什么?
EN

Stack Overflow用户
提问于 2020-06-16 02:53:30
回答 3查看 5.4K关注 0票数 2

我安装了rasa-演示代码示例。对于打开rasa API,我做了:

代码语言:javascript
复制
user@User:~/rasa-demo ‹master*›$ rasa run
No chat connector configured, falling back to the REST input channel. To connect your bot to another channel, read the docs here: https://rasa.com/docs/rasa/user-guide/messaging-and-voice-channels
2020-06-19 13:20:02 INFO     root  - Starting Rasa server on http://localhost:5005
2020-06-19 13:20:08 INFO     absl  - Using /var/folders/h5/9rj1zn8x4s59bk_mg_ktzv740000gn/T/tfhub_modules to cache modules.
2020-06-19 13:20:08 INFO     absl  - Downloading TF-Hub Module 'http://models.poly-ai.com/convert/v1/model.tar.gz'.
2020-06-19 13:20:26 INFO     absl  - Downloading http://models.poly-ai.com/convert/v1/model.tar.gz: 22.35MB
2020-06-19 13:20:43 INFO     absl  - Downloading http://models.poly-ai.com/convert/v1/model.tar.gz: 42.35MB
2020-06-19 13:21:02 INFO     absl  - Downloading http://models.poly-ai.com/convert/v1/model.tar.gz: 82.35MB
2020-06-19 13:21:21 INFO     absl  - Downloading http://models.poly-ai.com/convert/v1/model.tar.gz: 118.59MB
2020-06-19 13:21:40 INFO     absl  - Downloading http://models.poly-ai.com/convert/v1/model.tar.gz: 148.59MB
2020-06-19 13:21:41 INFO     absl  - Downloaded http://models.poly-ai.com/convert/v1/model.tar.gz, Total size: 152.02MB
2020-06-19 13:21:41 INFO     absl  - Downloaded TF-Hub Module 'http://models.poly-ai.com/convert/v1/model.tar.gz'.
2020-06-19 13:22:14 INFO     root  - Rasa server is up and running.

如何以API的形式查询聊天机器人?我希望能够提出一个请求,并通过请求进行对话,而不是使用shell。到目前为止,当我试图对rasa服务器进行卷曲时:

在:

代码语言:javascript
复制
user@User:~ $ curl -XPOST localhost:5005/webhooks/rest/webhook -d '{"message":"hi"}'

退出:

代码语言:javascript
复制
[]%

在rasa运行服务器上,我得到以下响应:

代码语言:javascript
复制
2020-06-19 13:23:17 ERROR    rasa.core.actions.action  - Failed to run custom action 'action_greet_user'. Couldn't connect to the server at 'http://localhost:5055/webhook'. Is the server running? Error: Cannot connect to host localhost:5055 ssl:default [Connection refused]
2020-06-19 13:23:17 ERROR    rasa.core.processor  - Encountered an exception while running action 'action_greet_user'. Bot will continue, but the actions events are lost. Please check the logs of your action server for more information.
2020-06-19 13:24:04 ERROR    rasa.core.actions.action  - Failed to run custom action 'action_greet_user'. Couldn't connect to the server at 'http://localhost:5055/webhook'. Is the server running? Error: Cannot connect to host localhost:5055 ssl:default [Connection refused]
2020-06-19 13:24:04 ERROR    rasa.core.processor  - Encountered an exception while running action 'action_greet_user'. Bot will continue, but the actions events are lost. Please check the logs of your action server for more information.

它不起作用。将Rasa服务器作为API请求的正确方法是什么?在读取了文档之后,还不清楚如何正确地使用文档

我也试过这个:

在:

代码语言:javascript
复制
import requests

response = requests.get('http://localhost:5005/webhooks/rest/webhook') 
print(response) 
print(response.headers) 
print(response.content)

退出:

代码语言:javascript
复制
<Response [405]>
{'Connection': 'keep-alive', 'Keep-Alive': '5', 'Allow': 'POST', 'Access-Control-Allow-Credentials': 'true', 'Content-Length': '60', 'Content-Type': 'text/plain; charset=utf-8'}
b'Error: Method GET not allowed for URL /webhooks/rest/webhook'
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2020-06-23 15:19:44

最后,我发现这就是您请求端点的方式:

代码语言:javascript
复制
localhost:5005/model/parse -s -d '{ "text": "hi" }'

文件应该更清楚。

票数 2
EN

Stack Overflow用户

发布于 2021-07-15 14:10:58

试着用:rasa run --enable-api启动rasa服务器,它为我工作。

票数 2
EN

Stack Overflow用户

发布于 2020-06-16 06:55:31

要访问REST端点,您应该使用rasa run 命令。这将启动一个Rasa服务器,启用您在凭证文件中定义的任何通道(如果没有提供该文件,Rasa将默认启用REST通道)。

然后,您可以像在文章中描述的那样查询端点,请参阅有关请求这里格式的更多细节。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62400205

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档