rasahq / forms_bot Goto Github PK
View Code? Open in Web Editor NEWbot which uses forms to do hotel and restaurant booking task
bot which uses forms to do hotel and restaurant booking task
ModuleNotFoundError: No module named 'rasa_core.policies.plans'
Makefile:12: recipe for target 'train-core' failed
make: *** [train-core] Error 1
As titled, I didn't find any 'activate_restaurant' defined in the domain file. Is it defined somewhere that I didn't installed? Thanks
Following is my code:
Actions.py:
from typing import Dict, Text, Any, List, Union, Optional
from rasa_sdk import Tracker
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.forms import FormAction
class RestaurantForm(FormAction):
"""Example of a custom form action"""
def name(self) -> Text:
"""Unique identifier of the form"""
return "restaurant_form"
@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
"""A list of required slots that the form has to fill"""
return ["cuisine", "num_people", "outdoor_seating", "preferences", "feedback"]
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
"""A dictionary to map required slots to
- an extracted entity
- intent: value pairs
- a whole message
or a list of them, where a first match will be picked"""
return {
"cuisine": self.from_entity(entity="cuisine", not_intent="chitchat"),
"num_people": [
self.from_entity(
entity="num_people", intent=["inform", "request_restaurant"]
),
self.from_entity(entity="number"),
],
"outdoor_seating": [
self.from_entity(entity="seating"),
self.from_intent(intent="affirm", value=True),
self.from_intent(intent="deny", value=False),
],
"preferences": [
self.from_intent(intent="deny", value="no additional preferences"),
self.from_text(not_intent="affirm"),
],
"feedback": [self.from_entity(entity="feedback"), self.from_text()],
}
# USED FOR DOCS: do not rename without updating in docs
@staticmethod
def cuisine_db() -> List[Text]:
"""Database of supported cuisines"""
return [
"caribbean",
"chinese",
"french",
"greek",
"indian",
"italian",
"mexican",
]
@staticmethod
def is_int(string: Text) -> bool:
"""Check if a string is an integer"""
try:
int(string)
return True
except ValueError:
return False
# USED FOR DOCS: do not rename without updating in docs
def validate_cuisine(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Optional[Text]:
"""Validate cuisine value."""
if value.lower() in self.cuisine_db():
# validation succeeded, set the value of the "cuisine" slot to value
return {"cuisine": value}
else:
dispatcher.utter_template("utter_wrong_cuisine", tracker)
# validation failed, set this slot to None, meaning the
# user will be asked for the slot again
return {"cuisine": None}
def validate_num_people(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Optional[Text]:
"""Validate num_people value."""
if self.is_int(value) and int(value) > 0:
return {"num_people": value}
else:
dispatcher.utter_template("utter_wrong_num_people", tracker)
# validation failed, set slot to None
return {"num_people": None}
def validate_outdoor_seating(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Any:
"""Validate outdoor_seating value."""
if isinstance(value, str):
if "out" in value:
# convert "out..." to True
return {"outdoor_seating": True}
elif "in" in value:
# convert "in..." to False
return {"outdoor_seating": False}
else:
dispatcher.utter_template("utter_wrong_outdoor_seating", tracker)
# validation failed, set slot to None
return {"outdoor_seating": None}
else:
# affirm/deny was picked up as T/F
return {"outdoor_seating": value}
def submit(
self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> List[Dict]:
"""Define what the form has to do
after all required slots are filled"""
# utter submit template
dispatcher.utter_template("utter_submit", tracker)
return []
But when I load the bot in the terminal it shows the error:
Encountered an exception while running action 'restaurant_form'. Bot will continue, but the actions events are lost. Make sure to fix the exception in your custom code.
Can anyone please tell what is wrong here?
In order to train the bot we need to have training data. Could i know where have you provided it?
I am getting the following error when i am trying to run the forms_bot code
Bot loaded. Type a message and press enter (use '/stop' to exit):
hi
2018-10-01 17:56:09 DEBUG requests.packages.urllib3.connectionpool - Starting new HTTP connection (1): localhost
2018-10-01 17:56:09 DEBUG rasa_core.tracker_store - Creating a new tracker for id 'default'.
2018-10-01 17:56:09 DEBUG rasa_core.processor - Received user message 'hi' with intent '{'name': 'hi', 'confidence': 1.0}' and entities '[]'
2018-10-01 17:56:09 DEBUG rasa_core.processor - Logged UserUtterance - tracker now has 2 events
2018-10-01 17:56:09 DEBUG rasa_core.processor - Current slot values:
people: None
has_gym: None
breakfast: None
requested_slot: None
location: None
info: None
outdoor_seating: None
hotel: None
enddate: None
restaurant: None
cuisine: None
plan_complete: None
price: None
reservations: None
startdate: None
date_suitable: None
has_spa: None
2018-10-01 17:56:09 DEBUG rasa_core.policies.memoization - Current tracker state [None, {}, {'prev_action_listen': 1.0, 'intent_hi': 1.0}]
2018-10-01 17:56:09 DEBUG rasa_core.policies.memoization - There is no memorised next action
2018-10-01 17:56:09 DEBUG rasa_core.featurizers - Feature 'intent_hi' (value: '1.0') could not be found in feature map. Make sure you added all intents and entities to the domain
2018-10-01 17:56:09 DEBUG rasa_core.policies.ensemble - Predicted next action using policy_2_KerasPolicy
2018-10-01 17:56:09 DEBUG rasa_core.processor - Predicted next action 'activate_restaurant' with prob 0.80.
2018-10-01 17:56:09 ERROR rasa_core.processor - Encountered an exception while running action 'activate_restaurant'. Bot will continue, but the actions events are lost. Make sure to fix the exception in your custom code.
2018-10-01 17:56:09 ERROR rasa_core.processor - The model predicted the custom action 'activate_restaurant' but you didn't configure an endpoint to run this custom action. Please take a look at the docs and set an endpoint configuration. https://rasa.com/docs/core/customactions/
Traceback (most recent call last):
File "/home/sfrplindia1/Work/SantaFe/Raghuram/chatbots/venv3/lib/python3.5/site-packages/rasa_core/processor.py", line 324, in _run_action
events = action.run(dispatcher, tracker, self.domain)
File "/home/sfrplindia1/Work/SantaFe/Raghuram/chatbots/venv3/lib/python3.5/site-packages/rasa_core/actions/action.py", line 305, in run
"".format(self.name(), DOCS_BASE_URL))
Exception: The model predicted the custom action 'activate_restaurant' but you didn't configure an endpoint to run this custom action. Please take a look at the docs and set an endpoint configuration. https://rasa.com/docs/core/customactions/
2018-10-01 17:56:09 DEBUG rasa_core.processor - Action 'activate_restaurant' ended with events '[]'
2018-10-01 17:56:09 DEBUG rasa_core.policies.memoization - Current tracker state [{}, {'prev_action_listen': 1.0, 'intent_hi': 1.0}, {'prev_activate_restaurant': 1.0, 'intent_hi': 1.0}]
2018-10-01 17:56:09 DEBUG rasa_core.policies.memoization - There is no memorised next action
2018-10-01 17:56:09 DEBUG rasa_core.featurizers - Feature 'intent_hi' (value: '1.0') could not be found in feature map. Make sure you added all intents and entities to the domain
2018-10-01 17:56:09 DEBUG rasa_core.featurizers - Feature 'intent_hi' (value: '1.0') could not be found in feature map. Make sure you added all intents and entities to the domain
2018-10-01 17:56:09 DEBUG rasa_core.policies.ensemble - Predicted next action using policy_2_KerasPolicy
2018-10-01 17:56:09 DEBUG rasa_core.processor - Predicted next action 'deactivate_plan' with prob 0.66.
2018-10-01 17:56:09 ERROR rasa_core.processor - Encountered an exception while running action 'deactivate_plan'. Bot will continue, but the actions events are lost. Make sure to fix the exception in your custom code.
2018-10-01 17:56:09 ERROR rasa_core.processor - The model predicted the custom action 'deactivate_plan' but you didn't configure an endpoint t
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.