Skip to content

Commit 65b9328

Browse files
committed
Created using Colab
1 parent 0bfedbd commit 65b9328

File tree

1 file changed

+69
-66
lines changed

1 file changed

+69
-66
lines changed

notebooks/LlamaIndex_101.ipynb

Lines changed: 69 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
"metadata": {
55
"colab": {
66
"provenance": [],
7-
"authorship_tag": "ABX9TyNzaxKiokXX5SPot1IBiMhR",
7+
"collapsed_sections": [
8+
"HjI_gRaRutfj"
9+
],
10+
"authorship_tag": "ABX9TyOzyI9AMRRR7iatfugkbz3Y",
811
"include_colab_link": true
912
},
1013
"kernelspec": {
@@ -36,16 +39,54 @@
3639
"base_uri": "https://localhost:8080/"
3740
},
3841
"id": "y_GAV7-zos0Y",
39-
"outputId": "74d4a3c4-3576-455b-fbe2-1b8b67bf20d5"
42+
"outputId": "aafcb14a-2caf-4424-c772-1d2bf6246cb2"
4043
},
41-
"execution_count": 10,
44+
"execution_count": 1,
4245
"outputs": [
4346
{
4447
"output_type": "stream",
4548
"name": "stdout",
4649
"text": [
4750
" Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
48-
" Building wheel for wikipedia (setup.py) ... \u001b[?25l\u001b[?25hdone\n"
51+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m67.3/67.3 kB\u001b[0m \u001b[31m1.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
52+
"\u001b[?25h Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n",
53+
" Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n",
54+
" Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
55+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m50.4/50.4 kB\u001b[0m \u001b[31m219.0 kB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
56+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m320.6/320.6 kB\u001b[0m \u001b[31m1.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
57+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.1/1.1 MB\u001b[0m \u001b[31m1.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
58+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m526.8/526.8 kB\u001b[0m \u001b[31m1.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
59+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.4/2.4 MB\u001b[0m \u001b[31m1.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
60+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m273.8/273.8 kB\u001b[0m \u001b[31m1.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
61+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m92.2/92.2 kB\u001b[0m \u001b[31m1.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
62+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m75.6/75.6 kB\u001b[0m \u001b[31m1.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
63+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m77.9/77.9 kB\u001b[0m \u001b[31m1.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
64+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.7/1.7 MB\u001b[0m \u001b[31m2.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
65+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m15.5/15.5 MB\u001b[0m \u001b[31m2.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
66+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.0/2.0 MB\u001b[0m \u001b[31m3.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
67+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m67.6/67.6 kB\u001b[0m \u001b[31m2.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
68+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m6.8/6.8 MB\u001b[0m \u001b[31m3.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
69+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m59.9/59.9 kB\u001b[0m \u001b[31m2.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
70+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m52.5/52.5 kB\u001b[0m \u001b[31m2.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
71+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m130.5/130.5 kB\u001b[0m \u001b[31m4.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
72+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m107.0/107.0 kB\u001b[0m \u001b[31m3.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
73+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m141.1/141.1 kB\u001b[0m \u001b[31m4.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
74+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m41.3/41.3 kB\u001b[0m \u001b[31m2.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
75+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m62.8/62.8 kB\u001b[0m \u001b[31m2.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
76+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m58.3/58.3 kB\u001b[0m \u001b[31m2.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
77+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m341.4/341.4 kB\u001b[0m \u001b[31m4.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
78+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m141.9/141.9 kB\u001b[0m \u001b[31m1.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
79+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m295.8/295.8 kB\u001b[0m \u001b[31m1.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
80+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m71.9/71.9 kB\u001b[0m \u001b[31m3.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
81+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.4/3.4 MB\u001b[0m \u001b[31m4.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
82+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.2/1.2 MB\u001b[0m \u001b[31m5.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
83+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m130.2/130.2 kB\u001b[0m \u001b[31m4.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
84+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m46.0/46.0 kB\u001b[0m \u001b[31m2.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
85+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m307.7/307.7 kB\u001b[0m \u001b[31m3.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
86+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m86.8/86.8 kB\u001b[0m \u001b[31m283.9 kB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
87+
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m49.2/49.2 kB\u001b[0m \u001b[31m3.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
88+
"\u001b[?25h Building wheel for wikipedia (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
89+
" Building wheel for pypika (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n"
4990
]
5091
}
5192
]
@@ -62,20 +103,20 @@
62103
"metadata": {
63104
"id": "Ua0KNwgvyCaj"
64105
},
65-
"execution_count": 49,
106+
"execution_count": 2,
66107
"outputs": []
67108
},
68109
{
69110
"cell_type": "code",
70111
"source": [
71112
"import os\n",
72113
"\n",
73-
"os.environ['OPENAI_API_KEY'] = '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'"
114+
"os.environ['OPENAI_API_KEY'] = '[OPENAI_API_KEY]'"
74115
],
75116
"metadata": {
76117
"id": "--Q2zk06wElp"
77118
},
78-
"execution_count": 2,
119+
"execution_count": 3,
79120
"outputs": []
80121
},
81122
{
@@ -92,7 +133,7 @@
92133
"metadata": {
93134
"id": "tjwZjA8-wITr"
94135
},
95-
"execution_count": 3,
136+
"execution_count": 4,
96137
"outputs": []
97138
},
98139
{
@@ -359,24 +400,24 @@
359400
"base_uri": "https://localhost:8080/"
360401
},
361402
"id": "DrzbBAglwUo0",
362-
"outputId": "73f30202-a708-4112-8491-9152e228c6cb"
403+
"outputId": "5bd17a72-3733-4b8c-e421-5f363f05895f"
363404
},
364-
"execution_count": 35,
405+
"execution_count": 6,
365406
"outputs": [
366407
{
367408
"output_type": "stream",
368409
"name": "stdout",
369410
"text": [
370-
"--2024-07-24 17:20:40-- https://raw.githubusercontent.com/run-llama/llama_index/main/docs/docs/examples/data/paul_graham/paul_graham_essay.txt\n",
371-
"Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.110.133, 185.199.109.133, 185.199.111.133, ...\n",
372-
"Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.110.133|:443... connected.\n",
411+
"--2024-07-24 18:48:21-- https://raw.githubusercontent.com/run-llama/llama_index/main/docs/docs/examples/data/paul_graham/paul_graham_essay.txt\n",
412+
"Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.109.133, 185.199.108.133, 185.199.111.133, ...\n",
413+
"Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|:443... connected.\n",
373414
"HTTP request sent, awaiting response... 200 OK\n",
374415
"Length: 75042 (73K) [text/plain]\n",
375416
"Saving to: ‘./paul_graham/paul_graham_essay.txt’\n",
376417
"\n",
377418
"\r ./paul_gr 0%[ ] 0 --.-KB/s \r./paul_graham/paul_ 100%[===================>] 73.28K --.-KB/s in 0.02s \n",
378419
"\n",
379-
"2024-07-24 17:20:40 (3.33 MB/s) - ‘./paul_graham/paul_graham_essay.txt’ saved [75042/75042]\n",
420+
"2024-07-24 18:48:21 (2.95 MB/s) - ‘./paul_graham/paul_graham_essay.txt’ saved [75042/75042]\n",
380421
"\n"
381422
]
382423
}
@@ -393,7 +434,7 @@
393434
"metadata": {
394435
"id": "S8-QmnkCwIiU"
395436
},
396-
"execution_count": 37,
437+
"execution_count": 7,
397438
"outputs": []
398439
},
399440
{
@@ -410,21 +451,20 @@
410451
"metadata": {
411452
"id": "DfWglp75xc5f"
412453
},
413-
"execution_count": 38,
454+
"execution_count": 8,
414455
"outputs": []
415456
},
416457
{
417458
"cell_type": "code",
418459
"source": [
419460
"from llama_index.core import StorageContext\n",
420461
"\n",
421-
"storage_context = StorageContext.from_defaults(vector_store=vector_store)\n",
422-
"storage_context.docstore.add_documents(nodes)"
462+
"storage_context = StorageContext.from_defaults(vector_store=vector_store)"
423463
],
424464
"metadata": {
425465
"id": "-EVBlUC-xcj1"
426466
},
427-
"execution_count": 39,
467+
"execution_count": 11,
428468
"outputs": []
429469
},
430470
{
@@ -439,7 +479,7 @@
439479
"metadata": {
440480
"id": "8lMa4h9Cwn8b"
441481
},
442-
"execution_count": 40,
482+
"execution_count": 12,
443483
"outputs": []
444484
},
445485
{
@@ -450,7 +490,7 @@
450490
"metadata": {
451491
"id": "tJsfskjHxj0e"
452492
},
453-
"execution_count": 44,
493+
"execution_count": 13,
454494
"outputs": []
455495
},
456496
{
@@ -477,7 +517,7 @@
477517
"metadata": {
478518
"id": "yL9TsFwxxuoA"
479519
},
480-
"execution_count": 50,
520+
"execution_count": 14,
481521
"outputs": []
482522
},
483523
{
@@ -492,9 +532,9 @@
492532
"base_uri": "https://localhost:8080/"
493533
},
494534
"id": "JWc_n5Lhx2bq",
495-
"outputId": "cd992d20-c701-4eb7-aaf2-30f790d1ca24"
535+
"outputId": "972fa40f-065b-420a-d5e8-af36c1a2ad2d"
496536
},
497-
"execution_count": 51,
537+
"execution_count": 15,
498538
"outputs": [
499539
{
500540
"output_type": "stream",
@@ -504,46 +544,9 @@
504544
"\u001b[1;3;38;2;237;90;200m[pg_essay] Q: What did Paul Graham work on before Y Combinator?\n",
505545
"\u001b[0m\u001b[1;3;38;2;90;149;237m[pg_essay] Q: What did Paul Graham work on during Y Combinator?\n",
506546
"\u001b[0m\u001b[1;3;38;2;11;159;203m[pg_essay] Q: What did Paul Graham work on after Y Combinator?\n",
507-
"\u001b[0mGenerated 1 sub questions.\n",
508-
"\u001b[1;3;38;2;237;90;200m[pg_essay] Q: What did Paul Graham work on after Y Combinator?\n",
509-
"\u001b[0mGenerated 1 sub questions.\n",
510-
"\u001b[1;3;38;2;237;90;200m[pg_essay] Q: What is the title of Paul Graham's essay on What I Worked On?\n",
511-
"\u001b[0mGenerated 1 sub questions.\n",
512-
"\u001b[1;3;38;2;237;90;200m[pg_essay] Q: What is the title of Paul Graham's essay on What I Worked On?\n",
513-
"\u001b[0mGenerated 1 sub questions.\n",
514-
"\u001b[1;3;38;2;237;90;200m[pg_essay] Q: What did Paul Graham work on after Y Combinator?\n",
515-
"\u001b[0mGenerated 1 sub questions.\n",
516-
"\u001b[1;3;38;2;237;90;200m[pg_essay] Q: What is the title of Paul Graham's essay on What I Worked On?\n",
517-
"\u001b[0m"
518-
]
519-
},
520-
{
521-
"output_type": "stream",
522-
"name": "stderr",
523-
"text": [
524-
"/usr/lib/python3.10/abc.py:123: RuntimeWarning: coroutine 'run_async_tasks.<locals>._gather' was never awaited\n",
525-
" return _abc_subclasscheck(cls, subclass)\n",
526-
"RuntimeWarning: Enable tracemalloc to get the object allocation traceback\n",
527-
"/usr/lib/python3.10/abc.py:123: RuntimeWarning: coroutine 'SubQuestionQueryEngine._aquery_subq' was never awaited\n",
528-
" return _abc_subclasscheck(cls, subclass)\n",
529-
"RuntimeWarning: Enable tracemalloc to get the object allocation traceback\n"
530-
]
531-
},
532-
{
533-
"output_type": "stream",
534-
"name": "stdout",
535-
"text": [
536-
"Generated 1 sub questions.\n",
537-
"\u001b[1;3;38;2;237;90;200m[pg_essay] Q: What is the title of Paul Graham's essay on What I Worked On?\n",
538-
"\u001b[0m\u001b[1;3;38;2;237;90;200m[pg_essay] A: After Y Combinator, Paul Graham started painting.\n",
539-
"\u001b[0m\u001b[1;3;38;2;237;90;200m[pg_essay] A: The title of Paul Graham's essay on What I Worked On is \"What I Worked On\".\n",
540-
"\u001b[0m\u001b[1;3;38;2;237;90;200m[pg_essay] A: After Y Combinator, Paul Graham started painting.\n",
541-
"\u001b[0m\u001b[1;3;38;2;237;90;200m[pg_essay] A: What I Worked On\n",
542-
"\u001b[0m\u001b[1;3;38;2;237;90;200m[pg_essay] A: What I Worked On\n",
543-
"\u001b[0m\u001b[1;3;38;2;237;90;200m[pg_essay] A: The title of Paul Graham's essay on What I Worked On is \"What I Worked On\".\n",
547+
"\u001b[0m\u001b[1;3;38;2;237;90;200m[pg_essay] A: Paul Graham worked on building online stores through a web app called Viaweb before starting Y Combinator.\n",
544548
"\u001b[0m\u001b[1;3;38;2;11;159;203m[pg_essay] A: After Y Combinator, Paul Graham started painting.\n",
545-
"\u001b[0m\u001b[1;3;38;2;90;149;237m[pg_essay] A: Paul Graham worked on various projects during his time at Y Combinator.\n",
546-
"\u001b[0m\u001b[1;3;38;2;237;90;200m[pg_essay] A: Paul Graham worked on developing Viaweb before Y Combinator.\n",
549+
"\u001b[0m\u001b[1;3;38;2;90;149;237m[pg_essay] A: Paul Graham worked on various aspects during Y Combinator, including being an angel firm, funding startups in batches, providing seed investments, and offering support to startups similar to what he had received when starting his own company.\n",
547550
"\u001b[0m"
548551
]
549552
}
@@ -559,16 +562,16 @@
559562
"base_uri": "https://localhost:8080/"
560563
},
561564
"id": "T-ZC66Ltx5Za",
562-
"outputId": "d7a1c85d-d73c-467d-e0df-9e06078622e2"
565+
"outputId": "f45ec6bb-ee45-4526-80bd-ca7c30cdbf8f"
563566
},
564-
"execution_count": 52,
567+
"execution_count": 16,
565568
"outputs": [
566569
{
567570
"output_type": "stream",
568571
"name": "stdout",
569572
"text": [
570573
">>> The final response:\n",
571-
" Paul Graham worked on developing Viaweb before Y Combinator, on various projects during his time at Y Combinator, and started painting after Y Combinator.\n"
574+
" Paul Graham's life involved building online stores through Viaweb before Y Combinator, working on various aspects within Y Combinator such as funding startups and providing support, and then transitioning to painting after Y Combinator.\n"
572575
]
573576
}
574577
]

0 commit comments

Comments
 (0)