Skip to content

Commit 7cb652d

Browse files
authored
Removed query argument from GraphRAG's .search method (#145)
* Removed query argument from GraphRAG's .search method * Update CHANGELOG * Removed test for deprecation warning
1 parent 5668bdc commit 7cb652d

File tree

3 files changed

+1
-38
lines changed

3 files changed

+1
-38
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
### Changed
2626
- Moved the Embedder class to the neo4j_graphrag.embeddings directory for better organization alongside other custom embedders.
27+
- Removed query argument from the GraphRAG class' `.search` method; users must now use `query_text`.
2728
- Neo4jWriter component now runs a single query to merge node and set its embeddings if any.
2829

2930
## 0.6.3

src/neo4j_graphrag/generation/graphrag.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from __future__ import annotations
1616

1717
import logging
18-
import warnings
1918
from typing import Any, Optional
2019

2120
from pydantic import ValidationError
@@ -86,7 +85,6 @@ def search(
8685
examples: str = "",
8786
retriever_config: Optional[dict[str, Any]] = None,
8887
return_context: bool = False,
89-
query: Optional[str] = None,
9088
) -> RagResultModel:
9189
"""This method performs a full RAG search:
9290
1. Retrieval: context retrieval
@@ -99,28 +97,12 @@ def search(
9997
retriever_config (Optional[dict]): Parameters passed to the retriever
10098
search method; e.g.: top_k
10199
return_context (bool): Whether to append the retriever result to the final result (default: False)
102-
query (Optional[str]): The user question. Will be deprecated in favor of query_text.
103100
104101
Returns:
105102
RagResultModel: The LLM-generated answer
106103
107104
"""
108105
try:
109-
if query is not None:
110-
if query_text:
111-
warnings.warn(
112-
"Both 'query' and 'query_text' are provided, 'query_text' will be used.",
113-
DeprecationWarning,
114-
stacklevel=2,
115-
)
116-
elif isinstance(query, str):
117-
warnings.warn(
118-
"'query' is deprecated and will be removed in a future version, please use 'query_text' instead.",
119-
DeprecationWarning,
120-
stacklevel=2,
121-
)
122-
query_text = query
123-
124106
validated_data = RagSearchModel(
125107
query_text=query_text,
126108
examples=examples,

tests/unit/test_graphrag.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
from unittest.mock import MagicMock
16-
from warnings import catch_warnings
1716

1817
import pytest
1918
from neo4j_graphrag.exceptions import RagInitializationError, SearchValidationError
@@ -22,7 +21,6 @@
2221
from neo4j_graphrag.generation.types import RagResultModel
2322
from neo4j_graphrag.llm import LLMResponse
2423
from neo4j_graphrag.types import RetrieverResult, RetrieverResultItem
25-
from pydantic import ValidationError
2624

2725

2826
def test_graphrag_prompt_template() -> None:
@@ -101,21 +99,3 @@ def test_graphrag_search_error(retriever_mock: MagicMock, llm: MagicMock) -> Non
10199
with pytest.raises(SearchValidationError) as excinfo:
102100
rag.search(10) # type: ignore
103101
assert "Input should be a valid string" in str(excinfo)
104-
105-
106-
def test_graphrag_search_query_deprecation_warning(
107-
retriever_mock: MagicMock, llm: MagicMock
108-
) -> None:
109-
with catch_warnings(record=True) as warn_list:
110-
rag = GraphRAG(
111-
retriever=retriever_mock,
112-
llm=llm,
113-
)
114-
with pytest.raises(ValidationError):
115-
rag.search(query="Some query text")
116-
117-
assert len(warn_list) == 1
118-
assert (
119-
str(warn_list[0].message)
120-
== "'query' is deprecated and will be removed in a future version, please use 'query_text' instead."
121-
)

0 commit comments

Comments
 (0)