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] = []