monitoring_db#
- class besser.agent.db.monitoring_db.MonitoringDB[source]#
Bases:
object
This class is an interface to connect to a database where user interactions with the agent are stored to monitor the agent for later analysis.
- conn#
The connection to the monitoring database
- Type:
sqlalchemy.Connection
- connect_to_db(agent)[source]#
Connect to the monitoring database.
- Parameters:
agent (Agent) – The agent 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:
- insert_chat(session, message)[source]#
Insert a new record into the chat table of the monitoring database.
- insert_event(session, event)[source]#
Insert a new record into the event table of the monitoring database.
- insert_intent_prediction(session, state, predicted_intent)[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
state (State) – the state where the intent prediction took place (the session’s current state may have changed since the intent prediction, so we need it as argument)
predicted_intent (IntentClassifierPrediction) – the intent prediction
- 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_chat(session, n)[source]#
Retrieves a conversation history from the chat table of the database.
- Parameters:
- Returns:
the session record, should be a 1 row DataFrame
- Return type:
- besser.agent.db.monitoring_db.TABLE_CHAT = 'chat'#
The name of the database table that contains the chat records
- besser.agent.db.monitoring_db.TABLE_EVENT = 'event'#
The name of the database table that contains the event records
- besser.agent.db.monitoring_db.TABLE_INTENT_PREDICTION = 'intent_prediction'#
The name of the database table that contains the intent prediction records
- besser.agent.db.monitoring_db.TABLE_PARAMETER = 'parameter'#
The name of the database table that contains the parameter records
- besser.agent.db.monitoring_db.TABLE_SESSION = 'session'#
The name of the database table that contains the session records
- besser.agent.db.monitoring_db.TABLE_TRANSITION = 'transition'#
The name of the database table that contains the transition records