-
Notifications
You must be signed in to change notification settings - Fork 531
Description
Using the new global chat feature, implement an AI chatbot using the "text" feature of AI providers (see #7281).
First, verify that the chatbot is disabled when taking any test (exercise tool, directly or from a learning path). To avoid duplicate tabs and having the user cheat by using two tabs, we'll store the situation of any user in its session, something like $_SESSION['is_in_a_test']. That flag is reset whenever the user lands on a test result page, or when the user logs out, and it is set whenever we land on a test page. There should be traces of similar code from Chamilo 1.
The chatbot should have a strict prompt focusing users on the topic of the course. The language, this being said, should be the user's language, not the course language (unless the user switches language). The system prompt should be kept to something like
"You are a digital tutor and mentor. You help me understand topics related to my courses, in this case '{course title}'. The course is in '{course language}' but just answer me in whatever language I talk to you. This is an educational use, so content that would not be appropriate for children (or minors under any law) is not acceptable. You are not available to me when I'm taking an exam, just in case I forget and I ask why you weren't there."
We'll improve this prompt as we go.
Once the global chat is enabled and the AI chatbot setting (tutor_chatbot) is enabled, an "AI tutor" contact appears in the global chat window. It's always online.
We want to preserve some history from the user conversation from one session to another, so ideally, if we have something in the AI API to give a user ID or something to recall previous context, that would be nice, but for now just ensuring we don't mix user chats should be enough (and mandatory).
To do that, apparently we need to store a conversation ID in Chamilo, and then sending that at the beginning of the conversation with "previous_id" or "conversation_id" or something like that, depending on the API.
This might also require the specific use of the "chat" endpoints rather than "responses" or "conversations".
This might become a very used feature in Chamilo, so we need to be careful.