langchain_graph_retriever.adapters¶
astra ¶
Provides an adapter for AstraDB vector store integration.
AstraAdapter ¶
Bases: Adapter
Adapter for the AstraDB vector store.
This class integrates the LangChain AstraDB vector store with the graph retriever system, providing functionality for similarity search and document retrieval.
PARAMETER | DESCRIPTION |
---|---|
vector_store
|
The AstraDB vector store instance.
TYPE:
|
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/astra.py
aadjacent
async
¶
aadjacent(
edges: set[Edge],
query_embedding: list[float],
k: int,
filter: dict[str, Any] | None,
**kwargs: Any,
) -> Iterable[Content]
Asynchronously return the content items with at least one matching edge.
PARAMETER | DESCRIPTION |
---|---|
edges
|
The edges to look for. |
query_embedding
|
The query embedding used for selecting the most relevant content. |
k
|
The number of relevant content items to select for the edges.
TYPE:
|
filter
|
Optional metadata to filter the results. |
kwargs
|
Keyword arguments to pass to the similarity search.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Content]
|
Iterable of adjacent content items. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If unsupported edge types are encountered. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/astra.py
adjacent ¶
adjacent(
edges: set[Edge],
query_embedding: list[float],
k: int,
filter: dict[str, Any] | None,
**kwargs: Any,
) -> Iterable[Content]
Return the content items with at least one matching incoming edge.
PARAMETER | DESCRIPTION |
---|---|
edges
|
The edges to look for. |
query_embedding
|
The query embedding used for selecting the most relevant content. |
k
|
The number of relevant content items to select.
TYPE:
|
filter
|
Optional metadata to filter the results. |
kwargs
|
Keyword arguments to pass to the similarity search.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Content]
|
Iterable of adjacent content items. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If unsupported edge types are encountered. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/astra.py
aget
async
¶
Asynchronously get content items by ID.
Fewer content items may be returned than requested if some IDs are not found or if there are duplicated IDs. This method should NOT raise exceptions if no content items are found for some IDs.
Users should not assume that the order of the returned content items matches the order of the input IDs. Instead, users should rely on the ID field of the returned content items.
PARAMETER | DESCRIPTION |
---|---|
ids
|
List of IDs to get. |
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments. These are up to the implementation.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of content items that were found. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/astra.py
asearch
async
¶
asearch(
embedding: list[float],
k: int = 4,
filter: dict[str, str] | None = None,
**kwargs: Any,
) -> list[Content]
Asynchronously return content items most similar to the query vector.
PARAMETER | DESCRIPTION |
---|---|
embedding
|
The query embedding used for selecting the most relevant content. |
k
|
Number of content items to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of content items most similar to the query vector. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/astra.py
asearch_with_embedding
async
¶
asearch_with_embedding(
query: str,
k: int = 4,
filter: dict[str, str] | None = None,
**kwargs: Any,
) -> tuple[list[float], list[Content]]
Asynchronously return content items most similar to the query.
Also returns the embedded query vector.
PARAMETER | DESCRIPTION |
---|---|
query
|
Input text.
TYPE:
|
k
|
Number of content items to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
query_embedding
|
The query embedding used for selecting the most relevant content. |
contents
|
List of up to |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/astra.py
get ¶
Get content items by ID.
Fewer content items may be returned than requested if some IDs are not found or if there are duplicated IDs. This method should NOT raise exceptions if no content items are found for some IDs.
Users should not assume that the order of the returned content items matches the order of the input IDs. Instead, users should rely on the ID field of the returned content items.
PARAMETER | DESCRIPTION |
---|---|
ids
|
List of IDs to get. |
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments. These are up to the implementation.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of content items that were found. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/astra.py
search ¶
search(
embedding: list[float],
k: int = 4,
filter: dict[str, str] | None = None,
**kwargs: Any,
) -> list[Content]
Return content items most similar to the query vector.
PARAMETER | DESCRIPTION |
---|---|
embedding
|
The query embedding used for selecting the most relevant content. |
k
|
Number of content items to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of content items most similar to the query vector. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/astra.py
search_with_embedding ¶
search_with_embedding(
query: str,
k: int = 4,
filter: dict[str, str] | None = None,
**kwargs: Any,
) -> tuple[list[float], list[Content]]
Return content items most similar to the query.
Also returns the embedded query vector.
PARAMETER | DESCRIPTION |
---|---|
query
|
Input text.
TYPE:
|
k
|
Number of content items to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
query_embedding
|
The query embedding used for selecting the most relevant content. |
contents
|
List of up to |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/astra.py
cassandra ¶
Provides an adapter for Cassandra vector store integration.
CassandraAdapter ¶
CassandraAdapter(
vector_store: StoreT,
shredder: ShreddingTransformer | None = None,
nested_metadata_fields: set[str] = set(),
)
Bases: ShreddedLangchainAdapter[Cassandra]
Adapter for the Apache Cassandra vector store.
This class integrates the LangChain Cassandra vector store with the graph retriever system, providing functionality for similarity search and document retrieval.
PARAMETER | DESCRIPTION |
---|---|
vector_store
|
The Cassandra vector store instance.
TYPE:
|
shredder
|
An instance of the ShreddingTransformer used for doc insertion. If not passed then a default instance of ShreddingTransformer is used.
TYPE:
|
Initialize the base adapter.
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
aadjacent
async
¶
aadjacent(
edges: set[Edge],
query_embedding: list[float],
k: int,
filter: dict[str, Any] | None,
**kwargs: Any,
) -> Iterable[Content]
Asynchronously return the content items with at least one matching edge.
PARAMETER | DESCRIPTION |
---|---|
edges
|
The edges to look for. |
query_embedding
|
The query embedding used for selecting the most relevant content. |
k
|
The number of relevant content items to select for the edges.
TYPE:
|
filter
|
Optional metadata to filter the results. |
kwargs
|
Keyword arguments to pass to the similarity search.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Content]
|
Iterable of adjacent content items. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If unsupported edge types are encountered. |
Source code in packages/graph-retriever/src/graph_retriever/adapters/base.py
adjacent ¶
adjacent(
edges: set[Edge],
query_embedding: list[float],
k: int,
filter: dict[str, Any] | None,
**kwargs: Any,
) -> Iterable[Content]
Return the content items with at least one matching incoming edge.
PARAMETER | DESCRIPTION |
---|---|
edges
|
The edges to look for. |
query_embedding
|
The query embedding used for selecting the most relevant content. |
k
|
The number of relevant content items to select.
TYPE:
|
filter
|
Optional metadata to filter the results. |
kwargs
|
Keyword arguments to pass to the similarity search.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Content]
|
Iterable of adjacent content items. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If unsupported edge types are encountered. |
Source code in packages/graph-retriever/src/graph_retriever/adapters/base.py
aget
async
¶
Asynchronously get content items by ID.
Fewer content items may be returned than requested if some IDs are not found or if there are duplicated IDs. This method should NOT raise exceptions if no content items are found for some IDs.
Users should not assume that the order of the returned content items matches the order of the input IDs. Instead, users should rely on the ID field of the returned content items.
PARAMETER | DESCRIPTION |
---|---|
ids
|
List of IDs to get. |
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments. These are up to the implementation.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of content items that were found. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
asearch
async
¶
asearch(
embedding: list[float],
k: int = 4,
filter: dict[str, str] | None = None,
**kwargs: Any,
) -> list[Content]
Asynchronously return content items most similar to the query vector.
PARAMETER | DESCRIPTION |
---|---|
embedding
|
The query embedding used for selecting the most relevant content. |
k
|
Number of content items to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of content items most similar to the query vector. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
asearch_with_embedding
async
¶
asearch_with_embedding(
query: str,
k: int = 4,
filter: dict[str, Any] | None = None,
**kwargs: Any,
) -> tuple[list[float], list[Content]]
Asynchronously return content items most similar to the query.
Also returns the embedded query vector.
PARAMETER | DESCRIPTION |
---|---|
query
|
Input text.
TYPE:
|
k
|
Number of content items to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
query_embedding
|
The query embedding used for selecting the most relevant content. |
contents
|
List of up to |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
format_documents_hook ¶
Format the documents as content after executing the query.
PARAMETER | DESCRIPTION |
---|---|
docs
|
The documents returned from the vector store
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
The formatted content. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
get ¶
Get content items by ID.
Fewer content items may be returned than requested if some IDs are not found or if there are duplicated IDs. This method should NOT raise exceptions if no content items are found for some IDs.
Users should not assume that the order of the returned content items matches the order of the input IDs. Instead, users should rely on the ID field of the returned content items.
PARAMETER | DESCRIPTION |
---|---|
ids
|
List of IDs to get. |
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments. These are up to the implementation.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of content items that were found. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
search ¶
search(
embedding: list[float],
k: int = 4,
filter: dict[str, str] | None = None,
**kwargs: Any,
) -> list[Content]
Return contents most similar to the query vector.
PARAMETER | DESCRIPTION |
---|---|
embedding
|
Embedding to look up documents similar to. |
k
|
Number of Documents to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of Contents most similar to the query vector. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
search_with_embedding ¶
search_with_embedding(
query: str,
k: int = 4,
filter: dict[str, Any] | None = None,
**kwargs: Any,
) -> tuple[list[float], list[Content]]
Return content items most similar to the query.
Also returns the embedded query vector.
PARAMETER | DESCRIPTION |
---|---|
query
|
Input text.
TYPE:
|
k
|
Number of content items to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
query_embedding
|
The query embedding used for selecting the most relevant content. |
contents
|
List of up to |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
update_filter_hook ¶
Update the metadata filter before executing the query.
PARAMETER | DESCRIPTION |
---|---|
filter
|
Filter on the metadata to update. |
RETURNS | DESCRIPTION |
---|---|
dict[str, Any] | None
|
The updated filter on the metadata to apply. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
chroma ¶
Provides an adapter for Chroma vector store integration.
ChromaAdapter ¶
ChromaAdapter(
vector_store: StoreT,
shredder: ShreddingTransformer | None = None,
nested_metadata_fields: set[str] = set(),
)
Bases: ShreddedLangchainAdapter[Chroma]
Adapter for Chroma vector store.
This adapter integrates the LangChain Chroma vector store with the graph retriever system, allowing for similarity search and document retrieval.
PARAMETER | DESCRIPTION |
---|---|
vector_store
|
The Chroma vector store instance.
TYPE:
|
shredder
|
An instance of the ShreddingTransformer used for doc insertion. If not passed then a default instance of ShreddingTransformer is used.
TYPE:
|
Initialize the base adapter.
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
aadjacent
async
¶
aadjacent(
edges: set[Edge],
query_embedding: list[float],
k: int,
filter: dict[str, Any] | None,
**kwargs: Any,
) -> Iterable[Content]
Asynchronously return the content items with at least one matching edge.
PARAMETER | DESCRIPTION |
---|---|
edges
|
The edges to look for. |
query_embedding
|
The query embedding used for selecting the most relevant content. |
k
|
The number of relevant content items to select for the edges.
TYPE:
|
filter
|
Optional metadata to filter the results. |
kwargs
|
Keyword arguments to pass to the similarity search.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Content]
|
Iterable of adjacent content items. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If unsupported edge types are encountered. |
Source code in packages/graph-retriever/src/graph_retriever/adapters/base.py
adjacent ¶
adjacent(
edges: set[Edge],
query_embedding: list[float],
k: int,
filter: dict[str, Any] | None,
**kwargs: Any,
) -> Iterable[Content]
Return the content items with at least one matching incoming edge.
PARAMETER | DESCRIPTION |
---|---|
edges
|
The edges to look for. |
query_embedding
|
The query embedding used for selecting the most relevant content. |
k
|
The number of relevant content items to select.
TYPE:
|
filter
|
Optional metadata to filter the results. |
kwargs
|
Keyword arguments to pass to the similarity search.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Content]
|
Iterable of adjacent content items. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If unsupported edge types are encountered. |
Source code in packages/graph-retriever/src/graph_retriever/adapters/base.py
aget
async
¶
Asynchronously get content items by ID.
Fewer content items may be returned than requested if some IDs are not found or if there are duplicated IDs. This method should NOT raise exceptions if no content items are found for some IDs.
Users should not assume that the order of the returned content items matches the order of the input IDs. Instead, users should rely on the ID field of the returned content items.
PARAMETER | DESCRIPTION |
---|---|
ids
|
List of IDs to get. |
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments. These are up to the implementation.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of content items that were found. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
asearch
async
¶
asearch(
embedding: list[float],
k: int = 4,
filter: dict[str, str] | None = None,
**kwargs: Any,
) -> list[Content]
Asynchronously return content items most similar to the query vector.
PARAMETER | DESCRIPTION |
---|---|
embedding
|
The query embedding used for selecting the most relevant content. |
k
|
Number of content items to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of content items most similar to the query vector. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
asearch_with_embedding
async
¶
asearch_with_embedding(
query: str,
k: int = 4,
filter: dict[str, Any] | None = None,
**kwargs: Any,
) -> tuple[list[float], list[Content]]
Asynchronously return content items most similar to the query.
Also returns the embedded query vector.
PARAMETER | DESCRIPTION |
---|---|
query
|
Input text.
TYPE:
|
k
|
Number of content items to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
query_embedding
|
The query embedding used for selecting the most relevant content. |
contents
|
List of up to |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
format_documents_hook ¶
Format the documents as content after executing the query.
PARAMETER | DESCRIPTION |
---|---|
docs
|
The documents returned from the vector store
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
The formatted content. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
get ¶
Get content items by ID.
Fewer content items may be returned than requested if some IDs are not found or if there are duplicated IDs. This method should NOT raise exceptions if no content items are found for some IDs.
Users should not assume that the order of the returned content items matches the order of the input IDs. Instead, users should rely on the ID field of the returned content items.
PARAMETER | DESCRIPTION |
---|---|
ids
|
List of IDs to get. |
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments. These are up to the implementation.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of content items that were found. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
search ¶
search(
embedding: list[float],
k: int = 4,
filter: dict[str, str] | None = None,
**kwargs: Any,
) -> list[Content]
Return contents most similar to the query vector.
PARAMETER | DESCRIPTION |
---|---|
embedding
|
Embedding to look up documents similar to. |
k
|
Number of Documents to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of Contents most similar to the query vector. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
search_with_embedding ¶
search_with_embedding(
query: str,
k: int = 4,
filter: dict[str, Any] | None = None,
**kwargs: Any,
) -> tuple[list[float], list[Content]]
Return content items most similar to the query.
Also returns the embedded query vector.
PARAMETER | DESCRIPTION |
---|---|
query
|
Input text.
TYPE:
|
k
|
Number of content items to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
query_embedding
|
The query embedding used for selecting the most relevant content. |
contents
|
List of up to |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
update_filter_hook ¶
Update the metadata filter before executing the query.
PARAMETER | DESCRIPTION |
---|---|
filter
|
Filter on the metadata to update. |
RETURNS | DESCRIPTION |
---|---|
dict[str, Any] | None
|
The updated filter on the metadata to apply. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/chroma.py
in_memory ¶
Provides an adapter for the InMemoryVectorStore integration.
InMemoryAdapter ¶
Bases: LangchainAdapter[InMemoryVectorStore]
Adapter for InMemoryVectorStore vector store.
This adapter integrates the LangChain In-Memory vector store with the graph retriever system, enabling similarity search and document retrieval.
PARAMETER | DESCRIPTION |
---|---|
vector_store
|
The in-memory vector store instance.
TYPE:
|
Initialize the base adapter.
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
aadjacent
async
¶
aadjacent(
edges: set[Edge],
query_embedding: list[float],
k: int,
filter: dict[str, Any] | None,
**kwargs: Any,
) -> Iterable[Content]
Asynchronously return the content items with at least one matching edge.
PARAMETER | DESCRIPTION |
---|---|
edges
|
The edges to look for. |
query_embedding
|
The query embedding used for selecting the most relevant content. |
k
|
The number of relevant content items to select for the edges.
TYPE:
|
filter
|
Optional metadata to filter the results. |
kwargs
|
Keyword arguments to pass to the similarity search.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Content]
|
Iterable of adjacent content items. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If unsupported edge types are encountered. |
Source code in packages/graph-retriever/src/graph_retriever/adapters/base.py
adjacent ¶
adjacent(
edges: set[Edge],
query_embedding: list[float],
k: int,
filter: dict[str, Any] | None,
**kwargs: Any,
) -> Iterable[Content]
Return the content items with at least one matching incoming edge.
PARAMETER | DESCRIPTION |
---|---|
edges
|
The edges to look for. |
query_embedding
|
The query embedding used for selecting the most relevant content. |
k
|
The number of relevant content items to select.
TYPE:
|
filter
|
Optional metadata to filter the results. |
kwargs
|
Keyword arguments to pass to the similarity search.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Content]
|
Iterable of adjacent content items. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If unsupported edge types are encountered. |
Source code in packages/graph-retriever/src/graph_retriever/adapters/base.py
aget
async
¶
Asynchronously get content items by ID.
Fewer content items may be returned than requested if some IDs are not found or if there are duplicated IDs. This method should NOT raise exceptions if no content items are found for some IDs.
Users should not assume that the order of the returned content items matches the order of the input IDs. Instead, users should rely on the ID field of the returned content items.
PARAMETER | DESCRIPTION |
---|---|
ids
|
List of IDs to get. |
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments. These are up to the implementation.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of content items that were found. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
asearch
async
¶
asearch(
embedding: list[float],
k: int = 4,
filter: dict[str, str] | None = None,
**kwargs: Any,
) -> list[Content]
Asynchronously return content items most similar to the query vector.
PARAMETER | DESCRIPTION |
---|---|
embedding
|
The query embedding used for selecting the most relevant content. |
k
|
Number of content items to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of content items most similar to the query vector. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
asearch_with_embedding
async
¶
asearch_with_embedding(
query: str,
k: int = 4,
filter: dict[str, Any] | None = None,
**kwargs: Any,
) -> tuple[list[float], list[Content]]
Asynchronously return content items most similar to the query.
Also returns the embedded query vector.
PARAMETER | DESCRIPTION |
---|---|
query
|
Input text.
TYPE:
|
k
|
Number of content items to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
query_embedding
|
The query embedding used for selecting the most relevant content. |
contents
|
List of up to |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
format_documents_hook ¶
Format the documents as content after executing the query.
PARAMETER | DESCRIPTION |
---|---|
docs
|
The documents returned from the vector store
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
The formatted content. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
get ¶
Get content items by ID.
Fewer content items may be returned than requested if some IDs are not found or if there are duplicated IDs. This method should NOT raise exceptions if no content items are found for some IDs.
Users should not assume that the order of the returned content items matches the order of the input IDs. Instead, users should rely on the ID field of the returned content items.
PARAMETER | DESCRIPTION |
---|---|
ids
|
List of IDs to get. |
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments. These are up to the implementation.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of content items that were found. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
search ¶
search(
embedding: list[float],
k: int = 4,
filter: dict[str, str] | None = None,
**kwargs: Any,
) -> list[Content]
Return contents most similar to the query vector.
PARAMETER | DESCRIPTION |
---|---|
embedding
|
Embedding to look up documents similar to. |
k
|
Number of Documents to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of Contents most similar to the query vector. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
search_with_embedding ¶
search_with_embedding(
query: str,
k: int = 4,
filter: dict[str, Any] | None = None,
**kwargs: Any,
) -> tuple[list[float], list[Content]]
Return content items most similar to the query.
Also returns the embedded query vector.
PARAMETER | DESCRIPTION |
---|---|
query
|
Input text.
TYPE:
|
k
|
Number of content items to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
query_embedding
|
The query embedding used for selecting the most relevant content. |
contents
|
List of up to |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
update_filter_hook ¶
Update the metadata filter before executing the query.
PARAMETER | DESCRIPTION |
---|---|
filter
|
Filter on the metadata to update. |
RETURNS | DESCRIPTION |
---|---|
dict[str, Any] | None
|
The updated filter on the metadata to apply. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
inference ¶
Infers the appropriate adapter for a given vector store.
infer_adapter ¶
infer_adapter(store: Adapter | VectorStore) -> Adapter
Dynamically infer the adapter for a given vector store.
This function identifies the correct adapter based on the vector store type and instantiates it with the provided arguments.
PARAMETER | DESCRIPTION |
---|---|
store
|
The vector store instance.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Adapter
|
The initialized adapter for the given vector store. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/inference.py
langchain ¶
Defines the base class for vector store adapters.
LangchainAdapter ¶
Bases: Generic[StoreT]
, Adapter
Base adapter for integrating vector stores with the graph retriever system.
This class provides a foundation for custom adapters, enabling consistent interaction with various vector store implementations.
PARAMETER | DESCRIPTION |
---|---|
vector_store
|
The vector store instance.
TYPE:
|
Initialize the base adapter.
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
aadjacent
async
¶
aadjacent(
edges: set[Edge],
query_embedding: list[float],
k: int,
filter: dict[str, Any] | None,
**kwargs: Any,
) -> Iterable[Content]
Asynchronously return the content items with at least one matching edge.
PARAMETER | DESCRIPTION |
---|---|
edges
|
The edges to look for. |
query_embedding
|
The query embedding used for selecting the most relevant content. |
k
|
The number of relevant content items to select for the edges.
TYPE:
|
filter
|
Optional metadata to filter the results. |
kwargs
|
Keyword arguments to pass to the similarity search.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Content]
|
Iterable of adjacent content items. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If unsupported edge types are encountered. |
Source code in packages/graph-retriever/src/graph_retriever/adapters/base.py
adjacent ¶
adjacent(
edges: set[Edge],
query_embedding: list[float],
k: int,
filter: dict[str, Any] | None,
**kwargs: Any,
) -> Iterable[Content]
Return the content items with at least one matching incoming edge.
PARAMETER | DESCRIPTION |
---|---|
edges
|
The edges to look for. |
query_embedding
|
The query embedding used for selecting the most relevant content. |
k
|
The number of relevant content items to select.
TYPE:
|
filter
|
Optional metadata to filter the results. |
kwargs
|
Keyword arguments to pass to the similarity search.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Content]
|
Iterable of adjacent content items. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If unsupported edge types are encountered. |
Source code in packages/graph-retriever/src/graph_retriever/adapters/base.py
aget
async
¶
Asynchronously get content items by ID.
Fewer content items may be returned than requested if some IDs are not found or if there are duplicated IDs. This method should NOT raise exceptions if no content items are found for some IDs.
Users should not assume that the order of the returned content items matches the order of the input IDs. Instead, users should rely on the ID field of the returned content items.
PARAMETER | DESCRIPTION |
---|---|
ids
|
List of IDs to get. |
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments. These are up to the implementation.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of content items that were found. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
asearch
async
¶
asearch(
embedding: list[float],
k: int = 4,
filter: dict[str, str] | None = None,
**kwargs: Any,
) -> list[Content]
Asynchronously return content items most similar to the query vector.
PARAMETER | DESCRIPTION |
---|---|
embedding
|
The query embedding used for selecting the most relevant content. |
k
|
Number of content items to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of content items most similar to the query vector. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
asearch_with_embedding
async
¶
asearch_with_embedding(
query: str,
k: int = 4,
filter: dict[str, Any] | None = None,
**kwargs: Any,
) -> tuple[list[float], list[Content]]
Asynchronously return content items most similar to the query.
Also returns the embedded query vector.
PARAMETER | DESCRIPTION |
---|---|
query
|
Input text.
TYPE:
|
k
|
Number of content items to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
query_embedding
|
The query embedding used for selecting the most relevant content. |
contents
|
List of up to |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
format_documents_hook ¶
Format the documents as content after executing the query.
PARAMETER | DESCRIPTION |
---|---|
docs
|
The documents returned from the vector store
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
The formatted content. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
get ¶
Get content items by ID.
Fewer content items may be returned than requested if some IDs are not found or if there are duplicated IDs. This method should NOT raise exceptions if no content items are found for some IDs.
Users should not assume that the order of the returned content items matches the order of the input IDs. Instead, users should rely on the ID field of the returned content items.
PARAMETER | DESCRIPTION |
---|---|
ids
|
List of IDs to get. |
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments. These are up to the implementation.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of content items that were found. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
search ¶
search(
embedding: list[float],
k: int = 4,
filter: dict[str, str] | None = None,
**kwargs: Any,
) -> list[Content]
Return contents most similar to the query vector.
PARAMETER | DESCRIPTION |
---|---|
embedding
|
Embedding to look up documents similar to. |
k
|
Number of Documents to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of Contents most similar to the query vector. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
search_with_embedding ¶
search_with_embedding(
query: str,
k: int = 4,
filter: dict[str, Any] | None = None,
**kwargs: Any,
) -> tuple[list[float], list[Content]]
Return content items most similar to the query.
Also returns the embedded query vector.
PARAMETER | DESCRIPTION |
---|---|
query
|
Input text.
TYPE:
|
k
|
Number of content items to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
query_embedding
|
The query embedding used for selecting the most relevant content. |
contents
|
List of up to |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
update_filter_hook ¶
Update the metadata filter before executing the query.
PARAMETER | DESCRIPTION |
---|---|
filter
|
Filter on the metadata to update. |
RETURNS | DESCRIPTION |
---|---|
dict[str, Any] | None
|
The updated filter on the metadata to apply. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
ShreddedLangchainAdapter ¶
ShreddedLangchainAdapter(
vector_store: StoreT,
shredder: ShreddingTransformer | None = None,
nested_metadata_fields: set[str] = set(),
)
Bases: LangchainAdapter[StoreT]
Base adapter for integrating vector stores with the graph retriever system.
This class provides a foundation for custom adapters, enabling consistent interaction with various vector store implementations that do not support searching on list-based metadata values.
PARAMETER | DESCRIPTION |
---|---|
vector_store
|
The vector store instance.
TYPE:
|
shredder
|
An instance of the ShreddingTransformer used for doc insertion. If not passed then a default instance of ShreddingTransformer is used.
TYPE:
|
nested_metadata_fields
|
The set of metadata fields that contain nested values. |
Initialize the base adapter.
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
aadjacent
async
¶
aadjacent(
edges: set[Edge],
query_embedding: list[float],
k: int,
filter: dict[str, Any] | None,
**kwargs: Any,
) -> Iterable[Content]
Asynchronously return the content items with at least one matching edge.
PARAMETER | DESCRIPTION |
---|---|
edges
|
The edges to look for. |
query_embedding
|
The query embedding used for selecting the most relevant content. |
k
|
The number of relevant content items to select for the edges.
TYPE:
|
filter
|
Optional metadata to filter the results. |
kwargs
|
Keyword arguments to pass to the similarity search.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Content]
|
Iterable of adjacent content items. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If unsupported edge types are encountered. |
Source code in packages/graph-retriever/src/graph_retriever/adapters/base.py
adjacent ¶
adjacent(
edges: set[Edge],
query_embedding: list[float],
k: int,
filter: dict[str, Any] | None,
**kwargs: Any,
) -> Iterable[Content]
Return the content items with at least one matching incoming edge.
PARAMETER | DESCRIPTION |
---|---|
edges
|
The edges to look for. |
query_embedding
|
The query embedding used for selecting the most relevant content. |
k
|
The number of relevant content items to select.
TYPE:
|
filter
|
Optional metadata to filter the results. |
kwargs
|
Keyword arguments to pass to the similarity search.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Content]
|
Iterable of adjacent content items. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If unsupported edge types are encountered. |
Source code in packages/graph-retriever/src/graph_retriever/adapters/base.py
aget
async
¶
Asynchronously get content items by ID.
Fewer content items may be returned than requested if some IDs are not found or if there are duplicated IDs. This method should NOT raise exceptions if no content items are found for some IDs.
Users should not assume that the order of the returned content items matches the order of the input IDs. Instead, users should rely on the ID field of the returned content items.
PARAMETER | DESCRIPTION |
---|---|
ids
|
List of IDs to get. |
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments. These are up to the implementation.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of content items that were found. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
asearch
async
¶
asearch(
embedding: list[float],
k: int = 4,
filter: dict[str, str] | None = None,
**kwargs: Any,
) -> list[Content]
Asynchronously return content items most similar to the query vector.
PARAMETER | DESCRIPTION |
---|---|
embedding
|
The query embedding used for selecting the most relevant content. |
k
|
Number of content items to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of content items most similar to the query vector. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
asearch_with_embedding
async
¶
asearch_with_embedding(
query: str,
k: int = 4,
filter: dict[str, Any] | None = None,
**kwargs: Any,
) -> tuple[list[float], list[Content]]
Asynchronously return content items most similar to the query.
Also returns the embedded query vector.
PARAMETER | DESCRIPTION |
---|---|
query
|
Input text.
TYPE:
|
k
|
Number of content items to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
query_embedding
|
The query embedding used for selecting the most relevant content. |
contents
|
List of up to |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
format_documents_hook ¶
Format the documents as content after executing the query.
PARAMETER | DESCRIPTION |
---|---|
docs
|
The documents returned from the vector store
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
The formatted content. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
get ¶
Get content items by ID.
Fewer content items may be returned than requested if some IDs are not found or if there are duplicated IDs. This method should NOT raise exceptions if no content items are found for some IDs.
Users should not assume that the order of the returned content items matches the order of the input IDs. Instead, users should rely on the ID field of the returned content items.
PARAMETER | DESCRIPTION |
---|---|
ids
|
List of IDs to get. |
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments. These are up to the implementation.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of content items that were found. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
search ¶
search(
embedding: list[float],
k: int = 4,
filter: dict[str, str] | None = None,
**kwargs: Any,
) -> list[Content]
Return contents most similar to the query vector.
PARAMETER | DESCRIPTION |
---|---|
embedding
|
Embedding to look up documents similar to. |
k
|
Number of Documents to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of Contents most similar to the query vector. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
search_with_embedding ¶
search_with_embedding(
query: str,
k: int = 4,
filter: dict[str, Any] | None = None,
**kwargs: Any,
) -> tuple[list[float], list[Content]]
Return content items most similar to the query.
Also returns the embedded query vector.
PARAMETER | DESCRIPTION |
---|---|
query
|
Input text.
TYPE:
|
k
|
Number of content items to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
query_embedding
|
The query embedding used for selecting the most relevant content. |
contents
|
List of up to |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
update_filter_hook ¶
Update the metadata filter before executing the query.
PARAMETER | DESCRIPTION |
---|---|
filter
|
Filter on the metadata to update. |
RETURNS | DESCRIPTION |
---|---|
dict[str, Any] | None
|
The updated filter on the metadata to apply. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
open_search ¶
Provides an adapter for OpenSearch vector store integration.
OpenSearchAdapter ¶
OpenSearchAdapter(vector_store: OpenSearchVectorSearch)
Bases: LangchainAdapter[OpenSearchVectorSearch]
Adapter to traverse OpenSearch vector stores.
This adapter enables similarity search and document retrieval using an OpenSearch vector store.
PARAMETER | DESCRIPTION |
---|---|
vector_store
|
The OpenSearch vector store instance.
TYPE:
|
Notes
Graph Traversal is only supported when using either the "lucene"
or
"faiss"
engine.
For more info, see the OpenSearch Documentation
Initialize the base adapter.
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/open_search.py
aadjacent
async
¶
aadjacent(
edges: set[Edge],
query_embedding: list[float],
k: int,
filter: dict[str, Any] | None,
**kwargs: Any,
) -> Iterable[Content]
Asynchronously return the content items with at least one matching edge.
PARAMETER | DESCRIPTION |
---|---|
edges
|
The edges to look for. |
query_embedding
|
The query embedding used for selecting the most relevant content. |
k
|
The number of relevant content items to select for the edges.
TYPE:
|
filter
|
Optional metadata to filter the results. |
kwargs
|
Keyword arguments to pass to the similarity search.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Content]
|
Iterable of adjacent content items. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If unsupported edge types are encountered. |
Source code in packages/graph-retriever/src/graph_retriever/adapters/base.py
adjacent ¶
adjacent(
edges: set[Edge],
query_embedding: list[float],
k: int,
filter: dict[str, Any] | None,
**kwargs: Any,
) -> Iterable[Content]
Return the content items with at least one matching incoming edge.
PARAMETER | DESCRIPTION |
---|---|
edges
|
The edges to look for. |
query_embedding
|
The query embedding used for selecting the most relevant content. |
k
|
The number of relevant content items to select.
TYPE:
|
filter
|
Optional metadata to filter the results. |
kwargs
|
Keyword arguments to pass to the similarity search.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Iterable[Content]
|
Iterable of adjacent content items. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If unsupported edge types are encountered. |
Source code in packages/graph-retriever/src/graph_retriever/adapters/base.py
aget
async
¶
Asynchronously get content items by ID.
Fewer content items may be returned than requested if some IDs are not found or if there are duplicated IDs. This method should NOT raise exceptions if no content items are found for some IDs.
Users should not assume that the order of the returned content items matches the order of the input IDs. Instead, users should rely on the ID field of the returned content items.
PARAMETER | DESCRIPTION |
---|---|
ids
|
List of IDs to get. |
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments. These are up to the implementation.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of content items that were found. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
asearch
async
¶
asearch(
embedding: list[float],
k: int = 4,
filter: dict[str, str] | None = None,
**kwargs: Any,
) -> list[Content]
Asynchronously return content items most similar to the query vector.
PARAMETER | DESCRIPTION |
---|---|
embedding
|
The query embedding used for selecting the most relevant content. |
k
|
Number of content items to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of content items most similar to the query vector. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
asearch_with_embedding
async
¶
asearch_with_embedding(
query: str,
k: int = 4,
filter: dict[str, Any] | None = None,
**kwargs: Any,
) -> tuple[list[float], list[Content]]
Asynchronously return content items most similar to the query.
Also returns the embedded query vector.
PARAMETER | DESCRIPTION |
---|---|
query
|
Input text.
TYPE:
|
k
|
Number of content items to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
query_embedding
|
The query embedding used for selecting the most relevant content. |
contents
|
List of up to |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
format_documents_hook ¶
Format the documents as content after executing the query.
PARAMETER | DESCRIPTION |
---|---|
docs
|
The documents returned from the vector store
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
The formatted content. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
get ¶
Get content items by ID.
Fewer content items may be returned than requested if some IDs are not found or if there are duplicated IDs. This method should NOT raise exceptions if no content items are found for some IDs.
Users should not assume that the order of the returned content items matches the order of the input IDs. Instead, users should rely on the ID field of the returned content items.
PARAMETER | DESCRIPTION |
---|---|
ids
|
List of IDs to get. |
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments. These are up to the implementation.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of content items that were found. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
search ¶
search(
embedding: list[float],
k: int = 4,
filter: dict[str, str] | None = None,
**kwargs: Any,
) -> list[Content]
Return contents most similar to the query vector.
PARAMETER | DESCRIPTION |
---|---|
embedding
|
Embedding to look up documents similar to. |
k
|
Number of Documents to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[Content]
|
List of Contents most similar to the query vector. |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
search_with_embedding ¶
search_with_embedding(
query: str,
k: int = 4,
filter: dict[str, Any] | None = None,
**kwargs: Any,
) -> tuple[list[float], list[Content]]
Return content items most similar to the query.
Also returns the embedded query vector.
PARAMETER | DESCRIPTION |
---|---|
query
|
Input text.
TYPE:
|
k
|
Number of content items to return.
TYPE:
|
filter
|
Filter on the metadata to apply. |
kwargs
|
Additional keyword arguments.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
query_embedding
|
The query embedding used for selecting the most relevant content. |
contents
|
List of up to |
Source code in packages/langchain-graph-retriever/src/langchain_graph_retriever/adapters/langchain.py
update_filter_hook ¶
Update the metadata filter before executing the query.
PARAMETER | DESCRIPTION |
---|---|
filter
|
Filter on the metadata to update. |
RETURNS | DESCRIPTION |
---|---|
dict[str, Any] | None
|
The updated filter on the metadata to apply. |