diff --git a/Changes.md b/Changes.md
index 46b3527..d6ce612 100644
--- a/Changes.md
+++ b/Changes.md
@@ -2,6 +2,14 @@
---
+## 2026-04-26 – KI-Diagnose: Erreichbarkeitsprüfung und Fehlerlog für Ollama
+
+### Geändert
+- `src/Services/LlmService.php`: Neue Methode `isReachable()` für Diagnosezwecke; Fehlerlog in `callOllama()` bei cURL-Fehler oder leerer Antwort
+- `src/Views/settings/form.php`: Einstellungsseite prüft jetzt aktiv, ob der Ollama-Server erreichbar ist (nicht nur ob er konfiguriert ist); zeigt bei Verbindungsfehler einen konkreten Hinweis auf `OLLAMA_HOST=0.0.0.0:11434`
+
+---
+
## 2026-04-26 – Leistungszeitraum als freies Textfeld
### Geändert
diff --git a/src/Services/LlmService.php b/src/Services/LlmService.php
index 22b9007..f144826 100644
--- a/src/Services/LlmService.php
+++ b/src/Services/LlmService.php
@@ -93,6 +93,17 @@ class LlmService
return $data['message']['content'] ?? '';
}
+ /**
+ * Prüft ohne Timeout-Kosten, ob der Provider überhaupt erreichbar ist.
+ * Nur für Diagnosezwecke (Einstellungsseite) – nicht im normalen Request-Pfad nutzen.
+ */
+ public function isReachable(): bool
+ {
+ if ($this->mode === null) return false;
+ if ($this->mode === 'ollama') return $this->probeOllama($this->url);
+ return true; // OpenAI-Modus: kein schneller Probe verfügbar
+ }
+
private function detect(): void
{
$ollamaUrl = getenv('OLLAMA_URL') ?: ($_ENV['OLLAMA_URL'] ?? '');
@@ -147,7 +158,8 @@ class LlmService
'stream' => false,
];
- $ch = curl_init($this->url . '/api/generate');
+ $endpoint = $this->url . '/api/generate';
+ $ch = curl_init($endpoint);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
@@ -157,9 +169,17 @@ class LlmService
]);
$response = curl_exec($ch);
$err = curl_error($ch);
+ $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
- if ($err || !$response) return '';
+ if ($err) {
+ error_log("[Steuerkram] LlmService::callOllama() cURL-Fehler auf {$endpoint}: {$err}");
+ return '';
+ }
+ if (!$response) {
+ error_log("[Steuerkram] LlmService::callOllama() leere Antwort von {$endpoint} (HTTP {$httpCode})");
+ return '';
+ }
return json_decode($response, true)['response'] ?? '';
}
diff --git a/src/Views/settings/form.php b/src/Views/settings/form.php
index 96b5e3b..22a0f8e 100644
--- a/src/Views/settings/form.php
+++ b/src/Views/settings/form.php
@@ -140,14 +140,22 @@
Konfiguration via .env (lokales Ollama oder Remote-API).
- - ✓ Provider erkannt: = $h($providerLabel) ?> +
+
+ ✓ Provider erreichbar: = $h($providerLabel) ?>
+
+ ✗ Provider konfiguriert (= $h($providerLabel) ?>), aber Server nicht erreichbar.
+ Prüfe ob Ollama auf dem Host läuft und auf allen Interfaces hört (OLLAMA_HOST=0.0.0.0:11434).
+ Details im PHP-Fehlerlog des Webservers (docker compose logs web).
+
+ ✗ OLLAMA_URL gesetzt (= $h(rtrim($ollamaUrlEnv, '/')) ?>), aber kein Provider erkannt.
- — Kein LLM-Provider konfiguriert oder erreichbar (Auto-Discovery localhost:11434 fehlgeschlagen)
+ — Kein LLM-Provider konfiguriert (Auto-Discovery localhost:11434 fehlgeschlagen)