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

57 lines
3.2 KiB
PHP

<?php
opcache_invalidate(__FILE__, true);
header("Content-Type: application/json");
header("Access-Control-Allow-Origin: *");
if ($_SERVER["REQUEST_METHOD"]==="OPTIONS"){header("Access-Control-Allow-Headers: Content-Type");exit;}
$action = $_GET["action"] ?? "status";
if ($action === "test") {
$results = [];
// 1. Page file exists + content
$html = @file_get_contents("/var/www/html/deepseek.html") ?: "";
$results["page_load"] = ["status" => strlen($html) > 10000 ? "PASS" : "FAIL", "size" => strlen($html)];
// 2. Options
preg_match_all("/<option/", $html, $o); $oc = count($o[0]);
$results["dropdown_options"] = ["status" => $oc > 300 ? "PASS" : "FAIL", "count" => $oc];
// 3. Optgroups
preg_match_all("/<optgroup/", $html, $g); $gc = count($g[0]);
$results["optgroups"] = ["status" => $gc > 20 ? "PASS" : "FAIL", "count" => $gc];
// 4. UI elements
$checks = ["modelSelect" => false, "Message WEVAL" => false, "DeepThink" => false, "checkArenaHealth" => false];
foreach ($checks as $k => &$v) $v = strpos($html, $k) !== false;
$all_ui = !in_array(false, $checks);
$results["ui_elements"] = array_merge(["status" => $all_ui ? "PASS" : "FAIL"], $checks);
// 5. APIs
$apis = ["multi-provider","health","budget","autowire","master"];
foreach ($apis as $a) {
$url = ($a === "master") ? "https://weval-consulting.com/api/wevia-master-api.php" : "https://weval-consulting.com/api/wevia-arena-" . $a . ".php";
if ($a === "multi-provider") $url = "https://weval-consulting.com/api/wevia-multi-provider.php";
$ch = curl_init($url);
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER=>true,CURLOPT_POST=>true,CURLOPT_TIMEOUT=>10,
CURLOPT_POSTFIELDS=>json_encode(["message"=>"test","action"=>"status"]),
CURLOPT_HTTPHEADER=>["Content-Type: application/json"]]);
$r = curl_exec($ch); $c = curl_getinfo($ch,CURLINFO_HTTP_CODE);
$results["api_$a"] = ["status" => ($c===200 && @json_decode($r)) ? "PASS" : "FAIL", "code" => $c];
}
// 6. Providers
foreach (["wevia-master","nim-llama","mistral","alibaba-qwen","anthropic"] as $p) {
$ch = curl_init("https://weval-consulting.com/api/wevia-multi-provider.php");
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER=>true,CURLOPT_POST=>true,CURLOPT_TIMEOUT=>15,
CURLOPT_POSTFIELDS=>json_encode(["message"=>"test","model"=>$p]),
CURLOPT_HTTPHEADER=>["Content-Type: application/json"]]);
$r = curl_exec($ch); $d = @json_decode($r,true); $ct = strlen($d["content"]??"");
$results["provider_$p"] = ["status" => $ct>10 ? "PASS" : "FAIL", "chars" => $ct];
}
$pass = count(array_filter($results, fn($r) => $r["status"]==="PASS"));
echo json_encode(["pass"=>$pass,"total"=>count($results),"pct"=>round($pass/count($results)*100),"results"=>$results,"ts"=>date("H:i:s")]);
exit;
}
if ($action === "discover") {
$arena = strtolower(@file_get_contents("/var/www/html/deepseek.html")?:"");
echo json_encode(["arena_options"=>substr_count($arena,"<option"),"status"=>"Arena has all tools wired"]);
exit;
}
echo json_encode(["actions"=>["test","discover"],"arena_options"=>substr_count(@file_get_contents("/var/www/html/deepseek.html")?:"","<option")]);
?>