Session Manager
Conversation session management with SQLite storage.
- folderbot.session_manager.validate_topic_name(name)[source]
Normalize and validate a topic name.
Converts to lowercase, replaces spaces/hyphens with underscores, strips non-allowed characters, and validates the result.
Raises ValueError if the result is empty after normalization.
- class folderbot.session_manager.TopicReassignment[source]
Bases:
objectA single topic reassignment instruction.
- class folderbot.session_manager.TokenUsageRecord[source]
Bases:
objectA single token usage record.
- class folderbot.session_manager.SessionManager[source]
Bases:
objectManages conversation history in SQLite.
- get_history(user_id, topic=None)[source]
Get conversation history for a user, optionally filtered by topic.
- add_message(user_id, role, content, topic='general')[source]
Add a message to the conversation history.
- update_message_topics(user_id, reassignments)[source]
Bulk-update topic labels on messages by index.
Returns the number of messages actually updated. Raises ValueError if any topic name is invalid or index is out of bounds.
- Return type:
- Parameters:
user_id (int)
reassignments (list[TopicReassignment])
- set_last_notified_version(user_id, version)[source]
Set the last version the user was notified about.
- get_file_notifications_enabled(user_id)[source]
Check if file notifications are enabled for a user.
- set_file_notifications_enabled(user_id, enabled)[source]
Enable or disable file notifications for a user.
- save_upload(user_id, original_filename, hash_filename, extension, file_size, mime_type='application/pdf')[source]
Save upload metadata to the database.
- get_upload_by_id(upload_id, user_id)[source]
Get a single upload by ID, scoped to a user.
- Return type:
- Parameters:
- delete_upload(upload_id, user_id)[source]
Delete an upload record. Returns True if a row was deleted.