service.inclass.classroom_session module

class service.inclass.classroom_session.AgentType[source]

Bases: object

SCRIPT = '9'
TEACHER = '6'
class service.inclass.classroom_session.ClassroomSession(session_id)[source]

Bases: object

A class representing a classroom session.

add_user_message(content, user_action='chat')[source]

Adds a user message to the session’s chat history.

Parameters:
  • content (dict) – The content of the user’s message.

  • user_action (str) – The user’s action (optional).

Returns:

None

check_llm_job_done(task_id)[source]

Checks if an LLM job has completed.

Parameters:

task_id (str) – The task ID for the job.

Returns:

True if the job is done, False otherwise.

Return type:

bool

clear_session()[source]

Clears the session data from the chat action flow and function session databases.

Returns:

None

copy_current_session()[source]
Return type:

str

disable_user_input(function_id)[source]

Disables user input for the current session.

Parameters:

function_id (str) – The function ID associated with disabling input.

Returns:

None

enable_user_input(function_id)[source]

Enables user input for the current session.

Parameters:

function_id (str) – The function ID associated with enabling input.

Returns:

None

force_user_input(function_id)[source]

Forces the user input to be enabled for the current session.

Parameters:

function_id (str) – The function ID associated with forcing input.

Returns:

None

get_action_history(max_return=12, action_type='speak')[source]

Retrieves the action history for the session.

Parameters:
  • max_return (int) – Maximum number of messages to return (default is 12).

  • action_type (str) – The action type to filter the messages by (default is ‘speak’).

Returns:

A list of message actions from the chat action flow.

Return type:

list

get_activation()[source]

Retrieves the current activation state for the session.

Returns:

The activation state (‘middle’ by default).

Return type:

str

get_agent_by_id(agent_id)[source]

Retrieves an agent by its ID.

Parameters:

agent_id (str) – The agent ID to search for.

Returns:

A dictionary containing agent information.

Return type:

dict

get_agent_list()[source]

Retrieves a list of agents associated with the session.

Returns:

A list of agent IDs.

Return type:

list

get_all_agenda_of_section_by_lecture(lecture_id, parent_agenda_id)[source]

Retrieves all agenda items of a section by lecture using DFS.

Parameters:
  • lecture_id (str) – The lecture ID to search for.

  • parent_agenda_id (str) – The parent agenda ID to search for.

Returns:

A list of agenda items.

Return type:

list

get_current_function()[source]

Retrieves the current function for the session.

Returns:

The current function’s details.

Return type:

dict

get_history(action_type='speak', max_return=12)[source]

Retrieves the chat history for the session.

Parameters:
  • action_type (str) – The action type to filter the messages by (default is ‘speak’).

  • max_return (int) – The maximum number of messages to return (default is 12).

Returns:

A list of messages based on the action type.

Return type:

list

get_llm_job_response(task_id)[source]

Retrieves the response from a completed LLM job.

Parameters:

task_id (str) – The task ID for the job.

Returns:

The job’s response, or None if the job is not completed.

Return type:

str | None

get_teacher_agent_id()[source]

Retrieves the agent ID of the teacher for the session.

Returns:

The agent ID of the teacher.

Return type:

str

Raises:

Exception – If the teacher agent is not found.

get_user_input_status()[source]

Retrieves the current status of user input (enabled, disabled, or forced).

Returns:

The current user input status (‘enabled’, ‘disabled’, or ‘forced’).

Return type:

str

is_streaming()[source]

Checks if the session is currently streaming a response.

Returns:

True if the session is streaming, False otherwise.

Return type:

bool

load_next_agenda()[source]

Loads the next agenda item for the session.

Returns:

None

push_llm_job_to_list(request, try_list=None)[source]

Pushes an LLM job to the job list for execution.

Parameters:
  • request (dict) – The request data for the LLM job.

  • try_list (list) – The list of models to try (default is [‘glm-4’]).

Returns:

The job ID for the submitted LLM job.

Return type:

str

reset_displayed_file(value, function_id)[source]

Resets the displayed file content in the session.

Parameters:
  • value (str) – The content to display.

  • function_id (str) – The function ID for the action.

Returns:

None

send_answer_to_message(function_id, content, speaker_id)[source]

Sends an answer message to the chat action flow.

Parameters:
  • function_id (str) – The function ID associated with the answer.

  • content (dict) – The answer content.

  • speaker_id (str) – The speaker’s agent ID.

Returns:

None

send_function_to_message(function_id, speaker_id, content, action)[source]

Sends a function-specific message to the chat action flow.

Parameters:
  • function_id (str) – The function ID associated with the action.

  • speaker_id (str) – The speaker’s agent ID.

  • content (dict) – The content for the function.

  • action (str) – The action type (question, answer, etc.).

Returns:

None

send_markdown_message(function_id, message, speaker_id)[source]

Sends a markdown formatted message to the chat action flow.

Parameters:
  • function_id (str) – The function ID associated with the message.

  • message (str) – The markdown formatted message.

  • speaker_id (str) – The speaker’s agent ID.

Returns:

None

send_question_to_message(function_id, content, speaker_id)[source]

Sends a question message to the chat action flow.

Parameters:
  • function_id (str) – The function ID associated with the question.

  • content (dict) – The question content.

  • speaker_id (str) – The speaker’s agent ID.

Returns:

None

send_script_to_message(function_id, value, speaker_id)[source]

Sends a script message to the chat action flow.

Parameters:
  • function_id (str) – The function ID associated with the script.

  • value (dict) – The script content.

  • speaker_id (str) – The speaker’s agent ID.

Returns:

None

send_streamed_model_request(function_id, request, speaker_id, try_list)[source]

Sends a streamed model request to the system.

Parameters:
  • function_id (str) – The function ID associated with the request.

  • request (dict) – The request data to send.

  • speaker_id (str) – The speaker’s agent ID.

  • try_list (list) – The list of models to attempt for streaming.

Returns:

None

session_info()[source]

Retrieves session information from the database.

Returns:

A dictionary containing session information.

Return type:

dict

set_step_id()[source]

Sets the step ID for the current session based on the latest action.

Returns:

None

to_next_function()[source]

Marks the current function as done and proceeds to the next function in the session.

Returns:

None

update_function_status(function_id, status)[source]

Updates the status of a function in the session.

Parameters:
  • function_id (str) – The function ID to update.

  • status (dict) – The new status to set for the function.

Returns:

None