├── .gitignore
├── Cargo.lock
├── Cargo.toml
├── README.md
├── bitcoin.txt
├── curl.md
├── image
├── embedding.png
└── rag.png
├── llama-rag.sh
├── paris.json
├── paris.txt
└── src
└── main.rs
/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 |
--------------------------------------------------------------------------------
/Cargo.lock:
--------------------------------------------------------------------------------
1 | # This file is automatically @generated by Cargo.
2 | # It is not intended for manual editing.
3 | version = 3
4 |
5 | [[package]]
6 | name = "addr2line"
7 | version = "0.21.0"
8 | source = "registry+https://github.com/rust-lang/crates.io-index"
9 | checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb"
10 | dependencies = [
11 | "gimli",
12 | ]
13 |
14 | [[package]]
15 | name = "adler"
16 | version = "1.0.2"
17 | source = "registry+https://github.com/rust-lang/crates.io-index"
18 | checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
19 |
20 | [[package]]
21 | name = "aho-corasick"
22 | version = "1.1.2"
23 | source = "registry+https://github.com/rust-lang/crates.io-index"
24 | checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0"
25 | dependencies = [
26 | "memchr",
27 | ]
28 |
29 | [[package]]
30 | name = "anstream"
31 | version = "0.6.12"
32 | source = "registry+https://github.com/rust-lang/crates.io-index"
33 | checksum = "96b09b5178381e0874812a9b157f7fe84982617e48f71f4e3235482775e5b540"
34 | dependencies = [
35 | "anstyle",
36 | "anstyle-parse",
37 | "anstyle-query",
38 | "anstyle-wincon",
39 | "colorchoice",
40 | "utf8parse",
41 | ]
42 |
43 | [[package]]
44 | name = "anstyle"
45 | version = "1.0.6"
46 | source = "registry+https://github.com/rust-lang/crates.io-index"
47 | checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc"
48 |
49 | [[package]]
50 | name = "anstyle-parse"
51 | version = "0.2.3"
52 | source = "registry+https://github.com/rust-lang/crates.io-index"
53 | checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c"
54 | dependencies = [
55 | "utf8parse",
56 | ]
57 |
58 | [[package]]
59 | name = "anstyle-query"
60 | version = "1.0.2"
61 | source = "registry+https://github.com/rust-lang/crates.io-index"
62 | checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648"
63 | dependencies = [
64 | "windows-sys 0.52.0",
65 | ]
66 |
67 | [[package]]
68 | name = "anstyle-wincon"
69 | version = "3.0.2"
70 | source = "registry+https://github.com/rust-lang/crates.io-index"
71 | checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7"
72 | dependencies = [
73 | "anstyle",
74 | "windows-sys 0.52.0",
75 | ]
76 |
77 | [[package]]
78 | name = "anyhow"
79 | version = "1.0.80"
80 | source = "registry+https://github.com/rust-lang/crates.io-index"
81 | checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1"
82 |
83 | [[package]]
84 | name = "auto_enums"
85 | version = "0.8.5"
86 | source = "registry+https://github.com/rust-lang/crates.io-index"
87 | checksum = "1899bfcfd9340ceea3533ea157360ba8fa864354eccbceab58e1006ecab35393"
88 | dependencies = [
89 | "derive_utils",
90 | "proc-macro2",
91 | "quote",
92 | "syn",
93 | ]
94 |
95 | [[package]]
96 | name = "autocfg"
97 | version = "1.1.0"
98 | source = "registry+https://github.com/rust-lang/crates.io-index"
99 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
100 |
101 | [[package]]
102 | name = "backtrace"
103 | version = "0.3.69"
104 | source = "registry+https://github.com/rust-lang/crates.io-index"
105 | checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837"
106 | dependencies = [
107 | "addr2line",
108 | "cc",
109 | "cfg-if",
110 | "libc",
111 | "miniz_oxide",
112 | "object",
113 | "rustc-demangle",
114 | ]
115 |
116 | [[package]]
117 | name = "base64"
118 | version = "0.21.7"
119 | source = "registry+https://github.com/rust-lang/crates.io-index"
120 | checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
121 |
122 | [[package]]
123 | name = "bit-set"
124 | version = "0.5.3"
125 | source = "registry+https://github.com/rust-lang/crates.io-index"
126 | checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1"
127 | dependencies = [
128 | "bit-vec",
129 | ]
130 |
131 | [[package]]
132 | name = "bit-vec"
133 | version = "0.6.3"
134 | source = "registry+https://github.com/rust-lang/crates.io-index"
135 | checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
136 |
137 | [[package]]
138 | name = "bitflags"
139 | version = "1.3.2"
140 | source = "registry+https://github.com/rust-lang/crates.io-index"
141 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
142 |
143 | [[package]]
144 | name = "bitflags"
145 | version = "2.4.2"
146 | source = "registry+https://github.com/rust-lang/crates.io-index"
147 | checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf"
148 |
149 | [[package]]
150 | name = "bstr"
151 | version = "1.9.1"
152 | source = "registry+https://github.com/rust-lang/crates.io-index"
153 | checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706"
154 | dependencies = [
155 | "memchr",
156 | "regex-automata",
157 | "serde",
158 | ]
159 |
160 | [[package]]
161 | name = "bumpalo"
162 | version = "3.15.3"
163 | source = "registry+https://github.com/rust-lang/crates.io-index"
164 | checksum = "8ea184aa71bb362a1157c896979544cc23974e08fd265f29ea96b59f0b4a555b"
165 |
166 | [[package]]
167 | name = "bytes"
168 | version = "1.5.0"
169 | source = "registry+https://github.com/rust-lang/crates.io-index"
170 | checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223"
171 |
172 | [[package]]
173 | name = "cc"
174 | version = "1.0.88"
175 | source = "registry+https://github.com/rust-lang/crates.io-index"
176 | checksum = "02f341c093d19155a6e41631ce5971aac4e9a868262212153124c15fa22d1cdc"
177 |
178 | [[package]]
179 | name = "cfg-if"
180 | version = "1.0.0"
181 | source = "registry+https://github.com/rust-lang/crates.io-index"
182 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
183 |
184 | [[package]]
185 | name = "chat-prompts"
186 | version = "0.5.0"
187 | source = "registry+https://github.com/rust-lang/crates.io-index"
188 | checksum = "43c05828739b8160a0d77b9fa47f3a35949e1a72045d1908dd7d47a928218e9f"
189 | dependencies = [
190 | "endpoints",
191 | "enum_dispatch",
192 | "thiserror",
193 | ]
194 |
195 | [[package]]
196 | name = "clap"
197 | version = "4.5.1"
198 | source = "registry+https://github.com/rust-lang/crates.io-index"
199 | checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da"
200 | dependencies = [
201 | "clap_builder",
202 | ]
203 |
204 | [[package]]
205 | name = "clap_builder"
206 | version = "4.5.1"
207 | source = "registry+https://github.com/rust-lang/crates.io-index"
208 | checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb"
209 | dependencies = [
210 | "anstream",
211 | "anstyle",
212 | "clap_lex",
213 | "strsim",
214 | ]
215 |
216 | [[package]]
217 | name = "clap_lex"
218 | version = "0.7.0"
219 | source = "registry+https://github.com/rust-lang/crates.io-index"
220 | checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce"
221 |
222 | [[package]]
223 | name = "colorchoice"
224 | version = "1.0.0"
225 | source = "registry+https://github.com/rust-lang/crates.io-index"
226 | checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
227 |
228 | [[package]]
229 | name = "core-foundation"
230 | version = "0.9.4"
231 | source = "registry+https://github.com/rust-lang/crates.io-index"
232 | checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"
233 | dependencies = [
234 | "core-foundation-sys",
235 | "libc",
236 | ]
237 |
238 | [[package]]
239 | name = "core-foundation-sys"
240 | version = "0.8.6"
241 | source = "registry+https://github.com/rust-lang/crates.io-index"
242 | checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
243 |
244 | [[package]]
245 | name = "derive_utils"
246 | version = "0.14.1"
247 | source = "registry+https://github.com/rust-lang/crates.io-index"
248 | checksum = "61bb5a1014ce6dfc2a378578509abe775a5aa06bff584a547555d9efdb81b926"
249 | dependencies = [
250 | "proc-macro2",
251 | "quote",
252 | "syn",
253 | ]
254 |
255 | [[package]]
256 | name = "either"
257 | version = "1.10.0"
258 | source = "registry+https://github.com/rust-lang/crates.io-index"
259 | checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a"
260 |
261 | [[package]]
262 | name = "encoding_rs"
263 | version = "0.8.33"
264 | source = "registry+https://github.com/rust-lang/crates.io-index"
265 | checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1"
266 | dependencies = [
267 | "cfg-if",
268 | ]
269 |
270 | [[package]]
271 | name = "endpoints"
272 | version = "0.5.0"
273 | source = "registry+https://github.com/rust-lang/crates.io-index"
274 | checksum = "64a7daf7f0fc4a1375e344e7910d823de06f9f2fb91cf4941a8d0697753d72f6"
275 | dependencies = [
276 | "serde",
277 | "url",
278 | ]
279 |
280 | [[package]]
281 | name = "enum_dispatch"
282 | version = "0.3.12"
283 | source = "registry+https://github.com/rust-lang/crates.io-index"
284 | checksum = "8f33313078bb8d4d05a2733a94ac4c2d8a0df9a2b84424ebf4f33bfc224a890e"
285 | dependencies = [
286 | "once_cell",
287 | "proc-macro2",
288 | "quote",
289 | "syn",
290 | ]
291 |
292 | [[package]]
293 | name = "equivalent"
294 | version = "1.0.1"
295 | source = "registry+https://github.com/rust-lang/crates.io-index"
296 | checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
297 |
298 | [[package]]
299 | name = "errno"
300 | version = "0.3.8"
301 | source = "registry+https://github.com/rust-lang/crates.io-index"
302 | checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245"
303 | dependencies = [
304 | "libc",
305 | "windows-sys 0.52.0",
306 | ]
307 |
308 | [[package]]
309 | name = "fancy-regex"
310 | version = "0.12.0"
311 | source = "registry+https://github.com/rust-lang/crates.io-index"
312 | checksum = "7493d4c459da9f84325ad297371a6b2b8a162800873a22e3b6b6512e61d18c05"
313 | dependencies = [
314 | "bit-set",
315 | "regex",
316 | ]
317 |
318 | [[package]]
319 | name = "fastrand"
320 | version = "2.0.1"
321 | source = "registry+https://github.com/rust-lang/crates.io-index"
322 | checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"
323 |
324 | [[package]]
325 | name = "fnv"
326 | version = "1.0.7"
327 | source = "registry+https://github.com/rust-lang/crates.io-index"
328 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
329 |
330 | [[package]]
331 | name = "foreign-types"
332 | version = "0.3.2"
333 | source = "registry+https://github.com/rust-lang/crates.io-index"
334 | checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
335 | dependencies = [
336 | "foreign-types-shared",
337 | ]
338 |
339 | [[package]]
340 | name = "foreign-types-shared"
341 | version = "0.1.1"
342 | source = "registry+https://github.com/rust-lang/crates.io-index"
343 | checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
344 |
345 | [[package]]
346 | name = "form_urlencoded"
347 | version = "1.2.1"
348 | source = "registry+https://github.com/rust-lang/crates.io-index"
349 | checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456"
350 | dependencies = [
351 | "percent-encoding",
352 | ]
353 |
354 | [[package]]
355 | name = "futures"
356 | version = "0.3.30"
357 | source = "registry+https://github.com/rust-lang/crates.io-index"
358 | checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0"
359 | dependencies = [
360 | "futures-channel",
361 | "futures-core",
362 | "futures-executor",
363 | "futures-io",
364 | "futures-sink",
365 | "futures-task",
366 | "futures-util",
367 | ]
368 |
369 | [[package]]
370 | name = "futures-channel"
371 | version = "0.3.30"
372 | source = "registry+https://github.com/rust-lang/crates.io-index"
373 | checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78"
374 | dependencies = [
375 | "futures-core",
376 | "futures-sink",
377 | ]
378 |
379 | [[package]]
380 | name = "futures-core"
381 | version = "0.3.30"
382 | source = "registry+https://github.com/rust-lang/crates.io-index"
383 | checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d"
384 |
385 | [[package]]
386 | name = "futures-executor"
387 | version = "0.3.30"
388 | source = "registry+https://github.com/rust-lang/crates.io-index"
389 | checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d"
390 | dependencies = [
391 | "futures-core",
392 | "futures-task",
393 | "futures-util",
394 | ]
395 |
396 | [[package]]
397 | name = "futures-io"
398 | version = "0.3.30"
399 | source = "registry+https://github.com/rust-lang/crates.io-index"
400 | checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1"
401 |
402 | [[package]]
403 | name = "futures-macro"
404 | version = "0.3.30"
405 | source = "registry+https://github.com/rust-lang/crates.io-index"
406 | checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
407 | dependencies = [
408 | "proc-macro2",
409 | "quote",
410 | "syn",
411 | ]
412 |
413 | [[package]]
414 | name = "futures-sink"
415 | version = "0.3.30"
416 | source = "registry+https://github.com/rust-lang/crates.io-index"
417 | checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5"
418 |
419 | [[package]]
420 | name = "futures-task"
421 | version = "0.3.30"
422 | source = "registry+https://github.com/rust-lang/crates.io-index"
423 | checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004"
424 |
425 | [[package]]
426 | name = "futures-util"
427 | version = "0.3.30"
428 | source = "registry+https://github.com/rust-lang/crates.io-index"
429 | checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48"
430 | dependencies = [
431 | "futures-channel",
432 | "futures-core",
433 | "futures-io",
434 | "futures-macro",
435 | "futures-sink",
436 | "futures-task",
437 | "memchr",
438 | "pin-project-lite",
439 | "pin-utils",
440 | "slab",
441 | ]
442 |
443 | [[package]]
444 | name = "gimli"
445 | version = "0.28.1"
446 | source = "registry+https://github.com/rust-lang/crates.io-index"
447 | checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
448 |
449 | [[package]]
450 | name = "h2"
451 | version = "0.3.24"
452 | source = "registry+https://github.com/rust-lang/crates.io-index"
453 | checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9"
454 | dependencies = [
455 | "bytes",
456 | "fnv",
457 | "futures-core",
458 | "futures-sink",
459 | "futures-util",
460 | "http",
461 | "indexmap",
462 | "slab",
463 | "tokio",
464 | "tokio-util",
465 | "tracing",
466 | ]
467 |
468 | [[package]]
469 | name = "hashbrown"
470 | version = "0.14.3"
471 | source = "registry+https://github.com/rust-lang/crates.io-index"
472 | checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
473 |
474 | [[package]]
475 | name = "hermit-abi"
476 | version = "0.3.8"
477 | source = "registry+https://github.com/rust-lang/crates.io-index"
478 | checksum = "379dada1584ad501b383485dd706b8afb7a70fcbc7f4da7d780638a5a6124a60"
479 |
480 | [[package]]
481 | name = "http"
482 | version = "0.2.11"
483 | source = "registry+https://github.com/rust-lang/crates.io-index"
484 | checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb"
485 | dependencies = [
486 | "bytes",
487 | "fnv",
488 | "itoa",
489 | ]
490 |
491 | [[package]]
492 | name = "http-body"
493 | version = "0.4.6"
494 | source = "registry+https://github.com/rust-lang/crates.io-index"
495 | checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2"
496 | dependencies = [
497 | "bytes",
498 | "http",
499 | "pin-project-lite",
500 | ]
501 |
502 | [[package]]
503 | name = "httparse"
504 | version = "1.8.0"
505 | source = "registry+https://github.com/rust-lang/crates.io-index"
506 | checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904"
507 |
508 | [[package]]
509 | name = "httpdate"
510 | version = "1.0.3"
511 | source = "registry+https://github.com/rust-lang/crates.io-index"
512 | checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
513 |
514 | [[package]]
515 | name = "hyper"
516 | version = "0.14.28"
517 | source = "registry+https://github.com/rust-lang/crates.io-index"
518 | checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80"
519 | dependencies = [
520 | "bytes",
521 | "futures-channel",
522 | "futures-core",
523 | "futures-util",
524 | "h2",
525 | "http",
526 | "http-body",
527 | "httparse",
528 | "httpdate",
529 | "itoa",
530 | "pin-project-lite",
531 | "socket2 0.4.10",
532 | "tokio",
533 | "tower-service",
534 | "tracing",
535 | "want",
536 | ]
537 |
538 | [[package]]
539 | name = "hyper-tls"
540 | version = "0.5.0"
541 | source = "registry+https://github.com/rust-lang/crates.io-index"
542 | checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
543 | dependencies = [
544 | "bytes",
545 | "hyper",
546 | "native-tls",
547 | "tokio",
548 | "tokio-native-tls",
549 | ]
550 |
551 | [[package]]
552 | name = "idna"
553 | version = "0.5.0"
554 | source = "registry+https://github.com/rust-lang/crates.io-index"
555 | checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6"
556 | dependencies = [
557 | "unicode-bidi",
558 | "unicode-normalization",
559 | ]
560 |
561 | [[package]]
562 | name = "indexmap"
563 | version = "2.2.5"
564 | source = "registry+https://github.com/rust-lang/crates.io-index"
565 | checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4"
566 | dependencies = [
567 | "equivalent",
568 | "hashbrown",
569 | ]
570 |
571 | [[package]]
572 | name = "ipnet"
573 | version = "2.9.0"
574 | source = "registry+https://github.com/rust-lang/crates.io-index"
575 | checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3"
576 |
577 | [[package]]
578 | name = "itertools"
579 | version = "0.12.1"
580 | source = "registry+https://github.com/rust-lang/crates.io-index"
581 | checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
582 | dependencies = [
583 | "either",
584 | ]
585 |
586 | [[package]]
587 | name = "itoa"
588 | version = "1.0.10"
589 | source = "registry+https://github.com/rust-lang/crates.io-index"
590 | checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
591 |
592 | [[package]]
593 | name = "js-sys"
594 | version = "0.3.68"
595 | source = "registry+https://github.com/rust-lang/crates.io-index"
596 | checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee"
597 | dependencies = [
598 | "wasm-bindgen",
599 | ]
600 |
601 | [[package]]
602 | name = "lazy_static"
603 | version = "1.4.0"
604 | source = "registry+https://github.com/rust-lang/crates.io-index"
605 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
606 |
607 | [[package]]
608 | name = "libc"
609 | version = "0.2.153"
610 | source = "registry+https://github.com/rust-lang/crates.io-index"
611 | checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
612 |
613 | [[package]]
614 | name = "linux-raw-sys"
615 | version = "0.4.13"
616 | source = "registry+https://github.com/rust-lang/crates.io-index"
617 | checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
618 |
619 | [[package]]
620 | name = "llama-rag"
621 | version = "0.1.0"
622 | dependencies = [
623 | "anyhow",
624 | "bytes",
625 | "chat-prompts",
626 | "clap",
627 | "endpoints",
628 | "futures",
629 | "futures-util",
630 | "reqwest",
631 | "serde",
632 | "serde_json",
633 | "text-splitter",
634 | "tiktoken-rs",
635 | "tokio",
636 | ]
637 |
638 | [[package]]
639 | name = "lock_api"
640 | version = "0.4.11"
641 | source = "registry+https://github.com/rust-lang/crates.io-index"
642 | checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45"
643 | dependencies = [
644 | "autocfg",
645 | "scopeguard",
646 | ]
647 |
648 | [[package]]
649 | name = "log"
650 | version = "0.4.20"
651 | source = "registry+https://github.com/rust-lang/crates.io-index"
652 | checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
653 |
654 | [[package]]
655 | name = "memchr"
656 | version = "2.7.1"
657 | source = "registry+https://github.com/rust-lang/crates.io-index"
658 | checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
659 |
660 | [[package]]
661 | name = "mime"
662 | version = "0.3.17"
663 | source = "registry+https://github.com/rust-lang/crates.io-index"
664 | checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
665 |
666 | [[package]]
667 | name = "miniz_oxide"
668 | version = "0.7.2"
669 | source = "registry+https://github.com/rust-lang/crates.io-index"
670 | checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7"
671 | dependencies = [
672 | "adler",
673 | ]
674 |
675 | [[package]]
676 | name = "mio"
677 | version = "0.8.10"
678 | source = "registry+https://github.com/rust-lang/crates.io-index"
679 | checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09"
680 | dependencies = [
681 | "libc",
682 | "wasi",
683 | "windows-sys 0.48.0",
684 | ]
685 |
686 | [[package]]
687 | name = "native-tls"
688 | version = "0.2.11"
689 | source = "registry+https://github.com/rust-lang/crates.io-index"
690 | checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e"
691 | dependencies = [
692 | "lazy_static",
693 | "libc",
694 | "log",
695 | "openssl",
696 | "openssl-probe",
697 | "openssl-sys",
698 | "schannel",
699 | "security-framework",
700 | "security-framework-sys",
701 | "tempfile",
702 | ]
703 |
704 | [[package]]
705 | name = "num_cpus"
706 | version = "1.16.0"
707 | source = "registry+https://github.com/rust-lang/crates.io-index"
708 | checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
709 | dependencies = [
710 | "hermit-abi",
711 | "libc",
712 | ]
713 |
714 | [[package]]
715 | name = "object"
716 | version = "0.32.2"
717 | source = "registry+https://github.com/rust-lang/crates.io-index"
718 | checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441"
719 | dependencies = [
720 | "memchr",
721 | ]
722 |
723 | [[package]]
724 | name = "once_cell"
725 | version = "1.19.0"
726 | source = "registry+https://github.com/rust-lang/crates.io-index"
727 | checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
728 |
729 | [[package]]
730 | name = "openssl"
731 | version = "0.10.64"
732 | source = "registry+https://github.com/rust-lang/crates.io-index"
733 | checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f"
734 | dependencies = [
735 | "bitflags 2.4.2",
736 | "cfg-if",
737 | "foreign-types",
738 | "libc",
739 | "once_cell",
740 | "openssl-macros",
741 | "openssl-sys",
742 | ]
743 |
744 | [[package]]
745 | name = "openssl-macros"
746 | version = "0.1.1"
747 | source = "registry+https://github.com/rust-lang/crates.io-index"
748 | checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
749 | dependencies = [
750 | "proc-macro2",
751 | "quote",
752 | "syn",
753 | ]
754 |
755 | [[package]]
756 | name = "openssl-probe"
757 | version = "0.1.5"
758 | source = "registry+https://github.com/rust-lang/crates.io-index"
759 | checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
760 |
761 | [[package]]
762 | name = "openssl-sys"
763 | version = "0.9.101"
764 | source = "registry+https://github.com/rust-lang/crates.io-index"
765 | checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff"
766 | dependencies = [
767 | "cc",
768 | "libc",
769 | "pkg-config",
770 | "vcpkg",
771 | ]
772 |
773 | [[package]]
774 | name = "parking_lot"
775 | version = "0.12.1"
776 | source = "registry+https://github.com/rust-lang/crates.io-index"
777 | checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
778 | dependencies = [
779 | "lock_api",
780 | "parking_lot_core",
781 | ]
782 |
783 | [[package]]
784 | name = "parking_lot_core"
785 | version = "0.9.9"
786 | source = "registry+https://github.com/rust-lang/crates.io-index"
787 | checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e"
788 | dependencies = [
789 | "cfg-if",
790 | "libc",
791 | "redox_syscall",
792 | "smallvec",
793 | "windows-targets 0.48.5",
794 | ]
795 |
796 | [[package]]
797 | name = "percent-encoding"
798 | version = "2.3.1"
799 | source = "registry+https://github.com/rust-lang/crates.io-index"
800 | checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
801 |
802 | [[package]]
803 | name = "pin-project-lite"
804 | version = "0.2.13"
805 | source = "registry+https://github.com/rust-lang/crates.io-index"
806 | checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
807 |
808 | [[package]]
809 | name = "pin-utils"
810 | version = "0.1.0"
811 | source = "registry+https://github.com/rust-lang/crates.io-index"
812 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
813 |
814 | [[package]]
815 | name = "pkg-config"
816 | version = "0.3.30"
817 | source = "registry+https://github.com/rust-lang/crates.io-index"
818 | checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
819 |
820 | [[package]]
821 | name = "proc-macro2"
822 | version = "1.0.78"
823 | source = "registry+https://github.com/rust-lang/crates.io-index"
824 | checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae"
825 | dependencies = [
826 | "unicode-ident",
827 | ]
828 |
829 | [[package]]
830 | name = "quote"
831 | version = "1.0.35"
832 | source = "registry+https://github.com/rust-lang/crates.io-index"
833 | checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
834 | dependencies = [
835 | "proc-macro2",
836 | ]
837 |
838 | [[package]]
839 | name = "redox_syscall"
840 | version = "0.4.1"
841 | source = "registry+https://github.com/rust-lang/crates.io-index"
842 | checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
843 | dependencies = [
844 | "bitflags 1.3.2",
845 | ]
846 |
847 | [[package]]
848 | name = "regex"
849 | version = "1.10.3"
850 | source = "registry+https://github.com/rust-lang/crates.io-index"
851 | checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15"
852 | dependencies = [
853 | "aho-corasick",
854 | "memchr",
855 | "regex-automata",
856 | "regex-syntax",
857 | ]
858 |
859 | [[package]]
860 | name = "regex-automata"
861 | version = "0.4.5"
862 | source = "registry+https://github.com/rust-lang/crates.io-index"
863 | checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd"
864 | dependencies = [
865 | "aho-corasick",
866 | "memchr",
867 | "regex-syntax",
868 | ]
869 |
870 | [[package]]
871 | name = "regex-syntax"
872 | version = "0.8.2"
873 | source = "registry+https://github.com/rust-lang/crates.io-index"
874 | checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
875 |
876 | [[package]]
877 | name = "reqwest"
878 | version = "0.11.24"
879 | source = "registry+https://github.com/rust-lang/crates.io-index"
880 | checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251"
881 | dependencies = [
882 | "base64",
883 | "bytes",
884 | "encoding_rs",
885 | "futures-core",
886 | "futures-util",
887 | "h2",
888 | "http",
889 | "http-body",
890 | "hyper",
891 | "hyper-tls",
892 | "ipnet",
893 | "js-sys",
894 | "log",
895 | "mime",
896 | "native-tls",
897 | "once_cell",
898 | "percent-encoding",
899 | "pin-project-lite",
900 | "rustls-pemfile",
901 | "serde",
902 | "serde_json",
903 | "serde_urlencoded",
904 | "sync_wrapper",
905 | "system-configuration",
906 | "tokio",
907 | "tokio-native-tls",
908 | "tokio-util",
909 | "tower-service",
910 | "url",
911 | "wasm-bindgen",
912 | "wasm-bindgen-futures",
913 | "wasm-streams",
914 | "web-sys",
915 | "winreg",
916 | ]
917 |
918 | [[package]]
919 | name = "rustc-demangle"
920 | version = "0.1.23"
921 | source = "registry+https://github.com/rust-lang/crates.io-index"
922 | checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
923 |
924 | [[package]]
925 | name = "rustc-hash"
926 | version = "1.1.0"
927 | source = "registry+https://github.com/rust-lang/crates.io-index"
928 | checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
929 |
930 | [[package]]
931 | name = "rustix"
932 | version = "0.38.31"
933 | source = "registry+https://github.com/rust-lang/crates.io-index"
934 | checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949"
935 | dependencies = [
936 | "bitflags 2.4.2",
937 | "errno",
938 | "libc",
939 | "linux-raw-sys",
940 | "windows-sys 0.52.0",
941 | ]
942 |
943 | [[package]]
944 | name = "rustls-pemfile"
945 | version = "1.0.4"
946 | source = "registry+https://github.com/rust-lang/crates.io-index"
947 | checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c"
948 | dependencies = [
949 | "base64",
950 | ]
951 |
952 | [[package]]
953 | name = "ryu"
954 | version = "1.0.17"
955 | source = "registry+https://github.com/rust-lang/crates.io-index"
956 | checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1"
957 |
958 | [[package]]
959 | name = "schannel"
960 | version = "0.1.23"
961 | source = "registry+https://github.com/rust-lang/crates.io-index"
962 | checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534"
963 | dependencies = [
964 | "windows-sys 0.52.0",
965 | ]
966 |
967 | [[package]]
968 | name = "scopeguard"
969 | version = "1.2.0"
970 | source = "registry+https://github.com/rust-lang/crates.io-index"
971 | checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
972 |
973 | [[package]]
974 | name = "security-framework"
975 | version = "2.9.2"
976 | source = "registry+https://github.com/rust-lang/crates.io-index"
977 | checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de"
978 | dependencies = [
979 | "bitflags 1.3.2",
980 | "core-foundation",
981 | "core-foundation-sys",
982 | "libc",
983 | "security-framework-sys",
984 | ]
985 |
986 | [[package]]
987 | name = "security-framework-sys"
988 | version = "2.9.1"
989 | source = "registry+https://github.com/rust-lang/crates.io-index"
990 | checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a"
991 | dependencies = [
992 | "core-foundation-sys",
993 | "libc",
994 | ]
995 |
996 | [[package]]
997 | name = "serde"
998 | version = "1.0.197"
999 | source = "registry+https://github.com/rust-lang/crates.io-index"
1000 | checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2"
1001 | dependencies = [
1002 | "serde_derive",
1003 | ]
1004 |
1005 | [[package]]
1006 | name = "serde_derive"
1007 | version = "1.0.197"
1008 | source = "registry+https://github.com/rust-lang/crates.io-index"
1009 | checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b"
1010 | dependencies = [
1011 | "proc-macro2",
1012 | "quote",
1013 | "syn",
1014 | ]
1015 |
1016 | [[package]]
1017 | name = "serde_json"
1018 | version = "1.0.114"
1019 | source = "registry+https://github.com/rust-lang/crates.io-index"
1020 | checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0"
1021 | dependencies = [
1022 | "itoa",
1023 | "ryu",
1024 | "serde",
1025 | ]
1026 |
1027 | [[package]]
1028 | name = "serde_urlencoded"
1029 | version = "0.7.1"
1030 | source = "registry+https://github.com/rust-lang/crates.io-index"
1031 | checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"
1032 | dependencies = [
1033 | "form_urlencoded",
1034 | "itoa",
1035 | "ryu",
1036 | "serde",
1037 | ]
1038 |
1039 | [[package]]
1040 | name = "signal-hook-registry"
1041 | version = "1.4.1"
1042 | source = "registry+https://github.com/rust-lang/crates.io-index"
1043 | checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1"
1044 | dependencies = [
1045 | "libc",
1046 | ]
1047 |
1048 | [[package]]
1049 | name = "slab"
1050 | version = "0.4.9"
1051 | source = "registry+https://github.com/rust-lang/crates.io-index"
1052 | checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67"
1053 | dependencies = [
1054 | "autocfg",
1055 | ]
1056 |
1057 | [[package]]
1058 | name = "smallvec"
1059 | version = "1.13.1"
1060 | source = "registry+https://github.com/rust-lang/crates.io-index"
1061 | checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7"
1062 |
1063 | [[package]]
1064 | name = "socket2"
1065 | version = "0.4.10"
1066 | source = "registry+https://github.com/rust-lang/crates.io-index"
1067 | checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d"
1068 | dependencies = [
1069 | "libc",
1070 | "winapi",
1071 | ]
1072 |
1073 | [[package]]
1074 | name = "socket2"
1075 | version = "0.5.6"
1076 | source = "registry+https://github.com/rust-lang/crates.io-index"
1077 | checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871"
1078 | dependencies = [
1079 | "libc",
1080 | "windows-sys 0.52.0",
1081 | ]
1082 |
1083 | [[package]]
1084 | name = "strsim"
1085 | version = "0.11.0"
1086 | source = "registry+https://github.com/rust-lang/crates.io-index"
1087 | checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01"
1088 |
1089 | [[package]]
1090 | name = "syn"
1091 | version = "2.0.51"
1092 | source = "registry+https://github.com/rust-lang/crates.io-index"
1093 | checksum = "6ab617d94515e94ae53b8406c628598680aa0c9587474ecbe58188f7b345d66c"
1094 | dependencies = [
1095 | "proc-macro2",
1096 | "quote",
1097 | "unicode-ident",
1098 | ]
1099 |
1100 | [[package]]
1101 | name = "sync_wrapper"
1102 | version = "0.1.2"
1103 | source = "registry+https://github.com/rust-lang/crates.io-index"
1104 | checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
1105 |
1106 | [[package]]
1107 | name = "system-configuration"
1108 | version = "0.5.1"
1109 | source = "registry+https://github.com/rust-lang/crates.io-index"
1110 | checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7"
1111 | dependencies = [
1112 | "bitflags 1.3.2",
1113 | "core-foundation",
1114 | "system-configuration-sys",
1115 | ]
1116 |
1117 | [[package]]
1118 | name = "system-configuration-sys"
1119 | version = "0.5.0"
1120 | source = "registry+https://github.com/rust-lang/crates.io-index"
1121 | checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9"
1122 | dependencies = [
1123 | "core-foundation-sys",
1124 | "libc",
1125 | ]
1126 |
1127 | [[package]]
1128 | name = "tempfile"
1129 | version = "3.10.1"
1130 | source = "registry+https://github.com/rust-lang/crates.io-index"
1131 | checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1"
1132 | dependencies = [
1133 | "cfg-if",
1134 | "fastrand",
1135 | "rustix",
1136 | "windows-sys 0.52.0",
1137 | ]
1138 |
1139 | [[package]]
1140 | name = "text-splitter"
1141 | version = "0.6.3"
1142 | source = "registry+https://github.com/rust-lang/crates.io-index"
1143 | checksum = "8c323eda8714dcca987ed66e48edd368882c3214546182f755cb2226da52813d"
1144 | dependencies = [
1145 | "auto_enums",
1146 | "either",
1147 | "itertools",
1148 | "once_cell",
1149 | "regex",
1150 | "tiktoken-rs",
1151 | "unicode-segmentation",
1152 | ]
1153 |
1154 | [[package]]
1155 | name = "thiserror"
1156 | version = "1.0.57"
1157 | source = "registry+https://github.com/rust-lang/crates.io-index"
1158 | checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b"
1159 | dependencies = [
1160 | "thiserror-impl",
1161 | ]
1162 |
1163 | [[package]]
1164 | name = "thiserror-impl"
1165 | version = "1.0.57"
1166 | source = "registry+https://github.com/rust-lang/crates.io-index"
1167 | checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81"
1168 | dependencies = [
1169 | "proc-macro2",
1170 | "quote",
1171 | "syn",
1172 | ]
1173 |
1174 | [[package]]
1175 | name = "tiktoken-rs"
1176 | version = "0.5.8"
1177 | source = "registry+https://github.com/rust-lang/crates.io-index"
1178 | checksum = "40894b788eb28bbb7e36bdc8b7b1b1488b9c93fa3730f315ab965330c94c0842"
1179 | dependencies = [
1180 | "anyhow",
1181 | "base64",
1182 | "bstr",
1183 | "fancy-regex",
1184 | "lazy_static",
1185 | "parking_lot",
1186 | "rustc-hash",
1187 | ]
1188 |
1189 | [[package]]
1190 | name = "tinyvec"
1191 | version = "1.6.0"
1192 | source = "registry+https://github.com/rust-lang/crates.io-index"
1193 | checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50"
1194 | dependencies = [
1195 | "tinyvec_macros",
1196 | ]
1197 |
1198 | [[package]]
1199 | name = "tinyvec_macros"
1200 | version = "0.1.1"
1201 | source = "registry+https://github.com/rust-lang/crates.io-index"
1202 | checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
1203 |
1204 | [[package]]
1205 | name = "tokio"
1206 | version = "1.36.0"
1207 | source = "registry+https://github.com/rust-lang/crates.io-index"
1208 | checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931"
1209 | dependencies = [
1210 | "backtrace",
1211 | "bytes",
1212 | "libc",
1213 | "mio",
1214 | "num_cpus",
1215 | "parking_lot",
1216 | "pin-project-lite",
1217 | "signal-hook-registry",
1218 | "socket2 0.5.6",
1219 | "tokio-macros",
1220 | "windows-sys 0.48.0",
1221 | ]
1222 |
1223 | [[package]]
1224 | name = "tokio-macros"
1225 | version = "2.2.0"
1226 | source = "registry+https://github.com/rust-lang/crates.io-index"
1227 | checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
1228 | dependencies = [
1229 | "proc-macro2",
1230 | "quote",
1231 | "syn",
1232 | ]
1233 |
1234 | [[package]]
1235 | name = "tokio-native-tls"
1236 | version = "0.3.1"
1237 | source = "registry+https://github.com/rust-lang/crates.io-index"
1238 | checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2"
1239 | dependencies = [
1240 | "native-tls",
1241 | "tokio",
1242 | ]
1243 |
1244 | [[package]]
1245 | name = "tokio-util"
1246 | version = "0.7.10"
1247 | source = "registry+https://github.com/rust-lang/crates.io-index"
1248 | checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15"
1249 | dependencies = [
1250 | "bytes",
1251 | "futures-core",
1252 | "futures-sink",
1253 | "pin-project-lite",
1254 | "tokio",
1255 | "tracing",
1256 | ]
1257 |
1258 | [[package]]
1259 | name = "tower-service"
1260 | version = "0.3.2"
1261 | source = "registry+https://github.com/rust-lang/crates.io-index"
1262 | checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52"
1263 |
1264 | [[package]]
1265 | name = "tracing"
1266 | version = "0.1.40"
1267 | source = "registry+https://github.com/rust-lang/crates.io-index"
1268 | checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef"
1269 | dependencies = [
1270 | "pin-project-lite",
1271 | "tracing-core",
1272 | ]
1273 |
1274 | [[package]]
1275 | name = "tracing-core"
1276 | version = "0.1.32"
1277 | source = "registry+https://github.com/rust-lang/crates.io-index"
1278 | checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54"
1279 | dependencies = [
1280 | "once_cell",
1281 | ]
1282 |
1283 | [[package]]
1284 | name = "try-lock"
1285 | version = "0.2.5"
1286 | source = "registry+https://github.com/rust-lang/crates.io-index"
1287 | checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
1288 |
1289 | [[package]]
1290 | name = "unicode-bidi"
1291 | version = "0.3.15"
1292 | source = "registry+https://github.com/rust-lang/crates.io-index"
1293 | checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75"
1294 |
1295 | [[package]]
1296 | name = "unicode-ident"
1297 | version = "1.0.12"
1298 | source = "registry+https://github.com/rust-lang/crates.io-index"
1299 | checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
1300 |
1301 | [[package]]
1302 | name = "unicode-normalization"
1303 | version = "0.1.23"
1304 | source = "registry+https://github.com/rust-lang/crates.io-index"
1305 | checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5"
1306 | dependencies = [
1307 | "tinyvec",
1308 | ]
1309 |
1310 | [[package]]
1311 | name = "unicode-segmentation"
1312 | version = "1.11.0"
1313 | source = "registry+https://github.com/rust-lang/crates.io-index"
1314 | checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202"
1315 |
1316 | [[package]]
1317 | name = "url"
1318 | version = "2.5.0"
1319 | source = "registry+https://github.com/rust-lang/crates.io-index"
1320 | checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633"
1321 | dependencies = [
1322 | "form_urlencoded",
1323 | "idna",
1324 | "percent-encoding",
1325 | ]
1326 |
1327 | [[package]]
1328 | name = "utf8parse"
1329 | version = "0.2.1"
1330 | source = "registry+https://github.com/rust-lang/crates.io-index"
1331 | checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
1332 |
1333 | [[package]]
1334 | name = "vcpkg"
1335 | version = "0.2.15"
1336 | source = "registry+https://github.com/rust-lang/crates.io-index"
1337 | checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
1338 |
1339 | [[package]]
1340 | name = "want"
1341 | version = "0.3.1"
1342 | source = "registry+https://github.com/rust-lang/crates.io-index"
1343 | checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e"
1344 | dependencies = [
1345 | "try-lock",
1346 | ]
1347 |
1348 | [[package]]
1349 | name = "wasi"
1350 | version = "0.11.0+wasi-snapshot-preview1"
1351 | source = "registry+https://github.com/rust-lang/crates.io-index"
1352 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
1353 |
1354 | [[package]]
1355 | name = "wasm-bindgen"
1356 | version = "0.2.91"
1357 | source = "registry+https://github.com/rust-lang/crates.io-index"
1358 | checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f"
1359 | dependencies = [
1360 | "cfg-if",
1361 | "wasm-bindgen-macro",
1362 | ]
1363 |
1364 | [[package]]
1365 | name = "wasm-bindgen-backend"
1366 | version = "0.2.91"
1367 | source = "registry+https://github.com/rust-lang/crates.io-index"
1368 | checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b"
1369 | dependencies = [
1370 | "bumpalo",
1371 | "log",
1372 | "once_cell",
1373 | "proc-macro2",
1374 | "quote",
1375 | "syn",
1376 | "wasm-bindgen-shared",
1377 | ]
1378 |
1379 | [[package]]
1380 | name = "wasm-bindgen-futures"
1381 | version = "0.4.41"
1382 | source = "registry+https://github.com/rust-lang/crates.io-index"
1383 | checksum = "877b9c3f61ceea0e56331985743b13f3d25c406a7098d45180fb5f09bc19ed97"
1384 | dependencies = [
1385 | "cfg-if",
1386 | "js-sys",
1387 | "wasm-bindgen",
1388 | "web-sys",
1389 | ]
1390 |
1391 | [[package]]
1392 | name = "wasm-bindgen-macro"
1393 | version = "0.2.91"
1394 | source = "registry+https://github.com/rust-lang/crates.io-index"
1395 | checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed"
1396 | dependencies = [
1397 | "quote",
1398 | "wasm-bindgen-macro-support",
1399 | ]
1400 |
1401 | [[package]]
1402 | name = "wasm-bindgen-macro-support"
1403 | version = "0.2.91"
1404 | source = "registry+https://github.com/rust-lang/crates.io-index"
1405 | checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66"
1406 | dependencies = [
1407 | "proc-macro2",
1408 | "quote",
1409 | "syn",
1410 | "wasm-bindgen-backend",
1411 | "wasm-bindgen-shared",
1412 | ]
1413 |
1414 | [[package]]
1415 | name = "wasm-bindgen-shared"
1416 | version = "0.2.91"
1417 | source = "registry+https://github.com/rust-lang/crates.io-index"
1418 | checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838"
1419 |
1420 | [[package]]
1421 | name = "wasm-streams"
1422 | version = "0.4.0"
1423 | source = "registry+https://github.com/rust-lang/crates.io-index"
1424 | checksum = "b65dc4c90b63b118468cf747d8bf3566c1913ef60be765b5730ead9e0a3ba129"
1425 | dependencies = [
1426 | "futures-util",
1427 | "js-sys",
1428 | "wasm-bindgen",
1429 | "wasm-bindgen-futures",
1430 | "web-sys",
1431 | ]
1432 |
1433 | [[package]]
1434 | name = "web-sys"
1435 | version = "0.3.68"
1436 | source = "registry+https://github.com/rust-lang/crates.io-index"
1437 | checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446"
1438 | dependencies = [
1439 | "js-sys",
1440 | "wasm-bindgen",
1441 | ]
1442 |
1443 | [[package]]
1444 | name = "winapi"
1445 | version = "0.3.9"
1446 | source = "registry+https://github.com/rust-lang/crates.io-index"
1447 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
1448 | dependencies = [
1449 | "winapi-i686-pc-windows-gnu",
1450 | "winapi-x86_64-pc-windows-gnu",
1451 | ]
1452 |
1453 | [[package]]
1454 | name = "winapi-i686-pc-windows-gnu"
1455 | version = "0.4.0"
1456 | source = "registry+https://github.com/rust-lang/crates.io-index"
1457 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
1458 |
1459 | [[package]]
1460 | name = "winapi-x86_64-pc-windows-gnu"
1461 | version = "0.4.0"
1462 | source = "registry+https://github.com/rust-lang/crates.io-index"
1463 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
1464 |
1465 | [[package]]
1466 | name = "windows-sys"
1467 | version = "0.48.0"
1468 | source = "registry+https://github.com/rust-lang/crates.io-index"
1469 | checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
1470 | dependencies = [
1471 | "windows-targets 0.48.5",
1472 | ]
1473 |
1474 | [[package]]
1475 | name = "windows-sys"
1476 | version = "0.52.0"
1477 | source = "registry+https://github.com/rust-lang/crates.io-index"
1478 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
1479 | dependencies = [
1480 | "windows-targets 0.52.3",
1481 | ]
1482 |
1483 | [[package]]
1484 | name = "windows-targets"
1485 | version = "0.48.5"
1486 | source = "registry+https://github.com/rust-lang/crates.io-index"
1487 | checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
1488 | dependencies = [
1489 | "windows_aarch64_gnullvm 0.48.5",
1490 | "windows_aarch64_msvc 0.48.5",
1491 | "windows_i686_gnu 0.48.5",
1492 | "windows_i686_msvc 0.48.5",
1493 | "windows_x86_64_gnu 0.48.5",
1494 | "windows_x86_64_gnullvm 0.48.5",
1495 | "windows_x86_64_msvc 0.48.5",
1496 | ]
1497 |
1498 | [[package]]
1499 | name = "windows-targets"
1500 | version = "0.52.3"
1501 | source = "registry+https://github.com/rust-lang/crates.io-index"
1502 | checksum = "d380ba1dc7187569a8a9e91ed34b8ccfc33123bbacb8c0aed2d1ad7f3ef2dc5f"
1503 | dependencies = [
1504 | "windows_aarch64_gnullvm 0.52.3",
1505 | "windows_aarch64_msvc 0.52.3",
1506 | "windows_i686_gnu 0.52.3",
1507 | "windows_i686_msvc 0.52.3",
1508 | "windows_x86_64_gnu 0.52.3",
1509 | "windows_x86_64_gnullvm 0.52.3",
1510 | "windows_x86_64_msvc 0.52.3",
1511 | ]
1512 |
1513 | [[package]]
1514 | name = "windows_aarch64_gnullvm"
1515 | version = "0.48.5"
1516 | source = "registry+https://github.com/rust-lang/crates.io-index"
1517 | checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
1518 |
1519 | [[package]]
1520 | name = "windows_aarch64_gnullvm"
1521 | version = "0.52.3"
1522 | source = "registry+https://github.com/rust-lang/crates.io-index"
1523 | checksum = "68e5dcfb9413f53afd9c8f86e56a7b4d86d9a2fa26090ea2dc9e40fba56c6ec6"
1524 |
1525 | [[package]]
1526 | name = "windows_aarch64_msvc"
1527 | version = "0.48.5"
1528 | source = "registry+https://github.com/rust-lang/crates.io-index"
1529 | checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
1530 |
1531 | [[package]]
1532 | name = "windows_aarch64_msvc"
1533 | version = "0.52.3"
1534 | source = "registry+https://github.com/rust-lang/crates.io-index"
1535 | checksum = "8dab469ebbc45798319e69eebf92308e541ce46760b49b18c6b3fe5e8965b30f"
1536 |
1537 | [[package]]
1538 | name = "windows_i686_gnu"
1539 | version = "0.48.5"
1540 | source = "registry+https://github.com/rust-lang/crates.io-index"
1541 | checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
1542 |
1543 | [[package]]
1544 | name = "windows_i686_gnu"
1545 | version = "0.52.3"
1546 | source = "registry+https://github.com/rust-lang/crates.io-index"
1547 | checksum = "2a4e9b6a7cac734a8b4138a4e1044eac3404d8326b6c0f939276560687a033fb"
1548 |
1549 | [[package]]
1550 | name = "windows_i686_msvc"
1551 | version = "0.48.5"
1552 | source = "registry+https://github.com/rust-lang/crates.io-index"
1553 | checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
1554 |
1555 | [[package]]
1556 | name = "windows_i686_msvc"
1557 | version = "0.52.3"
1558 | source = "registry+https://github.com/rust-lang/crates.io-index"
1559 | checksum = "28b0ec9c422ca95ff34a78755cfa6ad4a51371da2a5ace67500cf7ca5f232c58"
1560 |
1561 | [[package]]
1562 | name = "windows_x86_64_gnu"
1563 | version = "0.48.5"
1564 | source = "registry+https://github.com/rust-lang/crates.io-index"
1565 | checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
1566 |
1567 | [[package]]
1568 | name = "windows_x86_64_gnu"
1569 | version = "0.52.3"
1570 | source = "registry+https://github.com/rust-lang/crates.io-index"
1571 | checksum = "704131571ba93e89d7cd43482277d6632589b18ecf4468f591fbae0a8b101614"
1572 |
1573 | [[package]]
1574 | name = "windows_x86_64_gnullvm"
1575 | version = "0.48.5"
1576 | source = "registry+https://github.com/rust-lang/crates.io-index"
1577 | checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
1578 |
1579 | [[package]]
1580 | name = "windows_x86_64_gnullvm"
1581 | version = "0.52.3"
1582 | source = "registry+https://github.com/rust-lang/crates.io-index"
1583 | checksum = "42079295511643151e98d61c38c0acc444e52dd42ab456f7ccfd5152e8ecf21c"
1584 |
1585 | [[package]]
1586 | name = "windows_x86_64_msvc"
1587 | version = "0.48.5"
1588 | source = "registry+https://github.com/rust-lang/crates.io-index"
1589 | checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
1590 |
1591 | [[package]]
1592 | name = "windows_x86_64_msvc"
1593 | version = "0.52.3"
1594 | source = "registry+https://github.com/rust-lang/crates.io-index"
1595 | checksum = "0770833d60a970638e989b3fa9fd2bb1aaadcf88963d1659fd7d9990196ed2d6"
1596 |
1597 | [[package]]
1598 | name = "winreg"
1599 | version = "0.50.0"
1600 | source = "registry+https://github.com/rust-lang/crates.io-index"
1601 | checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1"
1602 | dependencies = [
1603 | "cfg-if",
1604 | "windows-sys 0.48.0",
1605 | ]
1606 |
--------------------------------------------------------------------------------
/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "llama-rag"
3 | version = "0.1.0"
4 | edition = "2021"
5 | authors = ["SecondState Inc."]
6 |
7 | [dependencies]
8 | anyhow = "1.0"
9 | clap = { version = "4.4.6", features = ["cargo"] }
10 | text-splitter = { version = "0.6.3", features = ["tiktoken-rs"] }
11 | tiktoken-rs = "0.5.8"
12 | reqwest = { version = "0.11", features = ["json", "stream"] }
13 | tokio = { version = "1", features = ["full"] }
14 | serde_json = "1.0"
15 | serde = { version = "1.0", features = ["derive"] }
16 | endpoints = "^0.5"
17 | chat-prompts = "^0.5"
18 | futures = "0.3"
19 | futures-util = "0.3"
20 | bytes = "1.5.0"
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # The Example-LlamaEdge-RAG repo is replaced by the [LlamaEdge/RAG-API-Server](https://github.com/LlamaEdge/rag-api-server) repo.
2 |
3 | If you want to build a RAG application with one single binary, go to check out
4 |
5 | * Rag-api-server repo: https://github.com/LlamaEdge/rag-api-server
6 | * Docs: https://llamaedge.com/docs/intro/
7 |
8 |
9 | ---
10 | # ChatBot on LlamaEdge RAG
11 |
12 | This repository demonstrates a RAG chatbot powered by LlamaEdge RAG. The chatbot uses
13 |
14 | - The `/v1/embedding` endpoint of the `llama-api-server` to (1) compute the embeddings for the given document and (2) persist the embeddings in the specified Qdrant DB.
15 |
16 | - The `/v1/chat/completions` endpoint of the `llama-api-server` to (1) compute the embeddings for the user question; (2) query the Qdrant DB and retrieve the most similar documents to the user's input; (3) generate the completions for the user's input.
17 |
18 | Note that it is required to specify `--qdrant-url`, `--qdrant-collection-name`, `--qdrant-limit` CLI options while starting the `llama-api-server` to enable the RAG service.
19 |
20 | The entire workflow is depicted in the diagrams in the [Workflow](#workflow) section.
21 |
22 | If you'd like to use `curl` to interact with LlamaEdge RAG endpoints, you can refer to [curl.md](curl.md).
23 |
24 | ## Setup
25 |
26 | - Install `WasmEdge Runtime`
27 |
28 | ```console
29 | curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -v 0.13.5 --plugins wasi_nn-ggml wasmedge_rustls
30 | ```
31 |
32 | - Start Qdrant docker container
33 |
34 | ```console
35 | # Pull the Qdrant docker image
36 | docker pull qdrant/qdrant
37 |
38 | # Create a directory to store Qdrant data
39 | mkdir qdrant_storage
40 |
41 | # Run Qdrant service
42 | docker run -p 6333:6333 -p 6334:6334 -v $(pwd)/qdrant_storage:/qdrant/storage:z qdrant/qdrant
43 | ```
44 |
45 | - Start `llama-api-server`
46 |
47 | ```bash
48 | wasmedge --dir .:. --nn-preload default:GGML:AUTO:Llama-2-7b-chat-hf-Q5_K_M.gguf llama-api-server.wasm --prompt-template llama-2-chat --ctx-size 4096 --qdrant-url http://127.0.0.1:6333 --qdrant-collection-name "paris" --qdrant-limit 3
49 | ```
50 |
51 | ## Usage
52 |
53 | - Build and run
54 |
55 | ```console
56 | # clone the repository
57 | git clone https://github.com/LlamaEdge/Example-LlamaEdge-RAG.git
58 | cd Example-LlamaEdge-RAG
59 |
60 | # build the executable
61 | cargo build --release
62 |
63 | # run the executable
64 | ./target/release/llama-rag --file paris.txt
65 | ```
66 |
67 | If the command runs successfully, you will see the following output:
68 |
69 | ```console
70 | [INFO] Document: paris.txt
71 |
72 | [+] Chunking the document ...
73 | [+] Computing the embeddings for the document ...
74 |
75 | [You]:
76 | What is the sobriquet of Paris, France?
77 |
78 | [Bot]:
79 | Based on the provided context, the sobriquet of Paris, France is "the City of Light" (French: "la Ville Lumière").
80 |
81 |
82 | [You]:
83 | What is the location of Paris, France on the Seine River?
84 |
85 | [Bot]:
86 | According to the provided text, Paris is situated along the Seine River some 233 miles (375 km) upstream from the river’s mouth on the English Channel (La Manche). Therefore, the location of Paris, France on the Seine River is approximately 233 miles (375 km) upstream from the river's mouth.
87 | ```
88 |
89 | ## Workflow
90 |
91 | - Compute and store embeddings for a given text file
92 |
93 |
94 |
95 |
96 |
97 | - RAG-based chatbot
98 |
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/bitcoin.txt:
--------------------------------------------------------------------------------
1 | Abstract. A purely peer-to-peer version of electronic cash would allow online
2 | payments to be sent directly from one party to another without going through a
3 | financial institution. Digital signatures provide part of the solution, but the main
4 | benefits are lost if a trusted third party is still required to prevent double-spending.
5 | We propose a solution to the double-spending problem using a peer-to-peer network.
6 | The network timestamps transactions by hashing them into an ongoing chain of
7 | hash-based proof-of-work, forming a record that cannot be changed without redoing
8 | the proof-of-work. The longest chain not only serves as proof of the sequence of
9 | events witnessed, but proof that it came from the largest pool of CPU power. As
10 | long as a majority of CPU power is controlled by nodes that are not cooperating to
11 | attack the network, they'll generate the longest chain and outpace attackers. The
12 | network itself requires minimal structure. Messages are broadcast on a best effort
13 | basis, and nodes can leave and rejoin the network at will, accepting the longest
14 | proof-of-work chain as proof of what happened while they were gone. Bitcoin is a
15 | peer-to-peer electronic cash system.
16 |
17 | Commerce on the Internet has come to rely almost exclusively on financial institutions
18 | serving as trusted third parties to process electronic payments. While the system works
19 | well enough for most transactions, it still suffers from the inherent weaknesses of the
20 | trust based model. Completely non-reversible transactions are not really possible,
21 | since financial institutions cannot avoid mediating disputes. The cost of mediation
22 | increases transaction costs, limiting the minimum practical transaction size and
23 | cutting off the possibility for small casual transactions, and there is a broader cost
24 | in the loss of ability to make non-reversible payments for nonreversible services. With
25 | the possibility of reversal, the need for trust spreads. Merchants must be wary of
26 | their customers, hassling them for more information than they would otherwise need. A
27 | certain percentage of fraud is accepted as unavoidable. These costs and payment
28 | uncertainties can be avoided in person by using physical currency, but no mechanism
29 | exists to make payments over a communications channel without a trusted party.
30 |
31 |
--------------------------------------------------------------------------------
/curl.md:
--------------------------------------------------------------------------------
1 | # Run the RAG applications with LlamaEdge
2 |
3 | ## Setup
4 |
5 | - Install `WasmEdge Runtime`
6 |
7 | ```console
8 | curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -v 0.13.5 --plugins wasi_nn-ggml wasmedge_rustls
9 | ```
10 |
11 | - Start Qdrant docker container
12 |
13 | ```console
14 | # Pull the Qdrant docker image
15 | docker pull qdrant/qdrant
16 |
17 | # Create a directory to store Qdrant data
18 | mkdir qdrant_storage
19 |
20 | # Run Qdrant service
21 | docker run -p 6333:6333 -p 6334:6334 -v $(pwd)/qdrant_storage:/qdrant/storage:z qdrant/qdrant
22 | ```
23 |
24 | - Start `llama-api-server`
25 |
26 | **Note that use `improve-rag-endpoints` branch of LlamaEdge to compile `llama-api-server.wasm`.**
27 |
28 | ```bash
29 | wasmedge --dir .:. --nn-preload default:GGML:AUTO:Llama-2-7b-chat-hf-Q5_K_M.gguf llama-api-server.wasm \
30 | --prompt-template llama-2-chat \
31 | --ctx-size 4096 \
32 | --qdrant-url http://127.0.0.1:6333 \
33 | --qdrant-collection-name "paris" \
34 | --qdrant-limit 3
35 | ```
36 |
37 | ## Chat using `curl` command
38 |
39 | - Upload the chunks of `paris.txt` via `/v1/embeddings` endpoint
40 |
41 | ```bash
42 | curl -s -X POST http://localhost:8080/v1/embeddings \
43 | -H 'accept:application/json' \
44 | -H 'Content-Type: application/json' \
45 | -d '{"model":"dummy-embedding-model","input":["Paris, city and capital of France, situated in the north-central part of the country. People were living on the site of the present-day city, located along the Seine River some 233 miles (375 km) upstream from the river’s mouth on the English Channel (La Manche), by about 7600 BCE. The modern city has spread from the island (the Île de la Cité) and far beyond both banks of the Seine.","Paris occupies a central position in the rich agricultural region known as the Paris Basin, and it constitutes one of eight départements of the Île-de-France administrative region. It is by far the country’s most important centre of commerce and culture. Area city, 41 square miles (105 square km); metropolitan area, 890 square miles (2,300 square km).","Pop. (2020 est.) city, 2,145,906; (2020 est.) urban agglomeration, 10,858,874.","For centuries Paris has been one of the world’s most important and attractive cities. It is appreciated for the opportunities it offers for business and commerce, for study, for culture, and for entertainment; its gastronomy, haute couture, painting, literature, and intellectual community especially enjoy an enviable reputation. Its sobriquet “the City of Light” (“la Ville Lumière”), earned during the Enlightenment, remains appropriate, for Paris has retained its importance as a centre for education and intellectual pursuits.","Paris’s site at a crossroads of both water and land routes significant not only to France but also to Europe has had a continuing influence on its growth. Under Roman administration, in the 1st century BCE, the original site on the Île de la Cité was designated the capital of the Parisii tribe and territory. The Frankish king Clovis I had taken Paris from the Gauls by 494 CE and later made his capital there.","Under Hugh Capet (ruled 987–996) and the Capetian dynasty the preeminence of Paris was firmly established, and Paris became the political and cultural hub as modern France took shape. France has long been a highly centralized country, and Paris has come to be identified with a powerful central state, drawing to itself much of the talent and vitality of the provinces."]}'
46 | ```
47 |
48 | If the command runs successfully, the embeddings for the document chunks will be persisted in the Qdrant collection `paris` as well as returned in the response.
49 |
50 | - Query a user input via the`/v1/chat/completions` endpoint
51 |
52 | ```bash
53 | curl -s -X POST http://localhost:8080/v1/chat/completions \
54 | -H 'accept:application/json' \
55 | -H 'Content-Type: application/json' \
56 | -d '{"messages":[{"role":"user","content":"What is the location of Paris, France on the Seine River?\n"}],"model":"llama-2-7b","stream":false}'
57 | ```
58 |
59 | If the command runs successfully, you will see the following output:
60 |
61 | ```console
62 | {"id":"e6219b85-0453-407b-8737-f525fe15aa27","object":"chat.completion","created":1709286513,"model":"dummy-chat-model","choices":[{"index":0,"message":{"role":"assistant","content":"According to the provided text, Paris is situated along the Seine River some 233 miles (375 km) upstream from the river’s mouth on the English Channel (La Manche). Therefore, the location of Paris, France on the Seine River is approximately 233 miles (375 km) upstream from the river's mouth."},"finish_reason":"stop"}],"usage":{"prompt_tokens":389,"completion_tokens":78,"total_tokens":467}}
63 | ```
64 |
65 | ## Chat with ChatBot UI
66 |
67 | - Upload the chunks of `paris.txt` via `/v1/embeddings` endpoint. Download the paris.json [here](https://github.com/LlamaEdge/Example-LlamaEdge-RAG/blob/main/paris.json).
68 |
69 | ```bash
70 | curl -s -X POST http://localhost:8080/v1/embeddings \
71 | -H 'accept:application/json' \
72 | -H 'Content-Type: application/json' \
73 | -d @paris.json
74 | ```
75 |
76 | If the command runs successfully, the embeddings for the document chunks will be persisted in the Qdrant collection `paris` as well as returned in the response.
77 |
78 | - Interact with the RAG app via the Chatbot UI
79 |
80 | Then, you can open http://localhost:8080 in the browser to chat with the RAG.
81 |
82 | 
83 |
--------------------------------------------------------------------------------
/image/embedding.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LlamaEdge/Example-LlamaEdge-RAG/e51b3643c25800cc44addd4a30942490235c013d/image/embedding.png
--------------------------------------------------------------------------------
/image/rag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LlamaEdge/Example-LlamaEdge-RAG/e51b3643c25800cc44addd4a30942490235c013d/image/rag.png
--------------------------------------------------------------------------------
/llama-rag.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # * check if docker is installed
4 | if command -v docker &> /dev/null
5 | then
6 | printf "[+] Detecting Docker ...\n"
7 | result=$(docker --version)
8 | printf " %s\n" "$result"
9 | else
10 | printf "Docker is required for running this example.\n"
11 | exit 1
12 | fi
13 | printf "\n"
14 |
15 |
16 | # # * install WasmEdge with wasi-nn_ggml plugin
17 | printf "[+] Install WasmEdge with wasi-nn_ggml plugin ...\n\n"
18 | if curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -v 0.13.5 --plugins wasi_nn-ggml wasmedge_rustls; then
19 | source $HOME/.wasmedge/env
20 | wasmedge_path=$(which wasmedge)
21 | printf "\n The WasmEdge Runtime is installed in %s.\n\n" "$wasmedge_path"
22 | else
23 | printf " Failed to install WasmEdge\n"
24 | exit 1
25 | fi
26 | printf "\n"
27 |
28 | # * download Llama-2-7b-chat model
29 | file="Llama-2-7b-chat-hf-Q5_K_M.gguf"
30 | url="https://huggingface.co/second-state/Llama-2-7B-Chat-GGUF/resolve/main/Llama-2-7b-chat-hf-Q5_K_M.gguf"
31 |
32 | if [ ! -f "$file" ]; then
33 | printf "[+] Downloading '$file' ...\n\n"
34 | curl -LO https://huggingface.co/second-state/Llama-2-7B-Chat-GGUF/resolve/main/Llama-2-7b-chat-hf-Q5_K_M.gguf
35 | else
36 | printf "[+] Using the cached '$file' ...\n\n"
37 | fi
38 |
39 | # * start Qdrant docker container
40 | printf "[+] Starting Qdrant docker container...\n\n"
41 | found=$(docker image list | grep "qdrant/qdrant")
42 | if [ -z "$found" ]; then
43 | printf " Pulling the 'qdrant/qdrant' docker image...\n"
44 | docker pull qdrant/qdrant
45 | fi
46 |
47 | if [ ! -d "qdrant_storage" ]; then
48 | echo " Creating the 'qdrant_storage' directory for the local storage..."
49 | mkdir -p qdrant_storage
50 | fi
51 |
52 | nohup docker run -p 6333:6333 -p 6334:6334 -v $(pwd)/qdrant_storage:/qdrant/storage:z qdrant/qdrant >/dev/null 2>&1 &
53 |
54 | qdrant_pid=$!
55 | printf " Qdrant Server PID: %s\n\n" "$qdrant_pid"
56 |
57 | # wait for the Qdrant docker container to start.
58 | sleep 2
59 |
60 | # * download llama-api-server.wasm
61 | printf "[+] Downloading the latest 'llama-api-server.wasm' ...\n\n"
62 | curl -LO https://github.com/LlamaEdge/LlamaEdge/releases/latest/download/llama-api-server.wasm
63 | printf "\n\n"
64 |
65 | # * start api server
66 | printf "[+] Starting the LlamaEdge server ...\n\n"
67 | nohup wasmedge --dir .:. --nn-preload default:GGML:AUTO:Llama-2-7b-chat-hf-Q5_K_M.gguf llama-api-server.wasm --prompt-template llama-2-chat --ctx-size 4096 --qdrant-url http://127.0.0.1:6333 --qdrant-collection-name "paris" --qdrant-limit 3 >/dev/null 2>&1 &
68 |
69 | wasmedge_pid=$!
70 | printf " LlamaEdge Server PID: %s\n\n" "$wasmedge_pid"
71 |
72 | # wait for the LlamaEdge server to start. Loading the model takes a few seconds.
73 | sleep 5
74 |
75 | # * use curl to upload a document and generate embeddings
76 | printf "[+] Uploading a document and generating embeddings...\n\n"
77 |
78 | response=$(curl -s -X POST http://localhost:8080/v1/rag/document -H 'accept:application/json' -H 'Content-Type: application/json' -d '{"model":"dummy-embedding-model","input":["Paris, city and capital of France, situated in the north-central part of the country. People were living on the site of the present-day city, located along the Seine River some 233 miles (375 km) upstream from the river’s mouth on the English Channel (La Manche), by about 7600 BCE. The modern city has spread from the island (the Île de la Cité) and far beyond both banks of the Seine.","Paris occupies a central position in the rich agricultural region known as the Paris Basin, and it constitutes one of eight départements of the Île-de-France administrative region. It is by far the country’s most important centre of commerce and culture. Area city, 41 square miles (105 square km); metropolitan area, 890 square miles (2,300 square km).","Pop. (2020 est.) city, 2,145,906; (2020 est.) urban agglomeration, 10,858,874.","For centuries Paris has been one of the world’s most important and attractive cities. It is appreciated for the opportunities it offers for business and commerce, for study, for culture, and for entertainment; its gastronomy, haute couture, painting, literature, and intellectual community especially enjoy an enviable reputation. Its sobriquet “the City of Light” (“la Ville Lumière”), earned during the Enlightenment, remains appropriate, for Paris has retained its importance as a centre for education and intellectual pursuits.","Paris’s site at a crossroads of both water and land routes significant not only to France but also to Europe has had a continuing influence on its growth. Under Roman administration, in the 1st century BCE, the original site on the Île de la Cité was designated the capital of the Parisii tribe and territory. The Frankish king Clovis I had taken Paris from the Gauls by 494 CE and later made his capital there.","Under Hugh Capet (ruled 987–996) and the Capetian dynasty the preeminence of Paris was firmly established, and Paris became the political and cultural hub as modern France took shape. France has long been a highly centralized country, and Paris has come to be identified with a powerful central state, drawing to itself much of the talent and vitality of the provinces."]}')
79 |
80 | printf " %s" "$response"
81 | printf "\n\n"
82 |
83 | # * use curl to query
84 | printf "[+] Querying user's question...\n\n"
85 | printf " user query: What is the location of Paris, France on the Seine River?\n\n"
86 |
87 | response=$(curl -s -X POST http://localhost:8080/v1/rag/query -H 'accept:application/json' -H 'Content-Type: application/json' -d '{"messages":[{"role":"user","content":"What is the location of Paris, France on the Seine River?\n"}],"model":"llama-2-7b","stream":false}')
88 |
89 | printf " [Response] %s" "$response"
90 | printf "\n\n"
91 |
92 | # * stop the Qdrant docker container
93 | printf "[+] Stopping Qdrant Docker container ...\n\n"
94 | kill $qdrant_pid
95 |
96 | # * stop the LlamaEdge server
97 | printf "[+] Stopping LlamaEdge ...\n\n"
98 | kill $wasmedge_pid
99 |
100 | printf "[+] Done.\n\n"
101 | exit 0
--------------------------------------------------------------------------------
/paris.json:
--------------------------------------------------------------------------------
1 | {
2 | "model": "dummy-embedding-model",
3 | "input": [
4 | "Paris, city and capital of France, situated in the north-central part of the country. People were living on the site of the present-day city, located along the Seine River some 233 miles (375 km) upstream from the river’s mouth on the English Channel (La Manche), by about 7600 BCE. The modern city has spread from the island (the Île de la Cité) and far beyond both banks of the Seine.",
5 | "Paris occupies a central position in the rich agricultural region known as the Paris Basin, and it constitutes one of eight départements of the Île-de-France administrative region. It is by far the country’s most important centre of commerce and culture. Area city, 41 square miles (105 square km); metropolitan area, 890 square miles (2,300 square km).",
6 | "Pop. (2020 est.) city, 2,145,906; (2020 est.) urban agglomeration, 10,858,874.",
7 | "For centuries Paris has been one of the world’s most important and attractive cities. It is appreciated for the opportunities it offers for business and commerce, for study, for culture, and for entertainment; its gastronomy, haute couture, painting, literature, and intellectual community especially enjoy an enviable reputation. Its sobriquet “the City of Light” (“la Ville Lumière”), earned during the Enlightenment, remains appropriate, for Paris has retained its importance as a centre for education and intellectual pursuits.",
8 | "Paris’s site at a crossroads of both water and land routes significant not only to France but also to Europe has had a continuing influence on its growth. Under Roman administration, in the 1st century BCE, the original site on the Île de la Cité was designated the capital of the Parisii tribe and territory. The Frankish king Clovis I had taken Paris from the Gauls by 494 CE and later made his capital there.",
9 | "Under Hugh Capet (ruled 987–996) and the Capetian dynasty the preeminence of Paris was firmly established, and Paris became the political and cultural hub as modern France took shape. France has long been a highly centralized country, and Paris has come to be identified with a powerful central state, drawing to itself much of the talent and vitality of the provinces."
10 | ]
11 | }
--------------------------------------------------------------------------------
/paris.txt:
--------------------------------------------------------------------------------
1 | Paris, city and capital of France, situated in the north-central part of the country. People were living on the site of the present-day city, located along the Seine River some 233 miles (375 km) upstream from the river’s mouth on the English Channel (La Manche), by about 7600 BCE. The modern city has spread from the island (the Île de la Cité) and far beyond both banks of the Seine.
2 |
3 | Paris occupies a central position in the rich agricultural region known as the Paris Basin, and it constitutes one of eight départements of the Île-de-France administrative region. It is by far the country’s most important centre of commerce and culture. Area city, 41 square miles (105 square km); metropolitan area, 890 square miles (2,300 square km). Pop. (2020 est.) city, 2,145,906; (2020 est.) urban agglomeration, 10,858,874.
4 |
5 | For centuries Paris has been one of the world’s most important and attractive cities. It is appreciated for the opportunities it offers for business and commerce, for study, for culture, and for entertainment; its gastronomy, haute couture, painting, literature, and intellectual community especially enjoy an enviable reputation. Its sobriquet “the City of Light” (“la Ville Lumière”), earned during the Enlightenment, remains appropriate, for Paris has retained its importance as a centre for education and intellectual pursuits.
6 |
7 | Paris’s site at a crossroads of both water and land routes significant not only to France but also to Europe has had a continuing influence on its growth. Under Roman administration, in the 1st century BCE, the original site on the Île de la Cité was designated the capital of the Parisii tribe and territory. The Frankish king Clovis I had taken Paris from the Gauls by 494 CE and later made his capital there. Under Hugh Capet (ruled 987–996) and the Capetian dynasty the preeminence of Paris was firmly established, and Paris became the political and cultural hub as modern France took shape. France has long been a highly centralized country, and Paris has come to be identified with a powerful central state, drawing to itself much of the talent and vitality of the provinces.
--------------------------------------------------------------------------------
/src/main.rs:
--------------------------------------------------------------------------------
1 | use clap::{crate_version, Arg, Command};
2 | use endpoints::{
3 | chat::{
4 | ChatCompletionChunk, ChatCompletionRequestBuilder, ChatCompletionRequestMessage,
5 | ChatCompletionUserMessageContent,
6 | },
7 | common::FinishReason,
8 | embeddings::EmbeddingRequest,
9 | };
10 | use futures::StreamExt;
11 | use std::fs::File;
12 | use std::io::prelude::*;
13 | use std::io::stdout;
14 | use std::io::Write;
15 | use std::path::Path;
16 | use text_splitter::TextSplitter;
17 | use tiktoken_rs::cl100k_base;
18 |
19 | #[allow(unreachable_code)]
20 | #[tokio::main]
21 | async fn main() -> Result<(), String> {
22 | let matches = Command::new("llama-chat")
23 | .version(crate_version!())
24 | .arg(
25 | Arg::new("file")
26 | .long("file")
27 | .value_name("FILE")
28 | .help("File with the *.txt extension"),
29 | )
30 | .after_help("Example:\n wasmedge --dir .:. llama-rag.wasm --file paris.txt\n")
31 | .get_matches();
32 |
33 | // parse the command line arguments
34 | let file = matches.get_one::("file").unwrap();
35 | let file_path = std::path::PathBuf::from(file);
36 | if !file_path.exists() {
37 | return Err(format!("{} does not exist", file));
38 | }
39 | println!("[INFO] Document: {}\n", file);
40 |
41 | println!("[+] Chunking the document ...");
42 |
43 | // * load and chunk the text file
44 | let chunks = chunk_document(file)?;
45 |
46 | // * print chunks
47 | // println!(" Chunks: \n");
48 | // for chunk in chunks.iter() {
49 | // println!(" {}\n", chunk);
50 | // }
51 | // println!("\n");
52 |
53 | println!("[+] Computing the embeddings for the document ...");
54 |
55 | // * use LlamaEdge API for RAG to compute and persist embeddings for the chunks
56 | upload_chunks(&chunks).await?;
57 |
58 | loop {
59 | println!("\n[You]: ");
60 | let user_input = read_input();
61 |
62 | // * answer a user query based on the document
63 | let mut stream = query(&user_input).await?.bytes_stream();
64 |
65 | // * print result
66 | println!("\n[Bot]: ");
67 | let mut first = true;
68 | while let Some(item) = stream.next().await {
69 | match item {
70 | Ok(bytes) => {
71 | let s = String::from_utf8_lossy(&bytes).to_string();
72 |
73 | let stream =
74 | serde_json::Deserializer::from_str(&s).into_iter::();
75 |
76 | for value in stream {
77 | match value {
78 | Ok(v) => {
79 | let chat_completion_chunk: ChatCompletionChunk =
80 | serde_json::from_value(v).unwrap();
81 |
82 | let choice = &chat_completion_chunk.choices[0];
83 |
84 | match choice.finish_reason {
85 | None => {
86 | let token = choice.delta.content.as_ref().unwrap();
87 |
88 | if token.is_empty() {
89 | continue;
90 | }
91 |
92 | if first {
93 | first = false;
94 | print_text(token.trim_start());
95 | } else {
96 | print_text(token);
97 | };
98 | }
99 | Some(FinishReason::stop) => {
100 | break;
101 | }
102 | Some(FinishReason::length) => {
103 | if let Some(token) = choice.delta.content.as_ref() {
104 | print_text(token);
105 | }
106 |
107 | break;
108 | }
109 | Some(_) => panic!("Unexpected finish reason"),
110 | };
111 | }
112 | Err(err) => eprintln!("Error: {}", err),
113 | }
114 | }
115 | }
116 | Err(err) => eprintln!("Error: {}", err),
117 | }
118 | }
119 | println!("\n");
120 | }
121 |
122 | Ok(())
123 | }
124 |
125 | fn chunk_document(file: &str) -> Result, String> {
126 | let file_path = Path::new(file);
127 | if !file_path.exists() {
128 | return Err("File does not exist".to_string());
129 | }
130 | if file_path.extension().is_none() || file_path.extension().unwrap() != "txt" {
131 | return Err("File is not a text file".to_string());
132 | }
133 |
134 | // read contents from a text file
135 | let mut file = File::open(file_path).expect("failed to open file");
136 | let mut text = String::new();
137 | file.read_to_string(&mut text).expect("failed to read file");
138 |
139 | let tokenizer = cl100k_base().unwrap();
140 | let max_tokens = 100;
141 | let splitter = TextSplitter::new(tokenizer).with_trim_chunks(true);
142 |
143 | let chunks = splitter
144 | .chunks(&text, max_tokens)
145 | .map(|s| s.to_string())
146 | .collect::>();
147 |
148 | Ok(chunks)
149 | }
150 |
151 | async fn upload_chunks(chunks: &[String]) -> Result<(), String> {
152 | // create embedding request
153 | let embedding_request = EmbeddingRequest {
154 | model: "dummy-embedding-model".to_string(),
155 | input: chunks.to_vec(),
156 | encoding_format: None,
157 | user: None,
158 | };
159 |
160 | // * print the serialized embedding_request
161 | // println!("Serialized embedding_request:\n{}\n\n", serde_json::to_string_pretty(&embedding_request).unwrap());
162 |
163 | // create a client
164 | let client = reqwest::Client::new();
165 |
166 | let request_body = serde_json::to_value(&embedding_request).unwrap();
167 | match client
168 | .post("http://localhost:8080/v1/embeddings")
169 | .header("accept", "application/json")
170 | .header("Content-Type", "application/json")
171 | .json(&request_body)
172 | .send()
173 | .await
174 | {
175 | Ok(_) => Ok(()),
176 | Err(err) => {
177 | println!("Error: {}", err);
178 | Err(err.to_string())
179 | }
180 | }
181 | }
182 |
183 | async fn query(input: &str) -> Result {
184 | // create user message
185 | let user_message = ChatCompletionRequestMessage::new_user_message(
186 | ChatCompletionUserMessageContent::Text(input.to_string()),
187 | None,
188 | );
189 |
190 | // create a chat completion request
191 | let chat_request =
192 | ChatCompletionRequestBuilder::new("dummy-chat-completion-model", vec![user_message])
193 | .with_stream(true)
194 | .build();
195 |
196 | // * print the serialized chat_request
197 | // println!(
198 | // "\n\nSerialized chat_request:\n{}\n\n",
199 | // serde_json::to_string_pretty(&chat_request).unwrap()
200 | // );
201 |
202 | // create a client
203 | let client = reqwest::Client::new();
204 | let request_body = serde_json::to_value(&chat_request).unwrap();
205 |
206 | client
207 | .post("http://localhost:8080/v1/chat/completions")
208 | .header("accept", "application/json")
209 | .header("Content-Type", "application/json")
210 | .json(&request_body)
211 | .send()
212 | .await
213 | .map_err(|e| e.to_string())
214 | }
215 |
216 | fn print_text(text: &str) {
217 | print!("{}", text);
218 | stdout().flush().unwrap();
219 | }
220 |
221 | // For single line input, just press [Return] to end the input.
222 | // For multi-line input, end your input with '\\' and press [Return].
223 | //
224 | // For example:
225 | // [You]:
226 | // what is the capital of France?[Return]
227 | //
228 | // [You]:
229 | // Count the words in the following sentence: \[Return]
230 | // \[Return]
231 | // You can use Git to save new files and any changes to already existing files as a bundle of changes called a commit, which can be thought of as a “revision” to your project.[Return]
232 | //
233 | fn read_input() -> String {
234 | let mut answer = String::new();
235 | loop {
236 | let mut temp = String::new();
237 | std::io::stdin()
238 | .read_line(&mut temp)
239 | .expect("The read bytes are not valid UTF-8");
240 |
241 | if temp.ends_with("\\\n") {
242 | temp.pop();
243 | temp.pop();
244 | temp.push('\n');
245 | answer.push_str(&temp);
246 | continue;
247 | } else if temp.ends_with("\n") {
248 | answer.push_str(&temp);
249 | return answer;
250 | } else {
251 | return answer;
252 | }
253 | }
254 | }
255 |
--------------------------------------------------------------------------------