@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Services\SyntheticAiAssessment;
|
||||
use Illuminate\Console\Command;
|
||||
use Throwable;
|
||||
|
||||
class SgcAiAssess extends Command
|
||||
{
|
||||
protected $signature = 'sgc:ai-assess {result : Ficheiro JSON UTF-8 do ensaio fictício}';
|
||||
|
||||
protected $description = 'Conferir localmente cobertura e referências de um resultado do ensaio, sem rede';
|
||||
|
||||
public function handle(SyntheticAiAssessment $assessment): int
|
||||
{
|
||||
try {
|
||||
$path = realpath((string) $this->argument('result'));
|
||||
if ($path === false || ! is_file($path) || filesize($path) > 100000) {
|
||||
throw new \RuntimeException('Local result file required.');
|
||||
}
|
||||
$input = json_decode((string) file_get_contents($path), true, 16, JSON_THROW_ON_ERROR);
|
||||
if (! is_array($input) || ($input['synthetic_only'] ?? null) !== true || ! is_array($input['claims'] ?? null)) {
|
||||
throw new \RuntimeException('Synthetic result required.');
|
||||
}
|
||||
$result = $assessment->assess($input['claims']);
|
||||
$this->line(json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR));
|
||||
|
||||
return self::SUCCESS;
|
||||
} catch (Throwable) {
|
||||
$this->error('Não foi possível conferir o resultado fictício. Verifique o ficheiro e as referências; nenhum pedido externo foi efectuado.');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Services\SyntheticAiRehearsal;
|
||||
use Illuminate\Console\Command;
|
||||
use Throwable;
|
||||
|
||||
class SgcAiRehearsal extends Command
|
||||
{
|
||||
protected $signature = 'sgc:ai-rehearsal {--live : Executar uma chamada paga, apenas com o cenário fictício incorporado}';
|
||||
|
||||
protected $description = 'Pré-visualizar o ensaio de síntese IA; sem rede por defeito e sem acesso a processos reais';
|
||||
|
||||
public function handle(SyntheticAiRehearsal $rehearsal): int
|
||||
{
|
||||
try {
|
||||
$result = $this->option('live') ? $rehearsal->run() : $rehearsal->preview();
|
||||
$this->line(json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR));
|
||||
|
||||
return self::SUCCESS;
|
||||
} catch (Throwable) {
|
||||
// Never render request bodies, provider errors or credentials in console logs.
|
||||
$this->error('Ensaio não concluído. Confira activação/credencial e o resultado dos testes; nenhuma decisão do SGC foi alterada.');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user