{
"tool_response": {
"type": "text",
"file": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Controller\/ChatController.php",
"content": " return $result !== false ? $result : null;\n }\n\n \/**\n * Extract prompt text from system prompt data\n *\/\n private function extractPromptText(?array $promptData): ?string\n {\n if ($promptData === null) {\n return null;\n }\n\n $content = json_decode($promptData['content'], true);\n if ($content === null) {\n return null;\n }\n\n return $content['prompt'] ?? null;\n }\n\n \/**\n * Get messages for a session\n *\/\n private function getMessages(int $sessionId): array\n {\n $stmt = $this->db->prepare(\n 'SELECT * FROM chat_messages WHERE session_id = ? ORDER BY created_at ASC'\n );\n $stmt->execute([$sessionId]);\n\n return $stmt->fetchAll(\\PDO::FETCH_ASSOC);\n }\n\n \/**\n * Save a message to the database\n *\/\n private function saveMessage(\n int $sessionId,\n string $role,\n string $content,\n string $model,\n ?int $tokensInput = null,\n ?int $tokensOutput = null,\n array $sources = [],\n ?float $startMicrotime = null,\n ?float $endMicrotime = null,\n ?int $authorProfileId = null,\n ?int $systemPromptId = null,\n ?string $collectionsJson = null,\n ?int $contextLimit = null\n ): void {\n $stmt = $this->db->prepare(\n 'INSERT INTO chat_messages\n (session_id, role, content, model, tokens_input, tokens_output, sources,\n start_microtime, end_microtime, author_profile_id, system_prompt_id, collections, context_limit)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'\n );\n $stmt->execute([\n $sessionId,\n $role,\n $content,\n $model,\n $tokensInput,\n $tokensOutput,\n $sources !== [] ? json_encode($sources) : null,\n $startMicrotime,\n $endMicrotime,\n $authorProfileId,\n $systemPromptId,\n $collectionsJson,\n $contextLimit,\n ]);\n\n \/\/ Update session timestamp\n $this->db->prepare('UPDATE chat_sessions SET updated_at = NOW() WHERE id = ?')\n ->execute([$sessionId]);\n }\n\n \/**\n * Update session title",
"numLines": 80,
"startLine": 380,
"totalLines": 855
}
}
}