Assembling the prompt
Before each request to the AI model API, the system prompt is assembled dynamically by fetching static instructions from a JSON file, and contextual information from the database. The static part defines role, task and rules, while the dynamic part contains information specific to the current user and the current sequence in the lecture. It is formatted as Markdown before being sent to the model.
The response
The response from the AI model contains a text response, a boolean indicating whether the user has broken the guidelines, and a boolean indicating whether the user has met the criterion for the current sequence. The response and the indicator for met criteria are saved in the database before the answer is sent back to the client.
Progression
When progression is indicated, the current sequence is updated in the database, which means the next request automatically fetches contextual information for the next sequence. This limits the information in the context window to only what is relevant for the current sequence, while progression is handled automatically by the API. Responsibility for structure and coordination lies with the API, not the model, to guarantee that the correct structure is followed.