{
"event": "PreToolUse",
"tool_name": "Grep",
"tool_input": {
"pattern": "def save_sources",
"path": "\/var\/www\/scripts\/pipeline\/generate.py",
"output_mode": "content",
"-A": 20
}
}
{
"tool_response": {
"mode": "content",
"numFiles": 0,
"filenames": [],
"content": "545:def save_sources(order_id, context):\n546- \"\"\"Save RAG sources to content_sources.\"\"\"\n547- for ctx in context:\n548- # Try to find chunk_id by content match\n549- cursor = db.execute(\"SELECT id FROM chunks WHERE content LIKE %s LIMIT 1\", (ctx[\"content\"][:100] + \"%\",))\n550- chunk = cursor.fetchone()\n551- cursor.close()\n552-\n553- if chunk:\n554- cursor = db.execute(\n555- \"\"\"INSERT IGNORE INTO content_sources (order_id, chunk_id, relevance_score)\n556- VALUES (%s, %s, %s)\"\"\",\n557- (order_id, chunk[\"id\"], ctx[\"score\"]),\n558- )\n559- db.commit()\n560- cursor.close()\n561-\n562-\n563-def update_order_status(order_id, status):\n564- \"\"\"Update order status.\"\"\"\n565- cursor = db.execute(\"UPDATE content_orders SET status = %s, updated_at = NOW() WHERE id = %s\", (status, order_id))",
"numLines": 21
}
}