Spaces:
Running
Running
Upload demo.ipynb
Browse files- notebook/demo.ipynb +74 -53
notebook/demo.ipynb
CHANGED
@@ -1,53 +1,74 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
""
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
print(
|
30 |
-
for
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
""")
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "markdown",
|
5 |
+
"id": "dfad5f6b",
|
6 |
+
"metadata": {},
|
7 |
+
"source": [
|
8 |
+
"# Demo: AI-Powered Scientific Research Companion\n",
|
9 |
+
"This notebook demonstrates how to use the `Dispatcher` to search for papers, retrieve reproducible notebook cells, and fetch a knowledge graph."
|
10 |
+
]
|
11 |
+
},
|
12 |
+
{
|
13 |
+
"cell_type": "code",
|
14 |
+
"execution_count": null,
|
15 |
+
"id": "307d78b9",
|
16 |
+
"metadata": {},
|
17 |
+
"outputs": [],
|
18 |
+
"source": [
|
19 |
+
"from orchestrator.dispatcher import Dispatcher\n",
|
20 |
+
"\n",
|
21 |
+
"# Initialize dispatcher\n",
|
22 |
+
"dispatcher = Dispatcher()\n",
|
23 |
+
"\n",
|
24 |
+
"# Example query\n",
|
25 |
+
"query = \"CRISPR delivery\"\n",
|
26 |
+
"\n",
|
27 |
+
"# 1. Search for papers\n",
|
28 |
+
"papers = dispatcher.search_papers(query, limit=3)\n",
|
29 |
+
"print(\"Papers found:\")\n",
|
30 |
+
"for p in papers:\n",
|
31 |
+
" print(f\"- {p['title']} (ID: {p['id']})\")\n"
|
32 |
+
]
|
33 |
+
},
|
34 |
+
{
|
35 |
+
"cell_type": "code",
|
36 |
+
"execution_count": null,
|
37 |
+
"id": "8db389c8",
|
38 |
+
"metadata": {},
|
39 |
+
"outputs": [],
|
40 |
+
"source": [
|
41 |
+
"# 2. Retrieve notebook cells for the first paper\n",
|
42 |
+
"if papers:\n",
|
43 |
+
" first_id = papers[0]['id']\n",
|
44 |
+
" cells = dispatcher.get_notebook_cells(first_id)\n",
|
45 |
+
" print(f\"Notebook cells for paper {first_id}:\")\n",
|
46 |
+
" for i, cell in enumerate(cells, 1):\n",
|
47 |
+
" print(f\"Cell {i}:\")\n",
|
48 |
+
" print(cell)\n",
|
49 |
+
" print(\"------\")\n"
|
50 |
+
]
|
51 |
+
},
|
52 |
+
{
|
53 |
+
"cell_type": "code",
|
54 |
+
"execution_count": null,
|
55 |
+
"id": "52666e2a",
|
56 |
+
"metadata": {},
|
57 |
+
"outputs": [],
|
58 |
+
"source": [
|
59 |
+
"# 3. Fetch knowledge graph for the first paper\n",
|
60 |
+
"if papers:\n",
|
61 |
+
" graph = dispatcher.get_graph(first_id)\n",
|
62 |
+
" print(\"Graph nodes:\")\n",
|
63 |
+
" for node in graph.get(\"nodes\", []):\n",
|
64 |
+
" print(node)\n",
|
65 |
+
" print(\"Graph edges:\")\n",
|
66 |
+
" for edge in graph.get(\"edges\", []):\n",
|
67 |
+
" print(edge)\n"
|
68 |
+
]
|
69 |
+
}
|
70 |
+
],
|
71 |
+
"metadata": {},
|
72 |
+
"nbformat": 4,
|
73 |
+
"nbformat_minor": 5
|
74 |
+
}
|