Files
html/api/wevia-crewai.php
2026-04-12 22:57:03 +02:00

21 lines
887 B
PHP

<?php
header("Content-Type: application/json");
header("Access-Control-Allow-Origin: *");
$input = json_decode(file_get_contents("php://input"), true) ?: [];
$mission = $input["mission"] ?? $_GET["mission"] ?? "";
if (!$mission) { echo json_encode(["error"=>"mission required"]); exit; }
$secrets = [];
foreach(file("/etc/weval/secrets.env") as $l) {
$l = trim($l);
if ($l && $l[0] !== '#' && strpos($l,'=')!==false) {
list($k,$v) = explode('=',$l,2);
$secrets[$k] = trim($v,'"');
}
}
$gkey = $secrets["GROQ_KEY"] ?? "";
$cmd = "cd /opt/weval-crewai && GROQ_API_KEY=$gkey CREWAI_TRACING_ENABLED=false timeout 55 python3 wevia-crew.py " . escapeshellarg($mission) . " 2>&1 | tail -30";
$output = shell_exec($cmd);
$result = json_decode($output, true);
if ($result) { echo json_encode($result); }
else { echo json_encode(["result"=>$output,"status"=>"raw"]); }