Stories in custom policies?

Hi! I’m trying to create a custom policy who can decide from a story path. Is it possible to capture the story in my custom policy?? Which component gives me that?? Or can i read the stories.yml inside the custom policy?

Hey @matiasberthelot, welcome to the forum!

Before going any further, are you sure you need a custom policy? I’m asking because a lot of things can be achieved with the current policies, and it may be easier than writing a custom one. Can you give an example of what your policy should do that you can’t achieve otherwise?

Now to your question: If you look at rasa.core.policies.policy.Policy, which is the class your custom policy will inherit, you’ll notice that in the two methods you’ll need to override (train and predict_action_probabilities) you receive the stories in the form of trackers (during training, it can be multiple trackers, each storing one story; during prediction, it is just 1 tracker representing the story so far). I recommend you look at the code and familiarise yourself with the main methods in there. In general, a tracker contains conversation events, which then get turned into a sequence of conversation states, and these states are then featurised, i.e. turned into suitable numerical representations which can be used for making a prediction inside a policy. (The glossary might help you start, but I think that you’ll have to look at the relevant code sooner or later.)

Hi @SamS Thanks for your help. I just was testing what could I do by creating my own custom policy. Now I’m going to try what you said about the tracker. Greetings from Argentina!

1 Like