From 6acd7f3fae39c327b0b06b2d9d26654d49e62844 Mon Sep 17 00:00:00 2001 From: akashmangoai Date: Thu, 31 Oct 2024 14:59:27 +0530 Subject: [PATCH] fix --- .../adalflow/components/retriever/lancedb_retriver.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/adalflow/adalflow/components/retriever/lancedb_retriver.py b/adalflow/adalflow/components/retriever/lancedb_retriver.py index 7cda1abc..68314411 100644 --- a/adalflow/adalflow/components/retriever/lancedb_retriver.py +++ b/adalflow/adalflow/components/retriever/lancedb_retriver.py @@ -82,7 +82,13 @@ def retrieve(self, query: Union[str, List[str]], top_k: Optional[int] = None) -> if isinstance(query, str): query = [query] - # Embed the query text(s) with Embedder + if not query or (isinstance(query, str) and query.strip() == ""): + raise ValueError("Query cannot be empty.") + + # Check if table (index) exists before performing search + if not self.table: + raise ValueError("The index has not been initialized or the table is missing.") + query_embeddings = self.embedder(input=query).data output: List[RetrieverOutput] = []