PHP code example of promptphp / intercept-injection-guard
1. Go to this page and download the library: Download promptphp/intercept-injection-guard 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/ */
promptphp / intercept-injection-guard example snippets
declare(strict_types=1);
namespace App\Ai\Agents;
use Laravel\Ai\Contracts\Agent;
use Laravel\Ai\Contracts\HasMiddleware;
use Laravel\Ai\Promptable;
use PromptPHP\Intercept\InjectionGuard\PromptInjectionGuard;
use Stringable;
class SupportAgent implements Agent, HasMiddleware
{
use Promptable;
public function instructions(): Stringable|string
{
return 'You are a helpful support assistant.';
}
public function middleware(): array
{
return [
new PromptInjectionGuard,
];
}
}
public function middleware(): array
{
return [
new PromptInjectionGuard(
action: 'block',
),
];
}
sh
php artisan vendor:publish --tag=intercept-config
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.