Rasa聊天机器人无法响应用户输入

2024-03-28 10:14:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用DIETClassifier进行实体提取,这是我的管道:

pipeline:
  - name: SpacyNLP
    model: en_core_web_sm
  - name: SpacyTokenizer
  - name: CountVectorsFeaturizer
  - name: CRFEntityExtractor
  - name: DIETClassifier
    epochs: 200
    random_seed: 2

这是我对nlu文件中实体的意图示例:

version: "2.0"

nlu:
- intent: flight_search_intent
  examples: |
    - I want to [travel](Search_flight)
    - I want a travel [ticket](Search_flight)
    - I want a [flight](Search_flight) ticket
    - find a [flight](Search_flight) for me please
    - find a [flight](Search_flight) for me, please
    - Can you please find a [flight](Search_flight) ticket for me?
    - I want to book a [flight](Search_flight) ticket
    - I want to book a [ticket](Search_flight)
    - Can you please find a [flight](Search_flight) for me?
    - I want to book a [flight](Search_flight) asap
    - I want to book a [flight](Search_flight)
    - I am looking for a [flight](Search_flight)
    - find a [flight](Search_flight) for me
    - I wanna to [travel](Search_flight)
    - I need a [trip](Search_flight)

# 2) flight_search_intent_with_daeparture_and_destenation_cities_and_departure_date:
- intent: flight_search_intent_with_daeparture_and_destenation_cities_and_departure_date
  examples: |
    - I am looking for a [flight](Search_flight) from [Arrabury]{"entity": "city", "role": "departure"} to [Annaba]{"entity": "city", "role": "destination"} [Tomorrow](departure_date).
    - I want to book a [flight](Search_flight) from [Dammam]{"entity": "city", "role": "departure"} to [Jeddah]{"entity": "city", "role": "destination"} on [14/05/2022](departure_date).
    - I want to book a [flight](Search_flight) from [Berlin]{"entity": "city", "role": "departure"} to [San Francisco]{"entity": "city", "role": "destination"} on [30/1/2021](departure_date).
    - Can you please find a [flight](Search_flight) for me from [Al Madinah]{"entity": "city", "role": "departure"} to [Abha]{"entity": "city", "role": "destination"} on [3-4-2020](departure_date).
    - Book a [flight](Search_flight) from [Al Kharj]{"entity": "city", "role": "departure"} to [Bonthe]{"entity": "city", "role": "destination"} [Today](departure_date).
    - Book a [flight](Search_flight) from [Colombo]{"entity": "city", "role": "departure"} to [Paris]{"entity": "city", "role": "destination"} on [January,21st,2020](departure_date).
    - find a [flight](Search_flight) for me from [Berlin]{"entity": "city", "role": "departure"} to [San Francisco]{"entity": "city", "role": "destination"} on [January,21st,2020](departure_date).
    - I want to [fly](Search_flight) from [Berlin]{"entity": "city", "role": "departure"} to [San Francisco]{"entity": "city", "role": "destination"} on [17th January 2021](departure_date).
    - I wanna [trp](Search_flight) from [Berlin]{"entity": "city", "role": "departure"} to [San Francisco]{"entity": "city", "role": "destination"} on [17th January 2021](departure_date).
    - I need a [flight](Search_flight) from [Berlin]{"entity": "city", "role": "departure"} to [San Francisco]{"entity": "city", "role": "destination"} [Tomorrow](departure_date).

这是我的故事的一个例子:

#1) Flight serch function stories:
- story: flight_search_function_story_1
  steps:
  - intent: greet
  - action: utter_greet
  - intent: flight_search_intent
  - action: utter_ask_about_trip_kind
  - intent: provide_round_trip
  - action: utter_ask_about_departure_city
  - intent: provide_departure_city
  - action: utter_ask_about_departure_date
  - intent: provide_date
  - action: utter_ask_about_destination_city
  - intent: provide_destination_city
  - action: utter_ask_about_return_date
  - intent: provide_date
  - action: utter_suitable choices
  - action: utter_something_else
  - intent: thanking
  - action: utter_welcome_thanks
  - intent: goodbye
  - action: utter_goodbye

这是我域文件的一部分,我在其中列出了所有意图、实体和响应:

version: "2.0"

intents:
  - afternoon
  - morning
  - provide_date
  - nice_to_meet
  - provide_destination_city
  - get_Kind_of_cities
  - waiting
  - get_weather
  - greet
  - goodbye
  - goodnight
  - welcome_thanks
  - provide_one_way_trip
  - nice_to_talk
  - askingAboutDoingWithName
  - askingAboutDoingWithOutName
  - flight_search_intent_with_daeparture_and_destenation_cities_only
  - flight_search_with_destenation_only
  - flight_search_intent
  - provide_email
  - flight_search_intent_with_daeparture_and_destenation_cities_and_departure_date
  - provide_departure_city
  - evening
  - see_again
  - bot_challenge
  - provide_issue_deatils
  - user_waiting
  - well_done
  - sorry
  - get_Hoppies
  - thanking
  - flight_search_with_departure_only
  - provide_round_trip
  - provide_name
  - provide_phone_number
  - Connect_agent
  - place_to_visit

entities:
  - return_date
  - phone
  - provide_name
  - get_issue_details
  - weather_type
  - round_flight
  - report_issue
  - one_way_flight
  - hobby
  - return_decision
  - city_type
  - Search_flight
  - email
  - departure_date
  - name
  - city:
      roles:
        - departure
        - destination


responses:
  utter_greet:
  - text: "Hi I am Tickie! How can I help you?"

  utter_cheer_up:
  - text: "Here is something to cheer you up:"
    image: "https://i.imgur.com/nGF1K8f.jpg"

  utter_did_that_help:
  - text: "Did that help you?"

然而,当我用rasa train命令训练我的聊天机器人,并用rasa shell命令测试它时,它只给出用户(我)第一次输入的响应,然后响应停止工作!我在两周内发现了错误和解决方案,但我没有发现,这是一个示例:

enter image description here

有人能帮我吗?或者如果我上面提到的文件中有任何错误,有人能告诉我错误是什么吗?我遵循了rasa文档中的域文件以及如何定义意图中的实体,但我遇到了这个问题,并且我在互联网上找到的所有解释都不是rasa 2.0,因此我不知道问题出在哪里

但是,当我从域文件中删除实体时,它会有响应!但情况是这样的:

enter image description here

它说将实体添加到域文件中,正如我之前添加它们时向您展示的那样,响应停止工作


Tags: tofromcitysearchdatedestinationroleflight
1条回答
网友
1楼 · 发布于 2024-03-28 10:14:13

除非域文件没有显示实际域文件中的所有响应,否则您的问题是您没有为您的故事中的大多数响应提供响应文本。您可能在添加实体时意外删除了这些实体

相关问题 更多 >