Daniel Marques commited on
Commit
01b20fd
1 Parent(s): 3c037b0

feat: add fastapi

Browse files
Files changed (1) hide show
  1. static/index.html +23 -491
static/index.html CHANGED
@@ -1,4 +1,4 @@
1
- <!doctype html>
2
  <html lang="en">
3
  <head>
4
  <!-- Required meta tags -->
@@ -8,70 +8,22 @@
8
 
9
  <link rel="icon" type="image" href="static\social_icons\favicon.png" />
10
  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
11
- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
12
- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
 
 
 
 
 
 
 
 
 
13
 
14
  <title>localGPT</title>
15
  </head>
16
- <script>
17
- function openFileSelection() {
18
- const fileInput = document.getElementById("fileInput");
19
- fileInput.accept = ".csv, .pdf, .txt, .doc";
20
- fileInput.click();
21
- fileInput.addEventListener("change", handleFileSelection);
22
- }
23
-
24
- function handleFileSelection(event) {
25
- // You can perform some checks on the files here if you want
26
- // Open the modal after file selection
27
- const uploadModal = new bootstrap.Modal(
28
- document.getElementById("uploadModal"),
29
- );
30
- uploadModal.show();
31
- }
32
-
33
- function submitPromptForm() {
34
- // Show the modal
35
- $("#responseModal").modal("show");
36
-
37
- // Submit the form after a short delay to allow the modal to open
38
- setTimeout(function () {
39
- document.getElementById("promptForm").submit();
40
- }, 5);
41
- }
42
-
43
- function submitForm(action) {
44
- var form = document.getElementById("uploadForm");
45
-
46
- var input = document.createElement("input");
47
- input.type = "hidden";
48
- input.name = "action";
49
- input.value = action;
50
-
51
- form.appendChild(input);
52
-
53
- // After the form is submitted, close the current modal and open the new one.
54
- $("#uploadModal").on("hidden.bs.modal", function () {
55
- $("#ingesting-modal").modal("show");
56
- });
57
-
58
- if (action == "add" || action == "reset") {
59
- $("#uploadModal").modal("hide");
60
- }
61
-
62
- form.submit();
63
- }
64
- </script>
65
- {% if show_response_modal %}
66
- <script>
67
- $(document).ready(function () {
68
- $("#response_modal").modal("show");
69
- });
70
- </script>
71
- {% endif %}
72
  <style>
73
-
74
- @import url('https://fonts.googleapis.com/css2?family=Play:wght@400;700&display=swap');
75
 
76
  body {
77
  background-image: linear-gradient(90deg, #09203f, #0057ff);
@@ -81,7 +33,7 @@
81
  align-items: center;
82
  }
83
 
84
- .container{
85
  padding: 15px;
86
  display: flex;
87
  flex-direction: column;
@@ -89,18 +41,17 @@
89
  align-items: center;
90
  max-width: 1000px;
91
  margin: 0 auto;
92
- }
93
 
94
- .titlegpt{
95
- font-size: 9vw;
96
- color: white;
97
- font-family: 'Play', sans-serif;
98
- }
99
 
100
  .search {
101
  width: 100%;
102
- box-shadow:
103
- inset 0 1px 1px rgba(0, 0, 0, 0.075),
104
  0 0 8px rgba(255, 0, 0, 0.6);
105
  background-color: #fff;
106
  padding: 4px;
@@ -230,8 +181,7 @@
230
 
231
  .form-control:focus {
232
  border-color: #bc13cf;
233
- box-shadow:
234
- inset 0 1px 1px rgba(0, 0, 0, 0.075),
235
  0 0 8px rgba(255, 0, 0, 0.6);
236
  }
237
 
@@ -283,7 +233,7 @@
283
  }
284
 
285
  .accordion-button:not(.collapsed) {
286
- color:#ff0059;
287
  background-color: #f5b3cb;
288
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.125);
289
  }
@@ -291,424 +241,6 @@
291
  <body>
292
  <div class="container">
293
  <div class="titlegpt">LocalGPT</div>
294
- <div class="search">
295
- <div class="row">
296
- <div class="col-md-12">
297
- <div class="search-2">
298
- <form
299
- id="promptForm"
300
- action="{{ url_for('home_page') }}"
301
- method="POST"
302
- >
303
- <button
304
- type="button"
305
- class="tutorial_button"
306
- data-bs-toggle="modal"
307
- data-bs-target="#tutorial_modal"
308
- >
309
- Tutorial
310
- </button>
311
- <i class="bx bxs-map"></i>
312
- <input
313
- type="text"
314
- name="user_prompt"
315
- id="searchInput"
316
- placeholder="Tell a summary of what you want to know?"
317
- />
318
- <button type="button" onclick="submitPromptForm()">
319
- Search
320
- </button>
321
- </form>
322
- <form
323
- id="uploadForm"
324
- action="{{ url_for('home_page') }}"
325
- method="POST"
326
- enctype="multipart/form-data"
327
- >
328
- <input
329
- type="file"
330
- name="documents"
331
- id="fileInput"
332
- style="display: none"
333
- multiple
334
- />
335
- <button
336
- type="button"
337
- class="upload_button"
338
- onclick="openFileSelection()"
339
- >
340
- Upload
341
- </button>
342
- </form>
343
- </div>
344
- </div>
345
- </div>
346
- </div>
347
- </div>
348
-
349
- <!-- For some reason the script needs to go here to make the the enter key also trigger the generating response modal -->
350
- <script>
351
- document
352
- .getElementById("searchInput")
353
- .addEventListener("keydown", function (event) {
354
- if (event.keyCode === 13) {
355
- event.preventDefault(); // Prevent form submission
356
- submitPromptForm(); // Call the function to show the modal
357
- }
358
- });
359
- </script>
360
-
361
- <!-- Chat Response Modal -->
362
- <div
363
- class="modal fade"
364
- id="response_modal"
365
- tabindex="-1"
366
- aria-labelledby="response_modal"
367
- aria-hidden="true"
368
- >
369
- <div class="modal-dialog modal-xl modal-dialog-centered">
370
- <div class="modal-content">
371
- <div class="modal-header text-center">
372
- <h5
373
- class="modal-title w-100"
374
- id="response_modal"
375
- style="color: #292b2c"
376
- >
377
- Response
378
- </h5>
379
- </div>
380
- <div class="modal-body text-center" style="color: #292b2c">
381
- <strong>Search</strong>
382
- <br />
383
- <p>{{response_dict['Prompt']}}</p>
384
-
385
- <strong>Answer</strong>
386
- <br />
387
- <p style="margin-left: 5%; margin-right: 5%">
388
- {{response_dict['Answer']}}
389
- </p>
390
-
391
- <strong>Sources</strong>
392
- <div
393
- class="accordion"
394
- id="accordionExample"
395
- style="margin-top: 10px"
396
- >
397
- {% for item in response_dict['Sources'] %}
398
- <div class="accordion-item">
399
- <h2
400
- class="accordion-header text-center"
401
- id="heading{{ loop.index0 }}"
402
- >
403
- <button
404
- class="accordion-button d-block text-center"
405
- type="button"
406
- data-bs-toggle="collapse"
407
- data-bs-target="#collapse{{ loop.index0 }}"
408
- aria-expanded="true"
409
- aria-controls="collapse{{ loop.index0 }}"
410
- >
411
- {{ item[0] }}
412
- <!-- Source -->
413
- </button>
414
- </h2>
415
- <div
416
- id="collapse{{ loop.index0 }}"
417
- class="accordion-collapse collapse {% if loop.first %}show{% endif %}"
418
- aria-labelledby="heading{{ loop.index0 }}"
419
- data-bs-parent="#accordionExample"
420
- >
421
- <div
422
- class="accordion-body"
423
- style="
424
- text-align: justify;
425
- margin-left: 5%;
426
- margin-right: 5%;
427
- "
428
- >
429
- {{ item[1] }}
430
- <!-- Content -->
431
- </div>
432
- </div>
433
- </div>
434
- {% endfor %}
435
- </div>
436
- </div>
437
- <div class="modal-footer">
438
- <button
439
- type="button"
440
- class="default_button"
441
- data-bs-dismiss="modal"
442
- >
443
- Close
444
- </button>
445
- </div>
446
- </div>
447
- </div>
448
- </div>
449
-
450
- <!-- Generating Response Modal -->
451
- <div
452
- class="modal fade"
453
- id="responseModal"
454
- tabindex="-1"
455
- aria-labelledby="responseModalLabel"
456
- aria-hidden="true"
457
- data-bs-backdrop="static"
458
- data-bs-keyboard="false"
459
- >
460
- <div class="modal-dialog modal-dialog-centered">
461
- <div class="modal-content">
462
- <div class="modal-header justify-content-center">
463
- <h5
464
- class="modal-title justify-content-center"
465
- id="responseModalLabel"
466
- >
467
- Generating Response
468
- </h5>
469
- </div>
470
- <div class="modal-body text-center">
471
- <p>Please wait...</p>
472
- </div>
473
- </div>
474
- </div>
475
- </div>
476
-
477
- <!-- Upload Confirmation Modal -->
478
- <div
479
- class="modal fade"
480
- id="uploadModal"
481
- tabindex="-1"
482
- aria-labelledby="uploadModalLabel"
483
- aria-hidden="true"
484
- >
485
- <div class="modal-dialog modal-dialog-centered">
486
- <div class="modal-content">
487
- <div class="modal-header justify-content-center">
488
- <h5
489
- class="modal-title justify-content-center"
490
- id="uploadModalLabel"
491
- >
492
- File Upload Confirmation
493
- </h5>
494
- </div>
495
- <div class="modal-body margin-left: 5%; text-align: left;">
496
- <ul>
497
- <li>
498
- Click
499
- <span style="background-color: #ff0059; color: white">Add</span> if
500
- you want to add the documents selected to your pre-existing
501
- knowledge base.
502
- </li>
503
- <br />
504
- <li>
505
- Click
506
- <span style="background-color: #ff0059; color: white">Reset</span>
507
- if you want to reset your knowledge base, and then use your new
508
- documents as your new knowledge base.
509
- </li>
510
- <br />
511
- <li>
512
- Click
513
- <span style="background-color: gray; color: white">Cancel</span>
514
- if you don't want to make any changes.
515
- </li>
516
- </ul>
517
- </div>
518
- <div class="modal-footer justify-content-center">
519
- <button
520
- type="submit"
521
- name="button_clicked"
522
- value="add_document"
523
- class="default_button"
524
- onclick="submitForm('add')"
525
- >
526
- Add
527
- </button>
528
- <button
529
- type="submit"
530
- name="button_clicked"
531
- value="reset_document"
532
- class="default_button"
533
- onclick="submitForm('reset')"
534
- >
535
- Reset
536
- </button>
537
- <button type="button" class="cancel_button" data-bs-dismiss="modal">
538
- Cancel
539
- </button>
540
- </div>
541
- </div>
542
- </div>
543
- </div>
544
-
545
- <!-- Ingesting Documents Modal -->
546
- <div
547
- class="modal fade"
548
- id="ingesting-modal"
549
- tabindex="-1"
550
- role="dialog"
551
- data-bs-backdrop="static"
552
- data-bs-keyboard="false"
553
- >
554
- <div class="modal-dialog modal-dialog-centered" role="document">
555
- <div class="modal-content">
556
- <div class="modal-header justify-content-center">
557
- <h5 class="modal-title">Ingesting Documents...</h5>
558
- </div>
559
- <div class="modal-body text-center">
560
- <p>Please wait while we ingest the documents.</p>
561
- </div>
562
- </div>
563
- </div>
564
- </div>
565
-
566
- <!-- Tutorial Modal -->
567
- <div
568
- class="modal fade"
569
- id="tutorial_modal"
570
- tabindex="-1"
571
- aria-labelledby="tutorial_modal"
572
- aria-hidden="true"
573
- >
574
- <div class="modal-dialog modal-xl modal-dialog-centered">
575
- <div class="modal-content">
576
- <div class="modal-header text-center">
577
- <h5
578
- class="modal-title w-100"
579
- id="tutorial_modal"
580
- style="color: #292b2c"
581
- >
582
- Tutorial
583
- </h5>
584
- </div>
585
- <div class="modal-body" style="color: #292b2c">
586
- <strong style="margin-left: 5%; text-align: left">About</strong>
587
- <br />
588
- <p style="text-align: justify; margin-left: 5%; margin-right: 5%">
589
- Introducing a cutting-edge application that empowers users to
590
- leverage the capabilities of a language model, even in the absence
591
- of an internet connection. This advanced tool serves as an
592
- indispensable resource for accessing information beyond the
593
- confines of traditional language model tools such as chatGPT.
594
- <br /><br />
595
- One of the key advantages of this application is the preservation
596
- of data control. This feature becomes particularly valuable when
597
- handling sensitive data that must remain within the confines of an
598
- organization or personal documents that warrant utmost
599
- confidentiality, eliminating the need to transmit information
600
- through third-party channels.
601
- <br /><br />
602
- Seamlessly integrating personal documents into the system is
603
- effortless, ensuring a smooth user experience. Whether in the form
604
- of text, PDF, CSV, or Excel files, users can conveniently provide
605
- the desired information for inquiry. The application swiftly
606
- processes these documents, effectively creating a comprehensive
607
- database for the model to leverage, enabling accurate and
608
- insightful responses.
609
- <br /><br />
610
- A notable benefit of this approach lies in its efficient resource
611
- utilization. Unlike the resource-intensive retraining processes
612
- employed by alternative methods, the ingestion of documents within
613
- this application demands significantly less compute power. This
614
- efficiency optimization allows for a streamlined user experience,
615
- saving both time and computational resources.
616
- <br /><br />
617
- Discover the unparalleled capabilities of this technical marvel,
618
- as it enables users to tap into the full potential of language
619
- models, all while operating offline. Experience a new era of
620
- information access, bolstering productivity and expanding
621
- possibilities. Embrace this powerful tool and unlock the true
622
- potential of your data today.
623
- </p>
624
- <strong style="margin-left: 5%; text-align: left"
625
- >Upload Documents</strong
626
- >
627
- <br />
628
- <p
629
- style="
630
- line-height: 1.75;
631
- margin-left: 5%;
632
- margin-right: 5%;
633
- text-align: left;
634
- "
635
- >
636
- 1. To upload documents for the app to ingest as its new knowledge
637
- base click the
638
- <span style="background-color: #ff0059; color: white">Upload</span>
639
- button.
640
- <br />
641
- 2. Select the documents you want to serve as your new knowledge
642
- base to converse with.
643
- <br />
644
- 3. Then you will be prompted with a confirmation to either
645
- <span style="background-color: #ff0059; color: white">Add</span> the
646
- documents to your knowledge base,
647
- <span style="background-color: #ff0059; color: white">Reset</span>
648
- your knowledge base with the documents you just selected, or
649
- <span style="background-color: gray; color: white">Cancel</span>
650
- the upload.
651
- <br />
652
- 4. There will be a short wait time as the documents get ingested
653
- into the vector database as your new knowledge base.
654
- </p>
655
- <a
656
- href="static/document_examples/constitution.pdf"
657
- style="margin-left: 5%"
658
- download
659
- >
660
- <button class="default_button" style="width: auto">
661
- Example Constitution
662
- </button>
663
- </a>
664
- <a href="static/document_examples/news_articles.zip" download>
665
- <button class="default_button" style="width: auto">
666
- Example News Articles
667
- </button>
668
- </a>
669
-
670
- <br />
671
- <br />
672
- <strong style="margin-left: 5%; text-align: left">Searching</strong>
673
- <p
674
- style="
675
- line-height: 1.75;
676
- margin-left: 5%;
677
- margin-right: 5%;
678
- text-align: left;
679
- "
680
- >
681
- 1. In order to ask a question, type a question into the search bar
682
- like:
683
- <br />
684
- 2.
685
- <span style="background-color: gray; color: white"
686
- >Give me a summary of the documents</span
687
- >
688
- <br />
689
- 3. Hit enter on your keyboard or click
690
- <span style="background-color: #ff0059; color: white">Search</span>
691
- <br />
692
- 4. Wait while the LLM model consumes the prompt and prepares the
693
- answer.
694
- <br />
695
- 5. Once done, it will print the answer and the 4 sources it used
696
- as context from your documents; you can then ask another question
697
- without re-running the script, just wait for the prompt again.
698
- </p>
699
- <br />
700
- </div>
701
- <div class="modal-footer justify-content-center">
702
- <button
703
- type="button"
704
- class="default_button"
705
- data-bs-dismiss="modal"
706
- >
707
- Close
708
- </button>
709
- </div>
710
- </div>
711
- </div>
712
  </div>
713
  </body>
714
  </html>
 
1
+ <!DOCTYPE html>
2
  <html lang="en">
3
  <head>
4
  <!-- Required meta tags -->
 
8
 
9
  <link rel="icon" type="image" href="static\social_icons\favicon.png" />
10
  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
11
+ <link
12
+ href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
13
+ rel="stylesheet"
14
+ integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
15
+ crossorigin="anonymous"
16
+ />
17
+ <script
18
+ src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
19
+ integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
20
+ crossorigin="anonymous"
21
+ ></script>
22
 
23
  <title>localGPT</title>
24
  </head>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  <style>
26
+ @import url("https://fonts.googleapis.com/css2?family=Play:wght@400;700&display=swap");
 
27
 
28
  body {
29
  background-image: linear-gradient(90deg, #09203f, #0057ff);
 
33
  align-items: center;
34
  }
35
 
36
+ .container {
37
  padding: 15px;
38
  display: flex;
39
  flex-direction: column;
 
41
  align-items: center;
42
  max-width: 1000px;
43
  margin: 0 auto;
44
+ }
45
 
46
+ .titlegpt {
47
+ font-size: 9vw;
48
+ color: white;
49
+ font-family: "Play", sans-serif;
50
+ }
51
 
52
  .search {
53
  width: 100%;
54
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075),
 
55
  0 0 8px rgba(255, 0, 0, 0.6);
56
  background-color: #fff;
57
  padding: 4px;
 
181
 
182
  .form-control:focus {
183
  border-color: #bc13cf;
184
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075),
 
185
  0 0 8px rgba(255, 0, 0, 0.6);
186
  }
187
 
 
233
  }
234
 
235
  .accordion-button:not(.collapsed) {
236
+ color: #ff0059;
237
  background-color: #f5b3cb;
238
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.125);
239
  }
 
241
  <body>
242
  <div class="container">
243
  <div class="titlegpt">LocalGPT</div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
244
  </div>
245
  </body>
246
  </html>