service.inclass.main module

class service.inclass.main.INCLASS_SERVICE[source]

Bases: object

A service class for handling in-class session. It has four main methods: - trigger: Triggers an in-class session by processing user input and updating the session state. - launch_worker: Launches a worker that listens to a RabbitMQ queue and processes session jobs. - get_status: Retrieves the current status of a given in-class session. - get_updates: Retrieves updates for a given in-class session. (NOT IMPLEMENTED YET)

collection = Collection(Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'inclass'), 'session')
static get_status(session_id=<class 'str'>)[source]

Retrieves the current status of a given in-class session.

Parameters:

session_id (str) – The unique identifier for the session.

Returns:

A JSON string representation of the session status or an error message if not found.

Return type:

str

static get_updates()[source]
static launch_worker()[source]

Launches a worker that listens to a RabbitMQ queue and processes session jobs.

Continuously consumes tasks from a RabbitMQ queue, executes in-class session logic, and manages session state based on interaction and generation outcomes.

Returns:

None

logger = <Logger service.inclass.main (INFO)>
queue_name = 'inclass-main'
static trigger(session_id, user_input='', parent_service='', parent_job_id=None)[source]

Triggers an in-class session by processing user input and updating the session state.

Parameters:
  • session_id (str) – The unique identifier for the session.

  • user_input (str, optional) – The user input string or interactions. Defaults to an empty string.

  • parent_service (str, optional) – The parent service identifier.

  • parent_job_id (ObjectId, optional) – The parent job identifier for callback purposes.

Returns:

The session ID of the triggered session.

Return type:

str

class service.inclass.main.INCLASS_SERVICE_STATUS(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

Define the status of an in-class session.

Status: - TRIGGERED: the inclass worker is triggered in mongo - CLASS_ENDED: the inclass worker is finished - STREAMING: the inclass worker is waiting llms to generate - PROCESSED: the inclass worker is processed

CLASS_ENDED = 'class_ended'
PROCESSED = 'processed'
STREAMING = 'streaming'
TRIGGERED = 'triggered'
service.inclass.main.now(tz=None)

Returns new datetime object representing current time local to tz.

tz

Timezone object.

If no tz is specified, uses local timezone.