Skip to content

Commit 0babade

Browse files
Fix Qdrant collection initialization (#418)
1 parent becde98 commit 0babade

File tree

2 files changed

+55
-65
lines changed

2 files changed

+55
-65
lines changed

examples/vector_indices/QdrantIndexDemo.ipynb

Lines changed: 53 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@
1818
},
1919
{
2020
"cell_type": "code",
21-
"execution_count": null,
21+
"execution_count": 1,
2222
"id": "47264e32",
23-
"metadata": {},
23+
"metadata": {
24+
"ExecuteTime": {
25+
"end_time": "2023-02-10T12:20:23.988789Z",
26+
"start_time": "2023-02-10T12:20:23.967877Z"
27+
}
28+
},
2429
"outputs": [],
2530
"source": [
2631
"import logging\n",
@@ -32,12 +37,12 @@
3237
},
3338
{
3439
"cell_type": "code",
35-
"execution_count": 1,
40+
"execution_count": 2,
3641
"id": "0c9f4d21-145a-401e-95ff-ccb259e8ef84",
3742
"metadata": {
3843
"ExecuteTime": {
39-
"end_time": "2023-01-30T18:22:07.383871Z",
40-
"start_time": "2023-01-30T18:22:06.922046Z"
44+
"end_time": "2023-02-10T12:20:24.908956Z",
45+
"start_time": "2023-02-10T12:20:24.537064Z"
4146
},
4247
"pycharm": {
4348
"is_executing": true
@@ -50,12 +55,12 @@
5055
},
5156
{
5257
"cell_type": "code",
53-
"execution_count": 2,
58+
"execution_count": 3,
5459
"id": "b1757e8a",
5560
"metadata": {
5661
"ExecuteTime": {
57-
"end_time": "2023-01-30T18:22:07.509759Z",
58-
"start_time": "2023-01-30T18:22:07.385881Z"
62+
"end_time": "2023-02-10T12:20:24.986059Z",
63+
"start_time": "2023-02-10T12:20:24.910787Z"
5964
},
6065
"pycharm": {
6166
"is_executing": true
@@ -80,12 +85,12 @@
8085
},
8186
{
8287
"cell_type": "code",
83-
"execution_count": 3,
88+
"execution_count": 4,
8489
"id": "0a2bcc07",
8590
"metadata": {
8691
"ExecuteTime": {
87-
"end_time": "2023-01-30T18:22:08.604548Z",
88-
"start_time": "2023-01-30T18:22:07.512307Z"
92+
"end_time": "2023-02-10T12:20:30.170536Z",
93+
"start_time": "2023-02-10T12:20:29.402794Z"
8994
},
9095
"pycharm": {
9196
"is_executing": true
@@ -99,12 +104,12 @@
99104
},
100105
{
101106
"cell_type": "code",
102-
"execution_count": 4,
107+
"execution_count": 5,
103108
"id": "68cbd239-880e-41a3-98d8-dbb3fab55431",
104109
"metadata": {
105110
"ExecuteTime": {
106-
"end_time": "2023-01-30T18:22:08.611152Z",
107-
"start_time": "2023-01-30T18:22:08.608198Z"
111+
"end_time": "2023-02-10T12:20:30.175678Z",
112+
"start_time": "2023-02-10T12:20:30.172456Z"
108113
},
109114
"pycharm": {
110115
"is_executing": true
@@ -118,12 +123,12 @@
118123
},
119124
{
120125
"cell_type": "code",
121-
"execution_count": 5,
126+
"execution_count": 6,
122127
"id": "ba1558b3",
123128
"metadata": {
124129
"ExecuteTime": {
125-
"end_time": "2023-01-30T18:22:20.150199Z",
126-
"start_time": "2023-01-30T18:22:08.613561Z"
130+
"end_time": "2023-02-10T12:20:33.735897Z",
131+
"start_time": "2023-02-10T12:20:30.404245Z"
127132
},
128133
"pycharm": {
129134
"is_executing": true
@@ -134,19 +139,9 @@
134139
"name": "stdout",
135140
"output_type": "stream",
136141
"text": [
137-
"> Adding chunk: \t\t\n",
138-
"\n",
139-
"What I Worked On\n",
140-
"\n",
141-
"February 2021\n",
142-
"\n",
143-
"Before col...\n",
144-
"> Adding chunk: only up to age 25 and already there are such co...\n",
145-
"> Adding chunk: clear that it was even possible. To find out, w...\n",
146-
"> Adding chunk: a name for the kind of company Viaweb was, an \"...\n",
147-
"> Adding chunk: get their initial set of customers almost entir...\n",
148-
"> Adding chunk: had smart people and built impressive technolog...\n",
142+
"INFO:root:> [build_index_from_documents] Total LLM token usage: 0 tokens\n",
149143
"> [build_index_from_documents] Total LLM token usage: 0 tokens\n",
144+
"INFO:root:> [build_index_from_documents] Total embedding token usage: 17621 tokens\n",
150145
"> [build_index_from_documents] Total embedding token usage: 17621 tokens\n"
151146
]
152147
}
@@ -157,12 +152,12 @@
157152
},
158153
{
159154
"cell_type": "code",
160-
"execution_count": 6,
155+
"execution_count": 7,
161156
"id": "c36cadc1",
162157
"metadata": {
163158
"ExecuteTime": {
164-
"end_time": "2023-01-30T18:22:20.231198Z",
165-
"start_time": "2023-01-30T18:22:20.156095Z"
159+
"end_time": "2023-02-10T12:20:33.742793Z",
160+
"start_time": "2023-02-10T12:20:33.738289Z"
166161
}
167162
},
168163
"outputs": [],
@@ -173,12 +168,12 @@
173168
},
174169
{
175170
"cell_type": "code",
176-
"execution_count": 7,
171+
"execution_count": 8,
177172
"id": "70b372a7",
178173
"metadata": {
179174
"ExecuteTime": {
180-
"end_time": "2023-01-30T18:22:20.497373Z",
181-
"start_time": "2023-01-30T18:22:20.238928Z"
175+
"end_time": "2023-02-10T12:20:33.821131Z",
176+
"start_time": "2023-02-10T12:20:33.745017Z"
182177
}
183178
},
184179
"outputs": [],
@@ -197,26 +192,22 @@
197192
},
198193
{
199194
"cell_type": "code",
200-
"execution_count": 8,
195+
"execution_count": 9,
201196
"id": "35369eda",
202197
"metadata": {
203198
"ExecuteTime": {
204-
"end_time": "2023-01-30T18:22:22.963556Z",
205-
"start_time": "2023-01-30T18:22:20.504119Z"
199+
"end_time": "2023-02-10T12:20:51.328762Z",
200+
"start_time": "2023-02-10T12:20:33.822688Z"
206201
}
207202
},
208203
"outputs": [
209204
{
210205
"name": "stdout",
211206
"output_type": "stream",
212207
"text": [
213-
"> Top 1 nodes:\n",
214-
"> [Node 95fda200-57a3-4ec2-ad2d-32da0564ce4d] [Similarity score: 0.777002] had smart people and built impressive technology, and yet got crushed by Moore's Law. In the 1990...\n",
215-
"> Searching in chunk: doc_id: 33bf1319-d69c-48a5-a451-7a88751ce99b\n",
216-
"te...\n",
217-
"> Initial response: \n",
218-
"The author does not provide any information about what they did growing up.\n",
219-
"> [query] Total LLM token usage: 2829 tokens\n",
208+
"INFO:root:> [query] Total LLM token usage: 3841 tokens\n",
209+
"> [query] Total LLM token usage: 3841 tokens\n",
210+
"INFO:root:> [query] Total embedding token usage: 8 tokens\n",
220211
"> [query] Total embedding token usage: 8 tokens\n"
221212
]
222213
}
@@ -228,20 +219,21 @@
228219
},
229220
{
230221
"cell_type": "code",
231-
"execution_count": 9,
222+
"execution_count": 10,
232223
"id": "bedbb693-725f-478f-be26-fa7180ea38b2",
233224
"metadata": {
234225
"ExecuteTime": {
235-
"end_time": "2023-01-30T18:22:22.990701Z",
236-
"start_time": "2023-01-30T18:22:22.969707Z"
226+
"end_time": "2023-02-10T12:20:51.337062Z",
227+
"start_time": "2023-02-10T12:20:51.330857Z"
237228
}
238229
},
239230
"outputs": [
240231
{
241232
"data": {
242233
"text/markdown": [
243234
"<b>\n",
244-
"The author does not provide any information about what they did growing up.</b>"
235+
"\n",
236+
"The author grew up writing short stories, programming on an IBM 1401, and building a computer kit with a friend. He also wrote simple games, a program to predict how high his model rockets would fly, and a word processor. He studied philosophy in college, but switched to AI and taught himself Lisp. He wrote a book about Lisp hacking and reverse-engineered SHRDLU. He also took art classes at Harvard and applied to art schools, but was disappointed by the lack of teaching and learning in the painting department at the Accademia. He also had experience with 19th century studio painting conventions, such as having a little stove fed with kindling and a nude model sitting as close to it as possible.</b>"
245237
],
246238
"text/plain": [
247239
"<IPython.core.display.Markdown object>"
@@ -257,26 +249,22 @@
257249
},
258250
{
259251
"cell_type": "code",
260-
"execution_count": 10,
252+
"execution_count": 11,
261253
"id": "99212d33",
262254
"metadata": {
263255
"ExecuteTime": {
264-
"end_time": "2023-01-30T18:22:26.533275Z",
265-
"start_time": "2023-01-30T18:22:23.000258Z"
256+
"end_time": "2023-02-10T12:21:10.337294Z",
257+
"start_time": "2023-02-10T12:20:51.338718Z"
266258
}
267259
},
268260
"outputs": [
269261
{
270262
"name": "stdout",
271263
"output_type": "stream",
272264
"text": [
273-
"> Top 1 nodes:\n",
274-
"> [Node 95fda200-57a3-4ec2-ad2d-32da0564ce4d] [Similarity score: 0.815135] had smart people and built impressive technology, and yet got crushed by Moore's Law. In the 1990...\n",
275-
"> Searching in chunk: doc_id: 33bf1319-d69c-48a5-a451-7a88751ce99b\n",
276-
"te...\n",
277-
"> Initial response: \n",
278-
"After his time at Y Combinator, the author wrote essays and ran a forum. He also wrote about the concept of invented versus discovered and talked about space aliens. He also thanked those who read drafts of his work.\n",
279-
"> [query] Total LLM token usage: 2866 tokens\n",
265+
"INFO:root:> [query] Total LLM token usage: 3899 tokens\n",
266+
"> [query] Total LLM token usage: 3899 tokens\n",
267+
"INFO:root:> [query] Total embedding token usage: 14 tokens\n",
280268
"> [query] Total embedding token usage: 14 tokens\n"
281269
]
282270
}
@@ -288,20 +276,21 @@
288276
},
289277
{
290278
"cell_type": "code",
291-
"execution_count": 11,
279+
"execution_count": 12,
292280
"id": "1a720ad6",
293281
"metadata": {
294282
"ExecuteTime": {
295-
"end_time": "2023-01-30T18:22:26.553482Z",
296-
"start_time": "2023-01-30T18:22:26.539893Z"
283+
"end_time": "2023-02-10T12:21:10.355872Z",
284+
"start_time": "2023-02-10T12:21:10.343486Z"
297285
}
298286
},
299287
"outputs": [
300288
{
301289
"data": {
302290
"text/markdown": [
303291
"<b>\n",
304-
"After his time at Y Combinator, the author wrote essays and ran a forum. He also wrote about the concept of invented versus discovered and talked about space aliens. He also thanked those who read drafts of his work.</b>"
292+
"\n",
293+
"After his time at Y Combinator, the author wrote essays, worked on Lisp, painted, and moved to England. He wrote a new Lisp called Bel, which took four years to complete. After finishing Bel, he wrote a bunch of essays and started to think about other things he could work on. He wrote an essay for himself to answer the question of how to choose what to work on, and then wrote a more detailed version for others to read. He also reflected on the exponential growth of commodity processors and the tight coupling of money and coolness in the art world. He also found a rent-stabilized apartment in New York, which was much cheaper than market price. Finally, he worked on software that could be launched as soon as it was done.</b>"
305294
],
306295
"text/plain": [
307296
"<IPython.core.display.Markdown object>"
@@ -340,7 +329,7 @@
340329
"name": "python",
341330
"nbconvert_exporter": "python",
342331
"pygments_lexer": "ipython3",
343-
"version": "3.11.1"
332+
"version": "3.9.16"
344333
}
345334
},
346335
"nbformat": 4,

gpt_index/indices/vector_store/qdrant.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def _add_document_to_index(
124124
collection_name=collection_name,
125125
vector_size=len(text_embedding),
126126
)
127+
self._collection_initialized = True
127128

128129
while True:
129130
new_id = get_new_id(set())
@@ -174,7 +175,7 @@ def _delete(self, doc_id: str, **delete_kwargs: Any) -> None:
174175
self._client.delete(
175176
collection_name=self._collection_name,
176177
points_selector=rest.Filter(
177-
should=[
178+
must=[
178179
rest.FieldCondition(
179180
key="doc_id", match=rest.MatchValue(value=doc_id)
180181
)

0 commit comments

Comments
 (0)