Local
Plugin for handling local history managemnet.
- class LocalHistory(config)[source]
Class meant to manage the conversation history locally.
Default constructor for class
- Parameters:
config (Config) – Configuration class
- _abc_impl = <_abc._abc_data object>
- _initialize_database()[source]
Initialize the database connection and create tables if needed.
- Return type:
DatabaseManager- Returns:
A new instance of the database.
- Return type:
Database
- Raises:
MissingHistoryFileError – If the database cannot be initialized properly.
- clear(user_id)[source]
Clear the database by dropping and recreating tables.
- clear_from_chat(user_id, from_chat)[source]
Clear the database by dropping and recreating tables.
- read(user_id)[source]
Reads the history from the database.
- read_from_chat(user_id, from_chat)[source]
Reads the history from the database.
- Return type:
Optional[HistoryModel]- Parameters:
- Returns:
An optional single history entry
- Return type:
Optional[HistoryModel]
- Raises:
CorruptedHistoryError – Raised when there’s an error reading from the database.
MissingHistoryFileError – Raised when the database file is missing.
- write(chat_id, user_id, query, response)[source]
Write history to the database.
- Return type:
- Parameters:
- Raises:
CorruptedHistoryError – Raised when there’s an error writing to the database.
MissingHistoryFileError – Raised when the database file is missing.