Protokoll #15978

ID15978
Zeitstempel2025-12-25 16:58:22.062690
Clientroot
IP145.224.72.140
Modellclaude-sonnet-4-20250514
Statuscompleted
Tokens792 (Input: 45, Output: 747)
Dauer102 ms
Request-Zeit2025-12-25 16:58:22.062690
Response-Zeit2025-12-25 16:58:22.164674

Request

{
    "event": "PreToolUse",
    "tool_name": "Read",
    "tool_input": {
        "file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/AI\/ClaudeService.php",
        "offset": 1,
        "limit": 80
    }
}

Response

{
    "tool_response": {
        "type": "text",
        "file": {
            "filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/AI\/ClaudeService.php",
            "content": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Infrastructure\\AI;\n\n\/\/ @responsibility: Anthropic Claude API für RAG-Antworten\n\nuse Infrastructure\\Config\\CredentialService;\nuse RuntimeException;\n\nfinal class ClaudeService\n{\n    \/**\n     * Default timeout for HTTP requests in seconds (LLM responses can take time).\n     *\/\n    private const int DEFAULT_TIMEOUT = 120;\n\n    \/**\n     * Health check timeout in seconds.\n     *\/\n    private const int HEALTH_CHECK_TIMEOUT = 5;\n\n    \/**\n     * Anthropic API base URL.\n     *\/\n    private const string API_BASE_URL = 'https:\/\/api.anthropic.com\/v1';\n\n    \/**\n     * Anthropic API version header.\n     *\/\n    private const string API_VERSION = '2023-06-01';\n\n    \/**\n     * The Anthropic API key loaded from environment.\n     *\/\n    private readonly string $apiKey;\n\n    \/**\n     * Constructs a new ClaudeService instance.\n     *\n     * Loads the Anthropic API key from environment variables via CredentialService\n     * if not explicitly provided. This ensures secrets are never hardcoded and\n     * follow security best practices.\n     *\n     * @param string|null $apiKey Optional API key (defaults to loading from environment)\n     *\/\n    public function __construct(?string $apiKey = null)\n    {\n        $this->apiKey = $apiKey ?? CredentialService::getAnthropicApiKey();\n    }\n\n    \/**\n     * Sends a prompt to Claude and receives a text response.\n     *\n     * Makes a request to the Anthropic Messages API with the specified prompt,\n     * optional system prompt, model, token limit, and temperature. Returns the\n     * generated text along with token usage statistics.\n     *\n     * @param string      $prompt       The user prompt to send\n     * @param string|null $systemPrompt Optional system prompt for instructions (default: null)\n     * @param string      $model        The Claude model to use (default: claude-opus-4-5-20251101)\n     * @param int         $maxTokens    Maximum tokens in response (default: 4000)\n     * @param float       $temperature  Sampling temperature 0.0-1.0 (default: 0.7)\n     *\n     * @return array{text: string, usage: array{input_tokens: int, output_tokens: int}} Response text and token usage\n     *\n     * @throws RuntimeException If the API request fails or returns invalid data\n     *\n     * @example\n     * $service = new ClaudeService();\n     * $result = $service->ask('Explain quantum computing', 'You are a physics teacher.', 'claude-opus-4-5-20251101', 4000, 0.7);\n     * \/\/ Returns: [\n     * \/\/   'text' => 'Quantum computing is...',\n     * \/\/   'usage' => ['input_tokens' => 123, 'output_tokens' => 456]\n     * \/\/ ]\n     *\/\n    public function ask(\n        string $prompt,\n        ?string $systemPrompt = null,",
            "numLines": 80,
            "startLine": 1,
            "totalLines": 321
        }
    }
}
← Vorheriger Zur Liste Nächster →