Yes, I am using Rasa 1.1.7. I do not have an error message per say, but I spotted a difference in the debug stacktrace when I am using a database or not.
With a database :
2019-07-25 09:29:56 [1;30mDEBUG [0m [34mrasa.core.policies.memoization[0m - Current tracker state [None, None, None, None, {}]
2019-07-25 09:29:56 [1;30mDEBUG [0m [34mrasa.core.policies.memoization[0m - There is a memorised next action '0'
With no database :
2019-07-25 09:33:00 e[1;30mDEBUG e[0m e[34mrasa.core.policies.memoizatione[0m - Current tracker state [None, None, {}, {'intent_intent_bonjour': 1.0, 'prev_action_listen': 1.0}, {'intent_intent_bonjour': 1.0, 'prev_utter_bonjour': 1.0}]
2019-07-25 09:33:00 e[1;30mDEBUG e[0m e[34mrasa.core.policies.memoizatione[0m - There is a memorised next action '9'
Here’s the implementation of my custom tracker store :
logger = logging.getLogger(__name__)
class CustomSQLTrackerStore(SQLTrackerStore):
"""Store which can save and retrieve trackers from an SQL database."""
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class SQLEvent(Base):
from sqlalchemy import Column, Integer, String, Float, Text
__tablename__ = "events"
id = Column(Integer, primary_key=True)
sender_id = Column(String(255), nullable=False, index=True)
type_name = Column(String(255), nullable=False)
timestamp = Column(Float)
intent_name = Column(String(255))
action_name = Column(String(255))
data = Column(Text)
def __init__(self, url, domain: Optional[Domain] = None, dialect: Text = None, host: Optional[Text] = None,
port: Optional[int] = None, db: Text = None, username: Text = None, password: Text = None,
event_broker: Optional[EventChannel] = None, login_db: Optional[Text] = None ) -> None:
import sqlalchemy
from sqlalchemy.orm import sessionmaker
from sqlalchemy import create_engine
engine_url = self._get_db_url(
dialect, host, port, db, username, password, login_db
)
logger.debug(
"Attempting to connect to database " 'via "{}"'.format(repr(engine_url))
)
# Database might take a while to come up
while True:
try:
self.engine = create_engine(engine_url)
# if `login_db` has been provided, use current connection with
# that database to create working database `db`
if login_db:
self._create_database_and_update_engine(db, engine_url)
try:
self.Base.metadata.create_all(self.engine)
except (
sqlalchemy.exc.OperationalError,
sqlalchemy.exc.ProgrammingError,
) as e:
# Several Rasa services started in parallel may attempt to
# create tables at the same time. That is okay so long as
# the first services finishes the table creation.
logger.error("Could not create tables: {}".format(e))
self.session = sessionmaker(bind=self.engine)()
break
except (
sqlalchemy.exc.OperationalError,
sqlalchemy.exc.IntegrityError,
) as e:
logger.warning(e)
sleep(5)
logger.debug("Connection to SQL database '{}' successful".format(db))
super(SQLTrackerStore, self).__init__(domain, event_broker)
def retrieve(self, sender_id: Text) -> Optional[DialogueStateTracker]:
"""Create a tracker from all previously stored events."""
conversation_date = (ttime() - 180) ## 180 = 3 minutes
query = self.session.query(self.SQLEvent)
result = query.filter(self.SQLEvent.sender_id == sender_id).all()
events = [json.loads(event.data) for event in result]
if self.domain and len(events) > 0:
logger.debug("Recreating tracker from sender id '{}'".format(sender_id))
return DialogueStateTracker.from_dict(sender_id, events, self.domain.slots)
else:
logger.debug(
"Can't retrieve tracker matching"
"sender id '{}' and min timestamp '{}' from SQL storage. "
"Returning `None` instead.".format(sender_id, conversation_date)
)
return None
I’m starting the bot with (in a MakeFile in root directory) with : rasa run --cors "**" --endpoints endpoints.yml --debug --enable-api