Skip to content

Commit 771d77e

Browse files
committed
Add Weaviate documentation
1 parent 5d7eaf2 commit 771d77e

File tree

4 files changed

+48
-8
lines changed

4 files changed

+48
-8
lines changed

docs/source/api.rst

+15
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,21 @@ HybridCypherRetriever
4242
:members:
4343

4444

45+
46+
*******************
47+
External Retrievers
48+
*******************
49+
50+
This section includes retrievers that integrate with databases external to Neo4j.
51+
52+
53+
WeaviateNeo4jRetriever
54+
======================
55+
56+
.. autoclass:: neo4j_genai.retrievers.external.weaviate.WeaviateNeo4jRetriever
57+
:members:
58+
59+
4560
******
4661
Errors
4762
******

src/neo4j_genai/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
from .retrievers.hybrid import HybridCypherRetriever, HybridRetriever
1717
from .retrievers.text2cypher import Text2CypherRetriever
1818
from .retrievers.vector import VectorCypherRetriever, VectorRetriever
19+
from .retrievers.external.weaviate import WeaviateNeo4jRetriever
1920

2021
__all__ = [
2122
"VectorRetriever",
2223
"VectorCypherRetriever",
2324
"HybridRetriever",
2425
"HybridCypherRetriever",
2526
"Text2CypherRetriever",
27+
"WeaviateNeo4jRetriever",
2628
]

src/neo4j_genai/retrievers/external/weaviate/weaviate.py

+30-7
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,37 @@ def _get_search_results(
9595
If no embedder is provided, then it will assume that the vectorizer is used in Weaviate.
9696
9797
See the following documentation for more details:
98-
- [Query a vector index](https://neo4j.com/docs/cypher-manual/current/indexes-for-vector-search/#indexes-vector-query)
99-
- [db.index.vector.queryNodes()](https://neo4j.com/docs/operations-manual/5/reference/procedures/#procedure_db_index_vector_queryNodes)
100-
- [db.index.fulltext.queryNodes()](https://neo4j.com/docs/operations-manual/5/reference/procedures/#procedure_db_index_fulltext_querynodes)
98+
- `Query a vector index <https://neo4j.com/docs/cypher-manual/current/indexes-for-vector-search/#indexes-vector-query>`_
99+
- `db.index.vector.queryNodes() <https://neo4j.com/docs/operations-manual/5/reference/procedures/#procedure_db_index_vector_queryNodes>`_
100+
- `db.index.fulltext.queryNodes() <https://neo4j.com/docs/operations-manual/5/reference/procedures/#procedure_db_index_fulltext_querynodes>`_
101+
102+
103+
Example:
104+
105+
.. code-block:: python
106+
107+
import neo4j
108+
from neo4j_genai.retrievers import WeaviateNeo4jRetriever
109+
110+
driver = neo4j.GraphDatabase.driver(URI, auth=AUTH)
111+
112+
retriever = WeaviateNeo4jRetriever(
113+
driver=driver,
114+
client=weaviate_client,
115+
collection="Jeopardy",
116+
id_property_external="neo4j_id",
117+
id_property_neo4j="id",
118+
)
119+
120+
biology_embedding = ...
121+
retriever.search(query_vector=biology_embedding, top_k=2)
122+
123+
101124
Args:
102-
query_text (str): The text to get the closest neighbors of.
103-
query_vector (Optional[list[float]], optional): The vector embeddings to get the closest neighbors of. Defaults to None.
104-
top_k (int, optional): The number of neighbors to return. Defaults to 5.
105-
weaviate_filters (Optional[_Filters], optional): The filters to apply to the search query in Weaviate. Defaults to None.
125+
query_text (Optional[str]): The text to get the closest neighbors of.
126+
query_vector (Optional[list[float]]): The vector embeddings to get the closest neighbors of. Defaults to None.
127+
top_k (int): The number of neighbors to return. Defaults to 5.
128+
weaviate_filters (Optional[_Filters]): The filters to apply to the search query in Weaviate. Defaults to None.
106129
Raises:
107130
SearchValidationError: If validation of the input arguments fail.
108131
Returns:

tests/e2e/weaviate_e2e/test_weaviate_e2e.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import re
1717
import pytest
1818
import weaviate
19-
from neo4j_genai.retrievers.external.weaviate import WeaviateNeo4jRetriever
19+
from neo4j_genai import WeaviateNeo4jRetriever
2020
from langchain_community.embeddings import HuggingFaceEmbeddings
2121

2222
from neo4j_genai.types import RetrieverResult, RetrieverResultItem

0 commit comments

Comments
 (0)