Limekiller / moodle-block_openai_chat

An AI chat block for Moodle, powered by GPT
https://moodle.org/plugins/block_openai_chat
GNU General Public License v3.0
29 stars 18 forks source link

Add support for Moodle filters #25

Closed michael-milette closed 10 months ago

michael-milette commented 1 year ago

Good day,

Could you please pass the Source of Truth, User Name and Assistant Name fields through Moodle Filters?

Why? This will make it possible to do some pretty cool things without having to know a lot about making the block Moodle or course aware. Here are a few examples:

ASSISTANT'S NAME: Enabling customized language on multi-language sites using the Multi-Language (v2) plugin's plain text {mlang} tags. It will then be possible to have the Assistant called "Assistant" in English and "Asistente" in Spanish by setting the Assistant's name to:

{mlang en}Assistant{mlang}{mlang es}Asistente{mlang}

USER'S NAME: Something similar can be done for the user's name with the FilterCodes plugin installed. I the following example, the user's first name would appear as "Jack" if Jack was logged in, or "Guest" when he is not:

{ifloggedin}{firstname}{/ifloggedin}{ifnotloggedin}Guest{/ifnotloggedin}

Replacing {firstname} with {fullname} will display "Jack Richer" instead of just Jack.

COURSE, SITE and USER INFORMATION: Include information about the site or the course in the Source of Truth. For example, using the course name {coursename} tag from FilterCodes, OpenAI would understand the subject of the course, like "Moodle for Beginners" which would help it answer questions in that context. If on the Dashboard, Home page or other system context, this tag returns the site name. Example:

The name of this {ifincourse}course{/ifincourse}{ifnotincourse}site{/ifnotincourse} is {coursename}.

OpenAI can also become aware of the user's name by adding something like the following line to the Source of Truth when used with FilterCodes tags:

My name is {firstname} and I live in {city}, {country}.

These are just a few examples of the many possibilities by passing the Source of Truth, Assistant and User name fields through Moodle output API filters.

A PR will be coming shortly for the release-1.7 branch.

Best regards,

Michael Milette