Skip to content

Commit 9875dea

Browse files
committed
Add Weaviate documentation
1 parent 6503a23 commit 9875dea

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

0 commit comments

Comments
 (0)