mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-27 22:37:46 +00:00
community: Force opt-in for qa chains (#26278)
The underlying code is already documented as requiring appropriate RBAC control, but adding a forced user opt-in to make sure that users that don't read documentation are still aware of what's required from a security perspective. https://huntr.com/bounties/8f4ad910-7fdc-4089-8f0a-b5df5f32e7c5
This commit is contained in:
@@ -59,6 +59,7 @@ def test_graph_cypher_qa_chain_prompt_selection_1() -> None:
|
||||
return_intermediate_steps=False,
|
||||
qa_prompt=qa_prompt,
|
||||
cypher_prompt=cypher_prompt,
|
||||
allow_dangerous_requests=True,
|
||||
)
|
||||
assert chain.qa_chain.prompt == qa_prompt # type: ignore[union-attr]
|
||||
assert chain.cypher_generation_chain.prompt == cypher_prompt
|
||||
@@ -71,6 +72,7 @@ def test_graph_cypher_qa_chain_prompt_selection_2() -> None:
|
||||
graph=FakeGraphStore(),
|
||||
verbose=True,
|
||||
return_intermediate_steps=False,
|
||||
allow_dangerous_requests=True,
|
||||
)
|
||||
assert chain.qa_chain.prompt == CYPHER_QA_PROMPT # type: ignore[union-attr]
|
||||
assert chain.cypher_generation_chain.prompt == CYPHER_GENERATION_PROMPT
|
||||
@@ -87,6 +89,7 @@ def test_graph_cypher_qa_chain_prompt_selection_3() -> None:
|
||||
return_intermediate_steps=False,
|
||||
cypher_llm_kwargs={"memory": readonlymemory},
|
||||
qa_llm_kwargs={"memory": readonlymemory},
|
||||
allow_dangerous_requests=True,
|
||||
)
|
||||
assert chain.qa_chain.prompt == CYPHER_QA_PROMPT # type: ignore[union-attr]
|
||||
assert chain.cypher_generation_chain.prompt == CYPHER_GENERATION_PROMPT
|
||||
@@ -107,6 +110,7 @@ def test_graph_cypher_qa_chain_prompt_selection_4() -> None:
|
||||
return_intermediate_steps=False,
|
||||
cypher_llm_kwargs={"prompt": cypher_prompt, "memory": readonlymemory},
|
||||
qa_llm_kwargs={"prompt": qa_prompt, "memory": readonlymemory},
|
||||
allow_dangerous_requests=True,
|
||||
)
|
||||
assert chain.qa_chain.prompt == qa_prompt # type: ignore[union-attr]
|
||||
assert chain.cypher_generation_chain.prompt == cypher_prompt
|
||||
@@ -130,6 +134,7 @@ def test_graph_cypher_qa_chain_prompt_selection_5() -> None:
|
||||
cypher_prompt=cypher_prompt,
|
||||
cypher_llm_kwargs={"memory": readonlymemory},
|
||||
qa_llm_kwargs={"memory": readonlymemory},
|
||||
allow_dangerous_requests=True,
|
||||
)
|
||||
assert False
|
||||
except ValueError:
|
||||
@@ -181,6 +186,7 @@ def test_graph_cypher_qa_chain() -> None:
|
||||
return_intermediate_steps=False,
|
||||
cypher_llm_kwargs={"prompt": prompt, "memory": readonlymemory},
|
||||
memory=memory,
|
||||
allow_dangerous_requests=True,
|
||||
)
|
||||
chain.run("Test question")
|
||||
chain.run("Test new question")
|
||||
|
Reference in New Issue
Block a user