File tree 3 files changed +25
-6
lines changed
src/neo4j_genai/generation
3 files changed +25
-6
lines changed Original file line number Diff line number Diff line change 4
4
5
5
### Added
6
6
- Add optional custom_prompt arg to the Text2CypherRetriever class.
7
-
7
+
8
+ ### Changed
9
+ - ` GraphRAG.search ` method first parameter has been renamed ` query_text ` (was ` query ` ) for consistency with the retrievers interface.
10
+ - Made ` GraphRAG.search ` method backwards compatible with the query parameter, raising warnings to encourage using query_text instead.
11
+
8
12
## 0.3.1
9
13
10
14
### Fixed
11
15
- Corrected initialization to allow specifying the embedding model name.
12
16
- Removed sentence_transformers from embeddings/__ init__ .py to avoid ImportError when the package is not installed.
13
17
14
- ### Changed
15
- - ` GraphRAG.search ` method first parameter has been renamed ` query_text ` (was ` query ` ) for consistency with the retrievers interface.
16
-
17
18
## 0.3.0
18
19
19
20
### Added
Original file line number Diff line number Diff line change @@ -128,7 +128,7 @@ rag = GraphRAG(retriever=retriever, llm=llm)
128
128
129
129
# Query the graph
130
130
query_text = " How do I do similarity search in Neo4j?"
131
- response = rag.search(query = query_text, retriever_config = {" top_k" : 5 })
131
+ response = rag.search(query_text = query_text, retriever_config = {" top_k" : 5 })
132
132
print (response.answer)
133
133
```
134
134
Original file line number Diff line number Diff line change 15
15
from __future__ import annotations
16
16
17
17
import logging
18
+ import warnings
18
19
from typing import Any , Optional
19
20
20
21
from pydantic import ValidationError
@@ -53,10 +54,11 @@ def __init__(
53
54
54
55
def search (
55
56
self ,
56
- query_text : str ,
57
+ query_text : str = "" ,
57
58
examples : str = "" ,
58
59
retriever_config : Optional [dict [str , Any ]] = None ,
59
60
return_context : bool = False ,
61
+ query : Optional [str ] = None ,
60
62
) -> RagResultModel :
61
63
"""This method performs a full RAG search:
62
64
1. Retrieval: context retrieval
@@ -69,12 +71,28 @@ def search(
69
71
retriever_config (Optional[dict]): Parameters passed to the retriever
70
72
search method; e.g.: top_k
71
73
return_context (bool): Whether to return the retriever result (default: False)
74
+ query (Optional[str]): The user question. Will be deprecated in favor of query_text.
72
75
73
76
Returns:
74
77
RagResultModel: The LLM-generated answer
75
78
76
79
"""
77
80
try :
81
+ if query is not None :
82
+ if query_text :
83
+ warnings .warn (
84
+ "Both 'query' and 'query_text' are provided, 'query_text' will be used." ,
85
+ DeprecationWarning ,
86
+ stacklevel = 2 ,
87
+ )
88
+ elif isinstance (query , str ):
89
+ warnings .warn (
90
+ "'query' is deprecated and will be removed in a future version, please use 'query_text' instead." ,
91
+ DeprecationWarning ,
92
+ stacklevel = 2 ,
93
+ )
94
+ query_text = query
95
+
78
96
validated_data = RagSearchModel (
79
97
query_text = query_text ,
80
98
examples = examples ,
You can’t perform that action at this time.
0 commit comments