mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-13 05:25:07 +00:00
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 <chester.curme@gmail.com>
This commit is contained in:
committed by
GitHub
parent
e81b82ee0b
commit
31551dab40
@@ -99,6 +99,7 @@ class DuckDB(VectorStore):
|
|||||||
"Could not import duckdb package. "
|
"Could not import duckdb package. "
|
||||||
"Please install it with `pip install duckdb`."
|
"Please install it with `pip install duckdb`."
|
||||||
)
|
)
|
||||||
|
|
||||||
self.duckdb = duckdb
|
self.duckdb = duckdb
|
||||||
self._embedding = embedding
|
self._embedding = embedding
|
||||||
self._vector_key = vector_key
|
self._vector_key = vector_key
|
||||||
@@ -209,6 +210,11 @@ class DuckDB(VectorStore):
|
|||||||
Returns:
|
Returns:
|
||||||
A list of Documents most similar to the query.
|
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
|
embedding = self._embedding.embed_query(query) # type: ignore
|
||||||
list_cosine_similarity = self.duckdb.FunctionExpression(
|
list_cosine_similarity = self.duckdb.FunctionExpression(
|
||||||
"list_cosine_similarity",
|
"list_cosine_similarity",
|
||||||
|
Reference in New Issue
Block a user