Version 1.3
Changes summary
- Added
humanmessage role for human-in-the-loop scenarios - Triggering custom callbacks after remote message is received. Usefull for hooking thread moderation functions.
- Dynamic enabling and disabling tools. For scenarios where tools must be temporary disabled while executing the tread. Example: when prompt injection is detected.
- Method for retrieving last tool result.
- Added
executionTimestat toThreadusage. - Improved API communication
- Added new models
Triggering message callbacks
The code bellow will trigger custom callback function everytime message is added to the thread.
$thread->OnMessage(function($e) {
$thread = $e->thread ?? null;
$message = $e->message ?? null;
$usage = $e->usage ?? null;
$model = $e->model ?? $thread->GetModel();
});
// This will trigger the callback above
$thread->AddMessage(new \AIpi\Message('Hi!'));
// This will NOT trigger the callback above
$thread->AddMessage(new \AIpi\Message('Hi!'), ['runCallbacks' => false]);Enable/disable tools
// Temporary disable tools
$thread->DisableTools();
// ...some thread execution
// Enable tools
$thread->EnableTools();Retrieving last result from tools call
$toolResult = $thread->GetLastToolResult('SubmitEvaluation') ?? null;New models
API communication is improved plus some new models to the list:
google-gemini-2.5-progoogle-gemini-2.5-flashopenai-gpt-4.5-previewopenai-gpt-3.5-turbo// old but gold