maeser.chat.chat_session_manager module#

Module for managing chat sessions and interactions with multiple chat interfaces.

class maeser.chat.chat_session_manager.ChatSessionManager(chat_logs_manager: BaseChatLogsManager | None = None)[source]#

Bases: object

Manages and directs sessions for multiple chat interfaces.

Parameters:

chat_logs_manager (BaseChatLogsManager | None) – The chat logs manager to use for logging chat data. This can be a ChatLogsManager object or a custom chat logs manager that inherits from BaseChatLogsManager.

Returns:

None

add_feedback(branch_name: str, session_id: str, message_index: int, feedback: str) None[source]#

Adds feedback to the log for a specific response in a specific session.

Parameters:
  • branch_name (str) – The name of the branch.

  • session_id (str) – The session ID for the conversation.

  • message_index (int) – The index of the message to add feedback to.

  • feedback (str) – The feedback to add to the message.

Returns:

None

ask_question(message: str, branch_name: str, sess_id: str) dict[source]#

Asks a question in a specific session of a branch.

Parameters:
  • message (str) – The question to ask.

  • branch_name (str) – The chat branch to ask the question in.

  • sess_id (str) – The session ID to ask the question in.

Returns:

The response to the question.

Return type:

dict

property branches: dict#

The list of branches available for chat.

Type:

dict

property chat_log_path: str | None#

The path to the logs directory.

Type:

str | None

get_conversation_history(branch_name: str, session_id: str) dict[source]#

Gets the conversation history for a specific session in a specific branch.

Parameters:
  • branch_name (str) – The action of the branch to get the conversation history from.

  • session_id (str) – The session ID to get the conversation history from.

Returns:

The conversation history for the session.

Return type:

dict

get_new_session_id(branch_name: str, user: User | None = None) str[source]#

Creates a new chat session for the given branch and user. Includes creating a new log file for the session.

If no user is provided, “anon” will be used in place of authenticator.user_id.

Parameters:
  • branch_name (str) – The action of the branch to create a session for.

  • user (User | None) – The user to create the session for.

Returns:

The session ID for the new session.

Return type:

str

register_branch(branch_name: str, branch_label: str, graph: langgraph.graph.graph.CompiledGraph) None[source]#

Registers a new chat branch with its name, label, and compiled RAG graph.

See maeser.graphs for built-in RAG graphs.

Parameters:
  • branch_name (str) – The name of the branch.

  • branch_label (str) – The label of the branch.

  • graph (CompiledGraph) – The compiled RAG graph for the branch.

Returns:

None