From 31551dab4089e51f145373eaf5839887117cb21e Mon Sep 17 00:00:00 2001 From: Dhruvajyoti Sarma Date: Sun, 23 Mar 2025 00:57:21 +0530 Subject: [PATCH] feature: added warning when duckdb is used as a vectorstore without pandas (#30435) added warning when duckdb is used as a vectorstore without pandas being installed (currently used for similarity search result processing) Thank you for contributing to LangChain! - [ ] **PR title**: "community: added warning when duckdb is used as a vectorstore without pandas" - [ ] **PR message**: ***Delete this entire checklist*** and replace with - **Description:** displays a warning when using duckdb as a vector store without pandas being installed, as it is used by the `similarity_search` function - **Issue:** #29933 - **Dependencies:** None --------- Co-authored-by: Chester Curme --- libs/community/langchain_community/vectorstores/duckdb.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/community/langchain_community/vectorstores/duckdb.py b/libs/community/langchain_community/vectorstores/duckdb.py index ed10d3cb104..a11bf87071e 100644 --- a/libs/community/langchain_community/vectorstores/duckdb.py +++ b/libs/community/langchain_community/vectorstores/duckdb.py @@ -99,6 +99,7 @@ class DuckDB(VectorStore): "Could not import duckdb package. " "Please install it with `pip install duckdb`." ) + self.duckdb = duckdb self._embedding = embedding self._vector_key = vector_key @@ -209,6 +210,11 @@ class DuckDB(VectorStore): Returns: A list of Documents most similar to the query. """ + try: + import pandas as pandas + except ImportError: + warnings.warn("You may need to `pip install pandas` to use this method.") + embedding = self._embedding.embed_query(query) # type: ignore list_cosine_similarity = self.duckdb.FunctionExpression( "list_cosine_similarity",