19 lines
691 B
PHP
19 lines
691 B
PHP
<?php
|
|
header("Content-Type: text/event-stream");
|
|
header("Cache-Control: no-cache");
|
|
header("X-Accel-Buffering: no");
|
|
set_time_limit(60);
|
|
ob_implicit_flush(true);
|
|
if(ob_get_level())ob_end_flush();
|
|
function sse($d){echo "data: ".json_encode($d,JSON_UNESCAPED_UNICODE)."
|
|
|
|
";flush();}
|
|
$msg=$_GET["msg"]??"";
|
|
if(!$msg){sse(["error"=>"msg required"]);exit;}
|
|
sse(["type"=>"start","task"=>$msg]);
|
|
include __DIR__."/wevia-orchestrator.php";
|
|
$r=wevia_orchestrate($msg);
|
|
foreach($r["results"]??[] as $k=>$v){sse(["type"=>"agent","id"=>$k,"result"=>$v]);}
|
|
if($r["synthesis"]??null)sse(["type"=>"synthesis","content"=>$r["synthesis"]]);
|
|
sse(["type"=>"done","agents"=>$r["agents"]??0,"ms"=>$r["ms"]??0]);
|