因此,我尝试制作一个查询机器人,其中用户说“谁是比尔·盖茨”,并使用Wolfram alpha给出响应(例如)。我正在使用rasa nlu和rasa core,并且一切正确,但是当我用查询运行它时,它只返回[]。
我已经研究了这个问题,并尝试使用不同版本的rasa core,但似乎没有任何进展。我已经检查了API门户,并且请求正在记录,因此似乎唯一的问题是显示结果。
## query
* query
- actions.query.ActionQuery
slots:
query_object:
type: text
relations:
type: text
context:
type: text
intents:
- query.author
- query.calories
- query.height
- query.height.relation
- query.person
- query.person.relation
- query.person.money
- query.person.age
- query.item
- query.item.released
entities:
- query_object
- relations
- context
actions:
- actions.query.ActionQuery
.actions / query.py
from rasa_core.actions.action import Action
import requests
class ActionQuery(Action):
def name(self):
return 'action_query'
def run(self, dispatcher, tracker, domain):
query_object = tracker.get_slot('query_object')
print(query_object)
if tracker.get_slot('relations') :
relation = tracker.get_slot('relations')
if tracker.get_slot('context') :
context = tracker.get_slot('context')
r = requests.get("http://api.wolframalpha.com/v1/result?appid=HJGTTH-4WQG3TEREW&i={}%3f".format(query_object))
if r:
res = r.content()
dispatcher.utter_message("Hey , This is the answer if it shows ... -> " , res)
else:
dispatcher.utter_message(" sorry, I couldn't find anything on that ")
return
我有训练数据,并使用过Rasa Nlu并对其进行了训练,还对Rasa Core文件进行了训练。
提前谢谢