我正在尝试在 Rasa 平台上制作可操作的聊天机器人。我的基本机器人正在运行,但是每当我向聊天机器人询问有关数据库的问题时,它都没有输出。并且终端上未显示任何错误/异常。
示例 我-什么是pf uan number?
启动-“空”
//下面我附加了代码//
domain.yml
intents:
agent.acquaintance
agent.age
templates:
utter_agent.acquaintance:
- "I'm a virtual agent"
- "Think of me as a virtual agent."
- "Well, I'm not a person, I'm a virtual agent."
- "I'm a virtual being, not a real person."
- "I'm a conversational app."
utter_agent.age:
- "I prefer not to answer with a number. I know I'm young."
- "I was created recently, but don't know my exact age."
- "Age is just a number. You're only as old as you feel."
actions:
utter_agent.acquaintance
utter_agent.age
action_db
Stories.md
## story 01
*agent.acquaintance
utter_agent.acquaintance
story 02
*agent.age
utter_agent.age
Story 87
*pf.uan.number
action_db
pf.uan.number.md
## intent:pf.uan.number
Give my uan number
Lets go
my pf uan number
Your pf uan number
What is pf uan number?
action.py
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from rasa_core_sdk import Action
import pymysql
class ActionDb(Action):
def name(self):
return 'action_db'
def run(self, dispatcher, tracker, domain):
print("Hello1111")
db = pymysql.connect("xyz.net","admin","abcdefg","dbname")
cursor = db.cursor()
str1='PF_UAN_Number'
query = "SELECT COL_2 FROM csv_db1.TABLE_2 WHERE COL_1 = '" + str1 + "'"
cursor.execute(query)
data = cursor.fetchone()
print(data)
dispatcher.utter_message(data[0])
return []
答案 0 :(得分:0)
stories.md文件的格式错误,每个新故事都应以##
符号开头,并且动作应以-
开头
答案 1 :(得分:0)
stories.md 和 domain.yml 文件的格式错误。
您必须在story 02
的第Story 87
和##
行中添加注释,然后在添加之前添加-
。
所以会是这样:
## story 02
* agent.age
- utter_agent.age
在 domain.yml 中,操作和意图应以-
为前缀。
所以会是这样:
intents:
- agent.acquaintance
- agent.age
actions:
- utter_agent.acquaintance
- utter_agent.age
- action_db
我建议您检查此文档以查看stories.md和domain.yml文件的正确格式: