File size: 12,258 Bytes
c0183f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "568244795a9ebe10f8d565bb963a370eb6ece55a88a84d2ad76d2d3b1b13b963\n"
     ]
    }
   ],
   "source": [
    "!docker run -p \"6333:6333\" -p \"6334:6334\" --name \"rag-traversaal-qdrant\" --rm -d qdrant/qdrant:latest"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "CollectionsResponse(collections=[])"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import qdrant_client\n",
    "\n",
    "client = qdrant_client.QdrantClient(\"http://localhost:6333\", prefer_grpc=True)\n",
    "client.get_collections()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(\"concatenated_texts.txt\", \"r\", encoding=\"utf-8\") as file:\n",
    "    document = file.readlines()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['60518f4bf76f44438f643a4bc4f067d1',\n",
       " '4189eb47b3ec42a0b9ac75bcd35d1dc3',\n",
       " 'e5ed8e5c16bf444c88c995cc16ff242f',\n",
       " '845bbe91136845bf86eb8c235a1a9899',\n",
       " '27ebd890d66041db9d3f034220a4c189',\n",
       " '92570404adda4b94b394d6a0c9df4047',\n",
       " '01f1b47bed6a49a4a2f9a9a9a296ca56',\n",
       " '6c082253e2514233b7d06e9574c11549',\n",
       " '1b28d0e05eef4b04bc128eb9d73a579e',\n",
       " 'bae5f450079947a19970c4b5a4ef96c0',\n",
       " '0e304a69fac94cf485c128f803ea9293',\n",
       " 'ca153c72c530416b9c1bb4aeed51043b',\n",
       " '9f94c6fe31d945fdb09a29f79375f1c5',\n",
       " 'f6acf6ab0bd1472bac9dc5ec5d34196b',\n",
       " '54d586945a3840c9acc9eedc05397aa3',\n",
       " '9a3648bed41e4fef936ec244ec224ff0',\n",
       " '4da9713c65cd40c9aa3f01220514ea66',\n",
       " '898cb6b04b0e44bd9cdb15267225c807',\n",
       " '5a11e68d7cd748c5a87eb5fc1d4af813',\n",
       " '2f4a67f1bbf4499185ab433b5f6691d4',\n",
       " '36d8d8d25553460dae93c34e42572c2d',\n",
       " '99a752cca5054d3bb27fbd5ed2fbd583',\n",
       " 'd2727142b95642a0a10f126c372ed372',\n",
       " '609498f1a2e349f686a6972eb0f81ab5',\n",
       " '91fb75f295ef45ba95319811d7f462eb',\n",
       " '750152c8fbea4abf84531acc994e91b3',\n",
       " '00163ec6652f4cbda82cd7ead9af1294',\n",
       " '82b2a894fe534f0188dbe5f2acbd416a',\n",
       " 'b4f928c3f696409b840dd1523f09c845',\n",
       " '69f13526886845d09387971371ed44e0',\n",
       " 'af34fe8b9d4449d99faf07f86c62d4ae',\n",
       " '8901af122fec4b80825a90a83e5b7eb3',\n",
       " '8d00cc445997407ca1c7d6a868f360eb',\n",
       " 'cdc371ac2b61408f87cb4eac3359858c',\n",
       " 'ce030db0b98c416bbdd4d44643da166e',\n",
       " 'fb533df4e243433a9ca5a34026f451a4',\n",
       " 'fb8c194c1fea48f2a29023d64caa1608',\n",
       " 'dc7d5cffb1d247e4b11f4cc2ec3e3895',\n",
       " '0d375136b06f4741b945e37d8aa65b33',\n",
       " '1276bac82b60468f987e16b366545c8b',\n",
       " '7e4d4f1145dd411cbb347163eba1d5c3',\n",
       " '919482ba80a34982b1916c8ba3d557e3',\n",
       " '9c7c27f5ee1b4eec8d7d6bed82737bf5',\n",
       " '02da8f43fc8741afbb39a0d7cb0f0ad4',\n",
       " '8c2582f249294d79b6dbd72729a446c2',\n",
       " '0e8f79d928244e6e9c2c766427e06a6e',\n",
       " 'a1bb8207b6a648fead94f21c5899e71d',\n",
       " '31256c671ac2405c86ff47f28f87c15a',\n",
       " '962dd4e82a9c4f498c01d4699b12057a',\n",
       " '0d5892df212148e6a9d5903cb347c713',\n",
       " 'f92377d0a51e4634ac64d9f537d662dc',\n",
       " 'b24403e2aeba4b8fa0143dd42564f701',\n",
       " '10bebf27ce7a4cc6a08b6624e569bbd7',\n",
       " '258517c488fd46fb931122805f4bba66',\n",
       " 'bbff438912ab4cadada9451a329b56ff',\n",
       " 'f1566188aa4e49bb86d177f7341d6698',\n",
       " 'b18efedf95554240ac32a4f07181989d',\n",
       " '4711c751cfd248b99946b8db64aca7b2',\n",
       " 'ad533b04a8db418193fc3c1c69c02540',\n",
       " 'c23875ea211f4c4ca62cb992fbe70752',\n",
       " '330dd2b9be0b468fa87828f0142a8f95',\n",
       " '29a572cc42514073ad5d7b523920e83a',\n",
       " '5e2a145dc6e24406bd1facb79e8c4209',\n",
       " '04806ab967f948de81e37d101dbda052',\n",
       " 'b6abece983884d5f8905bda1a031835f',\n",
       " 'adbd8a7f7f5946abbc4d2e72118ce9f2',\n",
       " 'e38db15c3f0947a787c352476b214efa',\n",
       " '1c5890c861c04f099c4ce06a045e88f3',\n",
       " '2f9325b74d384ac483c1a0cf9e27053b',\n",
       " '26b0c98533b64d4f94fd2f8139c84e87',\n",
       " '647472c3ce0a48698192c2ecb27def99',\n",
       " '26661a5e7448495ebffbf40157a3c16f',\n",
       " '3c6ddb56eb0c424c8e3ca3e65c386dd7',\n",
       " 'd4da51a7708a42e09137866c2c81ec7c',\n",
       " 'ef4443f49dbc498b92fb6b6be2041bfd',\n",
       " '75bea376220d4d7e89c840f1f1e29d8c',\n",
       " '0400b8be462f496ead302a7839511d57',\n",
       " 'e9b59e39049140149aae6a0143e44e30',\n",
       " 'bc57346052854a9da9c85931f76e9466',\n",
       " 'fa350ce6888b4a6e9d9bb498cea1c20a',\n",
       " '07b2bdd6080b4952b4b6aa63e21b87a4',\n",
       " '693ba70750ff42519e60972e455f2eaf',\n",
       " '07407e4f022c458fb44cf3cd4bb8ba55',\n",
       " 'b4dccbcb8e884caa882cb820845e9d33',\n",
       " 'fb73562ea0ca4d79b036304f0e09489e',\n",
       " '0dd3c4e66cca4a608771b7eb48c72af1',\n",
       " '3d1d93041632423d86b17cfdb9fe9ff9',\n",
       " '061cbb179e524943a2f5c932a2c1187b',\n",
       " '89b9737e8e534ec191ddaf35526a482d',\n",
       " 'd668b613bd544b45bd83fbb4b02757ee',\n",
       " '4b7e523373d346a6831ae43966a03a6d',\n",
       " '0354baf30bda4592a6ec8bd137e565fc',\n",
       " '226b92c6425c4edc94f2d7da8cbf9c6d',\n",
       " '616c8163d8d1479aaeeb558ec8ca40fa',\n",
       " '9cd8ac53e16342deb3e6a585d60d12c5',\n",
       " 'b7ec9cbe0799459ea58c3c9cb45c64cd',\n",
       " 'c6f4ed907d664efdbe3d2be065fe0a38',\n",
       " '4b6eacef746b4b85984c7d1fc315804e',\n",
       " 'b99d12b60b0148b3851225f5f5ffc3d6',\n",
       " '66250067792040f7a007deb0db8c76e5',\n",
       " 'e78be2f3c9f04f108a181e6620cad83f',\n",
       " '4695e03fba714f1fa53c11efe09fface',\n",
       " '90b05385e558456fba99b58895ad985d',\n",
       " '71a3c32ca6124924bce8036ba51a178f',\n",
       " '3fcad1d3824d4ef0a0b16bd501d25ce7',\n",
       " '8a9d9e6a95a0473f8498d4929565d784',\n",
       " '4fccf4b7290845a0a18fde8c0b2e0169',\n",
       " '5ffea2ed56b349c0bdce1ab83a774cc1',\n",
       " '8ee78cb4f17846c198234dba9db46989',\n",
       " '27da952c754642a39cd627e58f4883da',\n",
       " 'fb888c0a17534ded9cc74490031c8b47',\n",
       " '532b447291464474bb00fb7cff8f04b8',\n",
       " '60d9a7820b674a7d8687bcd635ca9da2',\n",
       " '592cab7d865346319c4662e50da96ad6',\n",
       " 'd69368befd5b457c98be19b18b944c18',\n",
       " '878f9d0eb9be4aac9e0bc0da20a3b9fc',\n",
       " '50f7d525d62a4521851de55e9a65afb7',\n",
       " 'eebaa2fe2ee143b5a8e59fadd94962d4',\n",
       " 'c55477aaa46843bcbd4549812eb82f19',\n",
       " 'db630d767af14a2c9e785b80f87e560c',\n",
       " 'ea5af804bff1479e88663ddf80aa61ef',\n",
       " '4d43fe054fc7429ba40b03d03bb7d3a9',\n",
       " 'a2f9411edd8c427a9ab0a1c2d11ba2cf',\n",
       " 'c7097ae5f68a46688eca3f4a3fd2ac29',\n",
       " 'c8a183ca92a64322be9b1e9ce14c4c2d',\n",
       " '1d727180129a4a8ab8a42c4939067ed2',\n",
       " '8e5295f7304945c7ae4a063283a7a2da',\n",
       " '964ee1b2544b4115b50da34351639268',\n",
       " '5b58ac5bcd85498985e91ed48d60debe',\n",
       " 'e140210646fb4931aeed9a3db9f35ea2',\n",
       " 'd5a4cefbc8dd46a3a3c400cff9bb275c',\n",
       " '2c97fe14fb714a16ba7c5b7468ecc433',\n",
       " 'c1ceec5740eb4e73b59d84f5760b3abc',\n",
       " '1832549009cf430695156bbe975266ce',\n",
       " '79fcf57c49bd40f29da41fd454e2571e',\n",
       " '1722d54522624183b4dac8641e7de3c4',\n",
       " '10da1d2d3866499782e328d5da7c4fb6',\n",
       " 'a854a90e41b846bdad9b2eb451808047',\n",
       " '1015ef6be6f1415a99e54265888a391c',\n",
       " '746230e95f544063a455d2686fb59454',\n",
       " '4dd2e0981c9b40338c5245dcbd5e16cc',\n",
       " 'fae8776ade824e6fa9f75b5b6da8b7c8',\n",
       " '8a2807754cdf4dbca305e2bb0482cb77',\n",
       " '35748e70e8204e7fb9e6cc1632c669bb',\n",
       " '9821e1cefc19486ea20b0798cdc7b475',\n",
       " '78697b5335914326b96926d85ba5e493',\n",
       " 'bde89c4a1b1e412db0084a018fb42a71',\n",
       " '7854976c6f2a446eadfcae4023daf08f']"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "client.add(\n",
    "    collection_name=\"knowledge-base\",\n",
    "    documents=document\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['bedfe10a487344c7bb801e609317866e',\n",
       " 'fcb29ff832a54a288f4e14a18af54e3b',\n",
       " 'bb075302cadf4c3b8ee337bc50ba2db1',\n",
       " 'fa7c5b9fd8fa45ce838946864ef39d43',\n",
       " '1ce7f1b429284ac49af3dc4a1cb2946a',\n",
       " '296de64fdf7a4c84902f670a009db487',\n",
       " '2867af34e16342a9a857b0da142eb808',\n",
       " '68d7bf69de0b46caabae2f9ca6d08623']"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# client.add(\n",
    "#     collection_name=\"knowledge-base\",\n",
    "#     documents=[\n",
    "#         \"Qdrant is a vector database & vector similarity search engine. It deploys as an API service providing search for the nearest high-dimensional vectors. With Qdrant, embeddings or neural network encoders can be turned into full-fledged applications for matching, searching, recommending, and much more!\",\n",
    "#         \"Docker helps developers build, share, and run applications anywhere — without tedious environment configuration or management.\",\n",
    "#         \"PyTorch is a machine learning framework based on the Torch library, used for applications such as computer vision and natural language processing.\",\n",
    "#         \"MySQL is an open-source relational database management system (RDBMS). A relational database organizes data into one or more data tables in which data may be related to each other; these relations help structure the data. SQL is a language that programmers use to create, modify and extract data from the relational database, as well as control user access to the database.\",\n",
    "#         \"NGINX is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. NGINX is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption.\",\n",
    "#         \"FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.7+ based on standard Python type hints.\",\n",
    "#         \"SentenceTransformers is a Python framework for state-of-the-art sentence, text and image embeddings. You can use this framework to compute sentence / text embeddings for more than 100 languages. These embeddings can then be compared e.g. with cosine-similarity to find sentences with a similar meaning. This can be useful for semantic textual similar, semantic search, or paraphrase mining.\",\n",
    "#         \"The cron command-line utility is a job scheduler on Unix-like operating systems. Users who set up and maintain software environments use cron to schedule jobs (commands or shell scripts), also known as cron jobs, to run periodically at fixed times, dates, or intervals.\",\n",
    "#     ]\n",
    "# )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}