Protokoll #15494

ID15494
Zeitstempel2025-12-25 16:54:50.740405
Clientroot
IP145.224.72.140
Modellclaude-sonnet-4-20250514
Statuspending
Tokens1,347 (Input: 1,347, Output: 0)
Dauer-
Request-Zeit2025-12-25 16:54:50.740405
Response-Zeit-

Request

{
    "event": "PostToolUse",
    "raw_data": {
        "session_id": "f0f145c4-ac1d-417a-b15b-271983ae648b",
        "transcript_path": "\/root\/.claude\/projects\/-var-www\/f0f145c4-ac1d-417a-b15b-271983ae648b.jsonl",
        "cwd": "\/var\/www\/dev.campus.systemische-tools.de",
        "permission_mode": "acceptEdits",
        "hook_event_name": "PostToolUse",
        "tool_name": "Read",
        "tool_input": {
            "file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/AI\/OllamaClient.php"
        },
        "tool_response": {
            "type": "text",
            "file": {
                "filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/AI\/OllamaClient.php",
                "content": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Infrastructure\\AI;\n\n\/\/ @responsibility: Ollama-Client für LLM-Ausführung (Task-System)\n\nuse Infrastructure\\Config\\CredentialService;\n\nclass OllamaClient implements AIClientInterface\n{\n    private string $baseUrl;\n    private string $model;\n    private int $timeout;\n\n    public function __construct(\n        ?string $baseUrl = null,\n        string $model = 'mistral',\n        int $timeout = 120\n    ) {\n        $this->baseUrl = rtrim($baseUrl ?? CredentialService::getOllamaHost(), '\/');\n        $this->model = $model;\n        $this->timeout = $timeout;\n    }\n\n    public function execute(string $prompt, array $options = []): AIResponse\n    {\n        $model = $options['model'] ?? $this->model;\n        $startTime = microtime(true);\n\n        try {\n            $ch = curl_init($this->baseUrl . '\/api\/generate');\n\n            $payload = [\n                'model' => $model,\n                'prompt' => $prompt,\n                'stream' => false,\n            ];\n\n            if (isset($options['system'])) {\n                $payload['system'] = $options['system'];\n            }\n\n            if (isset($options['temperature'])) {\n                $payload['options']['temperature'] = $options['temperature'];\n            }\n\n            curl_setopt_array($ch, [\n                CURLOPT_POST => true,\n                CURLOPT_POSTFIELDS => json_encode($payload),\n                CURLOPT_RETURNTRANSFER => true,\n                CURLOPT_HTTPHEADER => ['Content-Type: application\/json'],\n                CURLOPT_TIMEOUT => $this->timeout,\n            ]);\n\n            $response = curl_exec($ch);\n            $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);\n            $error = curl_error($ch);\n            curl_close($ch);\n\n            $durationMs = (int) ((microtime(true) - $startTime) * 1000);\n\n            if ($response === false || $error !== '') {\n                return AIResponse::error(\"cURL Error: {$error}\", $model);\n            }\n\n            if ($httpCode !== 200) {\n                return AIResponse::error(\"HTTP Error: {$httpCode}\", $model);\n            }\n\n            $data = json_decode($response, true);\n\n            if (!isset($data['response'])) {\n                return AIResponse::error('Invalid response format', $model);\n            }\n\n            $tokensInput = $data['prompt_eval_count'] ?? $this->estimateTokens($prompt);\n            $tokensOutput = $data['eval_count'] ?? $this->estimateTokens($data['response']);\n\n            return AIResponse::success(\n                $data['response'],\n                $tokensInput,\n                $tokensOutput,\n                $durationMs,\n                $model,\n                [\n                    'total_duration' => $data['total_duration'] ?? null,\n                    'load_duration' => $data['load_duration'] ?? null,\n                    'eval_duration' => $data['eval_duration'] ?? null,\n                ]\n            );\n        } catch (\\Exception $e) {\n            return AIResponse::error($e->getMessage(), $model);\n        }\n    }\n\n    public function isAvailable(): bool\n    {\n        try {\n            $ch = curl_init($this->baseUrl . '\/api\/tags');\n            curl_setopt_array($ch, [\n                CURLOPT_RETURNTRANSFER => true,\n                CURLOPT_TIMEOUT => 5,\n            ]);\n\n            $response = curl_exec($ch);\n            $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);\n            curl_close($ch);\n\n            return $httpCode === 200;\n        } catch (\\Exception $e) {\n            return false;\n        }\n    }\n\n    public function getClientName(): string\n    {\n        return 'ollama';\n    }\n\n    public function getModelName(): string\n    {\n        return $this->model;\n    }\n\n    public function listModels(): array\n    {\n        try {\n            $ch = curl_init($this->baseUrl . '\/api\/tags');\n            curl_setopt_array($ch, [\n                CURLOPT_RETURNTRANSFER => true,\n                CURLOPT_TIMEOUT => 10,\n            ]);\n\n            $response = curl_exec($ch);\n            $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);\n            curl_close($ch);\n\n            if ($response === false || $httpCode !== 200) {\n                return [];\n            }\n\n            $data = json_decode($response, true);\n\n            return array_column($data['models'] ?? [], 'name');\n        } catch (\\Exception $e) {\n            return [];\n        }\n    }\n\n    private function estimateTokens(string $text): int\n    {\n        return max(1, (int) (strlen($text) \/ 4));\n    }\n}\n",
                "numLines": 157,
                "startLine": 1,
                "totalLines": 157
            }
        },
        "tool_use_id": "toolu_01NwV4GesBnnaintwLZHs9Wu"
    }
}

Response

-
← Vorheriger Zur Liste Nächster →