Skip to content

Commit

Permalink
proj viz
Browse files Browse the repository at this point in the history
  • Loading branch information
VomV committed Aug 2, 2024
1 parent 742bad8 commit 7ad5cca
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions rag_basic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -585,18 +585,18 @@
},
{
"cell_type": "code",
"execution_count": 39,
"execution_count": 42,
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'i' is not defined",
"ename": "TypeError",
"evalue": "'builtin_function_or_method' object is not subscriptable",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[39], line 4\u001b[0m\n\u001b[1;32m 1\u001b[0m df \u001b[38;5;241m=\u001b[39m pd\u001b[38;5;241m.\u001b[39mDataFrame\u001b[38;5;241m.\u001b[39mfrom_dict(\n\u001b[1;32m 2\u001b[0m [\n\u001b[1;32m 3\u001b[0m {\n\u001b[0;32m----> 4\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mx\u001b[39m\u001b[38;5;124m'\u001b[39m: docs_proj[\u001b[43mi\u001b[49m, \u001b[38;5;241m0\u001b[39m],\n\u001b[1;32m 5\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124my\u001b[39m\u001b[38;5;124m'\u001b[39m: docs_proj[i, \u001b[38;5;241m1\u001b[39m],\n\u001b[1;32m 6\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124msource\u001b[39m\u001b[38;5;124m'\u001b[39m: docs_processed[i]\u001b[38;5;241m.\u001b[39mmetadata[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124msource\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m.\u001b[39msplit[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m/\u001b[39m\u001b[38;5;124m'\u001b[39m][\u001b[38;5;241m1\u001b[39m],\n\u001b[1;32m 7\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mextract\u001b[39m\u001b[38;5;124m'\u001b[39m: docs_processed[i]\u001b[38;5;241m.\u001b[39mpage_content[:\u001b[38;5;241m100\u001b[39m] \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m...\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 8\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124msymbol\u001b[39m\u001b[38;5;124m'\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcircle\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 9\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124msize_col\u001b[39m\u001b[38;5;124m'\u001b[39m: \u001b[38;5;241m4\u001b[39m\n\u001b[1;32m 10\u001b[0m }\n\u001b[1;32m 11\u001b[0m ]\n\u001b[1;32m 12\u001b[0m )\n",
"\u001b[0;31mNameError\u001b[0m: name 'i' is not defined"
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[42], line 6\u001b[0m\n\u001b[1;32m 1\u001b[0m df \u001b[38;5;241m=\u001b[39m pd\u001b[38;5;241m.\u001b[39mDataFrame\u001b[38;5;241m.\u001b[39mfrom_dict(\n\u001b[1;32m 2\u001b[0m [\n\u001b[1;32m 3\u001b[0m {\n\u001b[1;32m 4\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mx\u001b[39m\u001b[38;5;124m'\u001b[39m: docs_proj[i, \u001b[38;5;241m0\u001b[39m],\n\u001b[1;32m 5\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124my\u001b[39m\u001b[38;5;124m'\u001b[39m: docs_proj[i, \u001b[38;5;241m1\u001b[39m],\n\u001b[0;32m----> 6\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124msource\u001b[39m\u001b[38;5;124m'\u001b[39m: \u001b[43mdocs_processed\u001b[49m\u001b[43m[\u001b[49m\u001b[43mi\u001b[49m\u001b[43m]\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmetadata\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43msource\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msplit\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m/\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m[\u001b[38;5;241m1\u001b[39m],\n\u001b[1;32m 7\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mextract\u001b[39m\u001b[38;5;124m'\u001b[39m: docs_processed[i]\u001b[38;5;241m.\u001b[39mpage_content[:\u001b[38;5;241m100\u001b[39m] \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m...\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 8\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124msymbol\u001b[39m\u001b[38;5;124m'\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcircle\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 9\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124msize_col\u001b[39m\u001b[38;5;124m'\u001b[39m: \u001b[38;5;241m4\u001b[39m,\n\u001b[1;32m 10\u001b[0m }\n\u001b[1;32m 11\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(\u001b[38;5;28mlen\u001b[39m(docs_processed))\n\u001b[1;32m 12\u001b[0m ]\n\u001b[1;32m 13\u001b[0m \u001b[38;5;241m+\u001b[39m [\n\u001b[1;32m 14\u001b[0m {\n\u001b[1;32m 15\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mx\u001b[39m\u001b[38;5;124m\"\u001b[39m: docs_proj[\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m, \u001b[38;5;241m0\u001b[39m],\n\u001b[1;32m 16\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124my\u001b[39m\u001b[38;5;124m\"\u001b[39m: docs_proj[\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m, \u001b[38;5;241m1\u001b[39m],\n\u001b[1;32m 17\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msource\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mUser query\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 18\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mextract\u001b[39m\u001b[38;5;124m\"\u001b[39m: user_query,\n\u001b[1;32m 19\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msize_col\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;241m100\u001b[39m,\n\u001b[1;32m 20\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msymbol\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mstar\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 21\u001b[0m }\n\u001b[1;32m 22\u001b[0m ]\n\u001b[1;32m 23\u001b[0m )\n",
"\u001b[0;31mTypeError\u001b[0m: 'builtin_function_or_method' object is not subscriptable"
]
}
],
Expand All @@ -606,14 +606,25 @@
" {\n",
" 'x': docs_proj[i, 0],\n",
" 'y': docs_proj[i, 1],\n",
" 'source': docs_processed[i].metadata['source'].split['/'][1],\n",
" 'source': docs_processed[i].metadata['source'].split('/')[1],\n",
" 'extract': docs_processed[i].page_content[:100] + \"...\",\n",
" 'symbol': \"circle\",\n",
" 'size_col': 4\n",
" 'size_col': 4,\n",
" }\n",
" for i in range(len(docs_processed))\n",
" ]\n",
" + [\n",
" {\n",
" \"x\": docs_proj[-1, 0],\n",
" \"y\": docs_proj[-1, 1],\n",
" \"source\": \"User query\",\n",
" \"extract\": user_query,\n",
" \"size_col\": 100,\n",
" \"symbol\": \"star\",\n",
" }\n",
" ]\n",
")\n",
"\n",
"\n"
]
}
Expand Down

0 comments on commit 7ad5cca

Please sign in to comment.