PHP code example of artisanpack-ui / ai

1. Go to this page and download the library: Download artisanpack-ui/ai 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/ */

    

artisanpack-ui / ai example snippets


use ArtisanPackUI\Ai\Facades\Ai;

Ai::/* ... */;

// or
ai()->/* ... */;

use ArtisanPackUI\Seo\Agents\MetaDescriptionAgent;

$suggestion = MetaDescriptionAgent::for( [
    'title' => $post->title,
    'body'  => $post->summary_or_body,
] )->run();

$post->update( [ 'meta_description' => $suggestion['meta_description'] ] );

addFilter( 'ap.ai.promptGenerated', function ( string $prompt, array $context ): string {
    return scrubPii( $prompt );
} );

addAction( 'ap.ai.responseReceived', function ( string $response, array $context ): void {
    Log::channel( 'ai-audit' )->info( 'model response', [
        'provider' => $context['provider'],
        'model'    => $context['model'],
        'bytes'    => strlen( $response ),
    ] );
} );

// config/artisanpack/ai.php
'features' => [
    'seo.suggest_meta_description' => [
        'model' => 'qwen2.5:7b',       // pin a smarter model
    ],
],