Services Layer (services)¶
This package contains the business logic of the application, acting as an intermediary between the web routes and the backend data/AI layers.
Authentication Service¶
- class kusibot.services.auth_service.AuthService[source]¶
Service class for handling user authentication and registration.
- user_repository¶
Repository for user data access.
- Type:
- possible_login(identifier, password)[source]¶
Logs in a user with the given identifier and password.
- Parameters:
identifier (str) – The username or email of the user.
password (str) – The password of the user.
- Returns:
The authenticated user object if login is successful, otherwise None.
- Return type:
- register(username, email, password, is_professional=False)[source]¶
Registers a new user in KusiBot.
- Parameters:
username (str) – The username of the new user.
email (str) – The email of the new user.
password (str) – The password of the new user.
is_professional (bool) – Whether the user is a professional user or not.
Chatbot Service¶
- class kusibot.services.chatbot_service.ChatbotService[source]¶
Service class for handling chatbot interactions.
- conv_repo¶
Repository for conversation data access.
- Type:
- msg_repo¶
Repository for message data access.
- Type:
- assessment_repo¶
Repository for assessment data access.
- Type:
- user_agents¶
A dictionary to store and manage a unique Manager Agent instance for each active user session, mapping user_id to agent instance.
- Type:
dict
- _clear_user_agent(user_id)[source]¶
Clears the chatbot manager for the user, effectively resetting their state.
- Parameters:
user_id – ID of the user to clear the chatbot manager for.
- _get_or_create_chatbot_manager(user_id)[source]¶
Gets or creates a ChatbotManagerAgent for the user to handle chatbot interactions keeping user-specific state and conversation management.
- Parameters:
user_id – ID of the user to get or create the chatbot manager for.
- Returns:
The chatbot manager for the user.
- Return type:
- create_or_get_conversation(user_id)[source]¶
Creates a new conversation for the authenticated user or gets the current conversation.
- Parameters:
user_id – ID of the current user to retrieve or create the conversation from.
- Returns:
Array of JSON messages for the new/current conversation.
- Return type:
messages
Dashboard Service¶
- class kusibot.services.dashboard_service.DashboardService[source]¶
Service class for handling dashboards interactions.
- user_repo¶
Repository for user data access.
- Type:
- conv_repo¶
Repository for conversation data access.
- Type:
- msg_repo¶
Repository for message data access.
- Type:
- assessment_repo¶
Repository for assessment data access.
- Type:
- assesment_question_repo¶
Repository for assessment question data access.
- get_assessments_for_user(user_id)[source]¶
Retrieves assessments and their questions for a given user.
- Parameters:
user_id – The ID of the user for whom to retrieve assessments.
- Returns:
A dictionary containing the assessments and their questions.
- Return type:
dict
- get_chat_users()[source]¶
Retrieves a list of non-professional users for the dashboard.
- Returns:
A list of dictionaries containing user IDs and usernames.
- Return type:
list