Spaces:
Runtime error
Runtime error
Delete app.py
Browse files
app.py
DELETED
@@ -1,455 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"cells": [
|
3 |
-
{
|
4 |
-
"cell_type": "markdown",
|
5 |
-
"metadata": {
|
6 |
-
"id": "XiUyHP4T2g5F"
|
7 |
-
},
|
8 |
-
"source": [
|
9 |
-
"# Install the dependicies\n",
|
10 |
-
"Run the code below to install the depencies we need for our functions"
|
11 |
-
]
|
12 |
-
},
|
13 |
-
{
|
14 |
-
"cell_type": "code",
|
15 |
-
"execution_count": 1,
|
16 |
-
"metadata": {
|
17 |
-
"colab": {
|
18 |
-
"base_uri": "https://localhost:8080/"
|
19 |
-
},
|
20 |
-
"id": "6LL4rxT6_W7h",
|
21 |
-
"outputId": "700a185c-1a2a-4f5a-b841-2295ec556b02"
|
22 |
-
},
|
23 |
-
"outputs": [
|
24 |
-
{
|
25 |
-
"name": "stdout",
|
26 |
-
"output_type": "stream",
|
27 |
-
"text": [
|
28 |
-
"Requirement already satisfied: llama-index in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (0.4.33)\n",
|
29 |
-
"Requirement already satisfied: dataclasses_json in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from llama-index) (0.5.7)\n",
|
30 |
-
"Requirement already satisfied: langchain in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from llama-index) (0.0.117)\n",
|
31 |
-
"Requirement already satisfied: numpy in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from llama-index) (1.24.2)\n",
|
32 |
-
"Requirement already satisfied: tenacity<9.0.0,>=8.2.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from llama-index) (8.2.2)\n",
|
33 |
-
"Requirement already satisfied: openai>=0.26.4 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from llama-index) (0.27.2)\n",
|
34 |
-
"Requirement already satisfied: pandas in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from llama-index) (1.5.3)\n",
|
35 |
-
"Requirement already satisfied: tiktoken in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from llama-index) (0.3.2)\n",
|
36 |
-
"Requirement already satisfied: requests>=2.20 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from openai>=0.26.4->llama-index) (2.28.2)\n",
|
37 |
-
"Requirement already satisfied: tqdm in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from openai>=0.26.4->llama-index) (4.65.0)\n",
|
38 |
-
"Requirement already satisfied: aiohttp in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from openai>=0.26.4->llama-index) (3.8.4)\n",
|
39 |
-
"Requirement already satisfied: marshmallow<4.0.0,>=3.3.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from dataclasses_json->llama-index) (3.19.0)\n",
|
40 |
-
"Requirement already satisfied: marshmallow-enum<2.0.0,>=1.5.1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from dataclasses_json->llama-index) (1.5.1)\n",
|
41 |
-
"Requirement already satisfied: typing-inspect>=0.4.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from dataclasses_json->llama-index) (0.8.0)\n",
|
42 |
-
"Requirement already satisfied: PyYAML>=5.4.1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from langchain->llama-index) (6.0)\n",
|
43 |
-
"Requirement already satisfied: SQLAlchemy<2,>=1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from langchain->llama-index) (1.2.19)\n",
|
44 |
-
"Requirement already satisfied: pydantic<2,>=1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from langchain->llama-index) (1.10.6)\n",
|
45 |
-
"Requirement already satisfied: python-dateutil>=2.8.1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from pandas->llama-index) (2.8.2)\n",
|
46 |
-
"Requirement already satisfied: pytz>=2020.1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from pandas->llama-index) (2022.7.1)\n",
|
47 |
-
"Requirement already satisfied: regex>=2022.1.18 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from tiktoken->llama-index) (2022.10.31)\n",
|
48 |
-
"Requirement already satisfied: attrs>=17.3.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp->openai>=0.26.4->llama-index) (22.2.0)\n",
|
49 |
-
"Requirement already satisfied: charset-normalizer<4.0,>=2.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp->openai>=0.26.4->llama-index) (3.1.0)\n",
|
50 |
-
"Requirement already satisfied: multidict<7.0,>=4.5 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp->openai>=0.26.4->llama-index) (6.0.4)\n",
|
51 |
-
"Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp->openai>=0.26.4->llama-index) (4.0.2)\n",
|
52 |
-
"Requirement already satisfied: yarl<2.0,>=1.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp->openai>=0.26.4->llama-index) (1.8.2)\n",
|
53 |
-
"Requirement already satisfied: frozenlist>=1.1.1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp->openai>=0.26.4->llama-index) (1.3.3)\n",
|
54 |
-
"Requirement already satisfied: aiosignal>=1.1.2 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp->openai>=0.26.4->llama-index) (1.3.1)\n",
|
55 |
-
"Requirement already satisfied: packaging>=17.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from marshmallow<4.0.0,>=3.3.0->dataclasses_json->llama-index) (23.0)\n",
|
56 |
-
"Requirement already satisfied: typing-extensions>=4.2.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from pydantic<2,>=1->langchain->llama-index) (4.5.0)\n",
|
57 |
-
"Requirement already satisfied: six>=1.5 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from python-dateutil>=2.8.1->pandas->llama-index) (1.16.0)\n",
|
58 |
-
"Requirement already satisfied: idna<4,>=2.5 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from requests>=2.20->openai>=0.26.4->llama-index) (3.4)\n",
|
59 |
-
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from requests>=2.20->openai>=0.26.4->llama-index) (1.26.15)\n",
|
60 |
-
"Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from requests>=2.20->openai>=0.26.4->llama-index) (2022.12.7)\n",
|
61 |
-
"Requirement already satisfied: mypy-extensions>=0.3.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from typing-inspect>=0.4.0->dataclasses_json->llama-index) (1.0.0)\n",
|
62 |
-
"Requirement already satisfied: colorama in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from tqdm->openai>=0.26.4->llama-index) (0.4.6)\n",
|
63 |
-
"Note: you may need to restart the kernel to use updated packages.\n",
|
64 |
-
"Requirement already satisfied: langchain in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (0.0.117)\n",
|
65 |
-
"Requirement already satisfied: PyYAML>=5.4.1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from langchain) (6.0)\n",
|
66 |
-
"Requirement already satisfied: SQLAlchemy<2,>=1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from langchain) (1.2.19)\n",
|
67 |
-
"Requirement already satisfied: aiohttp<4.0.0,>=3.8.3 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from langchain) (3.8.4)\n",
|
68 |
-
"Requirement already satisfied: dataclasses-json<0.6.0,>=0.5.7 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from langchain) (0.5.7)\n",
|
69 |
-
"Requirement already satisfied: numpy<2,>=1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from langchain) (1.24.2)\n",
|
70 |
-
"Requirement already satisfied: pydantic<2,>=1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from langchain) (1.10.6)\n",
|
71 |
-
"Requirement already satisfied: requests<3,>=2 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from langchain) (2.28.2)\n",
|
72 |
-
"Requirement already satisfied: tenacity<9.0.0,>=8.1.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from langchain) (8.2.2)\n",
|
73 |
-
"Requirement already satisfied: attrs>=17.3.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (22.2.0)\n",
|
74 |
-
"Requirement already satisfied: charset-normalizer<4.0,>=2.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (3.1.0)\n",
|
75 |
-
"Requirement already satisfied: multidict<7.0,>=4.5 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (6.0.4)\n",
|
76 |
-
"Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (4.0.2)\n",
|
77 |
-
"Requirement already satisfied: yarl<2.0,>=1.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.8.2)\n",
|
78 |
-
"Requirement already satisfied: frozenlist>=1.1.1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.3.3)\n",
|
79 |
-
"Requirement already satisfied: aiosignal>=1.1.2 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.3.1)\n",
|
80 |
-
"Requirement already satisfied: marshmallow<4.0.0,>=3.3.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from dataclasses-json<0.6.0,>=0.5.7->langchain) (3.19.0)\n",
|
81 |
-
"Requirement already satisfied: marshmallow-enum<2.0.0,>=1.5.1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from dataclasses-json<0.6.0,>=0.5.7->langchain) (1.5.1)\n",
|
82 |
-
"Requirement already satisfied: typing-inspect>=0.4.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from dataclasses-json<0.6.0,>=0.5.7->langchain) (0.8.0)\n",
|
83 |
-
"Requirement already satisfied: typing-extensions>=4.2.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from pydantic<2,>=1->langchain) (4.5.0)\n",
|
84 |
-
"Requirement already satisfied: idna<4,>=2.5 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from requests<3,>=2->langchain) (3.4)\n",
|
85 |
-
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from requests<3,>=2->langchain) (1.26.15)\n",
|
86 |
-
"Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from requests<3,>=2->langchain) (2022.12.7)\n",
|
87 |
-
"Requirement already satisfied: packaging>=17.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from marshmallow<4.0.0,>=3.3.0->dataclasses-json<0.6.0,>=0.5.7->langchain) (23.0)\n",
|
88 |
-
"Requirement already satisfied: mypy-extensions>=0.3.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from typing-inspect>=0.4.0->dataclasses-json<0.6.0,>=0.5.7->langchain) (1.0.0)\n",
|
89 |
-
"Note: you may need to restart the kernel to use updated packages.\n",
|
90 |
-
"Requirement already satisfied: gradio in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (3.23.0)\n",
|
91 |
-
"Requirement already satisfied: aiofiles in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (23.1.0)\n",
|
92 |
-
"Requirement already satisfied: aiohttp in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (3.8.4)\n",
|
93 |
-
"Requirement already satisfied: altair>=4.2.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (4.2.2)\n",
|
94 |
-
"Requirement already satisfied: fastapi in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (0.95.0)\n",
|
95 |
-
"Requirement already satisfied: ffmpy in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (0.3.0)\n",
|
96 |
-
"Requirement already satisfied: fsspec in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (2023.3.0)\n",
|
97 |
-
"Requirement already satisfied: httpx in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (0.23.3)\n",
|
98 |
-
"Requirement already satisfied: huggingface-hub in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (0.13.3)\n",
|
99 |
-
"Requirement already satisfied: jinja2 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (3.1.2)\n",
|
100 |
-
"Requirement already satisfied: markdown-it-py[linkify]>=2.0.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (2.2.0)\n",
|
101 |
-
"Requirement already satisfied: markupsafe in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (2.1.2)\n",
|
102 |
-
"Requirement already satisfied: matplotlib in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (3.7.1)\n",
|
103 |
-
"Requirement already satisfied: mdit-py-plugins<=0.3.3 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (0.3.3)\n",
|
104 |
-
"Requirement already satisfied: numpy in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (1.24.2)\n",
|
105 |
-
"Requirement already satisfied: orjson in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (3.8.8)\n",
|
106 |
-
"Requirement already satisfied: pandas in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (1.5.3)\n",
|
107 |
-
"Requirement already satisfied: pillow in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (9.4.0)\n",
|
108 |
-
"Requirement already satisfied: pydantic in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (1.10.6)\n",
|
109 |
-
"Requirement already satisfied: pydub in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (0.25.1)\n",
|
110 |
-
"Requirement already satisfied: python-multipart in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (0.0.6)\n",
|
111 |
-
"Requirement already satisfied: pyyaml in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (6.0)\n",
|
112 |
-
"Requirement already satisfied: requests in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (2.28.2)\n",
|
113 |
-
"Requirement already satisfied: semantic-version in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (2.10.0)\n",
|
114 |
-
"Requirement already satisfied: typing-extensions in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (4.5.0)\n",
|
115 |
-
"Requirement already satisfied: uvicorn in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (0.21.1)\n",
|
116 |
-
"Requirement already satisfied: websockets>=10.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from gradio) (10.4)\n",
|
117 |
-
"Requirement already satisfied: entrypoints in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from altair>=4.2.0->gradio) (0.4)\n",
|
118 |
-
"Requirement already satisfied: jsonschema>=3.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from altair>=4.2.0->gradio) (4.17.3)\n",
|
119 |
-
"Requirement already satisfied: toolz in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from altair>=4.2.0->gradio) (0.12.0)\n",
|
120 |
-
"Requirement already satisfied: filelock in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from huggingface-hub->gradio) (3.10.0)\n",
|
121 |
-
"Requirement already satisfied: tqdm>=4.42.1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from huggingface-hub->gradio) (4.65.0)\n",
|
122 |
-
"Requirement already satisfied: packaging>=20.9 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from huggingface-hub->gradio) (23.0)\n",
|
123 |
-
"Requirement already satisfied: mdurl~=0.1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from markdown-it-py[linkify]>=2.0.0->gradio) (0.1.2)\n",
|
124 |
-
"Requirement already satisfied: linkify-it-py<3,>=1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from markdown-it-py[linkify]>=2.0.0->gradio) (2.0.0)\n",
|
125 |
-
"Requirement already satisfied: python-dateutil>=2.8.1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from pandas->gradio) (2.8.2)\n",
|
126 |
-
"Requirement already satisfied: pytz>=2020.1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from pandas->gradio) (2022.7.1)\n",
|
127 |
-
"Requirement already satisfied: attrs>=17.3.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp->gradio) (22.2.0)\n",
|
128 |
-
"Requirement already satisfied: charset-normalizer<4.0,>=2.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp->gradio) (3.1.0)\n",
|
129 |
-
"Requirement already satisfied: multidict<7.0,>=4.5 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp->gradio) (6.0.4)\n",
|
130 |
-
"Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp->gradio) (4.0.2)\n",
|
131 |
-
"Requirement already satisfied: yarl<2.0,>=1.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp->gradio) (1.8.2)\n",
|
132 |
-
"Requirement already satisfied: frozenlist>=1.1.1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp->gradio) (1.3.3)\n",
|
133 |
-
"Requirement already satisfied: aiosignal>=1.1.2 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp->gradio) (1.3.1)\n",
|
134 |
-
"Requirement already satisfied: starlette<0.27.0,>=0.26.1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from fastapi->gradio) (0.26.1)\n",
|
135 |
-
"Requirement already satisfied: certifi in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from httpx->gradio) (2022.12.7)\n",
|
136 |
-
"Requirement already satisfied: httpcore<0.17.0,>=0.15.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from httpx->gradio) (0.16.3)\n",
|
137 |
-
"Requirement already satisfied: rfc3986[idna2008]<2,>=1.3 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from httpx->gradio) (1.5.0)\n",
|
138 |
-
"Requirement already satisfied: sniffio in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from httpx->gradio) (1.3.0)\n",
|
139 |
-
"Requirement already satisfied: contourpy>=1.0.1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from matplotlib->gradio) (1.0.7)\n",
|
140 |
-
"Requirement already satisfied: cycler>=0.10 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from matplotlib->gradio) (0.11.0)\n",
|
141 |
-
"Requirement already satisfied: fonttools>=4.22.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from matplotlib->gradio) (4.39.2)\n",
|
142 |
-
"Requirement already satisfied: kiwisolver>=1.0.1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from matplotlib->gradio) (1.4.4)\n",
|
143 |
-
"Requirement already satisfied: pyparsing>=2.3.1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from matplotlib->gradio) (3.0.9)\n",
|
144 |
-
"Requirement already satisfied: idna<4,>=2.5 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from requests->gradio) (3.4)\n",
|
145 |
-
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from requests->gradio) (1.26.15)\n",
|
146 |
-
"Requirement already satisfied: click>=7.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from uvicorn->gradio) (8.1.3)\n",
|
147 |
-
"Requirement already satisfied: h11>=0.8 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from uvicorn->gradio) (0.14.0)\n",
|
148 |
-
"Requirement already satisfied: colorama in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from click>=7.0->uvicorn->gradio) (0.4.6)\n",
|
149 |
-
"Requirement already satisfied: anyio<5.0,>=3.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from httpcore<0.17.0,>=0.15.0->httpx->gradio) (3.6.2)\n",
|
150 |
-
"Requirement already satisfied: pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from jsonschema>=3.0->altair>=4.2.0->gradio) (0.19.3)\n",
|
151 |
-
"Requirement already satisfied: uc-micro-py in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from linkify-it-py<3,>=1->markdown-it-py[linkify]>=2.0.0->gradio) (1.0.1)\n",
|
152 |
-
"Requirement already satisfied: six>=1.5 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from python-dateutil>=2.8.1->pandas->gradio) (1.16.0)\n",
|
153 |
-
"Note: you may need to restart the kernel to use updated packages.\n",
|
154 |
-
"Requirement already satisfied: openai in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (0.27.2)\n",
|
155 |
-
"Requirement already satisfied: requests>=2.20 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from openai) (2.28.2)\n",
|
156 |
-
"Requirement already satisfied: tqdm in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from openai) (4.65.0)\n",
|
157 |
-
"Requirement already satisfied: aiohttp in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from openai) (3.8.4)\n",
|
158 |
-
"Requirement already satisfied: charset-normalizer<4,>=2 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from requests>=2.20->openai) (3.1.0)\n",
|
159 |
-
"Requirement already satisfied: idna<4,>=2.5 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from requests>=2.20->openai) (3.4)\n",
|
160 |
-
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from requests>=2.20->openai) (1.26.15)\n",
|
161 |
-
"Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from requests>=2.20->openai) (2022.12.7)\n",
|
162 |
-
"Requirement already satisfied: attrs>=17.3.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp->openai) (22.2.0)\n",
|
163 |
-
"Requirement already satisfied: multidict<7.0,>=4.5 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp->openai) (6.0.4)\n",
|
164 |
-
"Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp->openai) (4.0.2)\n",
|
165 |
-
"Requirement already satisfied: yarl<2.0,>=1.0 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp->openai) (1.8.2)\n",
|
166 |
-
"Requirement already satisfied: frozenlist>=1.1.1 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp->openai) (1.3.3)\n",
|
167 |
-
"Requirement already satisfied: aiosignal>=1.1.2 in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from aiohttp->openai) (1.3.1)\n",
|
168 |
-
"Requirement already satisfied: colorama in c:\\users\\ewok\\appdata\\roaming\\python\\python311\\site-packages (from tqdm->openai) (0.4.6)\n",
|
169 |
-
"Note: you may need to restart the kernel to use updated packages.\n"
|
170 |
-
]
|
171 |
-
}
|
172 |
-
],
|
173 |
-
"source": [
|
174 |
-
"%pip install llama-index\n",
|
175 |
-
"%pip install langchain\n",
|
176 |
-
"%pip install gradio\n",
|
177 |
-
"%pip install openai"
|
178 |
-
]
|
179 |
-
},
|
180 |
-
{
|
181 |
-
"cell_type": "markdown",
|
182 |
-
"metadata": {
|
183 |
-
"id": "FbuYetOy25eM"
|
184 |
-
},
|
185 |
-
"source": [
|
186 |
-
"# Define the functions\n",
|
187 |
-
"The following code defines the functions we need to construct the index and query it"
|
188 |
-
]
|
189 |
-
},
|
190 |
-
{
|
191 |
-
"cell_type": "code",
|
192 |
-
"execution_count": 5,
|
193 |
-
"metadata": {
|
194 |
-
"id": "UelAqQgk_yIt"
|
195 |
-
},
|
196 |
-
"outputs": [
|
197 |
-
{
|
198 |
-
"ename": "AttributeError",
|
199 |
-
"evalue": "module 'time' has no attribute 'clock'",
|
200 |
-
"output_type": "error",
|
201 |
-
"traceback": [
|
202 |
-
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
203 |
-
"\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
|
204 |
-
"Cell \u001b[1;32mIn[5], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m \u001b[39mimport\u001b[39;00m SimpleDirectoryReader, GPTSimpleVectorIndex, LLMPredictor, PromptHelper\n\u001b[0;32m 2\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m \u001b[39mimport\u001b[39;00m OpenAI\n\u001b[0;32m 3\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39msys\u001b[39;00m\n",
|
205 |
-
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\llama_index\\__init__.py:18\u001b[0m\n\u001b[0;32m 15\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39membeddings\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mopenai\u001b[39;00m \u001b[39mimport\u001b[39;00m OpenAIEmbedding\n\u001b[0;32m 17\u001b[0m \u001b[39m# structured\u001b[39;00m\n\u001b[1;32m---> 18\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mindices\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mcommon\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mstruct_store\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m SQLDocumentContextBuilder\n\u001b[0;32m 19\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mindices\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mempty\u001b[39;00m \u001b[39mimport\u001b[39;00m GPTEmptyIndex\n\u001b[0;32m 21\u001b[0m \u001b[39m# indices\u001b[39;00m\n",
|
206 |
-
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\llama_index\\indices\\__init__.py:4\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[39m\"\"\"LlamaIndex data structures.\"\"\"\u001b[39;00m\n\u001b[0;32m 3\u001b[0m \u001b[39m# indices\u001b[39;00m\n\u001b[1;32m----> 4\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mindices\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mkeyword_table\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m GPTKeywordTableIndex\n\u001b[0;32m 5\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mindices\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mkeyword_table\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mrake_base\u001b[39;00m \u001b[39mimport\u001b[39;00m GPTRAKEKeywordTableIndex\n\u001b[0;32m 6\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mindices\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mkeyword_table\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39msimple_base\u001b[39;00m \u001b[39mimport\u001b[39;00m GPTSimpleKeywordTableIndex\n",
|
207 |
-
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\llama_index\\indices\\keyword_table\\__init__.py:4\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[39m\"\"\"Keyword Table Index Data Structures.\"\"\"\u001b[39;00m\n\u001b[0;32m 3\u001b[0m \u001b[39m# indices\u001b[39;00m\n\u001b[1;32m----> 4\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mindices\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mkeyword_table\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m GPTKeywordTableIndex\n\u001b[0;32m 5\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mindices\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mkeyword_table\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mrake_base\u001b[39;00m \u001b[39mimport\u001b[39;00m GPTRAKEKeywordTableIndex\n\u001b[0;32m 6\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mindices\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mkeyword_table\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39msimple_base\u001b[39;00m \u001b[39mimport\u001b[39;00m GPTSimpleKeywordTableIndex\n",
|
208 |
-
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\llama_index\\indices\\keyword_table\\base.py:16\u001b[0m\n\u001b[0;32m 14\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39masync_utils\u001b[39;00m \u001b[39mimport\u001b[39;00m run_async_tasks\n\u001b[0;32m 15\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mdata_structs\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mdata_structs\u001b[39;00m \u001b[39mimport\u001b[39;00m KeywordTable\n\u001b[1;32m---> 16\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mindices\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m DOCUMENTS_INPUT, BaseGPTIndex\n\u001b[0;32m 17\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mindices\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mkeyword_table\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mutils\u001b[39;00m \u001b[39mimport\u001b[39;00m extract_keywords_given_response\n\u001b[0;32m 18\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mindices\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mquery\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m BaseGPTIndexQuery\n",
|
209 |
-
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\llama_index\\indices\\base.py:23\u001b[0m\n\u001b[0;32m 21\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39membeddings\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mopenai\u001b[39;00m \u001b[39mimport\u001b[39;00m OpenAIEmbedding\n\u001b[0;32m 22\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mindices\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mnode_utils\u001b[39;00m \u001b[39mimport\u001b[39;00m get_nodes_from_document\n\u001b[1;32m---> 23\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mindices\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mprompt_helper\u001b[39;00m \u001b[39mimport\u001b[39;00m PromptHelper\n\u001b[0;32m 24\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mindices\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mquery\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m BaseGPTIndexQuery\n\u001b[0;32m 25\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mindices\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mquery\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mquery_runner\u001b[39;00m \u001b[39mimport\u001b[39;00m QueryRunner\n",
|
210 |
-
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\llama_index\\indices\\prompt_helper.py:12\u001b[0m\n\u001b[0;32m 10\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mconstants\u001b[39;00m \u001b[39mimport\u001b[39;00m MAX_CHUNK_OVERLAP\n\u001b[0;32m 11\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mdata_structs\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mdata_structs\u001b[39;00m \u001b[39mimport\u001b[39;00m Node\n\u001b[1;32m---> 12\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mlangchain_helpers\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mchain_wrapper\u001b[39;00m \u001b[39mimport\u001b[39;00m LLMPredictor\n\u001b[0;32m 13\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mlangchain_helpers\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mtext_splitter\u001b[39;00m \u001b[39mimport\u001b[39;00m TokenTextSplitter\n\u001b[0;32m 14\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mprompts\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m Prompt\n",
|
211 |
-
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\llama_index\\langchain_helpers\\chain_wrapper.py:6\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[39m\"\"\"Wrapper functions around an LLM chain.\"\"\"\u001b[39;00m\n\u001b[0;32m 3\u001b[0m \u001b[39m# NOTE: moved to llama_index/llm_predictor/base.py\u001b[39;00m\n\u001b[0;32m 4\u001b[0m \u001b[39m# NOTE: this is for backwards compatibility\u001b[39;00m\n\u001b[1;32m----> 6\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mllm_predictor\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m ( \u001b[39m# noqa: F401\u001b[39;00m\n\u001b[0;32m 7\u001b[0m LLMChain,\n\u001b[0;32m 8\u001b[0m LLMMetadata,\n\u001b[0;32m 9\u001b[0m LLMPredictor,\n\u001b[0;32m 10\u001b[0m )\n",
|
212 |
-
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\llama_index\\llm_predictor\\__init__.py:4\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[39m\"\"\"Init params.\"\"\"\u001b[39;00m\n\u001b[0;32m 3\u001b[0m \u001b[39m# TODO: move LLMPredictor to this folder\u001b[39;00m\n\u001b[1;32m----> 4\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mllm_predictor\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m LLMPredictor\n\u001b[0;32m 5\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mllama_index\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mllm_predictor\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mstructured\u001b[39;00m \u001b[39mimport\u001b[39;00m StructuredLLMPredictor\n\u001b[0;32m 7\u001b[0m __all__ \u001b[39m=\u001b[39m [\n\u001b[0;32m 8\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mLLMPredictor\u001b[39m\u001b[39m\"\u001b[39m,\n\u001b[0;32m 9\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mStructuredLLMPredictor\u001b[39m\u001b[39m\"\u001b[39m,\n\u001b[0;32m 10\u001b[0m ]\n",
|
213 |
-
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\llama_index\\llm_predictor\\base.py:9\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mtyping\u001b[39;00m \u001b[39mimport\u001b[39;00m Any, Generator, Optional, Protocol, Tuple\n\u001b[0;32m 8\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mopenai\u001b[39;00m\n\u001b[1;32m----> 9\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m \u001b[39mimport\u001b[39;00m Cohere, LLMChain, OpenAI\n\u001b[0;32m 10\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mchat_models\u001b[39;00m \u001b[39mimport\u001b[39;00m ChatOpenAI\n\u001b[0;32m 11\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mllms\u001b[39;00m \u001b[39mimport\u001b[39;00m AI21\n",
|
214 |
-
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\langchain\\__init__.py:5\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[39m\"\"\"Main entrypoint into package.\"\"\"\u001b[39;00m\n\u001b[0;32m 3\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mtyping\u001b[39;00m \u001b[39mimport\u001b[39;00m Optional\n\u001b[1;32m----> 5\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39magents\u001b[39;00m \u001b[39mimport\u001b[39;00m MRKLChain, ReActChain, SelfAskWithSearchChain\n\u001b[0;32m 6\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mcache\u001b[39;00m \u001b[39mimport\u001b[39;00m BaseCache\n\u001b[0;32m 7\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mcallbacks\u001b[39;00m \u001b[39mimport\u001b[39;00m (\n\u001b[0;32m 8\u001b[0m set_default_callback_manager,\n\u001b[0;32m 9\u001b[0m set_handler,\n\u001b[0;32m 10\u001b[0m set_tracing_callback_manager,\n\u001b[0;32m 11\u001b[0m )\n",
|
215 |
-
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\langchain\\agents\\__init__.py:3\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[39m\"\"\"Interface for agents.\"\"\"\u001b[39;00m\n\u001b[0;32m 2\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39magents\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39magent\u001b[39;00m \u001b[39mimport\u001b[39;00m Agent, AgentExecutor\n\u001b[1;32m----> 3\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39magents\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39magent_toolkits\u001b[39;00m \u001b[39mimport\u001b[39;00m (\n\u001b[0;32m 4\u001b[0m create_csv_agent,\n\u001b[0;32m 5\u001b[0m create_json_agent,\n\u001b[0;32m 6\u001b[0m create_openapi_agent,\n\u001b[0;32m 7\u001b[0m create_pandas_dataframe_agent,\n\u001b[0;32m 8\u001b[0m create_sql_agent,\n\u001b[0;32m 9\u001b[0m create_vectorstore_agent,\n\u001b[0;32m 10\u001b[0m create_vectorstore_router_agent,\n\u001b[0;32m 11\u001b[0m )\n\u001b[0;32m 12\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39magents\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mconversational\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m ConversationalAgent\n\u001b[0;32m 13\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39magents\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39minitialize\u001b[39;00m \u001b[39mimport\u001b[39;00m initialize_agent\n",
|
216 |
-
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\langchain\\agents\\agent_toolkits\\__init__.py:3\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[39m\"\"\"Agent toolkits.\"\"\"\u001b[39;00m\n\u001b[1;32m----> 3\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39magents\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39magent_toolkits\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mcsv\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m create_csv_agent\n\u001b[0;32m 4\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39magents\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39magent_toolkits\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mjson\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m create_json_agent\n\u001b[0;32m 5\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39magents\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39magent_toolkits\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mjson\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mtoolkit\u001b[39;00m \u001b[39mimport\u001b[39;00m JsonToolkit\n",
|
217 |
-
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\langchain\\agents\\agent_toolkits\\csv\\base.py:5\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mtyping\u001b[39;00m \u001b[39mimport\u001b[39;00m Any, Optional\n\u001b[0;32m 4\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39magents\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39magent\u001b[39;00m \u001b[39mimport\u001b[39;00m AgentExecutor\n\u001b[1;32m----> 5\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39magents\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39magent_toolkits\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mpandas\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m create_pandas_dataframe_agent\n\u001b[0;32m 6\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mllms\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m BaseLLM\n\u001b[0;32m 9\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mcreate_csv_agent\u001b[39m(\n\u001b[0;32m 10\u001b[0m llm: BaseLLM, path: \u001b[39mstr\u001b[39m, pandas_kwargs: Optional[\u001b[39mdict\u001b[39m] \u001b[39m=\u001b[39m \u001b[39mNone\u001b[39;00m, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkwargs: Any\n\u001b[0;32m 11\u001b[0m ) \u001b[39m-\u001b[39m\u001b[39m>\u001b[39m AgentExecutor:\n",
|
218 |
-
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\langchain\\agents\\agent_toolkits\\pandas\\base.py:6\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39magents\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39magent\u001b[39;00m \u001b[39mimport\u001b[39;00m AgentExecutor\n\u001b[0;32m 5\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39magents\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39magent_toolkits\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mpandas\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mprompt\u001b[39;00m \u001b[39mimport\u001b[39;00m PREFIX, SUFFIX\n\u001b[1;32m----> 6\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39magents\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mmrkl\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m ZeroShotAgent\n\u001b[0;32m 7\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mcallbacks\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m BaseCallbackManager\n\u001b[0;32m 8\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mchains\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mllm\u001b[39;00m \u001b[39mimport\u001b[39;00m LLMChain\n",
|
219 |
-
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\langchain\\agents\\mrkl\\base.py:11\u001b[0m\n\u001b[0;32m 9\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39magents\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mtools\u001b[39;00m \u001b[39mimport\u001b[39;00m Tool\n\u001b[0;32m 10\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mcallbacks\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m BaseCallbackManager\n\u001b[1;32m---> 11\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mchains\u001b[39;00m \u001b[39mimport\u001b[39;00m LLMChain\n\u001b[0;32m 12\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mllms\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m BaseLLM\n\u001b[0;32m 13\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mprompts\u001b[39;00m \u001b[39mimport\u001b[39;00m PromptTemplate\n",
|
220 |
-
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\langchain\\chains\\__init__.py:15\u001b[0m\n\u001b[0;32m 13\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mchains\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mllm_requests\u001b[39;00m \u001b[39mimport\u001b[39;00m LLMRequestsChain\n\u001b[0;32m 14\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mchains\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mllm_summarization_checker\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m LLMSummarizationCheckerChain\n\u001b[1;32m---> 15\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mchains\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mloading\u001b[39;00m \u001b[39mimport\u001b[39;00m load_chain\n\u001b[0;32m 16\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mchains\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mmapreduce\u001b[39;00m \u001b[39mimport\u001b[39;00m MapReduceChain\n\u001b[0;32m 17\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mchains\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mmoderation\u001b[39;00m \u001b[39mimport\u001b[39;00m OpenAIModerationChain\n",
|
221 |
-
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\langchain\\chains\\loading.py:23\u001b[0m\n\u001b[0;32m 21\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mchains\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mqa_with_sources\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m QAWithSourcesChain\n\u001b[0;32m 22\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mchains\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mqa_with_sources\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mvector_db\u001b[39;00m \u001b[39mimport\u001b[39;00m VectorDBQAWithSourcesChain\n\u001b[1;32m---> 23\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mchains\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39msql_database\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m SQLDatabaseChain\n\u001b[0;32m 24\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mchains\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mvector_db_qa\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m VectorDBQA\n\u001b[0;32m 25\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mllms\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mloading\u001b[39;00m \u001b[39mimport\u001b[39;00m load_llm, load_llm_from_config\n",
|
222 |
-
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\langchain\\chains\\sql_database\\base.py:13\u001b[0m\n\u001b[0;32m 11\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mprompts\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m BasePromptTemplate\n\u001b[0;32m 12\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mschema\u001b[39;00m \u001b[39mimport\u001b[39;00m BaseLanguageModel\n\u001b[1;32m---> 13\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39msql_database\u001b[39;00m \u001b[39mimport\u001b[39;00m SQLDatabase\n\u001b[0;32m 16\u001b[0m \u001b[39mclass\u001b[39;00m \u001b[39mSQLDatabaseChain\u001b[39;00m(Chain, BaseModel):\n\u001b[0;32m 17\u001b[0m \u001b[39m \u001b[39m\u001b[39m\"\"\"Chain for interacting with SQL Database.\u001b[39;00m\n\u001b[0;32m 18\u001b[0m \n\u001b[0;32m 19\u001b[0m \u001b[39m Example:\u001b[39;00m\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 24\u001b[0m \u001b[39m db_chain = SQLDatabaseChain(llm=OpenAI(), database=db)\u001b[39;00m\n\u001b[0;32m 25\u001b[0m \u001b[39m \"\"\"\u001b[39;00m\n",
|
223 |
-
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\langchain\\sql_database.py:6\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m__future__\u001b[39;00m \u001b[39mimport\u001b[39;00m annotations\n\u001b[0;32m 4\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mtyping\u001b[39;00m \u001b[39mimport\u001b[39;00m Any, Iterable, List, Optional\n\u001b[1;32m----> 6\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39msqlalchemy\u001b[39;00m \u001b[39mimport\u001b[39;00m MetaData, create_engine, inspect, select, text\n\u001b[0;32m 7\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39msqlalchemy\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mengine\u001b[39;00m \u001b[39mimport\u001b[39;00m Engine\n\u001b[0;32m 8\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39msqlalchemy\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mexc\u001b[39;00m \u001b[39mimport\u001b[39;00m ProgrammingError, SQLAlchemyError\n",
|
224 |
-
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\sqlalchemy\\__init__.py:8\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[39m# sqlalchemy/__init__.py\u001b[39;00m\n\u001b[0;32m 2\u001b[0m \u001b[39m# Copyright (C) 2005-2019 the SQLAlchemy authors and contributors\u001b[39;00m\n\u001b[0;32m 3\u001b[0m \u001b[39m# <see AUTHORS file>\u001b[39;00m\n\u001b[0;32m 4\u001b[0m \u001b[39m#\u001b[39;00m\n\u001b[0;32m 5\u001b[0m \u001b[39m# This module is part of SQLAlchemy and is released under\u001b[39;00m\n\u001b[0;32m 6\u001b[0m \u001b[39m# the MIT License: http://www.opensource.org/licenses/mit-license.php\u001b[39;00m\n\u001b[1;32m----> 8\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m \u001b[39mimport\u001b[39;00m util \u001b[39mas\u001b[39;00m _util \u001b[39m# noqa\u001b[39;00m\n\u001b[0;32m 9\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39minspection\u001b[39;00m \u001b[39mimport\u001b[39;00m inspect \u001b[39m# noqa\u001b[39;00m\n\u001b[0;32m 10\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39mschema\u001b[39;00m \u001b[39mimport\u001b[39;00m BLANK_SCHEMA \u001b[39m# noqa\u001b[39;00m\n",
|
225 |
-
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\sqlalchemy\\util\\__init__.py:14\u001b[0m\n\u001b[0;32m 11\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mfunctools\u001b[39;00m \u001b[39mimport\u001b[39;00m partial \u001b[39m# noqa\u001b[39;00m\n\u001b[0;32m 12\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mfunctools\u001b[39;00m \u001b[39mimport\u001b[39;00m update_wrapper \u001b[39m# noqa\u001b[39;00m\n\u001b[1;32m---> 14\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39m_collections\u001b[39;00m \u001b[39mimport\u001b[39;00m coerce_generator_arg \u001b[39m# noqa\u001b[39;00m\n\u001b[0;32m 15\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39m_collections\u001b[39;00m \u001b[39mimport\u001b[39;00m collections_abc \u001b[39m# noqa\u001b[39;00m\n\u001b[0;32m 16\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39m_collections\u001b[39;00m \u001b[39mimport\u001b[39;00m column_dict \u001b[39m# noqa\u001b[39;00m\n",
|
226 |
-
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\sqlalchemy\\util\\_collections.py:16\u001b[0m\n\u001b[0;32m 13\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mtypes\u001b[39;00m\n\u001b[0;32m 14\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mweakref\u001b[39;00m\n\u001b[1;32m---> 16\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39mcompat\u001b[39;00m \u001b[39mimport\u001b[39;00m binary_types\n\u001b[0;32m 17\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39mcompat\u001b[39;00m \u001b[39mimport\u001b[39;00m collections_abc\n\u001b[0;32m 18\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39m.\u001b[39;00m\u001b[39mcompat\u001b[39;00m \u001b[39mimport\u001b[39;00m itertools_filterfalse\n",
|
227 |
-
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\sqlalchemy\\util\\compat.py:264\u001b[0m\n\u001b[0;32m 261\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39minspect\u001b[39;00m \u001b[39mimport\u001b[39;00m formatargspec \u001b[39mas\u001b[39;00m inspect_formatargspec \u001b[39m# noqa\u001b[39;00m\n\u001b[0;32m 263\u001b[0m \u001b[39mif\u001b[39;00m win32 \u001b[39mor\u001b[39;00m jython:\n\u001b[1;32m--> 264\u001b[0m time_func \u001b[39m=\u001b[39m time\u001b[39m.\u001b[39;49mclock\n\u001b[0;32m 265\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m 266\u001b[0m time_func \u001b[39m=\u001b[39m time\u001b[39m.\u001b[39mtime\n",
|
228 |
-
"\u001b[1;31mAttributeError\u001b[0m: module 'time' has no attribute 'clock'"
|
229 |
-
]
|
230 |
-
}
|
231 |
-
],
|
232 |
-
"source": [
|
233 |
-
"from llama_index import SimpleDirectoryReader, GPTListIndex, readers, GPTSimpleVectorIndex, LLMPredictor, PromptHelper\n",
|
234 |
-
"from langchain import OpenAI\n",
|
235 |
-
"import sys\n",
|
236 |
-
"import os\n",
|
237 |
-
"from IPython.display import Markdown, display\n",
|
238 |
-
"\n",
|
239 |
-
"def construct_index(directory_path):\n",
|
240 |
-
" # set maximum input size\n",
|
241 |
-
" max_input_size = 4096\n",
|
242 |
-
" # set number of output tokens\n",
|
243 |
-
" num_outputs = 2000\n",
|
244 |
-
" # set maximum chunk overlap\n",
|
245 |
-
" max_chunk_overlap = 20\n",
|
246 |
-
" # set chunk size limit\n",
|
247 |
-
" chunk_size_limit = 600\n",
|
248 |
-
"\n",
|
249 |
-
" # define LLM\n",
|
250 |
-
" llm_predictor = LLMPredictor(llm=OpenAI(temperature=0.5, model_name=\"gpt-3.5-turbo\", max_tokens=num_outputs))\n",
|
251 |
-
" prompt_helper = PromptHelper(max_input_size, num_outputs, max_chunk_overlap, chunk_size_limit=chunk_size_limit)\n",
|
252 |
-
"\n",
|
253 |
-
" documents = SimpleDirectoryReader(directory_path).load_data()\n",
|
254 |
-
"\n",
|
255 |
-
" index = GPTSimpleVectorIndex(\n",
|
256 |
-
" documents, llm_predictor=llm_predictor, prompt_helper=prompt_helper\n",
|
257 |
-
" )\n",
|
258 |
-
"\n",
|
259 |
-
" index.save_to_disk('index.json')\n",
|
260 |
-
"\n",
|
261 |
-
" return index\n",
|
262 |
-
"\n",
|
263 |
-
"\n"
|
264 |
-
]
|
265 |
-
},
|
266 |
-
{
|
267 |
-
"cell_type": "code",
|
268 |
-
"execution_count": null,
|
269 |
-
"metadata": {
|
270 |
-
"id": "27L4VAQiTNlc"
|
271 |
-
},
|
272 |
-
"outputs": [],
|
273 |
-
"source": [
|
274 |
-
"def ask_ai():\n",
|
275 |
-
" index = GPTSimpleVectorIndex.load_from_disk('index.json')\n",
|
276 |
-
" while True: \n",
|
277 |
-
" query = input(\"What do you want to ask? \")\n",
|
278 |
-
" response = index.query(query, response_mode=\"compact\")\n",
|
279 |
-
" display(Markdown(f\"Response: <b>{response.response}</b>\"))"
|
280 |
-
]
|
281 |
-
},
|
282 |
-
{
|
283 |
-
"cell_type": "markdown",
|
284 |
-
"metadata": {
|
285 |
-
"id": "Vz1jp33jGumu"
|
286 |
-
},
|
287 |
-
"source": [
|
288 |
-
"# Set OpenAI API Key\n",
|
289 |
-
"You need an OPENAI API key to be able to run this code.\n",
|
290 |
-
"\n",
|
291 |
-
"If you don't have one yet, get it by [signing up](https://platform.openai.com/overview). Then click your account icon on the top right of the screen and select \"View API Keys\". Create an API key.\n",
|
292 |
-
"\n",
|
293 |
-
"Then run the code below and paste your API key into the text input."
|
294 |
-
]
|
295 |
-
},
|
296 |
-
{
|
297 |
-
"cell_type": "code",
|
298 |
-
"execution_count": null,
|
299 |
-
"metadata": {
|
300 |
-
"colab": {
|
301 |
-
"base_uri": "https://localhost:8080/"
|
302 |
-
},
|
303 |
-
"id": "RoJHE4fsAT3w",
|
304 |
-
"outputId": "b4870c80-9c24-48b0-80cd-6b9dc5b9f8a6"
|
305 |
-
},
|
306 |
-
"outputs": [],
|
307 |
-
"source": [
|
308 |
-
"os.environ[\"OPENAI_API_KEY\"] = input(\"Paste your OpenAI key here and hit enter:\")"
|
309 |
-
]
|
310 |
-
},
|
311 |
-
{
|
312 |
-
"cell_type": "markdown",
|
313 |
-
"metadata": {
|
314 |
-
"id": "ZVrddlAL4I_v"
|
315 |
-
},
|
316 |
-
"source": [
|
317 |
-
"#Construct an index\n",
|
318 |
-
"Now we are ready to construct the index. This will take every file in the folder 'data', split it into chunks, and embed it with OpenAI's embeddings API.\n",
|
319 |
-
"\n",
|
320 |
-
"**Notice:** running this code will cost you credits on your OpenAPI account ($0.02 for every 1,000 tokens). If you've just set up your account, the free credits that you have should be more than enough for this experiment."
|
321 |
-
]
|
322 |
-
},
|
323 |
-
{
|
324 |
-
"cell_type": "code",
|
325 |
-
"execution_count": null,
|
326 |
-
"metadata": {
|
327 |
-
"colab": {
|
328 |
-
"base_uri": "https://localhost:8080/"
|
329 |
-
},
|
330 |
-
"id": "kCYTE2EqBB7O",
|
331 |
-
"outputId": "136bd773-5974-42e7-aae3-fa0c4d06b213"
|
332 |
-
},
|
333 |
-
"outputs": [],
|
334 |
-
"source": [
|
335 |
-
"construct_index(\"C:\\Users\\Ewok\\OneDrive - FAST National University\\Desktop\\Custom chatbot\\context.data\")"
|
336 |
-
]
|
337 |
-
},
|
338 |
-
{
|
339 |
-
"cell_type": "code",
|
340 |
-
"execution_count": null,
|
341 |
-
"metadata": {
|
342 |
-
"colab": {
|
343 |
-
"base_uri": "https://localhost:8080/",
|
344 |
-
"height": 311
|
345 |
-
},
|
346 |
-
"id": "s_uwsPGEIGsb",
|
347 |
-
"outputId": "160d9bfc-70ed-43fa-8adb-b8089f601883"
|
348 |
-
},
|
349 |
-
"outputs": [],
|
350 |
-
"source": [
|
351 |
-
"ask_ai()"
|
352 |
-
]
|
353 |
-
},
|
354 |
-
{
|
355 |
-
"cell_type": "code",
|
356 |
-
"execution_count": null,
|
357 |
-
"metadata": {},
|
358 |
-
"outputs": [],
|
359 |
-
"source": [
|
360 |
-
"import tkinter as tk\n",
|
361 |
-
"from llama_index import GPTSimpleVectorIndex, LLMPredictor, PromptHelper\n",
|
362 |
-
"from langchain import OpenAI\n",
|
363 |
-
"from IPython.display import Markdown, display\n",
|
364 |
-
"\n",
|
365 |
-
"# Define the ask_ai() function\n",
|
366 |
-
"def ask_ai(question):\n",
|
367 |
-
" index = GPTSimpleVectorIndex.load_from_disk('index.json')\n",
|
368 |
-
" response = index.query(question, response_mode=\"compact\")\n",
|
369 |
-
" return response.response\n",
|
370 |
-
"\n",
|
371 |
-
"# Define the GUI\n",
|
372 |
-
"class ChatBotGUI:\n",
|
373 |
-
" def __init__(self, master):\n",
|
374 |
-
" self.master = master\n",
|
375 |
-
" master.title(\"Chat Bot\")\n",
|
376 |
-
"\n",
|
377 |
-
" # Create a label and an entry for the question\n",
|
378 |
-
" self.label = tk.Label(master, text=\"Ask me anything:\")\n",
|
379 |
-
" self.label.pack()\n",
|
380 |
-
"\n",
|
381 |
-
" self.entry = tk.Entry(master)\n",
|
382 |
-
" self.entry.pack()\n",
|
383 |
-
"\n",
|
384 |
-
" # Create a button to submit the question\n",
|
385 |
-
" self.button = tk.Button(master, text=\"Submit\", command=self.submit_question)\n",
|
386 |
-
" self.button.pack()\n",
|
387 |
-
"\n",
|
388 |
-
" # Create a text box to display the response\n",
|
389 |
-
" self.textbox = tk.Text(master)\n",
|
390 |
-
" self.textbox.pack()\n",
|
391 |
-
"\n",
|
392 |
-
" def submit_question(self):\n",
|
393 |
-
" question = self.entry.get()\n",
|
394 |
-
" response = ask_ai(question)\n",
|
395 |
-
" self.textbox.insert(tk.END, \"You: \" + question + \"\\n\")\n",
|
396 |
-
" self.textbox.insert(tk.END, \"Bot: \" + response + \"\\n\\n\")\n",
|
397 |
-
" self.entry.delete(0, tk.END)\n",
|
398 |
-
"\n",
|
399 |
-
"# Create an instance of the GUI and start the main loop\n",
|
400 |
-
"root = tk.Tk()\n",
|
401 |
-
"chatbot_gui = ChatBotGUI(root)\n",
|
402 |
-
"root.mainloop()"
|
403 |
-
]
|
404 |
-
},
|
405 |
-
{
|
406 |
-
"cell_type": "code",
|
407 |
-
"execution_count": null,
|
408 |
-
"metadata": {},
|
409 |
-
"outputs": [],
|
410 |
-
"source": [
|
411 |
-
"import gradio as gr\n",
|
412 |
-
"\n",
|
413 |
-
"def ask_ai(query):\n",
|
414 |
-
" index = GPTSimpleVectorIndex.load_from_disk('index.json')\n",
|
415 |
-
" response = index.query(query, response_mode=\"compact\")\n",
|
416 |
-
" return response.response\n",
|
417 |
-
"\n",
|
418 |
-
"gr.Interface(\n",
|
419 |
-
" fn=ask_ai, \n",
|
420 |
-
" inputs=gr.inputs.Textbox(label=\"Input your question here\"), \n",
|
421 |
-
" outputs=gr.outputs.Textbox(label=\"Response\")\n",
|
422 |
-
").launch(share=True)\n"
|
423 |
-
]
|
424 |
-
}
|
425 |
-
],
|
426 |
-
"metadata": {
|
427 |
-
"colab": {
|
428 |
-
"provenance": []
|
429 |
-
},
|
430 |
-
"kernelspec": {
|
431 |
-
"display_name": "Python 3",
|
432 |
-
"language": "python",
|
433 |
-
"name": "python3"
|
434 |
-
},
|
435 |
-
"language_info": {
|
436 |
-
"codemirror_mode": {
|
437 |
-
"name": "ipython",
|
438 |
-
"version": 3
|
439 |
-
},
|
440 |
-
"file_extension": ".py",
|
441 |
-
"mimetype": "text/x-python",
|
442 |
-
"name": "python",
|
443 |
-
"nbconvert_exporter": "python",
|
444 |
-
"pygments_lexer": "ipython3",
|
445 |
-
"version": "3.11.0"
|
446 |
-
},
|
447 |
-
"vscode": {
|
448 |
-
"interpreter": {
|
449 |
-
"hash": "837f538c543f9b2d2992c09ff501c8e7dd16af4ba72a49bea9ce11c22c2825e5"
|
450 |
-
}
|
451 |
-
}
|
452 |
-
},
|
453 |
-
"nbformat": 4,
|
454 |
-
"nbformat_minor": 0
|
455 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|