diff --git a/application/app.py b/application/app.py index 08d4d316..2b99d612 100644 --- a/application/app.py +++ b/application/app.py @@ -19,13 +19,11 @@ if platform.system() == "Windows": # loading the .env file dotenv.load_dotenv() -# loading the index and the store and the prompt template -index = faiss.read_index("docs.index") + with open("combine_prompt.txt", "r") as f: template = f.read() -with open("faiss_store.pkl", "rb") as f: - store = pickle.load(f) + app = Flask(__name__) @@ -40,6 +38,20 @@ def api_answer(): data = request.get_json() question = data["question"] api_key = data["api_key"] + # check if the vectorstore is set + if "active_docs" in data: + vectorstore = "vectorstores/" + data["active_docs"] + + else: + vectorstore = "" + print(vectorstore) + + # loading the index and the store and the prompt template + index = faiss.read_index(f"{vectorstore}docs.index") + + + with open(f"{vectorstore}faiss_store.pkl", "rb") as f: + store = pickle.load(f) store.index = index # create a prompt template diff --git a/application/static/dist/css/output.css b/application/static/dist/css/output.css index 5fc831f4..9d1609a7 100644 --- a/application/static/dist/css/output.css +++ b/application/static/dist/css/output.css @@ -513,14 +513,6 @@ video { --tw-backdrop-sepia: ; } -.pointer-events-none { - pointer-events: none; -} - -.pointer-events-auto { - pointer-events: auto; -} - .static { position: static; } @@ -533,10 +525,6 @@ video { position: absolute; } -.relative { - position: relative; -} - .inset-0 { top: 0px; right: 0px; @@ -544,6 +532,10 @@ video { left: 0px; } +.bottom-0 { + bottom: 0px; +} + .top-0 { top: 0px; } @@ -552,18 +544,10 @@ video { left: 0px; } -.bottom-0 { - bottom: 0px; -} - .z-10 { z-index: 10; } -.ml-1 { - margin-left: 0.25rem; -} - .ml-2 { margin-left: 0.5rem; } @@ -588,8 +572,8 @@ video { margin-bottom: 0.75rem; } -.box-content { - box-sizing: content-box; +.block { + display: block; } .inline-block { @@ -604,18 +588,14 @@ video { display: none; } -.h-full { - height: 100%; -} - -.h-4 { - height: 1rem; -} - .h-5\/6 { height: 83.333333%; } +.h-full { + height: 100%; +} + .max-h-screen { max-height: 100vh; } @@ -628,36 +608,14 @@ video { width: 100%; } -.w-auto { - width: auto; -} - -.w-4 { - width: 1rem; -} - -.flex-shrink-0 { - flex-shrink: 0; -} - .transform { transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y)); } -.appearance-none { - -webkit-appearance: none; - -moz-appearance: none; - appearance: none; -} - .flex-col { flex-direction: column; } -.flex-wrap { - flex-wrap: wrap; -} - .items-center { align-items: center; } @@ -666,10 +624,6 @@ video { align-items: stretch; } -.justify-end { - justify-content: flex-end; -} - .justify-center { justify-content: center; } @@ -694,55 +648,16 @@ video { overflow-y: auto; } -.overflow-x-hidden { - overflow-x: hidden; +.rounded-lg { + border-radius: 0.5rem; } .rounded { border-radius: 0.25rem; } -.rounded-md { - border-radius: 0.375rem; -} - -.rounded-none { - border-radius: 0px; -} - -.rounded-lg { - border-radius: 0.5rem; -} - -.rounded-t-md { - border-top-left-radius: 0.375rem; - border-top-right-radius: 0.375rem; -} - -.rounded-b-md { - border-bottom-right-radius: 0.375rem; - border-bottom-left-radius: 0.375rem; -} - -.border-2 { - border-width: 2px; -} - -.border-b { - border-bottom-width: 1px; -} - -.border-t { - border-top-width: 1px; -} - -.border-none { - border-style: none; -} - -.border-gray-200 { - --tw-border-opacity: 1; - border-color: rgb(229 231 235 / var(--tw-border-opacity)); +.border { + border-width: 1px; } .border-gray-300 { @@ -750,21 +665,11 @@ video { border-color: rgb(209 213 219 / var(--tw-border-opacity)); } -.bg-blue-600 { - --tw-bg-opacity: 1; - background-color: rgb(37 99 235 / var(--tw-bg-opacity)); -} - .bg-white { --tw-bg-opacity: 1; background-color: rgb(255 255 255 / var(--tw-bg-opacity)); } -.bg-purple-600 { - --tw-bg-opacity: 1; - background-color: rgb(147 51 234 / var(--tw-bg-opacity)); -} - .bg-indigo-500 { --tw-bg-opacity: 1; background-color: rgb(99 102 241 / var(--tw-bg-opacity)); @@ -790,40 +695,17 @@ video { background-color: rgb(229 231 235 / var(--tw-bg-opacity)); } -.bg-gray-500 { +.bg-gray-50 { --tw-bg-opacity: 1; - background-color: rgb(107 114 128 / var(--tw-bg-opacity)); -} - -.bg-clip-padding { - background-clip: padding-box; -} - -.p-4 { - padding: 1rem; -} - -.p-1 { - padding: 0.25rem; + background-color: rgb(249 250 251 / var(--tw-bg-opacity)); } .p-2 { padding: 0.5rem; } -.px-6 { - padding-left: 1.5rem; - padding-right: 1.5rem; -} - -.py-2\.5 { - padding-top: 0.625rem; - padding-bottom: 0.625rem; -} - -.py-2 { - padding-top: 0.5rem; - padding-bottom: 0.5rem; +.p-2\.5 { + padding: 0.625rem; } .px-4 { @@ -836,9 +718,9 @@ video { padding-bottom: 0.75rem; } -.px-3 { - padding-left: 0.75rem; - padding-right: 0.75rem; +.py-2 { + padding-top: 0.5rem; + padding-bottom: 0.5rem; } .pt-4 { @@ -857,10 +739,6 @@ video { padding-bottom: 1rem; } -.pr-16 { - padding-right: 4rem; -} - .text-left { text-align: left; } @@ -873,20 +751,6 @@ video { text-align: right; } -.font-mono { - font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; -} - -.text-xs { - font-size: 0.75rem; - line-height: 1rem; -} - -.text-xl { - font-size: 1.25rem; - line-height: 1.75rem; -} - .text-lg { font-size: 1.125rem; line-height: 1.75rem; @@ -901,91 +765,36 @@ video { font-weight: 500; } -.uppercase { - text-transform: uppercase; -} - -.leading-tight { - line-height: 1.25; -} - -.leading-normal { - line-height: 1.5; -} - -.text-white { - --tw-text-opacity: 1; - color: rgb(255 255 255 / var(--tw-text-opacity)); -} - -.text-current { - color: currentColor; -} - -.text-gray-800 { - --tw-text-opacity: 1; - color: rgb(31 41 55 / var(--tw-text-opacity)); -} - -.text-black { - --tw-text-opacity: 1; - color: rgb(0 0 0 / var(--tw-text-opacity)); -} - .text-blue-500 { --tw-text-opacity: 1; color: rgb(59 130 246 / var(--tw-text-opacity)); } -.text-gray-700 { - --tw-text-opacity: 1; - color: rgb(55 65 81 / var(--tw-text-opacity)); -} - .text-yellow-500 { --tw-text-opacity: 1; color: rgb(234 179 8 / var(--tw-text-opacity)); } -.opacity-50 { - opacity: 0.5; +.text-white { + --tw-text-opacity: 1; + color: rgb(255 255 255 / var(--tw-text-opacity)); +} + +.text-gray-900 { + --tw-text-opacity: 1; + color: rgb(17 24 39 / var(--tw-text-opacity)); } .opacity-75 { opacity: 0.75; } -.shadow-md { - --tw-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1); - --tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color); - box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow); -} - -.shadow-lg { - --tw-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1); - --tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color); - box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow); -} - .shadow-xl { --tw-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1); --tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color); box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow); } -.outline-none { - outline: 2px solid transparent; - outline-offset: 2px; -} - -.transition { - transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter; - transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter; - transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-backdrop-filter; - transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); - transition-duration: 150ms; -} - .transition-opacity { transition-property: opacity; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); @@ -998,14 +807,6 @@ video { transition-duration: 150ms; } -.duration-150 { - transition-duration: 150ms; -} - -.ease-in-out { - transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); -} - @media screen and (max-width: 1024px) { .text-lg { font-size: 3.125rem; @@ -1046,26 +847,6 @@ video { background-color: rgb(29 78 216 / var(--tw-bg-opacity)); } -.hover\:bg-purple-700:hover { - --tw-bg-opacity: 1; - background-color: rgb(126 34 206 / var(--tw-bg-opacity)); -} - -.hover\:bg-gray-700:hover { - --tw-bg-opacity: 1; - background-color: rgb(55 65 81 / var(--tw-bg-opacity)); -} - -.hover\:bg-blue-800:hover { - --tw-bg-opacity: 1; - background-color: rgb(30 64 175 / var(--tw-bg-opacity)); -} - -.hover\:text-black:hover { - --tw-text-opacity: 1; - color: rgb(0 0 0 / var(--tw-text-opacity)); -} - .hover\:text-blue-800:hover { --tw-text-opacity: 1; color: rgb(30 64 175 / var(--tw-text-opacity)); @@ -1076,81 +857,51 @@ video { color: rgb(133 77 14 / var(--tw-text-opacity)); } -.hover\:no-underline:hover { - text-decoration-line: none; -} - -.hover\:opacity-75:hover { - opacity: 0.75; -} - -.hover\:shadow-lg:hover { - --tw-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1); - --tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color); - box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow); -} - -.focus\:border-indigo-700:focus { +.focus\:border-blue-500:focus { --tw-border-opacity: 1; - border-color: rgb(67 56 202 / var(--tw-border-opacity)); + border-color: rgb(59 130 246 / var(--tw-border-opacity)); } -.focus\:bg-blue-700:focus { - --tw-bg-opacity: 1; - background-color: rgb(29 78 216 / var(--tw-bg-opacity)); +.focus\:ring-blue-500:focus { + --tw-ring-opacity: 1; + --tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity)); } -.focus\:bg-purple-700:focus { - --tw-bg-opacity: 1; - background-color: rgb(126 34 206 / var(--tw-bg-opacity)); -} +@media (prefers-color-scheme: dark) { + .dark\:border-gray-600 { + --tw-border-opacity: 1; + border-color: rgb(75 85 99 / var(--tw-border-opacity)); + } -.focus\:bg-white:focus { - --tw-bg-opacity: 1; - background-color: rgb(255 255 255 / var(--tw-bg-opacity)); -} + .dark\:bg-gray-700 { + --tw-bg-opacity: 1; + background-color: rgb(55 65 81 / var(--tw-bg-opacity)); + } -.focus\:opacity-100:focus { - opacity: 1; -} + .dark\:text-white { + --tw-text-opacity: 1; + color: rgb(255 255 255 / var(--tw-text-opacity)); + } -.focus\:shadow-lg:focus { - --tw-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1); - --tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color); - box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow); -} + .dark\:placeholder-gray-400::-moz-placeholder { + --tw-placeholder-opacity: 1; + color: rgb(156 163 175 / var(--tw-placeholder-opacity)); + } -.focus\:shadow-none:focus { - --tw-shadow: 0 0 #0000; - --tw-shadow-colored: 0 0 #0000; - box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow); -} + .dark\:placeholder-gray-400::placeholder { + --tw-placeholder-opacity: 1; + color: rgb(156 163 175 / var(--tw-placeholder-opacity)); + } -.focus\:outline-none:focus { - outline: 2px solid transparent; - outline-offset: 2px; -} + .dark\:focus\:border-blue-500:focus { + --tw-border-opacity: 1; + border-color: rgb(59 130 246 / var(--tw-border-opacity)); + } -.focus\:ring-0:focus { - --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color); - --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color); - box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000); -} - -.active\:bg-blue-800:active { - --tw-bg-opacity: 1; - background-color: rgb(30 64 175 / var(--tw-bg-opacity)); -} - -.active\:bg-purple-800:active { - --tw-bg-opacity: 1; - background-color: rgb(107 33 168 / var(--tw-bg-opacity)); -} - -.active\:shadow-lg:active { - --tw-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1); - --tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color); - box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow); + .dark\:focus\:ring-blue-500:focus { + --tw-ring-opacity: 1; + --tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity)); + } } @media (min-width: 640px) { diff --git a/application/static/src/chat.js b/application/static/src/chat.js index 9a830f23..862aba3e 100644 --- a/application/static/src/chat.js +++ b/application/static/src/chat.js @@ -20,7 +20,9 @@ if (el) { 'Content-Type': 'application/json', }, - body: JSON.stringify({question: message, api_key: localStorage.getItem('apiKey')}), + body: JSON.stringify({question: message, + api_key: localStorage.getItem('apiKey'), + active_docs: localStorage.getItem('activeDocs'),}), }) .then(response => response.json()) .then(data => { diff --git a/application/static/src/choiceChange.js b/application/static/src/choiceChange.js new file mode 100644 index 00000000..24887723 --- /dev/null +++ b/application/static/src/choiceChange.js @@ -0,0 +1,3 @@ + document.getElementById("select-docs").addEventListener("change", function() { + localStorage.setItem('activeDocs', this.value) + }); \ No newline at end of file diff --git a/application/templates/index.html b/application/templates/index.html index 80688a8f..50becfca 100644 --- a/application/templates/index.html +++ b/application/templates/index.html @@ -60,7 +60,14 @@ This will return a new DataFrame with all the columns from both tables, and only

The source code is available on Github


Currently It uses python pandas documentation, so it will respond to information relevant to pandas. If you want to train it on different documentation - please follow this guide


-

If you want to launch it on your own server - follow this guide

+

If you want to launch it on your own server - follow this guide


+ + @@ -99,5 +106,7 @@ This will return a new DataFrame with all the columns from both tables, and only + + diff --git a/application/vectorstores/python/pandas/docs.index b/application/vectorstores/python/pandas/docs.index new file mode 100644 index 00000000..b5e33008 Binary files /dev/null and b/application/vectorstores/python/pandas/docs.index differ diff --git a/application/vectorstores/python/pandas/faiss_store.pkl b/application/vectorstores/python/pandas/faiss_store.pkl new file mode 100644 index 00000000..bef85b3e Binary files /dev/null and b/application/vectorstores/python/pandas/faiss_store.pkl differ diff --git a/application/vectorstores/python/scikit-learn/docs.index b/application/vectorstores/python/scikit-learn/docs.index new file mode 100644 index 00000000..7461d041 Binary files /dev/null and b/application/vectorstores/python/scikit-learn/docs.index differ diff --git a/application/vectorstores/python/scikit-learn/faiss_store.pkl b/application/vectorstores/python/scikit-learn/faiss_store.pkl new file mode 100644 index 00000000..c2b51849 Binary files /dev/null and b/application/vectorstores/python/scikit-learn/faiss_store.pkl differ