PHP code example of ultimate-multisite / ai-agent
1. Go to this page and download the library: Download ultimate-multisite/ai-agent library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ultimate-multisite / ai-agent example snippets
define( 'SD_AI_AGENT_CLOUD_BASE_URL', 'http://127.0.0.1:3000/v1' );
add_filter(
'sd_ai_agent_customer_agent_integrations',
static function( array $integrations ): array {
$integrations['ultimate-multisite-support-tickets'] = array(
'enabled' => true,
'profile' => 'support-customer',
'system_instruction' => 'Answer customers only from the approved support knowledge base.',
'abilities' => array( 'sd-ai-agent/knowledge-search' ),
'collections' => array( 'support-docs' ),
'provider_id' => '', // Uses the server default when empty.
'model_id' => '',
'max_message_length' => 4000,
'max_history_turns' => 8,
'max_iterations' => 6,
'max_runtime_seconds' => 120,
);
return $integrations;
}
);
$runtime = sd_ai_agent_customer_agent_runtime();
$caps = $runtime->discover_capabilities();
if ( version_compare( $caps['contract_version'], '1.0.0', '<' ) ) {
return;
}
$conversation = $runtime->create_or_recover_conversation(
'ultimate-multisite-support-tickets',
$external_session_id
);
$job = $runtime->enqueue_turn(
'ultimate-multisite-support-tickets',
$external_session_id,
$external_message_id,
$customer_message
);
add_action( 'wp_abilities_api_init', function() {
wp_register_ability( 'my_custom_tool', [
'label' => 'My Custom Tool',
'description' => 'Does something useful',
'category' => 'my-plugin',
'callback' => 'my_tool_callback',
'schema' => [
'type' => 'object',
'properties' => [
'param' => [ 'type' => 'string', 'description' => 'A parameter' ],
],
],
] );
} );
add_filter( 'ai_agent_context_providers', function( $providers ) {
$providers[] = [
'label' => 'My Plugin Context',
'priority' => 10,
'callback' => function() {
return "Current inventory count: " . get_inventory_count();
},
];
return $providers;
} );