monitoring_db#

class besser.bot.db.monitoring_db.MonitoringDB[source]#

Bases: object

This class is an interface to connect to a database where user interactions with the bot are stored to monitor the bot for later analysis.

conn#

The connection to the monitoring database

Type:

sqlalchemy.Connection

connected#

Whether there is an active connection to the monitoring database or not

Type:

bool

close_connection()[source]#

Close the connection to the monitoring database

connect_to_db(bot)[source]#

Connect to the monitoring database.

Parameters:

bot (Bot) – The bot that contains the database-related properties.

get_table(table_name)[source]#

Gets all the content of a database table (i.e., SELECT * FROM table_name).

Parameters:

table_name – the name of the table

Returns:

the table in a dataframe

Return type:

pandas.DataFrame

initialize_db()[source]#

Initialize the monitoring database, creating the tables if necessary.

insert_intent_prediction(session)[source]#

Insert a new intent prediction record into the intent predictions table of the monitoring database.

Parameters:

session (Session) – the session containing the predicted intent to insert into the database

insert_session(session)[source]#

Insert a new session record into the sessions table of the monitoring database.

Parameters:

session (Session) – the session to insert into the database

insert_transition(session, transition)[source]#

Insert a new transition record into the transitions table of the monitoring database.

Parameters:
  • session (Session) – the session the transition belongs to

  • transition (Transition) – the transition to insert into the database

run_statement(stmt)[source]#

Executes a SQL statement.

Parameters:

stmt (sqlalchemy.Executable) – the SQL statement

Returns:

the result of the SQL statement

Return type:

sqlalchemy.CursorResult[Any] | None

select_session(session)[source]#

Retrieves a session record from the sessions table of the database.

Parameters:

session (Session) – the session to get from the database

Returns:

the session record, should be a 1 row DataFrame

Return type:

pandas.DataFrame

besser.bot.db.monitoring_db.TABLE_INTENT_PREDICTION = 'intent_prediction'#

The name of the database table that contains the intent prediction records

besser.bot.db.monitoring_db.TABLE_PARAMETER = 'parameter'#

The name of the database table that contains the parameter records

besser.bot.db.monitoring_db.TABLE_SESSION = 'session'#

The name of the database table that contains the session records

besser.bot.db.monitoring_db.TABLE_TRANSITION = 'transition'#

The name of the database table that contains the transition records