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