Skip to content

Commit 1b0f2e2

Browse files
committed
Add documentation for schema and examples in prompt_params
1 parent 4ff0530 commit 1b0f2e2

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/neo4j_graphrag/retrievers/text2cypher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Text2CypherRetriever(Retriever):
5555
llm (neo4j_graphrag.generation.llm.LLMInterface): LLM object to generate the Cypher query.
5656
neo4j_schema (Optional[str]): Neo4j schema used to generate the Cypher query.
5757
examples (Optional[list[str], optional): Optional user input/query pairs for the LLM to use as examples.
58-
custom_prompt (Optional[str]): Optional custom prompt to use instead of auto generated prompt. Will not include the neo4j_schema or examples args, if provided.
58+
custom_prompt (Optional[str]): Optional custom prompt to use instead of auto generated prompt. Will include the neo4j_schema for schema and examples for examples prompt parameters, if they are provided.
5959
6060
Raises:
6161
RetrieverInitializationError: If validation of the input arguments fail.
@@ -130,7 +130,7 @@ def get_search_results(
130130
131131
Args:
132132
query_text (str): The natural language query used to search the Neo4j database.
133-
prompt_params (Dict[str, Any]): additional values to inject into the custom prompt, if it is provided. Example: {'schema': 'this is the graph schema'}
133+
prompt_params (Dict[str, Any]): additional values to inject into the custom prompt, if it is provided. If the schema or examples parameter is specified, it will overwrite the corresponding value passed during initialization. Example: {'schema': 'this is the graph schema'}
134134
135135
Raises:
136136
SearchValidationError: If validation of the input arguments fail.

tests/unit/retrievers/test_text2cypher.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,12 @@ def test_t2c_retriever_initialization_with_custom_prompt_and_schema_and_examples
256256

257257
@patch("neo4j_graphrag.retrievers.base.get_version")
258258
def test_t2c_retriever_initialization_with_custom_prompt_and_schema_and_examples_for_prompt_params(
259-
_verify_version_mock: MagicMock,
259+
mock_get_version: MagicMock,
260260
driver: MagicMock,
261261
llm: MagicMock,
262262
neo4j_record: MagicMock,
263263
) -> None:
264+
mock_get_version.return_value = ((5, 23, 0), False, False)
264265
prompt = "This is a custom prompt. {query_text} {schema} {examples}"
265266
neo4j_schema = "dummy-schema"
266267
examples = ["example-1", "example-2"]
@@ -287,11 +288,12 @@ def test_t2c_retriever_initialization_with_custom_prompt_and_schema_and_examples
287288

288289
@patch("neo4j_graphrag.retrievers.base.get_version")
289290
def test_t2c_retriever_initialization_with_custom_prompt_and_unused_schema_and_examples(
290-
_verify_version_mock: MagicMock,
291+
mock_get_version: MagicMock,
291292
driver: MagicMock,
292293
llm: MagicMock,
293294
neo4j_record: MagicMock,
294295
) -> None:
296+
mock_get_version.return_value = ((5, 23, 0), False, False)
295297
prompt = "This is a custom prompt. {query_text} {schema} {examples}"
296298
neo4j_schema = "dummy-schema"
297299
examples = ["example-1", "example-2"]

0 commit comments

Comments
 (0)