File tree Expand file tree Collapse file tree 2 files changed +42
-3
lines changed
src/neo4j_genai/generation Expand file tree Collapse file tree 2 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -156,7 +156,7 @@ LLMInterface
156
156
157
157
158
158
OpenAILLM
159
- =========
159
+ ---------
160
160
161
161
.. autoclass :: neo4j_genai.llm.OpenAILLM
162
162
:members:
@@ -182,6 +182,17 @@ ERExtractionTemplate
182
182
:members:
183
183
184
184
185
+ ****
186
+ RAG
187
+ ****
188
+
189
+ GraphRAG
190
+ ========
191
+
192
+ .. autoclass :: neo4j_genai.generation.graphrag.GraphRAG
193
+ :members:
194
+
195
+
185
196
.. _database-interaction-section :
186
197
187
198
********************
Original file line number Diff line number Diff line change 34
34
35
35
36
36
class GraphRAG :
37
+ """Performs a GraphRAG search using a specific retriever
38
+ and LLM.
39
+
40
+ Example:
41
+
42
+ .. code-block:: python
43
+
44
+ import neo4j
45
+ from neo4j_genai.retrievers import VectorRetriever
46
+ from neo4j_genai.llm.openai_llm import OpenAILLM
47
+ from neo4j_genai.generation import GraphRAG
48
+
49
+ driver = neo4j.GraphDatabase.driver(URI, auth=AUTH)
50
+
51
+ retriever = VectorRetriever(driver, "vector-index-name", custom_embedder)
52
+ llm = OpenAILLM()
53
+ graph_rag = GraphRAG(retriever, llm)
54
+ graph_rag.search(query_text="Find me a book about Fremen")
55
+
56
+ Args:
57
+ retriever (Retriever): The retriever used to find relevant context to pass to the LLM.
58
+ llm (LLMInterface): The LLM used to generate the answer.
59
+ prompt_template (RagTemplate): The prompt template that will be formatted with context and user question and passed to the LLM.
60
+
61
+ Raises:
62
+ RagInitializationError: If validation of the input arguments fail.
63
+ """
64
+
37
65
def __init__ (
38
66
self ,
39
67
retriever : Retriever ,
@@ -67,10 +95,10 @@ def search(
67
95
68
96
Args:
69
97
query_text (str): The user question
70
- examples: Examples added to the LLM prompt.
98
+ examples (str) : Examples added to the LLM prompt.
71
99
retriever_config (Optional[dict]): Parameters passed to the retriever
72
100
search method; e.g.: top_k
73
- return_context (bool): Whether to return the retriever result (default: False)
101
+ return_context (bool): Whether to append the retriever result to the final result (default: False)
74
102
query (Optional[str]): The user question. Will be deprecated in favor of query_text.
75
103
76
104
Returns:
You can’t perform that action at this time.
0 commit comments