|
21 | 21 | { |
22 | 22 | "metadata": { |
23 | 23 | "ExecuteTime": { |
24 | | - "end_time": "2025-11-22T07:10:04.327797Z", |
25 | | - "start_time": "2025-11-22T07:10:01.111867Z" |
| 24 | + "end_time": "2025-11-22T17:06:36.495021Z", |
| 25 | + "start_time": "2025-11-22T17:06:35.814138Z" |
26 | 26 | } |
27 | 27 | }, |
28 | 28 | "cell_type": "code", |
29 | | - "source": [ |
30 | | - "%pip install -qU langchain-core langchain-redis \"langchain-openai>=1.0.3\" \"redis<7.0\"\n", |
31 | | - "%pip install -qU -e \"../[langcache]\"" |
32 | | - ], |
| 29 | + "source": "%pip install -qU langchain-core \"langchain-redis[langcache]\" \"langchain-openai>=1.0.3\" \"redis<7.0\"", |
33 | 30 | "outputs": [ |
34 | 31 | { |
35 | 32 | "name": "stdout", |
36 | 33 | "output_type": "stream", |
37 | 34 | "text": [ |
| 35 | + "\r\n", |
38 | 36 | "Note: you may need to restart the kernel to use updated packages.\n" |
39 | 37 | ] |
40 | 38 | } |
41 | 39 | ], |
42 | | - "execution_count": 5 |
| 40 | + "execution_count": 3 |
43 | 41 | }, |
44 | 42 | { |
45 | 43 | "metadata": {}, |
|
57 | 55 | { |
58 | 56 | "metadata": { |
59 | 57 | "ExecuteTime": { |
60 | | - "end_time": "2025-11-22T07:10:04.339135Z", |
61 | | - "start_time": "2025-11-22T07:10:04.337286Z" |
| 58 | + "end_time": "2025-11-22T17:06:36.502005Z", |
| 59 | + "start_time": "2025-11-22T17:06:36.499949Z" |
62 | 60 | } |
63 | 61 | }, |
64 | 62 | "cell_type": "code", |
|
79 | 77 | ] |
80 | 78 | } |
81 | 79 | ], |
82 | | - "execution_count": 6 |
| 80 | + "execution_count": 4 |
83 | 81 | }, |
84 | 82 | { |
85 | 83 | "metadata": {}, |
|
89 | 87 | { |
90 | 88 | "metadata": { |
91 | 89 | "ExecuteTime": { |
92 | | - "end_time": "2025-11-22T07:10:04.351558Z", |
93 | | - "start_time": "2025-11-22T07:10:04.349814Z" |
| 90 | + "end_time": "2025-11-22T17:06:38.048298Z", |
| 91 | + "start_time": "2025-11-22T17:06:36.519903Z" |
94 | 92 | } |
95 | 93 | }, |
96 | 94 | "cell_type": "code", |
|
105 | 103 | "from langchain_redis import RedisCache, RedisSemanticCache, LangCacheSemanticCache" |
106 | 104 | ], |
107 | 105 | "outputs": [], |
108 | | - "execution_count": 7 |
| 106 | + "execution_count": 5 |
109 | 107 | }, |
110 | 108 | { |
111 | 109 | "metadata": {}, |
|
115 | 113 | { |
116 | 114 | "metadata": { |
117 | 115 | "ExecuteTime": { |
118 | | - "end_time": "2025-11-22T07:10:04.360419Z", |
119 | | - "start_time": "2025-11-22T07:10:04.358547Z" |
| 116 | + "end_time": "2025-11-22T17:06:38.059329Z", |
| 117 | + "start_time": "2025-11-22T17:06:38.057687Z" |
120 | 118 | } |
121 | 119 | }, |
122 | 120 | "cell_type": "code", |
|
143 | 141 | ] |
144 | 142 | } |
145 | 143 | ], |
146 | | - "execution_count": 8 |
| 144 | + "execution_count": 6 |
147 | 145 | }, |
148 | 146 | { |
149 | 147 | "metadata": {}, |
|
153 | 151 | { |
154 | 152 | "metadata": { |
155 | 153 | "ExecuteTime": { |
156 | | - "end_time": "2025-11-22T07:10:05.188067Z", |
157 | | - "start_time": "2025-11-22T07:10:04.365151Z" |
| 154 | + "end_time": "2025-11-22T17:06:39.414088Z", |
| 155 | + "start_time": "2025-11-22T17:06:38.071005Z" |
158 | 156 | } |
159 | 157 | }, |
160 | 158 | "cell_type": "code", |
|
201 | 199 | "Result: \n", |
202 | 200 | "\n", |
203 | 201 | "Caching is the process of storing frequently accessed data in a temporary storage location for faster retrieval. This helps to reduce the time and resources needed to access the data from its original source. Caching is commonly used in computer systems, web browsers, and databases to improve performance and efficiency.\n", |
204 | | - "Time: 0.68 seconds\n", |
| 202 | + "Time: 1.15 seconds\n", |
205 | 203 | "\n", |
206 | 204 | "Second call (cached):\n", |
207 | 205 | "Result: \n", |
208 | 206 | "\n", |
209 | 207 | "Caching is the process of storing frequently accessed data in a temporary storage location for faster retrieval. This helps to reduce the time and resources needed to access the data from its original source. Caching is commonly used in computer systems, web browsers, and databases to improve performance and efficiency.\n", |
210 | 208 | "Time: 0.00 seconds\n", |
211 | 209 | "\n", |
212 | | - "Speed improvement: 525.11x faster\n", |
| 210 | + "Speed improvement: 552.26x faster\n", |
213 | 211 | "Cache cleared\n" |
214 | 212 | ] |
215 | 213 | } |
216 | 214 | ], |
217 | | - "execution_count": 9 |
| 215 | + "execution_count": 7 |
218 | 216 | }, |
219 | 217 | { |
220 | 218 | "metadata": {}, |
|
224 | 222 | { |
225 | 223 | "metadata": { |
226 | 224 | "ExecuteTime": { |
227 | | - "end_time": "2025-11-22T07:10:07.296869Z", |
228 | | - "start_time": "2025-11-22T07:10:05.206110Z" |
| 225 | + "end_time": "2025-11-22T17:06:43.518554Z", |
| 226 | + "start_time": "2025-11-22T17:06:39.428393Z" |
229 | 227 | } |
230 | 228 | }, |
231 | 229 | "cell_type": "code", |
|
277 | 275 | "Result: \n", |
278 | 276 | "\n", |
279 | 277 | "The capital of France is Paris.\n", |
280 | | - "Time: 1.37 seconds\n", |
| 278 | + "Time: 3.05 seconds\n", |
281 | 279 | "\n", |
282 | 280 | "Similar query:\n", |
283 | 281 | "Prompt: Can you tell me the capital city of France?\n", |
284 | 282 | "\n", |
285 | 283 | "Result: \n", |
286 | 284 | "\n", |
287 | 285 | "The capital of France is Paris.\n", |
288 | | - "Time: 0.39 seconds\n", |
| 286 | + "Time: 0.14 seconds\n", |
289 | 287 | "\n", |
290 | | - "Speed improvement: 3.48x faster\n", |
| 288 | + "Speed improvement: 21.12x faster\n", |
291 | 289 | "Semantic cache cleared\n" |
292 | 290 | ] |
293 | 291 | } |
294 | 292 | ], |
295 | | - "execution_count": 10 |
| 293 | + "execution_count": 8 |
296 | 294 | }, |
297 | 295 | { |
298 | 296 | "metadata": {}, |
|
311 | 309 | { |
312 | 310 | "metadata": { |
313 | 311 | "ExecuteTime": { |
314 | | - "end_time": "2025-11-22T07:10:09.664948Z", |
315 | | - "start_time": "2025-11-22T07:10:07.313993Z" |
| 312 | + "end_time": "2025-11-22T17:06:44.679848Z", |
| 313 | + "start_time": "2025-11-22T17:06:43.540988Z" |
316 | 314 | } |
317 | 315 | }, |
318 | 316 | "cell_type": "code", |
|
390 | 388 | "Result: \n", |
391 | 389 | "\n", |
392 | 390 | "The capital of France is Paris.\n", |
393 | | - "Time: 2.02 seconds\n", |
| 391 | + "Time: 0.85 seconds\n", |
394 | 392 | "\n", |
395 | 393 | "Similar query:\n", |
396 | 394 | "Prompt: Can you tell me the capital city of France?\n", |
397 | 395 | "\n", |
398 | 396 | "Result: \n", |
399 | 397 | "\n", |
400 | 398 | "The capital of France is Paris.\n", |
401 | | - "Time: 0.15 seconds\n", |
| 399 | + "Time: 0.13 seconds\n", |
402 | 400 | "\n", |
403 | | - "(Similar query) Speed improvement: 13.78x faster\n", |
| 401 | + "(Similar query) Speed improvement: 6.75x faster\n", |
404 | 402 | "Semantic cache cleared\n" |
405 | 403 | ] |
406 | 404 | } |
407 | 405 | ], |
408 | | - "execution_count": 11 |
| 406 | + "execution_count": 9 |
409 | 407 | }, |
410 | 408 | { |
411 | 409 | "metadata": { |
412 | 410 | "ExecuteTime": { |
413 | | - "end_time": "2025-11-22T07:10:09.686945Z", |
414 | | - "start_time": "2025-11-22T07:10:09.685687Z" |
| 411 | + "end_time": "2025-11-22T17:06:44.697353Z", |
| 412 | + "start_time": "2025-11-22T17:06:44.696216Z" |
415 | 413 | } |
416 | 414 | }, |
417 | 415 | "cell_type": "code", |
|
432 | 430 | { |
433 | 431 | "metadata": { |
434 | 432 | "ExecuteTime": { |
435 | | - "end_time": "2025-11-22T07:10:15.708721Z", |
436 | | - "start_time": "2025-11-22T07:10:09.689547Z" |
| 433 | + "end_time": "2025-11-22T17:06:50.714859Z", |
| 434 | + "start_time": "2025-11-22T17:06:44.700932Z" |
437 | 435 | } |
438 | 436 | }, |
439 | 437 | "cell_type": "code", |
|
470 | 468 | ] |
471 | 469 | } |
472 | 470 | ], |
473 | | - "execution_count": 12 |
| 471 | + "execution_count": 10 |
474 | 472 | }, |
475 | 473 | { |
476 | 474 | "metadata": {}, |
|
480 | 478 | { |
481 | 479 | "metadata": { |
482 | 480 | "ExecuteTime": { |
483 | | - "end_time": "2025-11-22T07:10:17.430674Z", |
484 | | - "start_time": "2025-11-22T07:10:15.729854Z" |
| 481 | + "end_time": "2025-11-22T17:06:52.510744Z", |
| 482 | + "start_time": "2025-11-22T17:06:50.738791Z" |
485 | 483 | } |
486 | 484 | }, |
487 | 485 | "cell_type": "code", |
|
524 | 522 | ] |
525 | 523 | } |
526 | 524 | ], |
527 | | - "execution_count": 13 |
| 525 | + "execution_count": 11 |
528 | 526 | }, |
529 | 527 | { |
530 | 528 | "metadata": {}, |
|
0 commit comments