Comments (2)
- 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
- 启动服务后,后续可利用如下代码进行调试:
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)
from rasa_ch_faq.
问题 5 答案已补充到源文件。
from rasa_ch_faq.
Related Issues (12)
- python train.py 报错,麻烦帮看下啥问题 HOT 1
- 执行rasa命令提示命未找到命令 HOT 5
- rasa3.0如何实现图片的上传 HOT 1
- 多轮对话确定一个推荐,怎么实现?
- 运行时报了Noreturn HOT 5
- 在前端中无法正常问答,该排查哪一部分呢? HOT 6
- 单独 python bert_tokenizer.py 报错,是不是huggingface加载模型方式有变化? HOT 5
- 训练时间过长 HOT 3
- 有计划升级到3.0吗? HOT 1
- 关于前端文件的使用 HOT 3
- 运行rasa train时报错显示OSError HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rasa_ch_faq.