PHP code example of sistemas-eel / agente-ia-client

1. Go to this page and download the library: Download sistemas-eel/agente-ia-client 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/ */

    

sistemas-eel / agente-ia-client example snippets


use SistemasEel\AgenteIaClient\Agente\TokenValidator;

$validator = new TokenValidator([
    'introspection_endpoint' => getenv('AGENTE_INTROSPECTION_ENDPOINT'), // URL que confirma se o token recebido é válido e ativo
    'client_id' => getenv('AGENTE_CLIENT_ID'),
    'client_secret' => getenv('AGENTE_CLIENT_SECRET'),
    '

use App\Http\Controllers\Agente\ConsultarDocumentosController;
use App\Http\Controllers\Agente\CriarSolicitacaoController;
use Illuminate\Support\Facades\Route;

Route::post('/agente/documentos/consultar', ConsultarDocumentosController::class);
Route::post('/agente/solicitacoes/criar', CriarSolicitacaoController::class);

use App\Agente\ConsultarDocumentosHandler;
use Illuminate\Http\Request;
use SistemasEel\AgenteIaClient\Agente\Laravel\LaravelAgenteEndpoint;

class ConsultarDocumentosController
{
    public function __invoke(
        Request $request,
        LaravelAgenteEndpoint $endpoint,
        ConsultarDocumentosHandler $handler
    ) {
        return $endpoint->handle($request, $handler, [
            ['chave' => 'termo', 'tipo' => 'string', 'obrigatorio' => false],
            ['chave' => 'limite', 'tipo' => 'integer', 'obrigatorio' => false],
        ], 'consultar');
    }
}



return [
    'introspection_endpoint' => getenv('AGENTE_INTROSPECTION_ENDPOINT') ?: '',
    'client_id' => getenv('AGENTE_CLIENT_ID') ?: '',
    'client_secret' => getenv('AGENTE_CLIENT_SECRET') ?: '',
    '=> 'string', 'obrigatorio' => false],
        ['chave' => 'limite', 'tipo' => 'integer', 'obrigatorio' => false],
    ],
];



$config =  = agente_guard_http_request();

$response = agente_execute_handler(
    $handler,
    array_merge($config, ['request_id' => $requestId]),
    $requestId
);

agente_emit_response($response, $requestId);

[
    'status' => 200,
    'body' => [
        'protocolo' => 'DOCUMENTOS-CONSULTA',
        'resposta_direta' => 'Encontrei 2 documento(s).',
    ],
]

[
    ['chave' => 'termo', 'tipo' => 'string', 'obrigatorio' => false],
    ['chave' => 'limite', 'tipo' => 'integer', 'obrigatorio' => false],
    ['chave' => 'prioridade', 'tipo' => 'enum', 'obrigatorio' => false, 'opcoes' => ['baixa', 'media', 'alta']],
]
bash
php artisan vendor:publish --tag=agente-ia-config