@@ -60,14 +60,7 @@ def test_graphrag_happy_path(
6060 )
6161
6262 llm .invoke .assert_called_once_with (
63- [
64- {
65- "role" : "system" ,
66- "content" : "Answer the user question using the provided context." ,
67- },
68- {
69- "role" : "user" ,
70- "content" : """Context:
63+ """Context:
7164<Record node={'question': 'In 1953 Watson & Crick built a model of the molecular structure of this, the gene-carrying substance'}>
7265<Record node={'question': 'This organ removes excess glucose from the blood & stores it as glycogen'}>
7366
@@ -79,8 +72,8 @@ def test_graphrag_happy_path(
7972
8073Answer:
8174""" ,
82- } ,
83- ]
75+ None ,
76+ system_instruction = "Answer the user question using the provided context." ,
8477 )
8578 assert isinstance (result , RagResultModel )
8679 assert result .answer == "some text"
@@ -155,21 +148,13 @@ def test_graphrag_happy_path_with_neo4j_message_history(
155148 llm .invoke .assert_has_calls (
156149 [
157150 call (
158- [
159- {"role" : "system" , "content" : first_invocation_system_instruction },
160- {"role" : "user" , "content" : first_invocation_input },
161- ]
151+ input = first_invocation_input ,
152+ system_instruction = first_invocation_system_instruction ,
162153 ),
163154 call (
164- [
165- {
166- "role" : "system" ,
167- "content" : "Answer the user question using the provided context." ,
168- },
169- {"role" : "user" , "content" : "initial question" },
170- {"role" : "assistant" , "content" : "answer to initial question" },
171- {"role" : "user" , "content" : second_invocation },
172- ]
155+ second_invocation ,
156+ message_history .messages ,
157+ system_instruction = "Answer the user question using the provided context." ,
173158 ),
174159 ]
175160 )
@@ -205,14 +190,7 @@ def test_graphrag_happy_path_return_context(
205190 )
206191
207192 llm .invoke .assert_called_once_with (
208- [
209- {
210- "role" : "system" ,
211- "content" : "Answer the user question using the provided context." ,
212- },
213- {
214- "role" : "user" ,
215- "content" : """Context:
193+ """Context:
216194<Record node={'question': 'In 1953 Watson & Crick built a model of the molecular structure of this, the gene-carrying substance'}>
217195<Record node={'question': 'This organ removes excess glucose from the blood & stores it as glycogen'}>
218196
@@ -224,8 +202,8 @@ def test_graphrag_happy_path_return_context(
224202
225203Answer:
226204""" ,
227- } ,
228- ] ,
205+ None ,
206+ system_instruction = "Answer the user question using the provided context." ,
229207 )
230208 assert isinstance (result , RagResultModel )
231209 assert result .answer == "some text"
@@ -258,14 +236,7 @@ def test_graphrag_happy_path_examples(
258236 )
259237
260238 llm .invoke .assert_called_once_with (
261- [
262- {
263- "role" : "system" ,
264- "content" : "Answer the user question using the provided context." ,
265- },
266- {
267- "role" : "user" ,
268- "content" : """Context:
239+ """Context:
269240<Record node={'question': 'In 1953 Watson & Crick built a model of the molecular structure of this, the gene-carrying substance'}>
270241<Record node={'question': 'This organ removes excess glucose from the blood & stores it as glycogen'}>
271242
@@ -277,8 +248,8 @@ def test_graphrag_happy_path_examples(
277248
278249Answer:
279250""" ,
280- } ,
281- ]
251+ None ,
252+ system_instruction = "Answer the user question using the provided context." ,
282253 )
283254 assert result .answer == "some text"
284255
0 commit comments