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

RASA提问,增加RASA FAQ的语料库 #2

Open
1 of 5 tasks
leijue222 opened this issue Mar 21, 2021 · 2 comments
Open
1 of 5 tasks

RASA提问,增加RASA FAQ的语料库 #2

leijue222 opened this issue Mar 21, 2021 · 2 comments

Comments

@leijue222
Copy link

leijue222 commented Mar 21, 2021

想到一个加一个吧。

  • 1. rasa run和rasa run actions的区别?
  • 2. Rasa和RasaX的区别?
  • 3. Rasa在何处调用Bert?
  • 4. 回译文本工具的作用是什么?
  • 5. API的形式调用Rasa的地址是多少以及需要传递什么参数?(答案)
@leijue222
Copy link
Author

  1. Rasa以API的形式访问的常用命令:
查看5005端口是否被占用 netstat -aon | findstr 5005
启动Rasa API服务(跨域)rasa run --enable-api --cors "*"
启动Rasa API服务(保存日志)rasa run --enable-api --log-file out.log
启动Rasa API服务(指定模型)rasa run --enable-api -m models
  1. 启动服务后,后续可利用如下代码进行调试:
import json
import secrets
import requests


def post(url, data=None):
    data = json.dumps(data, ensure_ascii=False)
    data = data.encode(encoding="utf-8")
    r = requests.post(url=url, data=data)
    r = json.loads(r.text)
    return r


if __name__ == "__main__":
    conversation_id = secrets.token_urlsafe(16)  # 随机生成会话id
    messages_url = "http://localhost:5005/conversations/{}/messages".format(conversation_id)  # 发送消息
    predict_url = "http://localhost:5005/conversations/{}/predict".format(conversation_id)  # 预测下一步动作
    execute_url = "http://localhost:5005/conversations/{}/execute".format(conversation_id)  # 执行动作
    action = "action_listen"  # 动作初始化为等待输入
    while True:
        if action in ["action_listen", "action_default_fallback", "action_restart"]:
            # 等待输入
            text = input("Your input ->  ")
            post(messages_url, data={"text": text, "sender": "user"})  # 发送消息

        response = post(predict_url)  # 预测下一步动作
        action = response["scores"][0]["action"]  # 取出置信度最高的下一步动作

        response = post(execute_url, data={"name": action})  # 执行动作
        messages = response["messages"]  # 取出对话信息
        if messages:
            print(messages)

官网API接口文档链接,以及中文博客参考。

@Dustyposa
Copy link
Owner

问题 5 答案已补充到源文件。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants