mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-06 13:18:12 +00:00
community[minor]: Add the option to omit schema refresh in Neo4jGraph (#19654)
This commit is contained in:
parent
5fc6531c74
commit
87d2a6b777
@ -149,6 +149,8 @@ class Neo4jGraph(GraphStore):
|
|||||||
sanitize (bool): A flag to indicate whether to remove lists with
|
sanitize (bool): A flag to indicate whether to remove lists with
|
||||||
more than 128 elements from results. Useful for removing
|
more than 128 elements from results. Useful for removing
|
||||||
embedding-like properties from database responses. Default is False.
|
embedding-like properties from database responses. Default is False.
|
||||||
|
refresh_schema (bool): A flag whether to refresh schema information
|
||||||
|
at initialization. Default is True.
|
||||||
|
|
||||||
*Security note*: Make sure that the database connection uses credentials
|
*Security note*: Make sure that the database connection uses credentials
|
||||||
that are narrowly-scoped to only include necessary permissions.
|
that are narrowly-scoped to only include necessary permissions.
|
||||||
@ -170,6 +172,7 @@ class Neo4jGraph(GraphStore):
|
|||||||
database: Optional[str] = None,
|
database: Optional[str] = None,
|
||||||
timeout: Optional[float] = None,
|
timeout: Optional[float] = None,
|
||||||
sanitize: bool = False,
|
sanitize: bool = False,
|
||||||
|
refresh_schema: bool = True,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Create a new Neo4j graph wrapper instance."""
|
"""Create a new Neo4j graph wrapper instance."""
|
||||||
try:
|
try:
|
||||||
@ -211,16 +214,17 @@ class Neo4jGraph(GraphStore):
|
|||||||
"Please ensure that the username and password are correct"
|
"Please ensure that the username and password are correct"
|
||||||
)
|
)
|
||||||
# Set schema
|
# Set schema
|
||||||
try:
|
if refresh_schema:
|
||||||
self.refresh_schema()
|
try:
|
||||||
except neo4j.exceptions.ClientError as e:
|
self.refresh_schema()
|
||||||
if e.code == "Neo.ClientError.Procedure.ProcedureNotFound":
|
except neo4j.exceptions.ClientError as e:
|
||||||
raise ValueError(
|
if e.code == "Neo.ClientError.Procedure.ProcedureNotFound":
|
||||||
"Could not use APOC procedures. "
|
raise ValueError(
|
||||||
"Please ensure the APOC plugin is installed in Neo4j and that "
|
"Could not use APOC procedures. "
|
||||||
"'apoc.meta.data()' is allowed in Neo4j configuration "
|
"Please ensure the APOC plugin is installed in Neo4j and that "
|
||||||
)
|
"'apoc.meta.data()' is allowed in Neo4j configuration "
|
||||||
raise e
|
)
|
||||||
|
raise e
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def get_schema(self) -> str:
|
def get_schema(self) -> str:
|
||||||
|
Loading…
Reference in New Issue
Block a user