diff --git a/frontend/app/components/Chat/ChatInterface.tsx b/frontend/app/components/Chat/ChatInterface.tsx index 158bd6c08..c577c409d 100644 --- a/frontend/app/components/Chat/ChatInterface.tsx +++ b/frontend/app/components/Chat/ChatInterface.tsx @@ -341,10 +341,11 @@ const ChatInterfaceComponent: React.FC = ({ }); const data: QueryPayload = await response.json(); - if (data) { if (data.error !== "") { triggerNotification(data.error, true); + setIsFetching(false); + setFetchingStatus("DONE"); } setChunks(data.chunks); diff --git a/frontend/package-lock.json b/frontend/package-lock.json index c42f30800..d1556e428 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "verba", - "version": "1.0.0", + "version": "1.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "verba", - "version": "1.0.0", + "version": "1.0.2", "dependencies": { "@mdx-js/mdx": "^2.3.0", "@mdx-js/react": "^2.3.0", @@ -23,7 +23,6 @@ "react-colorful": "^5.6.1", "react-countup": "^6.4.2", "react-dom": "18.2.0", - "react-dropzone": "^14.2.3", "react-icons": "^4.11.0", "react-markdown": "^8.0.7", "react-spinners": "^0.13.8", @@ -38,7 +37,6 @@ "@tailwindcss/typography": "^0.5.12", "@types/react-syntax-highlighter": "^15.5.7", "@types/react-window": "^1.8.5", - "@welldone-software/why-did-you-render": "^7.0.1", "daisyui": "^4.10.1", "prettier": "^3.2.5" } @@ -763,6 +761,126 @@ "node": ">= 10" } }, + "node_modules/@next/swc-darwin-x64": { + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.0.tgz", + "integrity": "sha512-HFSDu7lb1U3RDxXNeKH3NGRR5KyTPBSUTuIOr9jXoAso7i76gNYvnTjbuzGVWt2X5izpH908gmOYWtI7un+JrA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-gnu": { + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.0.tgz", + "integrity": "sha512-iQsoWziO5ZMxDWZ4ZTCAc7hbJ1C9UDj/gATSqTaMjW2bJFwAsvf9UM79AKnljBl73uPZ+V0kH4rvnHTco4Ps2w==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-musl": { + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.0.tgz", + "integrity": "sha512-0JOk2uzLUt8fJK5LpsKKZa74zAch7bJjjgJzR9aOMs231AlE4gPYzsSm430ckZitjPGKeH5bgDZjqwqJQKIS2w==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-gnu": { + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.0.tgz", + "integrity": "sha512-uYHkuTzX0NM6biKNp7hdKTf+BF0iMV254SxO0B8PgrQkxUBKGmk5ysHKB+FYBfdf9xei/t8OIKlXJs9ckD943A==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-musl": { + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.0.tgz", + "integrity": "sha512-paN89nLs2dTBDtfXWty1/NVPit+q6ldwdktixYSVwiiAz647QDCd+EIYqoiS+/rPG3oXs/A7rWcJK9HVqfnMVg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-arm64-msvc": { + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.0.tgz", + "integrity": "sha512-j1oiidZisnymYjawFqEfeGNcE22ZQ7lGUaa4pGOCVWrWeIDkPSj8zYgS9TzMNlg17Q3wSWCQC/F5uJAhSh7qcA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-ia32-msvc": { + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.0.tgz", + "integrity": "sha512-6ff6F4xb+QGD1jhx/dOT9Ot7PQ/GAYekV9ykwEh2EFS/cLTyU4Y3cXkX5cNtNIhpctS5NvyjW9gIksRNErYE0A==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-x64-msvc": { + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.0.tgz", + "integrity": "sha512-09DbG5vXAxz0eTFSf1uebWD36GF3D5toynRkgo2AlSrxwGZkWtJ1RhmrczRYQ17eD5bdo4FZ0ibiffdq5kc4vg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, "node_modules/@next/third-parties": { "version": "14.2.3", "resolved": "https://registry.npmjs.org/@next/third-parties/-/third-parties-14.2.3.tgz", @@ -1118,18 +1236,6 @@ "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/@welldone-software/why-did-you-render": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/@welldone-software/why-did-you-render/-/why-did-you-render-7.0.1.tgz", - "integrity": "sha512-Qe/8Xxa2G+LMdI6VoazescPzjjkHYduCDa8aHOJR50e9Bgs8ihkfMBY+ev7B4oc3N59Zm547Sgjf8h5y0FOyoA==", - "dev": true, - "dependencies": { - "lodash": "^4" - }, - "peerDependencies": { - "react": "^16 || ^17 || ^18" - } - }, "node_modules/acorn": { "version": "8.10.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", @@ -1363,14 +1469,6 @@ "has-symbols": "^1.0.3" } }, - "node_modules/attr-accept": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/attr-accept/-/attr-accept-2.2.2.tgz", - "integrity": "sha512-7prDjvt9HmqiZ0cl5CRjtS84sEyhsHP2coDkaZKRKVfCDo9s7iw7ChVmar78Gu9pC4SoR/28wFu/G5JJhTnqEg==", - "engines": { - "node": ">=4" - } - }, "node_modules/autoprefixer": { "version": "10.4.15", "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.15.tgz", @@ -2581,17 +2679,6 @@ "node": "^10.12.0 || >=12.0.0" } }, - "node_modules/file-selector": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/file-selector/-/file-selector-0.6.0.tgz", - "integrity": "sha512-QlZ5yJC0VxHxQQsQhXvBaC7VRJ2uaxTf+Tfpu4Z/OcVQJVpZO+DGU0rkoVW5ce2SccxugvpBJoMvUs59iILYdw==", - "dependencies": { - "tslib": "^2.4.0" - }, - "engines": { - "node": ">= 12" - } - }, "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -3641,12 +3728,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true - }, "node_modules/lodash.castarray": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/lodash.castarray/-/lodash.castarray-4.4.0.tgz", @@ -5261,22 +5342,6 @@ "react": "^18.2.0" } }, - "node_modules/react-dropzone": { - "version": "14.2.3", - "resolved": "https://registry.npmjs.org/react-dropzone/-/react-dropzone-14.2.3.tgz", - "integrity": "sha512-O3om8I+PkFKbxCukfIR3QAGftYXDZfOE2N1mr/7qebQJHs7U+/RSL/9xomJNpRg9kM5h9soQSdf0Gc7OHF5Fug==", - "dependencies": { - "attr-accept": "^2.2.2", - "file-selector": "^0.6.0", - "prop-types": "^15.8.1" - }, - "engines": { - "node": ">= 10.13" - }, - "peerDependencies": { - "react": ">= 16.8 || 18.0.0" - } - }, "node_modules/react-icons": { "version": "4.11.0", "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.11.0.tgz", @@ -6514,126 +6579,6 @@ "type": "github", "url": "https://github.com/sponsors/wooorm" } - }, - "node_modules/@next/swc-darwin-x64": { - "version": "14.2.0", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.0.tgz", - "integrity": "sha512-HFSDu7lb1U3RDxXNeKH3NGRR5KyTPBSUTuIOr9jXoAso7i76gNYvnTjbuzGVWt2X5izpH908gmOYWtI7un+JrA==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-arm64-gnu": { - "version": "14.2.0", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.0.tgz", - "integrity": "sha512-iQsoWziO5ZMxDWZ4ZTCAc7hbJ1C9UDj/gATSqTaMjW2bJFwAsvf9UM79AKnljBl73uPZ+V0kH4rvnHTco4Ps2w==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-arm64-musl": { - "version": "14.2.0", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.0.tgz", - "integrity": "sha512-0JOk2uzLUt8fJK5LpsKKZa74zAch7bJjjgJzR9aOMs231AlE4gPYzsSm430ckZitjPGKeH5bgDZjqwqJQKIS2w==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-x64-gnu": { - "version": "14.2.0", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.0.tgz", - "integrity": "sha512-uYHkuTzX0NM6biKNp7hdKTf+BF0iMV254SxO0B8PgrQkxUBKGmk5ysHKB+FYBfdf9xei/t8OIKlXJs9ckD943A==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-x64-musl": { - "version": "14.2.0", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.0.tgz", - "integrity": "sha512-paN89nLs2dTBDtfXWty1/NVPit+q6ldwdktixYSVwiiAz647QDCd+EIYqoiS+/rPG3oXs/A7rWcJK9HVqfnMVg==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-win32-arm64-msvc": { - "version": "14.2.0", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.0.tgz", - "integrity": "sha512-j1oiidZisnymYjawFqEfeGNcE22ZQ7lGUaa4pGOCVWrWeIDkPSj8zYgS9TzMNlg17Q3wSWCQC/F5uJAhSh7qcA==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-win32-ia32-msvc": { - "version": "14.2.0", - "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.0.tgz", - "integrity": "sha512-6ff6F4xb+QGD1jhx/dOT9Ot7PQ/GAYekV9ykwEh2EFS/cLTyU4Y3cXkX5cNtNIhpctS5NvyjW9gIksRNErYE0A==", - "cpu": [ - "ia32" - ], - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-win32-x64-msvc": { - "version": "14.2.0", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.0.tgz", - "integrity": "sha512-09DbG5vXAxz0eTFSf1uebWD36GF3D5toynRkgo2AlSrxwGZkWtJ1RhmrczRYQ17eD5bdo4FZ0ibiffdq5kc4vg==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } } } } diff --git a/goldenverba/components/interfaces.py b/goldenverba/components/interfaces.py index e0bedb974..8fa9958c1 100644 --- a/goldenverba/components/interfaces.py +++ b/goldenverba/components/interfaces.py @@ -154,6 +154,15 @@ def embed( """ raise NotImplementedError("embed method must be implemented by a subclass.") + def check_embedder_pre_requirements(self) -> tuple[bool, list]: + """Check if the embedder has all the necessary pre-requirements. + @returns tuple[bool, list] - Bool whether the embedding was successful and list of missing requirements. + """ + missing_env_vars = [var for var in self.requires_env if not os.getenv(var)] + if missing_env_vars: + return False, [f"Environment:{var}" for var in missing_env_vars] + return True, [] + def import_data( self, documents: list[Document], client: Client, logging: list[dict] ) -> bool: diff --git a/goldenverba/components/managers.py b/goldenverba/components/managers.py index 0393fc7ba..fcd90605b 100644 --- a/goldenverba/components/managers.py +++ b/goldenverba/components/managers.py @@ -177,7 +177,8 @@ def __init__(self): "CohereEmbedder": CohereEmbedder(), "OllamaEmbedder": OllamaEmbedder(), } - self.selected_embedder: str = "ADAEmbedder" + self.set_embedder("ADAEmbedder") + def embed( self, diff --git a/goldenverba/components/retriever/WindowRetriever.py b/goldenverba/components/retriever/WindowRetriever.py index 6a26baf64..f2479db07 100644 --- a/goldenverba/components/retriever/WindowRetriever.py +++ b/goldenverba/components/retriever/WindowRetriever.py @@ -1,5 +1,6 @@ from weaviate import Client from weaviate.gql.get import HybridFusion +from wasabi import msg from goldenverba.components.chunk import Chunk from goldenverba.components.interfaces import Embedder, Retriever @@ -67,16 +68,29 @@ def retrieve( ], ).do() - for chunk in query_results["data"]["Get"][chunk_class]: - chunk_obj = Chunk( - chunk["text"], - chunk["doc_name"], - chunk["doc_type"], - chunk["doc_uuid"], - chunk["chunk_id"], - ) - chunk_obj.set_score(chunk["_additional"]["score"]) - chunks.append(chunk_obj) + if "errors" in query_results: + for error in query_results["errors"]: + msg.fail(f"The query retriever result in the window retriever contains an error: ({str(error)})") + + query_result_by_chunk_class = query_results["data"]["Get"].get(chunk_class) + + if query_result_by_chunk_class is not None: + try: + iter(query_result_by_chunk_class) + for chunk in query_result_by_chunk_class: + chunk_obj = Chunk( + chunk["text"], + chunk["doc_name"], + chunk["doc_type"], + chunk["doc_uuid"], + chunk["chunk_id"], + ) + chunk_obj.set_score(chunk["_additional"]["score"]) + chunks.append(chunk_obj) + except TypeError: + msg.fail(f"{chunk_class} is not iterable.") + else: + msg.info(f"No data found for {chunk_class}.") sorted_chunks = sorted(chunks, key=lambda x: x.score, reverse=True) diff --git a/goldenverba/server/api.py b/goldenverba/server/api.py index 0b90a77be..c0e087a31 100644 --- a/goldenverba/server/api.py +++ b/goldenverba/server/api.py @@ -326,6 +326,7 @@ async def query(payload: QueryPayload): except Exception as e: msg.warn(f"Query failed: {str(e)}") return JSONResponse( + status_code=500, content={ "chunks": [], "took": 0, diff --git a/goldenverba/server/frontend/out/404.html b/goldenverba/server/frontend/out/404.html index d8f17021a..659074cb0 100644 --- a/goldenverba/server/frontend/out/404.html +++ b/goldenverba/server/frontend/out/404.html @@ -1 +1,2 @@ -404: This page could not be found.Verba

404

This page could not be found.

\ No newline at end of file +404: This page could not be found.Verba

404

This page could not be found.

+ diff --git a/goldenverba/server/frontend/out/index.html b/goldenverba/server/frontend/out/index.html index 3c18ce7d6..05352b407 100644 --- a/goldenverba/server/frontend/out/index.html +++ b/goldenverba/server/frontend/out/index.html @@ -1 +1,2 @@ -Verba

Loading Verba

\ No newline at end of file +Verba

Loading Verba

+ diff --git a/goldenverba/verba_manager.py b/goldenverba/verba_manager.py index 965d536f7..0bcaa5df1 100644 --- a/goldenverba/verba_manager.py +++ b/goldenverba/verba_manager.py @@ -437,7 +437,7 @@ def get_schemas(self) -> dict: .get("count", 0) ) except Exception as e: - msg.error(f"Couldn't retrieve information about Collections, if you're using Weaviate Embedded, try to reset `~/.local/share/weaviate` ({str(e)})") + msg.fail(f"Couldn't retrieve information about Collections, if you're using Weaviate Embedded, try to reset `~/.local/share/weaviate` ({str(e)})") return schemas