I see there is mxchat_prepare_context filter I could maybe use
Hi @samymsa,
Yes you can pass dynamic data via that filter. Here is an example you can add to your functions.php file:
add_filter('mxchat_prepare_context', function($context, $session_id) {
$today = date('F j, Y');
$time = date('g:i A');
$timezone = wp_timezone_string(); // WordPress configured timezone
$dynamic_info = "The current date/time is {$today} at {$time} ({$timezone}). Note: This is the server time, not necessarily the user's local time.\n\n";
return $dynamic_info . $context;
}, 10, 2);
This filter was actually meant for this exact purpose! I never did fully roll it out publicly, it’s somewhat of a hidden gem. I will work on getting an entire page up for it within the next week or two and update the readme, but I did make this page a few months back which talks about it some.
I’ll try this, thanks for your quick answer!
Hi Maxwell,
Following up our conversation, would it be possible for you to add a hook that allows to alter the system_prompt_instructions, or maybe simpler to allow shortcodes inside the system prompt (not into the current message context)?
This way we would be able to add dynamic data into the system prompt. I’m currently forced to use a mu-plugin and hook into the get_options, which is not ideal.
Best,
Samy
Closing this topic and opening a dedicated one about dynamic data / shortcodes inside system prompt.
Thanks again for you support @m4xw3ll !