{
"event": "PreToolUse",
"tool_name": "Read",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Controller\/ChatController.php",
"offset": 620,
"limit": 80
}
}
{
"tool_response": {
"type": "text",
"file": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Controller\/ChatController.php",
"content": " Beantworte die Frage des Nutzers basierend auf dem bereitgestellten Kontext.\n - Antworte auf Deutsch\n - Sei präzise und hilfreich\n - Wenn der Kontext die Frage nicht beantwortet, sage das ehrlich\n - Verweise auf die Quellen wenn passend\n PROMPT;\n }\n\n \/**\n * Ask chat question using ChatService\n *\n * @param array<string> $collections Array of collection names (empty = no RAG)\n *\/\n private function askChat(string $question, string $model, array $collections, int $limit, ?string $stylePrompt = null, ?string $customSystemPrompt = null, float $temperature = 0.7, int $maxTokens = 4096): array\n {\n try {\n return $this->chatService->chat($question, $model, $collections, $limit, $stylePrompt, $customSystemPrompt, $temperature, $maxTokens);\n } catch (\\RuntimeException $e) {\n throw new \\RuntimeException('Chat-Service konnte nicht ausgeführt werden: ' . $e->getMessage(), 0, $e);\n }\n }\n\n \/**\n * Render chat response HTML using view partial\n *\/\n private function renderResponse(string $question, array $result, string $model): void\n {\n \/\/ Convert markdown-style formatting to HTML\n $formattedAnswer = $this->formatAnswer($result['answer'] ?? '');\n\n $this->view('chat.partials.response', [\n 'question' => $question,\n 'result' => $result,\n 'model' => $model,\n 'formattedAnswer' => $formattedAnswer,\n ]);\n }\n\n \/**\n * Format markdown-like answer to HTML.\n *\n * Converts basic markdown syntax to HTML. Uses line-based processing\n * to correctly handle list blocks mixed with regular text.\n *\/\n private function formatAnswer(string $text): string\n {\n \/\/ Escape HTML first\n $text = htmlspecialchars($text);\n\n \/\/ Headers\n $text = preg_replace('\/^### (.+)$\/m', '<h4>$1<\/h4>', $text);\n $text = preg_replace('\/^## (.+)$\/m', '<h3>$1<\/h3>', $text);\n $text = preg_replace('\/^# (.+)$\/m', '<h3>$1<\/h3>', $text);\n\n \/\/ Bold\n $text = preg_replace('\/\\*\\*(.+?)\\*\\*\/', '<strong>$1<\/strong>', $text);\n\n \/\/ Italic\n $text = preg_replace('\/\\*(.+?)\\*\/', '<em>$1<\/em>', $text);\n\n \/\/ Code\n $text = preg_replace('\/`(.+?)`\/', '<code>$1<\/code>', $text);\n\n \/\/ Blockquotes\n $text = preg_replace('\/^> (.+)$\/m', '<blockquote>$1<\/blockquote>', $text);\n\n \/\/ Lists: Process line by line to correctly wrap consecutive list items\n $text = $this->formatLists($text);\n\n \/\/ Line breaks\n $text = nl2br($text);\n\n \/\/ Clean up multiple <br> tags\n $text = preg_replace('\/(<br\\s*\\\/?>\\s*){3,}\/', '<br><br>', $text);\n\n return $text;\n }\n\n \/**\n * Format list items and wrap consecutive items in <ul> tags.",
"numLines": 80,
"startLine": 620,
"totalLines": 745
}
}
}