在 RASA 核心/NLU 中获取用户对意图的价值



我有与中相同的问题:在RASA核心/NLU中获取意向值但是我想要用户对于给定意图给出的值。

例如:

User: I want to take it (this sentence is an intent called: 'use_it')
Bot: ....
User: .... (Later in the chat I decide to answer with the same phrase of intent 'use it') 
Bot: you said previously "I want to take it"

我怎么能做像tracker.get_slot这样的事情,但要有意图?

我不想要最后一个意图的名称,我想要用户给定意图的文本。

在将意向文本存储在插槽中的意向之后执行自定义操作:

from rasa_core_sdk import Action
from rasa_core_sdk.events import SlotSet
class ActionStoreIntentMessage(Action):
"""Stores the bot use case in a slot"""
def name(self):
return "action_store_intent_message"
def run(self, dispatcher, tracker, domain):
# we grab the whole user utterance here as there are no real entities
# in the use case
message = tracker.latest_message.get('text')
return [SlotSet('intent_message', message)]

然后,您可以在一个彻底的模板中使用设置槽的值:

slots:
intent_message:
type: text
templates:
utter_last_intent:
- "you said previously: {intent_message}"

您可以使用任务跟踪器。

text=tracker.latest_message['text']

最新更新