maeser.controllers.chat_interface module#
Module for handling chat interface rendering.
This module contains a function to render the chat interface template with relevant data.
© 2024 Blaine Freestone, Carson Bush
This file is part of Maeser.
Maeser is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Maeser is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with Maeser. If not, see <https://www.gnu.org/licenses/>.
- maeser.controllers.chat_interface.controller(chat_sessions_manager: ChatSessionManager, max_requests: int | None = None, rate_limit_interval: int | None = None, current_user=None, app_name: str | None = None, main_logo_light: str | None = None, main_logo_dark: str | None = None, chat_head: str | None = None, favicon: str | None = None)[source]#
Renders the chat interface template with relevant data.
- Parameters:
chat_sessions_manager (ChatSessionManager) – The chat session manager object.
max_requests (int, optional) – The maximum number of requests a user can make. Defaults to None.
rate_limit_interval (int, optional) – The interval in seconds for rate limiting requests. Defaults to None.
current_user (object, optional) – The current user object. Defaults to None.
- Returns:
conversation: None (no active conversation)
buttons: The dictionary of available chat branches
links: A list of dictionaries representing previous chat sessions for the current user
requests_remaining: The number of requests remaining for the current user (10 if current_user is None)
max_requests_remaining: The maximum number of requests allowed
requests_remaining_interval_ms: The interval in milliseconds for rate limiting requests (rate_limit_interval * 1000 / 3)
- Return type:
The rendered ‘chat_interface.html’ template with the following data