Skip to content

Commit 3cdb5e8

Browse files
authoredSep 17, 2024··
docs: Adds warnings to cypher chain about credentials (#6827)
1 parent 567d10b commit 3cdb5e8

File tree

5 files changed

+69
-3
lines changed

5 files changed

+69
-3
lines changed
 

‎docs/core_docs/docs/how_to/graph_prompting.ipynb

+14-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,20 @@
66
"source": [
77
"# How to improve results with prompting\n",
88
"\n",
9-
"In this guide we’ll go over prompting strategies to improve graph database query generation. We’ll largely focus on methods for getting relevant database-specific information in your prompt."
9+
"In this guide we’ll go over prompting strategies to improve graph database query generation. We’ll largely focus on methods for getting relevant database-specific information in your prompt.\n",
10+
"\n",
11+
"```{=mdx}\n",
12+
":::warning\n",
13+
"\n",
14+
"The `GraphCypherQAChain` used in this guide will execute Cypher statements against the provided database.\n",
15+
"For production, make sure that the database connection uses credentials that are narrowly-scoped to only include necessary permissions.\n",
16+
"\n",
17+
"Failure to do so may result in data corruption or loss, since the calling code\n",
18+
"may attempt commands that would result in deletion, mutation of data\n",
19+
"if appropriately prompted or reading sensitive data if such data is present in the database.\n",
20+
"\n",
21+
":::\n",
22+
"```"
1023
]
1124
},
1225
{

‎docs/core_docs/docs/how_to/graph_semantic.ipynb

+14-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,20 @@
1212
"While that option provides excellent flexibility, the solution could be brittle and not consistently generating precise Cypher statements.\n",
1313
"Instead of generating Cypher statements, we can implement Cypher templates as tools in a semantic layer that an LLM agent can interact with.\n",
1414
"\n",
15-
"![graph_semantic.png](../../static/img/graph_semantic.png)"
15+
"![graph_semantic.png](../../static/img/graph_semantic.png)\n",
16+
"\n",
17+
"```{=mdx}\n",
18+
":::warning\n",
19+
"\n",
20+
"The code in this guide will execute Cypher statements against the provided database.\n",
21+
"For production, make sure that the database connection uses credentials that are narrowly-scoped to only include necessary permissions.\n",
22+
"\n",
23+
"Failure to do so may result in data corruption or loss, since the calling code\n",
24+
"may attempt commands that would result in deletion, mutation of data\n",
25+
"if appropriately prompted or reading sensitive data if such data is present in the database.\n",
26+
"\n",
27+
":::\n",
28+
"```"
1629
]
1730
},
1831
{

‎docs/core_docs/docs/tutorials/graph.ipynb

+13-1
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,20 @@
181181
"\n",
182182
"![graph_chain.webp](../../static/img/graph_chain.webp)\n",
183183
"\n",
184+
"LangChain comes with a built-in chain for this workflow that is designed to work with Neo4j: `GraphCypherQAChain`.\n",
184185
"\n",
185-
"LangChain comes with a built-in chain for this workflow that is designed to work with Neo4j: [GraphCypherQAChain](https://python.langchain.com/docs/use_cases/graph/graph_cypher_qa)"
186+
"```{=mdx}\n",
187+
":::warning\n",
188+
"\n",
189+
"The `GraphCypherQAChain` used in this guide will execute Cypher statements against the provided database.\n",
190+
"For production, make sure that the database connection uses credentials that are narrowly-scoped to only include necessary permissions.\n",
191+
"\n",
192+
"Failure to do so may result in data corruption or loss, since the calling code\n",
193+
"may attempt commands that would result in deletion, mutation of data\n",
194+
"if appropriately prompted or reading sensitive data if such data is present in the database.\n",
195+
"\n",
196+
":::\n",
197+
"```"
186198
]
187199
},
188200
{

‎langchain/src/chains/graph_qa/cypher.ts

+14
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ export interface FromLLMInput {
3939
}
4040

4141
/**
42+
* Chain for question-answering against a graph by generating Cypher statements.
43+
*
4244
* @example
4345
* ```typescript
4446
* const chain = new GraphCypherQAChain({
@@ -47,6 +49,18 @@ export interface FromLLMInput {
4749
* });
4850
* const res = await chain.invoke("Who played in Pulp Fiction?");
4951
* ```
52+
*
53+
* @security
54+
* This chain will execute Cypher statements against the provided database.
55+
* Make sure that the database connection uses credentials
56+
* that are narrowly-scoped to only include necessary permissions.
57+
* Failure to do so may result in data corruption or loss, since the calling code
58+
* may attempt commands that would result in deletion, mutation of data
59+
* if appropriately prompted or reading sensitive data if such data is present in the database.
60+
* The best way to guard against such negative outcomes is to (as appropriate) limit the
61+
* permissions granted to the credentials used with this tool.
62+
*
63+
* See https://js.langchain.com/docs/security for more information.
5064
*/
5165
export class GraphCypherQAChain extends BaseChain {
5266
// eslint-disable-next-line @typescript-eslint/no-explicit-any

‎libs/langchain-community/src/chains/graph_qa/cypher.ts

+14
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ export interface FromLLMInput {
3131
}
3232

3333
/**
34+
* Chain for question-answering against a graph by generating Cypher statements.
35+
*
3436
* @example
3537
* ```typescript
3638
* const chain = new GraphCypherQAChain({
@@ -39,6 +41,18 @@ export interface FromLLMInput {
3941
* });
4042
* const res = await chain.invoke("Who played in Pulp Fiction?");
4143
* ```
44+
*
45+
* @security
46+
* This chain will execute Cypher statements against the provided database.
47+
* Make sure that the database connection uses credentials
48+
* that are narrowly-scoped to only include necessary permissions.
49+
* Failure to do so may result in data corruption or loss, since the calling code
50+
* may attempt commands that would result in deletion, mutation of data
51+
* if appropriately prompted or reading sensitive data if such data is present in the database.
52+
* The best way to guard against such negative outcomes is to (as appropriate) limit the
53+
* permissions granted to the credentials used with this tool.
54+
*
55+
* See https://js.langchain.com/docs/security for more information.
4256
*/
4357
export class GraphCypherQAChain extends BaseChain {
4458
private graph: Neo4jGraph;

0 commit comments

Comments
 (0)
Please sign in to comment.