Skip to content

Commit 759ec1b

Browse files
committed
fix notebook
1 parent adab5d8 commit 759ec1b

File tree

1 file changed

+65
-48
lines changed

1 file changed

+65
-48
lines changed

docs/user_guide/08_semantic_router.ipynb

Lines changed: 65 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
},
3333
{
3434
"cell_type": "code",
35-
"execution_count": 56,
35+
"execution_count": 1,
3636
"metadata": {},
3737
"outputs": [],
3838
"source": [
@@ -88,9 +88,18 @@
8888
},
8989
{
9090
"cell_type": "code",
91-
"execution_count": 57,
91+
"execution_count": 2,
9292
"metadata": {},
93-
"outputs": [],
93+
"outputs": [
94+
{
95+
"name": "stderr",
96+
"output_type": "stream",
97+
"text": [
98+
"/Users/robert.shelton/Library/Caches/pypoetry/virtualenvs/redisvl-56gG2io_-py3.11/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
99+
" from .autonotebook import tqdm as notebook_tqdm\n"
100+
]
101+
}
102+
],
94103
"source": [
95104
"import os\n",
96105
"from redisvl.extensions.router import SemanticRouter\n",
@@ -110,7 +119,7 @@
110119
},
111120
{
112121
"cell_type": "code",
113-
"execution_count": 63,
122+
"execution_count": 3,
114123
"metadata": {},
115124
"outputs": [
116125
{
@@ -144,7 +153,7 @@
144153
},
145154
{
146155
"cell_type": "code",
147-
"execution_count": 64,
156+
"execution_count": 4,
148157
"metadata": {},
149158
"outputs": [
150159
{
@@ -153,7 +162,7 @@
153162
"11"
154163
]
155164
},
156-
"execution_count": 64,
165+
"execution_count": 4,
157166
"metadata": {},
158167
"output_type": "execute_result"
159168
}
@@ -171,7 +180,7 @@
171180
},
172181
{
173182
"cell_type": "code",
174-
"execution_count": 29,
183+
"execution_count": 5,
175184
"metadata": {},
176185
"outputs": [
177186
{
@@ -180,7 +189,7 @@
180189
"RouteMatch(name='technology', distance=0.419145862261)"
181190
]
182191
},
183-
"execution_count": 29,
192+
"execution_count": 5,
184193
"metadata": {},
185194
"output_type": "execute_result"
186195
}
@@ -193,7 +202,7 @@
193202
},
194203
{
195204
"cell_type": "code",
196-
"execution_count": 30,
205+
"execution_count": 6,
197206
"metadata": {},
198207
"outputs": [
199208
{
@@ -202,7 +211,7 @@
202211
"RouteMatch(name=None, distance=None)"
203212
]
204213
},
205-
"execution_count": 30,
214+
"execution_count": 6,
206215
"metadata": {},
207216
"output_type": "execute_result"
208217
}
@@ -222,7 +231,7 @@
222231
},
223232
{
224233
"cell_type": "code",
225-
"execution_count": 37,
234+
"execution_count": 7,
226235
"metadata": {},
227236
"outputs": [
228237
{
@@ -232,7 +241,7 @@
232241
" RouteMatch(name='sports', distance=0.67106004556)]"
233242
]
234243
},
235-
"execution_count": 37,
244+
"execution_count": 7,
236245
"metadata": {},
237246
"output_type": "execute_result"
238247
}
@@ -245,7 +254,7 @@
245254
},
246255
{
247256
"cell_type": "code",
248-
"execution_count": 38,
257+
"execution_count": 8,
249258
"metadata": {},
250259
"outputs": [
251260
{
@@ -255,7 +264,7 @@
255264
" RouteMatch(name='sports', distance=0.62926441431)]"
256265
]
257266
},
258-
"execution_count": 38,
267+
"execution_count": 8,
259268
"metadata": {},
260269
"output_type": "execute_result"
261270
}
@@ -284,7 +293,7 @@
284293
},
285294
{
286295
"cell_type": "code",
287-
"execution_count": 39,
296+
"execution_count": 9,
288297
"metadata": {},
289298
"outputs": [],
290299
"source": [
@@ -297,7 +306,7 @@
297306
},
298307
{
299308
"cell_type": "code",
300-
"execution_count": 40,
309+
"execution_count": 10,
301310
"metadata": {},
302311
"outputs": [
303312
{
@@ -306,7 +315,7 @@
306315
"[RouteMatch(name='sports', distance=0.663253903389)]"
307316
]
308317
},
309-
"execution_count": 40,
318+
"execution_count": 10,
310319
"metadata": {},
311320
"output_type": "execute_result"
312321
}
@@ -325,7 +334,7 @@
325334
},
326335
{
327336
"cell_type": "code",
328-
"execution_count": 41,
337+
"execution_count": 11,
329338
"metadata": {},
330339
"outputs": [
331340
{
@@ -357,7 +366,7 @@
357366
" 'routing_config': {'max_k': 3, 'aggregation_method': 'min'}}"
358367
]
359368
},
360-
"execution_count": 41,
369+
"execution_count": 11,
361370
"metadata": {},
362371
"output_type": "execute_result"
363372
}
@@ -368,14 +377,14 @@
368377
},
369378
{
370379
"cell_type": "code",
371-
"execution_count": 42,
380+
"execution_count": 12,
372381
"metadata": {},
373382
"outputs": [
374383
{
375384
"name": "stdout",
376385
"output_type": "stream",
377386
"text": [
378-
"\u001b[32m16:05:23\u001b[0m \u001b[34mredisvl.index.index\u001b[0m \u001b[1;30mINFO\u001b[0m Index already exists, not overwriting.\n"
387+
"\u001b[32m11:57:04\u001b[0m \u001b[34mredisvl.index.index\u001b[0m \u001b[1;30mINFO\u001b[0m Index already exists, not overwriting.\n"
379388
]
380389
}
381390
],
@@ -387,7 +396,7 @@
387396
},
388397
{
389398
"cell_type": "code",
390-
"execution_count": 43,
399+
"execution_count": 13,
391400
"metadata": {},
392401
"outputs": [],
393402
"source": [
@@ -396,14 +405,14 @@
396405
},
397406
{
398407
"cell_type": "code",
399-
"execution_count": 44,
408+
"execution_count": 14,
400409
"metadata": {},
401410
"outputs": [
402411
{
403412
"name": "stdout",
404413
"output_type": "stream",
405414
"text": [
406-
"\u001b[32m16:05:29\u001b[0m \u001b[34mredisvl.index.index\u001b[0m \u001b[1;30mINFO\u001b[0m Index already exists, not overwriting.\n"
415+
"\u001b[32m11:57:06\u001b[0m \u001b[34mredisvl.index.index\u001b[0m \u001b[1;30mINFO\u001b[0m Index already exists, not overwriting.\n"
407416
]
408417
}
409418
],
@@ -422,7 +431,7 @@
422431
},
423432
{
424433
"cell_type": "code",
425-
"execution_count": 45,
434+
"execution_count": 15,
426435
"metadata": {},
427436
"outputs": [
428437
{
@@ -432,7 +441,7 @@
432441
" 'topic-router:technology:7e4bca5853c1c3298b4d001de13c3c7a79a6e0f134f81acc2e7cddbd6845961f']"
433442
]
434443
},
435-
"execution_count": 45,
444+
"execution_count": 15,
436445
"metadata": {},
437446
"output_type": "execute_result"
438447
}
@@ -450,27 +459,35 @@
450459
},
451460
{
452461
"cell_type": "code",
453-
"execution_count": 47,
462+
"execution_count": 16,
454463
"metadata": {},
455464
"outputs": [
456465
{
457466
"data": {
458467
"text/plain": [
459-
"[{'id': 'topic-router:technology:149a9c9919c58534aa0f369e85ad95ba7f00aa0513e0f81e2aff2ea4a717b0e0',\n",
468+
"[{'id': 'topic-router:technology:f243fb2d073774e81c7815247cb3013794e6225df3cbe3769cee8c6cefaca777',\n",
469+
" 'reference_id': 'f243fb2d073774e81c7815247cb3013794e6225df3cbe3769cee8c6cefaca777',\n",
470+
" 'route_name': 'technology',\n",
471+
" 'reference': 'latest AI trends'},\n",
472+
" {'id': 'topic-router:technology:851f51cce5a9ccfbbcb66993908be6b7871479af3e3a4b139ad292a1bf7e0676',\n",
473+
" 'reference_id': '851f51cce5a9ccfbbcb66993908be6b7871479af3e3a4b139ad292a1bf7e0676',\n",
474+
" 'route_name': 'technology',\n",
475+
" 'reference': 'what are the latest advancements in AI?'},\n",
476+
" {'id': 'topic-router:technology:149a9c9919c58534aa0f369e85ad95ba7f00aa0513e0f81e2aff2ea4a717b0e0',\n",
460477
" 'reference_id': '149a9c9919c58534aa0f369e85ad95ba7f00aa0513e0f81e2aff2ea4a717b0e0',\n",
461478
" 'route_name': 'technology',\n",
462479
" 'reference': \"what's trending in tech?\"},\n",
463-
" {'id': 'topic-router:technology:7e4bca5853c1c3298b4d001de13c3c7a79a6e0f134f81acc2e7cddbd6845961f',\n",
464-
" 'reference_id': '7e4bca5853c1c3298b4d001de13c3c7a79a6e0f134f81acc2e7cddbd6845961f',\n",
465-
" 'route_name': 'technology',\n",
466-
" 'reference': 'new tech gadgets'},\n",
467480
" {'id': 'topic-router:technology:85cc73a1437df27caa2f075a29c497e5a2e532023fbb75378aedbae80779ab37',\n",
468481
" 'reference_id': '85cc73a1437df27caa2f075a29c497e5a2e532023fbb75378aedbae80779ab37',\n",
469482
" 'route_name': 'technology',\n",
470-
" 'reference': 'tell me about the newest gadgets'}]"
483+
" 'reference': 'tell me about the newest gadgets'},\n",
484+
" {'id': 'topic-router:technology:7e4bca5853c1c3298b4d001de13c3c7a79a6e0f134f81acc2e7cddbd6845961f',\n",
485+
" 'reference_id': '7e4bca5853c1c3298b4d001de13c3c7a79a6e0f134f81acc2e7cddbd6845961f',\n",
486+
" 'route_name': 'technology',\n",
487+
" 'reference': 'new tech gadgets'}]"
471488
]
472489
},
473-
"execution_count": 47,
490+
"execution_count": 16,
474491
"metadata": {},
475492
"output_type": "execute_result"
476493
}
@@ -483,19 +500,19 @@
483500
},
484501
{
485502
"cell_type": "code",
486-
"execution_count": 48,
503+
"execution_count": 17,
487504
"metadata": {},
488505
"outputs": [
489506
{
490507
"data": {
491508
"text/plain": [
492-
"[{'id': 'topic-router:technology:149a9c9919c58534aa0f369e85ad95ba7f00aa0513e0f81e2aff2ea4a717b0e0',\n",
493-
" 'reference_id': '149a9c9919c58534aa0f369e85ad95ba7f00aa0513e0f81e2aff2ea4a717b0e0',\n",
509+
"[{'id': 'topic-router:technology:f243fb2d073774e81c7815247cb3013794e6225df3cbe3769cee8c6cefaca777',\n",
510+
" 'reference_id': 'f243fb2d073774e81c7815247cb3013794e6225df3cbe3769cee8c6cefaca777',\n",
494511
" 'route_name': 'technology',\n",
495-
" 'reference': \"what's trending in tech?\"}]"
512+
" 'reference': 'latest AI trends'}]"
496513
]
497514
},
498-
"execution_count": 48,
515+
"execution_count": 17,
499516
"metadata": {},
500517
"output_type": "execute_result"
501518
}
@@ -515,29 +532,29 @@
515532
},
516533
{
517534
"cell_type": "code",
518-
"execution_count": 51,
535+
"execution_count": 18,
519536
"metadata": {},
520537
"outputs": [
521538
{
522539
"data": {
523540
"text/plain": [
524-
"3"
541+
"5"
525542
]
526543
},
527-
"execution_count": 51,
544+
"execution_count": 18,
528545
"metadata": {},
529546
"output_type": "execute_result"
530547
}
531548
],
532549
"source": [
533550
"# by route name\n",
534-
"deleted_count = router.delete_route_references(route_name=\"technology\")\n",
551+
"deleted_count = router.delete_route_references(route_name=\"sports\")\n",
535552
"deleted_count"
536553
]
537554
},
538555
{
539556
"cell_type": "code",
540-
"execution_count": 52,
557+
"execution_count": 19,
541558
"metadata": {},
542559
"outputs": [
543560
{
@@ -546,14 +563,14 @@
546563
"1"
547564
]
548565
},
549-
"execution_count": 52,
566+
"execution_count": 19,
550567
"metadata": {},
551568
"output_type": "execute_result"
552569
}
553570
],
554571
"source": [
555572
"# by id\n",
556-
"deleted_count = router.delete_route_references(route_name=refs[0][\"route_name\"], reference_ids=[refs[0][\"reference_id\"]])\n",
573+
"deleted_count = router.delete_route_references(reference_ids=[refs[0][\"reference_id\"]])\n",
557574
"deleted_count"
558575
]
559576
},
@@ -566,7 +583,7 @@
566583
},
567584
{
568585
"cell_type": "code",
569-
"execution_count": 54,
586+
"execution_count": 20,
570587
"metadata": {},
571588
"outputs": [],
572589
"source": [
@@ -576,7 +593,7 @@
576593
},
577594
{
578595
"cell_type": "code",
579-
"execution_count": 55,
596+
"execution_count": 21,
580597
"metadata": {},
581598
"outputs": [],
582599
"source": [

0 commit comments

Comments
 (0)