graph_retriever.adapters¶
Adapter ¶
Bases: ABC
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.
Source code in packages/graph-retriever/src/graph_retriever/adapters/base.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/graph-retriever/src/graph_retriever/adapters/base.py
asearch
async
¶
asearch(
embedding: list[float],
k: int = 4,
filter: dict[str, Any] | 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/graph-retriever/src/graph_retriever/adapters/base.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/graph-retriever/src/graph_retriever/adapters/base.py
get
abstractmethod
¶
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/graph-retriever/src/graph_retriever/adapters/base.py
search
abstractmethod
¶
search(
embedding: list[float],
k: int = 4,
filter: dict[str, Any] | 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/graph-retriever/src/graph_retriever/adapters/base.py
search_with_embedding
abstractmethod
¶
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 |