Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fill slots in other parts of utterance templates than text #3763

Closed
erohmensing opened this issue Jun 12, 2019 · 7 comments
Closed

Fill slots in other parts of utterance templates than text #3763

erohmensing opened this issue Jun 12, 2019 · 7 comments
Assignees
Labels
area:rasa-oss 🎡 Anything related to the open source Rasa framework help wanted type:enhancement ✨ Additions of new features or changes to existing ones, should be doable in a single PR

Comments

@erohmensing
Copy link
Contributor

Right now, we only fill the {slot} format of utterance templates in the - text attribute of utterance templates. We could extend this to also fill keywords in other templates, e.g. "image" and "buttons", so that someone can use kwargs to fill them dynamically from their actions code.

Example use case:
https://forum.rasa.com/t/how-to-send-image-url-to-templates-dynamically/11074

@erohmensing erohmensing added type:enhancement ✨ Additions of new features or changes to existing ones, should be doable in a single PR area:rasa-oss 🎡 Anything related to the open source Rasa framework labels Jun 12, 2019
@RanaMostafaAbdElMohsen
Copy link
Contributor

Hey @erohmensing ,
I began investigating the issue.
What I concluded so far from slots.py there are slot formats for type names below :

- text
- float
- boolean
- List
- unfeaturized
- categorical

I believe what is required here to extend for - images and - buttons as well, correct?

@erohmensing
Copy link
Contributor Author

Hi @RanaMostafaAbdElMohsen! This isn't about slot types, but rather about which utterance fields get filled. The logic happens here:

text = re.sub(r"{([^\n]+?)}", r"{0[\1]}", template["text"])

As you can see, only the text field of the template is getting updated with slot values. However, templates can also have images, buttons, quick_replies, attachment, and custom fields (custom will be a dict that has anything in it)

A template is a dictionary, where its keys are text, etc -- in order to merge this PR, we would make sure it did that replacing in every key, value pair of the template. Then for custom, we would have to go one step further and make sure that every key, value within the custom dict has replacement too (probably recursively)

Does that help? I promise I've made it sound much more complicated than it probably would be :)

@RanaMostafaAbdElMohsen
Copy link
Contributor

Does that help? I promise I've made it sound much more complicated than it probably would be :)

Yes it helped :) Thanks @erohmensing

@akelad
Copy link
Contributor

akelad commented Jul 18, 2019

@RanaMostafaAbdElMohsen any progress on this yet?

@RanaMostafaAbdElMohsen
Copy link
Contributor

RanaMostafaAbdElMohsen commented Jul 20, 2019

Hi @akelad ,
I was working on resolving an issue and was recently resolved. Currently, I am investigating this issue and hopefully there will be a progress in it soon.

@RanaMostafaAbdElMohsen
Copy link
Contributor

Hi @erohmensing ,
I have made a PR initially for filling slot utterance templates for image. Can you please advise me if I am on right track to support other fields ?

@erohmensing
Copy link
Contributor Author

closed in #4077 and #4079 -- thanks guys!

Contribute to Rasa automation moved this from 🚀Doing to ✅Done Jul 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:rasa-oss 🎡 Anything related to the open source Rasa framework help wanted type:enhancement ✨ Additions of new features or changes to existing ones, should be doable in a single PR
Projects
No open projects
Development

No branches or pull requests

3 participants