"no message"]); exit; } $t0 = microtime(true); @include_once "/opt/wevia-brain/wevia-vault-context.php"; $vaultCtx = function_exists("wevia_vault_context") ? wevia_vault_context($msg, 3) : ""; $sys = "Tu es WEVIA Master, IA souveraine de WEVAL Consulting. Casablanca+Paris. SAP Partner. ERP, Cloud souverain, IA, Cybersecurite, Data/Ethica." . $vaultCtx; @require_once "/opt/wevads/vault/credentials.php"; $key = defined("CEREBRAS_KEY") ? CEREBRAS_KEY : (defined("CEREBRAS_API_KEY") ? CEREBRAS_API_KEY : ""); if (!$key) { $s=@file_get_contents("/etc/weval/secrets.env"); preg_match("/CEREBRAS_API_KEY=(.+)/", $s, $m); $key=trim($m[1]??""); } if ($key) { $ch = curl_init("https://api.cerebras.ai/v1/chat/completions"); curl_setopt_array($ch, [CURLOPT_POST=>true, CURLOPT_RETURNTRANSFER=>true, CURLOPT_TIMEOUT=>15, CURLOPT_CONNECTTIMEOUT=>3, CURLOPT_HTTPHEADER=>["Content-Type: application/json", "Authorization: Bearer $key"], CURLOPT_POSTFIELDS=>json_encode(["model"=>"qwen-3-235b-a22b-instruct-2507","messages"=>[["role"=>"system","content"=>$sys],["role"=>"user","content"=>$msg]],"max_tokens"=>2000,"temperature"=>0.7])]); $r = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($code == 200 && $r) { $d = json_decode($r, true); $content = trim($d["choices"][0]["message"]["content"] ?? ""); if (strlen($content) > 20) { echo json_encode(["content"=>$content,"provider"=>"Cerebras Qwen-235B","source"=>"vault-llm","vault_injected"=>strlen($vaultCtx)>0,"ms"=>round((microtime(true)-$t0)*1000)]); exit; } } } echo json_encode(["content"=>"Service indisponible","provider"=>"none","key_len"=>strlen($key)]);