mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-16 06:53:16 +00:00
community[patch]: Neo4j enhanced schema (#20983)
Scan the database for example values and provide them to an LLM for better inference of Text2cypher
This commit is contained in:
@@ -291,3 +291,45 @@ def test_driver_config() -> None:
|
||||
driver_config={"max_connection_pool_size": 1},
|
||||
)
|
||||
graph.query("RETURN 'foo'")
|
||||
|
||||
|
||||
def test_enhanced_schema() -> None:
|
||||
"""Test that neo4j works with driver config."""
|
||||
url = os.environ.get("NEO4J_URI")
|
||||
username = os.environ.get("NEO4J_USERNAME")
|
||||
password = os.environ.get("NEO4J_PASSWORD")
|
||||
assert url is not None
|
||||
assert username is not None
|
||||
assert password is not None
|
||||
|
||||
graph = Neo4jGraph(
|
||||
url=url, username=username, password=password, enhanced_schema=True
|
||||
)
|
||||
graph.query("MATCH (n) DETACH DELETE n")
|
||||
graph.add_graph_documents(test_data)
|
||||
graph.refresh_schema()
|
||||
expected_output = {
|
||||
"node_props": {
|
||||
"foo": [
|
||||
{
|
||||
"property": "id",
|
||||
"type": "STRING",
|
||||
"values": ["foo"],
|
||||
"distinct_count": 1,
|
||||
}
|
||||
],
|
||||
"bar": [
|
||||
{
|
||||
"property": "id",
|
||||
"type": "STRING",
|
||||
"values": ["bar"],
|
||||
"distinct_count": 1,
|
||||
}
|
||||
],
|
||||
},
|
||||
"rel_props": {},
|
||||
"relationships": [{"start": "foo", "type": "REL", "end": "bar"}],
|
||||
}
|
||||
# remove metadata portion of schema
|
||||
del graph.structured_schema["metadata"]
|
||||
assert graph.structured_schema == expected_output
|
||||
|
Reference in New Issue
Block a user