added python cells to notebook search
This commit is contained in:
@@ -52,7 +52,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 8,
|
||||
"id": "7f02f5c4",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -117,12 +117,20 @@
|
||||
"\n",
|
||||
" data = json.loads(notebook_path.read_text())\n",
|
||||
" \n",
|
||||
" # Get text from all markdown cells\n",
|
||||
" markdown_cells = [\n",
|
||||
" cell[\"source\"] for cell in data.get(\"cells\", []) \n",
|
||||
" if cell.get(\"cell_type\") == \"markdown\"\n",
|
||||
" ]\n",
|
||||
" text = \"\\n\\n\".join(\"\".join(cell) for cell in markdown_cells).strip()\n",
|
||||
" # Include both markdown and code if available\n",
|
||||
" cells = []\n",
|
||||
" for cell in data.get(\"cells\", []):\n",
|
||||
" if cell.get(\"cell_type\") == \"markdown\":\n",
|
||||
" cells.append(\"\".join(cell[\"source\"]))\n",
|
||||
" elif cell.get(\"cell_type\") == \"code\":\n",
|
||||
" code = \"\".join(cell[\"source\"])\n",
|
||||
" cells.append(f\"```python\\n{code}\\n```\")\n",
|
||||
" if \"outputs\" in cell:\n",
|
||||
" for output in cell[\"outputs\"]:\n",
|
||||
" if \"text\" in output:\n",
|
||||
" cells.append(\"\".join(output[\"text\"]))\n",
|
||||
" \n",
|
||||
" text = \"\\n\\n\".join(cells).strip()\n",
|
||||
" \n",
|
||||
" if text:\n",
|
||||
" self.docs.append({\n",
|
||||
|
||||
Reference in New Issue
Block a user