service.inclass.functions.askQuestion module
- class service.inclass.functions.askQuestion.AskQuestion[source]
Bases:
Function
Implementation For askQuestion function on the student-end. Each askQuestion consists of a question that must be asked to the student.
- static async_call_director(classroom_session, history, agent_list, ban_end_sequence, **kwargs)[source]
Initiates a call to the director to determine the next actor in the conversation based on the roles and history.
- Parameters:
classroom_session (ClassroomSession) – The classroom session object for managing interactions.
history (list) – The conversation history to use as context.
agent_list (list) – List of agents eligible to respond.
ban_end_sequence (bool) – Whether to disallow special end-sequence roles.
- Returns:
The job object containing details of the call to the director.
- Return type:
dict
- static format_history(message, agent_dict)[source]
Formats a message’s history for logging purposes.
- Parameters:
message (dict) – The message containing content and actor information.
agent_dict (dict) – A mapping of agent IDs to their names.
- Returns:
A formatted string representing the message’s actor and content.
- Return type:
str
- static format_history_for_agent(message, agent_dict)[source]
Formats a message history for presenting to an agent.
- Parameters:
message (dict) – The message containing content and actor information.
agent_dict (dict) – A mapping of agent IDs to their names.
- Returns:
A formatted string for the agent, with actor and content details.
- Return type:
str
- static format_question(value, with_answer=True)[source]
Formats the question based on the question type (multiple choice or single choice).
- Parameters:
value (dict) – Contains question details such as type, text, options, and answer.
with_answer (bool, optional) – Whether to include the correct answer in the output. Defaults to True.
- Returns:
The formatted question string. str (optional): The correct answer, if with_answer is True.
- Return type:
str
- static format_question_obj(value, with_answer=True)[source]
Formats a question object, optionally excluding fields such as ‘answer’ and ‘analysis’.
- Parameters:
value (dict) – The question object to format.
with_answer (bool, optional) – Whether to include fields such as ‘answer’ and ‘analysis’. Defaults to True.
- Returns:
The formatted question object with added ‘pure_text’ field.
- Return type:
dict
- static get_agent_id2name_dict(classroom_session, agent_list)[source]
Creates a dictionary mapping agent IDs to their names.
- Parameters:
classroom_session (ClassroomSession) – The classroom session to query agent details.
agent_list (list) – A list of agent IDs.
- Returns:
A dictionary mapping agent IDs to their names.
- Return type:
dict
- static get_agent_name_by_id(agent_id, classroom_session)[source]
Retrieves the name of an agent by their ID.
- Parameters:
agent_id (str or ObjectId) – The ID of the agent.
classroom_session (ClassroomSession) – The classroom session to query agent details.
- Returns:
The name of the agent.
- Return type:
str
- static get_agent_role(agent_id, classroom_session)[source]
Retrieves the role and identity of an agent.
- ROLE:
“user”: the real human student. Role: the whole classroom’s purpose is to teach the student the knowledge in the classroom.
“小刘老师” or “小詹老师”: AI teachers. Role: responsible for teaching and answering students’ questions.
“助教”: AI teaching assistants. Role: responsible for maintaining the classroom order, when students are speaking out of topic or trying to deviate from the course’s theme, the assistant will stand up to maintain the classroom’s discipline.
“显眼包”: AI students. Role: Class Clown: Crafted to spark creativity, engender a lively classroom ambiance, and act as a supportive peer, this agent also assists the teacher in steering the class’s focus when the learner’s attention wanders.
“好奇宝宝”: AI students. Role: Inquisitive Mind: Characterized by a propensity for inquiring about lecture content, this agent fosters a culture of inquiry and dialogue, prompting others to engage in critical thinking and collaborative discourse.
“笔记员”: AI students. Role: Note Taker: With a penchant for summarizing and disseminating key points from the class discussions, this agent aids in the cognitive organization and retention of information for all participants.
“思考者”: AI students. Role: Deep Thinker: This agent is dedicated to profound contemplation and to posing thoughtprovoking questions that challenge and extend the intellectual boundaries of the classroom.
- Parameters:
agent_id (str) – The ID of the agent.
classroom_session (ClassroomSession) – The classroom session to query agent details.
- Returns:
A dictionary containing the agent’s identity and role description.
- Return type:
dict
- init_status = {'agent_talked': False, 'force_agent': False, 'llm_job_id': None, 'phase': -1, 'student_answer': '', 'student_answer_correct': False}
- static is_agent_ta(agent_id, classroom_session)[source]
Checks if the given agent is a teaching assistant (TA).
- Parameters:
agent_id (str or ObjectId) – The ID of the agent to check.
classroom_session (ClassroomSession) – The classroom session to query agent details.
- Returns:
True if the agent is a TA, False otherwise.
- Return type:
bool
- static is_agent_teacher(agent_id, classroom_session)[source]
Checks if the given agent is a teacher.
- Parameters:
agent_id (str or ObjectId) – The ID of the agent to check.
classroom_session (ClassroomSession) – The classroom session to query agent details.
- Returns:
True if the agent is a teacher, False otherwise.
- Return type:
bool
- static step(value, function_id, classroom_session)[source]
Handles the step-wise execution of the AskQuestion function, transitioning between phases like question preparation, presenting the question, evaluating the student’s answer, and concluding with feedback.
- Phases:
NEED_TRANSFORM_SENTENCE: The question needs to be transformed.
NOT_ASKED: The question has not been asked yet.
WAITING_STUDENT_ANSWER: Waiting for an answer from the student.
FORCE_CALL_TEACHER_BEFORE_RETURN: Forces a call to the teacher to check the student’s answer.
WAIT_FINISH: Waiting for the finish signal.
TEACHER_RESPONSE_FINISHED: Indicates the teacher’s response has finished.
- Parameters:
value (dict) – The question data, including type, options, and answer.
function_id (str) – The unique identifier for the current function.
classroom_session (ClassroomSession) – The classroom session object to interact with the student and agents.
- Returns:
Whether the function is ready to move to the next step.
- Return type:
bool
- class service.inclass.functions.askQuestion.AskQuestionAgentNameConst[source]
Bases:
object
Define the agent names used in the AskQuestion function.
- END_SEQUENCE_NAME = 'PPT翻页员'
- USER_NAME = '真人学生'
- class service.inclass.functions.askQuestion.AskQuestionStatus[source]
Bases:
object
Enumeration class representing the status of asking a question.
- States:
NEED_TRANSFORM_SENTENCE (-1): Indicates that the sentence needs to be transformed.
NOT_ASKED (0): The question has not been asked yet.
WAITING_STUDENT_ANSWER (1): Waiting for an answer from the student.
CHECKING_DID_STUDENT_ANSWER (2): Checking if the student has answered. If not answered, transitions to WAITING_STUDENT_ANSWER. If answered, transitions to NEED_CALL_DIRECTOR.
WAITING_USER_INPUT (3): Waiting for input from the user after the question has been answered.
NEED_CALL_DIRECTOR (4): Indicates that it’s time to call the director.
WAITING_DIRECTOR_RETURN (5): Waiting for the director’s return.
FINISHED (9): Indicates the process is finished.
CONTINUE_FINISHED (10): Finished in “continue mode.”
DIRECTOR_NOT_FOUND_FINISHED (20): Indicates an error where the director was not found.
FORCE_CALL_TEACHER_BEFORE_RETURN (21): Forces a call to the teacher before returning.
WAIT_FINISH (22): Waiting for the finish signal.
TEACHER_RESPONSE_FINISHED (23): Indicates the teacher’s response has finished.
- CHECKING_DID_STUDENT_ANSWER = 2
- CONTINUE_FINISHED = 10
- DIRECTOR_NOT_FOUND_FINISHED = 20
- FINISHED = 9
- FORCE_CALL_TEACHER_BEFORE_RETURN = 21
- NEED_CALL_DIRECTOR = 4
- NEED_TRANSFORM_SENTENCE = -1
- NOT_ASKED = 0
- TEACHER_RESPONSE_FINISHED = 23
- WAITING_DIRECTOR_RETURN = 5
- WAITING_STUDENT_ANSWER = 1
- WAITING_USER_INPUT = 3
- WAIT_FINISH = 22