In the documentation for the Knowledge Base, there are a lot of examples given, but none of them seem able to directly reference an item in the list.
Example:
- what [restaurants]{"entity": "object_type", "value": "restaurant"} can you recommend?
This will return a list of all the restaurants in the database. Cool. Got it.
But what if I don’t want to see a list first? What if I want to directly reference a restaurant?
If I set object_type to Mike’s Pizza, the action fails because it’s looking for the TYPE ‘Mikes Pizza’, but Mikes Pizza is an entry under the type of restaurant. There is no type ‘marks pizza’.
But the docs seem to address this with the example:
- what is the [price range]{"entity": "attribute", "value": "price-range"} of [Berlin Burrito Company](restaurant)?
So I tried to emulate that, and instead of setting the slot object_type, I set the slot restaurant.
But that fails - action_query_knowledge_base has no object_type sent to it, so it instead issues one of the rephrase utterances. I’ve tried this. Setting restaurant, without object_type being set, returns nothing.
Might be possible if you can set a slot along with an intent without actually tagging a word to go into that slot. No clue how to do that though.
With the knowledge base, it seems like the ONLY way to reference Mike’s Pizza is to first get a list, then pick Mike’s pizza from it. Which is a dumb way to do it when you know which restaurant you want.
I HAVE to be missing something, but the documentation is… kinda garbage at actually explaining it.
I’m thinking what I’m missing is maybe object_type must be set to restaurant, BEFORE you do the Mikes Pizza query - but for my use case I need to set that transparently. I don’t want the user to have to write an extra line just to set it. But I cannot find anywhere that mentions setting a slot being tied to an intent without pulling that slot from the text the user entered.
EDIT: So in trying to understand this, I made a new bot, using the examples listed at Knowledge Base Actions
Used the json dataset provided, used the nlu examples for the intent query_knowledge_base, set up slots and actions and intents, trained, fired up Rasa-X, and started a conversation.
I asked: what restaurants can you recommend? It ran: query_knowledge_base{“object_type”:“restaurant”}(1.0)
I told it to run action_query_knowledge_base and it replied:
Found the following objects of type 'restaurant':
1: Donath
2: Berlin Burrito Company
3: I due forni
Cool, thats expected.
Next I asked, word for word from the NLU training:
what is the price range of berlin burrito company?
It ran: query_knowledge_base{"attribute":"price-range","restaurant":"berlin burrito company"}(1.0)
action_query_knowledge_base replied:
Could you please rephrase your message? I didn't quite get that.
It seems the ONLY WAY to work with a knowledge base is to extremely non-intuitively first ask for the list of items, then say something that selects ‘the first one’, and THEN once that is selected you can ask for info. Or ask for the ‘price range’ on ‘the second one’.
Am I experiencing brain damage/a stroke and I’m seriously misunderstanding how this works, or is the Knowledge Base Actions page completely wrong and no one has ever tested if it actually worked as intended? By looking at the KB code at https://github.com/RasaHQ/rasa-sdk/blob/main/rasa_sdk/knowledge_base/actions.py, it appears that nowhere in that code is there any place where the NAME of the restaurant is used. The only things referenced are the object_type (restaurant) and a mention, which can ONLY be set by it’s ordinal number, and an attribute, like price range.
So it’s literally impossible to ask for the cuisine of Berlin Burrito Company, you have to ask for the cuisine of the second one. Sure you could set a synonym of 2 for the burrito place, but we already have the name. Why is it not able to use it? People don’t speak like that.
Imagine this bot is running for the company that owns Chilis. You log in.
What time does Chilis close tonight?
Bot: Rephrase that.
What restaurants do you have?
Bot: Gives a list
Ok, what time is chilis open til?
Bot: Rephrase that
God dammit, what time is THE FOURTH ONE open until.
Bow: 1am
Thats not how conversation works.
For feedback on the knowledge base, as I’m understanding it, it’s utterly worthless. Again I could have had a stroke and am seriously missing something, but following the documentation for it on the docs site… its completely broken.
But, I need this functionality so it appears I am re-writing the entire knowledge base actions ground up.