微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Rasa自定义操作不起作用-Google Colab

如何解决Rasa自定义操作不起作用-Google Colab

我正在尝试在Colab上实现RASA chatbot,并发现很难自定义动作。.除了动作之外,其他所有功能都可以正常工作。.我觉得我的聊天框没有输入动作。.任何人都可以指导我..

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"])

预期产量
我希望输出:已输入打印机HI我在打印机中。
我得到的输出我没有得到预期的输出,我只是得到输入的文本框。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。