我正在尝试在 Colab 上实施 RASA 聊天机器人,并且发现很难自定义操作。休息一切正常,除了操作。我觉得我的聊天框没有进入我的操作。任何人都可以指导我。
nlu_md = """
## intent:greet
- Hello
- hello
- good morning
## intent:justbook
- table for 1
- make reservations for me
- make reservations for 1 person
"""
%store nlu_md > nlu.md
stories_md = """
## Story 1
* greet
- action_print
"""
%store stories_md > stories.md
domain_yml = """
%YAML 1.1
---
actions:
- utter_booking_confirmation
- utter_greeting
- utter_thankyou
- __main__.Printer
- action_print
entities:
- time
- date
- number_of_people
intents:
- time
- when
- book
- greet
- justbook
templates:
utter_greeting:
- text: Welcome to the restaurant ! How can I help you ?
utter_thankyou:
- text: Thank You for using our services ! See you again soon !
utter_confirm:
- text: Your booking is confirmed for {number_of_people} on {date} at {time}. Thank You. See you soon
"""
%store domain_yml > domain.yml
行动
from rasa_core_sdk import Tracker
from rasa_core_sdk import Action
from rasa_core_sdk.events import SlotSet
from rasa_core_sdk.executor import CollectingDispatcher
from rasa_core.actions import Action
class Printer(Action):
def name(self):
return "action_print"
def run(self, dispatcher, tracker, domain):
no_of_people=tracker.slots['number_of_people']
time=tracker.slots['time']
date=tracker.slots['date']
print('ENTERED PRINTER')
dispatcher.utter_message('hi i am in Printer')
#return ''
聊天框!
from rasa_core.agent import Agent
from rasa_core.utils import EndpointConfig
from rasa_core.interpreter import RasaNLUInterpreter
from rasa_core.utils import EndpointConfig
agent = Agent.load('models/dialogue',interpreter=RasaNLUInterpreter('/content/drive/My Drive/restaurant bot/models/nlu/default/restaurantbot'),
action_endpoint=EndpointConfig(url="http://127.0.0.1:5055/webhook"))
print("Bot is ready to talk! Start conversation with 'hi'")
while True:
st = input()
if st == 'stop':
break
responses = agent.handle_text(st)
for response in responses:
print(response["text"])
预期输出
我期待输出: Entered Printer HI 我在打印机中。
输出我得到我没有得到预期的输出,我只是得到输入的文本框..