首页 > 解决方案 > 如何 curl 访问 RASA NLU(starter-pack-rasa-stack)?

问题描述

通过此链接https://github.com/RasaHQ/starter-pack-rasa-stack

我已经设法使用以下命令启动服务器:make cmdline成功测试它!

如果我想使用Postmancurl 命令访问我的机器人服务器怎么办?或者我必须编写额外的代码吗?

这是我的方法:

1.制作动作服务器

Narongs-MacBook-Pro:starter-pack-rasa-stack softmastx$ make action-server
python -m rasa_core_sdk.endpoint --actions actions
INFO:__main__:Starting action endpoint server...
ERROR:rasa_core_sdk.executor:Failed to register package 'actions'.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/rasa_core_sdk/executor.py", line 144, in register_package
    self._import_submodules(package)
  File "/usr/local/lib/python2.7/site-packages/rasa_core_sdk/executor.py", line 131, in _import_submodules
    package = importlib.import_module(package)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "actions.py", line 16, in <module>
    from rasa_core.channels.direct import CollectingOutputChannel
ImportError: No module named direct
INFO:__main__:Action endpoint is up and running. on ('0.0.0.0', 5055)

2.制作命令行

2018-10-12 08:22:20.869093: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2018-10-12 08:22:22 INFO     root  - Rasa Core server is up and running on http://localhost:5005
Bot loaded. Type a message and press enter (use '/stop' to exit): 

请指教。谢谢你。

标签: rasa-nlurasa-core

解决方案


make cmdline不会启动额外的 NLU 服务器。所以你不能直接 curl Rasa NLU API。但是,您可以直接向 Core 发送消息:

curl --request POST \
  --url http://localhost:5005/webhooks/rest/webhook \
  --header 'content-type: application/json' \
  --data '{
  "message": "Hello"
}'

如果你想启动一个额外的 NLU 服务器,你必须运行:

python -m rasa_nlu.server --path models/current

然后,您可以使用以下命令 curl Rasa NLU:

curl --request GET \
  --url 'http://localhost:5000/parse?q=Hello&project=nlu'

推荐阅读