30 lines
1.9 KiB
PHP
30 lines
1.9 KiB
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
header('Access-Control-Allow-Origin: *');
|
|
$MF = 'http://127.0.0.1:5001';
|
|
$action = $_GET['action'] ?? $_POST['action'] ?? 'health';
|
|
switch($action) {
|
|
case 'health':
|
|
$r = @file_get_contents("$MF/health");
|
|
$h = json_decode($r, true);
|
|
$reps = json_decode(@file_get_contents("$MF/api/report/list"), true);
|
|
echo json_encode(['status'=>($h && $h['status'] === 'ok') ? 'active' : 'down','service'=>'MiroFish Swarm Intelligence','reports'=>$reps['count'] ?? 0,'capabilities'=>['report_generate','report_chat','simulation','graph'],'url'=>'https://mirofish.weval-consulting.com']);
|
|
break;
|
|
case 'ceo':
|
|
$health = json_decode(@file_get_contents("$MF/health"), true);
|
|
$reports = json_decode(@file_get_contents("$MF/api/report/list"), true);
|
|
$arch = json_decode(@file_get_contents("/var/www/html/api/architecture-index.json"), true);
|
|
echo json_encode(['mirofish'=>['status'=>$health['status'] ?? 'unknown','reports'=>$reports['count'] ?? 0],'infrastructure'=>['score'=>$arch['recommendations']['score'] ?? 0,'docker'=>count($arch['docker'] ?? [])],'actions'=>['Generate prediction report','Chat with report','Run simulation','CEO insights']]);
|
|
break;
|
|
case 'generate':
|
|
$topic = $_POST['topic'] ?? $_GET['topic'] ?? '';
|
|
if (!$topic) { echo json_encode(['error'=>'topic required']); break; }
|
|
$ctx = stream_context_create(['http'=>['method'=>'POST','header'=>"Content-Type: application/json\r\n",'content'=>json_encode(['topic'=>$topic,'language'=>'fr']),'timeout'=>30]]);
|
|
echo @file_get_contents("$MF/api/report/generate", false, $ctx) ?: '{}';
|
|
break;
|
|
case 'reports':
|
|
echo @file_get_contents("$MF/api/report/list") ?: '{"count":0}';
|
|
break;
|
|
default:
|
|
echo json_encode(['error'=>'Unknown action','actions'=>['health','ceo','generate','reports']]);
|
|
} |