user - show come papers on ML
bot - there are 1000 papers related to ML that i can provide
user- ok, show the distribution of the paper type
bot - creates an pie chart and send it to the user
example image created by bot -
so basically I have to create an pie chart at runtime on the basis of user demand and send it to user. How can i send an image to user? I created a slot named image_location that holds the location of the image in my project folder and then I utter that image but all it does is show the image location filled in the slot image_location.
when and intend called show_Stat is detected then i called action_make_stats that create the graph and stores it’s location in the slot image_loc, and then I execute utter_show_Stats
image_loc: type: unfeaturized
utter_show_stats:
- text: ‘stats: {image_loc}’
code snippet -
class ActionMakeStats(Action):
def name(self):
return 'action_make_stats'
def run(self, dispatcher, tracker, domain):
paper_domain = tracker.get_slot('paper_domain')
domain_count = {}
for domain in paper_domain:
if domain in domain_count.keys():
domain_count[domain] += 1
else:
domain_count[domain] = 1
counts = list(domain_count.values())
explode = [0] * len(counts)
explode[counts.index(max(counts))] = 0.1
plt.pie(
x = counts,
labels = list(domain_count.keys()),
explode = explode,
autopct='%.2f%%',
shadow = True,
startangle = 90
)
plt.savefig('stat.png')
plt.close()
return [SlotSet('image_loc', 'stat.png')]
instead of getting image from the bot i get a response “stat.png”
for now i testing it using rasa-x