diff --git a/v4_ci4/app/Commands/RadarAiPing.php b/v4_ci4/app/Commands/RadarAiPing.php new file mode 100644 index 00000000..c66ad071 --- /dev/null +++ b/v4_ci4/app/Commands/RadarAiPing.php @@ -0,0 +1,39 @@ +isConfigured()) { + CLI::error('Clé absente (gemini_api_key.txt)'); + + return; + } + CLI::write('Provider=' . $ai->provider() . ' model=' . $ai->model(), 'white'); + $t0 = \microtime(true); + $res = $ai->complete('Réponds uniquement: PONG'); + $ms = (int) \round((\microtime(true) - $t0) * 1000); + CLI::write('OK en ' . $ms . ' ms — ' . \mb_substr($res->text, 0, 80), 'green'); + } catch (\Throwable $e) { + CLI::error($e->getMessage()); + CLI::write('Si timeout 0 bytes : firewall/IPv6 sortant vers generativelanguage.googleapis.com', 'yellow'); + } + } +} diff --git a/v4_ci4/app/Config/Ai.php b/v4_ci4/app/Config/Ai.php index bbb089b0..504ea6e7 100644 --- a/v4_ci4/app/Config/Ai.php +++ b/v4_ci4/app/Config/Ai.php @@ -29,7 +29,7 @@ class Ai extends BaseConfig public string $geminiBaseUrl = 'https://generativelanguage.googleapis.com/v1beta'; - public int $timeoutSeconds = 90; + public int $timeoutSeconds = 25; public int $maxOutputTokens = 2048; diff --git a/v4_ci4/app/Libraries/Ai/AiHttp.php b/v4_ci4/app/Libraries/Ai/AiHttp.php index 676f7be9..906cb8c9 100644 --- a/v4_ci4/app/Libraries/Ai/AiHttp.php +++ b/v4_ci4/app/Libraries/Ai/AiHttp.php @@ -31,8 +31,11 @@ final class AiHttp $opts = [ \CURLOPT_RETURNTRANSFER => true, \CURLOPT_CUSTOMREQUEST => \strtoupper($method), + \CURLOPT_CONNECTTIMEOUT => 10, \CURLOPT_TIMEOUT => $timeout, \CURLOPT_HTTPHEADER => $headers, + // cPanel : IPv6 cassé → hang 90s / 0 bytes. Forcer IPv4. + \CURLOPT_IPRESOLVE => \CURL_IPRESOLVE_V4, ]; if ($body !== null) { $opts[\CURLOPT_POSTFIELDS] = $body; @@ -43,7 +46,10 @@ final class AiHttp if ($res === false) { $err = \curl_error($ch); \curl_close($ch); - throw new AiException('AI HTTP cURL: ' . $err); + throw new AiException( + 'Serveur → Gemini timeout/réseau (' . $err . '). ' + . 'Souvent IPv6 ou firewall sortant vers generativelanguage.googleapis.com.' + ); } \curl_close($ch); diff --git a/v4_ci4/app/Libraries/Radar/GoogleWorkspaceToken.php b/v4_ci4/app/Libraries/Radar/GoogleWorkspaceToken.php index e9591448..f4baf20c 100644 --- a/v4_ci4/app/Libraries/Radar/GoogleWorkspaceToken.php +++ b/v4_ci4/app/Libraries/Radar/GoogleWorkspaceToken.php @@ -94,6 +94,8 @@ class GoogleWorkspaceToken \CURLOPT_CONNECTTIMEOUT => 8, \CURLOPT_TIMEOUT => 25, \CURLOPT_HTTPHEADER => $headers, + // cPanel : IPv6 cassé → hang / 0 bytes. Forcer IPv4 (comme AiHttp). + \CURLOPT_IPRESOLVE => \CURL_IPRESOLVE_V4, ]; if ($body !== null) { $opts[\CURLOPT_POSTFIELDS] = $body;