Skip to content

Version 1.3

Choose a tag to compare

@skito skito released this 25 Jun 15:08
· 16 commits to main since this release

Changes summary

  • Added human message 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 executionTime stat to Thread usage.
  • 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-pro
  • google-gemini-2.5-flash
  • openai-gpt-4.5-preview
  • openai-gpt-3.5-turbo // old but gold