Handle custom fields from an NLU Message
See original GitHub issueA forum user (post) brought up a good point that at the moment if you build a custom NLU component, you have to put any additional information (like sentiment) into the entities key of the Message
for the formation to be passed onto the dialogue manager.
A sentiment component right now should return output like this:
{ ‘intent’:
{ ‘name’:‘greet’, ‘confidence’:0.44503513568867775 }
, ‘entities’:[
{ ‘value’:‘neg’, ‘confidence’:0.9933702940854111, ‘entity’:‘sentiment’, ‘extractor’:‘sentiment_extractor’ }
}
It would be more intuitive to have this information in a separate field since sentiment isn’t really an entity:
{ “intent”:
{ “name”: “foo”, “confidence”: 0.1234567890 }
, “entities”: [], “sentiment”: [
{ “value”: “NEUTRAL”, “score”: 0.123, “confidence”: 0.897 }
], }
On the NLU side the Message
class would already allow this extra field (only on the master branch of rasa though) - see here. But I’m not sure whether the dialogue manager will handle that properly.
@degiz said he would look into this when he’s back from vacation
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (9 by maintainers)
Exalate commented:
degiz commented:
@mjaycub added the
low
one for now, doesn’t seem to be burning.Exalate commented:
akelad commented:
So what I meant in this situation is that
UserMessage
(from the channel definition, which is the one that gets put in the tracker) actually has ametadata
field at the moment. But thetracker.latest_message
method doesn’t even let you access that right now, only the parse data. That’s actually a separate issue as well, that to access any metadata you assign there you have to iterate through the tracker events.But yeah so what I’m saying is that we use a key like
metadata
, where users could provide extra NLU attributes. And I guess that would then be accessible fromtracker.latest_message.get("metadata")
. Or we actually fill theUserMessage
metadata field with that as well, kind of depends.