From bcf5eaeeebe9206e6991d5d668db1f55bd1a4723 Mon Sep 17 00:00:00 2001 From: Ayush Chaurasia Date: Tue, 17 Sep 2024 23:36:57 +0530 Subject: [PATCH] update LanceDB integration (#16057) --- .../llama_index/vector_stores/lancedb/base.py | 16 +++++++++++----- .../pyproject.toml | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/llama-index-integrations/vector_stores/llama-index-vector-stores-lancedb/llama_index/vector_stores/lancedb/base.py b/llama-index-integrations/vector_stores/llama-index-vector-stores-lancedb/llama_index/vector_stores/lancedb/base.py index 37ab0ab617e40..f109e6abec616 100644 --- a/llama-index-integrations/vector_stores/llama-index-vector-stores-lancedb/llama_index/vector_stores/lancedb/base.py +++ b/llama-index-integrations/vector_stores/llama-index-vector-stores-lancedb/llama_index/vector_stores/lancedb/base.py @@ -482,14 +482,20 @@ def query( else: raise ValueError(f"Invalid query type: {query_type}") - lance_query = ( - self._table.search( + if query_type == "hybrid": + lance_query = ( + self._table.search( + vector_column_name=self.vector_column_name, query_type="hybrid" + ) + .vector(query.query_embedding) + .text(query.query_str) + ) + else: + lance_query = self._table.search( query=_query, vector_column_name=self.vector_column_name, ) - .limit(query.similarity_top_k * self.overfetch_factor) - .where(where) - ) + lance_query.limit(query.similarity_top_k * self.overfetch_factor).where(where) if query_type != "fts": lance_query.nprobes(self.nprobes) diff --git a/llama-index-integrations/vector_stores/llama-index-vector-stores-lancedb/pyproject.toml b/llama-index-integrations/vector_stores/llama-index-vector-stores-lancedb/pyproject.toml index 34b13ccc59935..97791acaed334 100644 --- a/llama-index-integrations/vector_stores/llama-index-vector-stores-lancedb/pyproject.toml +++ b/llama-index-integrations/vector_stores/llama-index-vector-stores-lancedb/pyproject.toml @@ -31,7 +31,7 @@ version = "0.2.3" [tool.poetry.dependencies] python = ">=3.9,<4.0" -lancedb = ">=0.8.0,<0.13.0" +lancedb = ">=0.13.0" tantivy = "*" llama-index-core = "^0.11.0"