@@ -120,6 +120,37 @@ class NeptuneOpenCypherQAChain(Chain):
120
120
extra_instructions : Optional [str ] = None
121
121
"""Extra instructions by the appended to the query generation prompt."""
122
122
123
+ allow_dangerous_requests : bool = False
124
+ """Forced user opt-in to acknowledge that the chain can make dangerous requests.
125
+
126
+ *Security note*: Make sure that the database connection uses credentials
127
+ that are narrowly-scoped to only include necessary permissions.
128
+ Failure to do so may result in data corruption or loss, since the calling
129
+ code may attempt commands that would result in deletion, mutation
130
+ of data if appropriately prompted or reading sensitive data if such
131
+ data is present in the database.
132
+ The best way to guard against such negative outcomes is to (as appropriate)
133
+ limit the permissions granted to the credentials used with this tool.
134
+
135
+ See https://python.langchain.com/docs/security for more information.
136
+ """
137
+
138
+ def __init__ (self , ** kwargs : Any ) -> None :
139
+ """Initialize the chain."""
140
+ super ().__init__ (** kwargs )
141
+ if self .allow_dangerous_requests is not True :
142
+ raise ValueError (
143
+ "In order to use this chain, you must acknowledge that it can make "
144
+ "dangerous requests by setting `allow_dangerous_requests` to `True`."
145
+ "You must narrowly scope the permissions of the database connection "
146
+ "to only include necessary permissions. Failure to do so may result "
147
+ "in data corruption or loss or reading sensitive data if such data is "
148
+ "present in the database."
149
+ "Only use this chain if you understand the risks and have taken the "
150
+ "necessary precautions. "
151
+ "See https://python.langchain.com/docs/security for more information."
152
+ )
153
+
123
154
@property
124
155
def input_keys (self ) -> List [str ]:
125
156
"""Return the input keys.
0 commit comments