22import time
33
44from llama_index .core import get_response_synthesizer
5- from llama_index .core .agent . react . base import ReActAgent
5+ from llama_index .core .agent import ReActAgent
66from llama_index .core .response_synthesizers .type import ResponseMode
77from llama_index .core .tools import QueryEngineTool , ToolMetadata
88from llama_index .core .workflow import (
2424company_policy_files_directory = "sample_data/company_policies"
2525personal_preferences_files_directory = "sample_data/personal_preferences"
2626
27- llm = UiPathOpenAI ()
27+ llm = UiPathOpenAI (model = "gpt-4o-2024-11-20" )
2828uipath = UiPath ()
2929
3030
@@ -111,7 +111,7 @@ class SubQuestionQueryEngine(Workflow):
111111 async def workflow_entrypoint (
112112 self , ctx : Context , ev : CustomStartEvent
113113 ) -> QueryEvent | AddDataToIndexEvent :
114- await ctx .set ("original_query" , ev .query )
114+ await ctx .store . set ("original_query" , ev .query )
115115
116116 if ev .add_data_to_index :
117117 return AddDataToIndexEvent ()
@@ -227,7 +227,7 @@ async def create_sub_questions_plan(
227227 "What are the user's preferences?",
228228 ]
229229 }}
230- Here is the user query: { await ctx .get ("original_query" )}
230+ Here is the user query: { await ctx .store . get ("original_query" )}
231231
232232 And here is the list of tools: { query_engine_tools }
233233 """
@@ -238,7 +238,7 @@ async def create_sub_questions_plan(
238238 response_obj = json .loads (str (response ))
239239 sub_questions = response_obj ["sub_questions" ]
240240
241- await ctx .set ("sub_question_count" , len (sub_questions ))
241+ await ctx .store . set ("sub_question_count" , len (sub_questions ))
242242
243243 for question in sub_questions :
244244 ctx .send_event (SubQuestionEvent (question = question ))
@@ -254,8 +254,8 @@ async def handle_sub_question(self, ev: SubQuestionEvent) -> AnswerEvent:
254254 response_mode = ResponseMode .SIMPLE_SUMMARIZE
255255 )
256256
257- react_agent = ReActAgent . from_tools ( query_engine_tools , llm = llm , verbose = True )
258- response = react_agent .chat ( ev .question )
257+ react_agent = ReActAgent ( tools = query_engine_tools , llm = llm , verbose = True )
258+ response = await react_agent .run ( user_msg = ev .question )
259259
260260 return AnswerEvent (question = ev .question , answer = str (response ))
261261
@@ -264,7 +264,7 @@ async def combine_and_interpret_answers(
264264 self , ctx : Context , ev : AnswerEvent
265265 ) -> OutputEvent | None :
266266 ready = ctx .collect_events (
267- ev , [AnswerEvent ] * await ctx .get ("sub_question_count" )
267+ ev , [AnswerEvent ] * await ctx .store . get ("sub_question_count" )
268268 )
269269 if ready is None :
270270 return None
@@ -294,7 +294,7 @@ async def combine_and_interpret_answers(
294294 ---
295295 Be concise yet comprehensive in your response.
296296
297- Original query: { await ctx .get ("original_query" )}
297+ Original query: { await ctx .store . get ("original_query" )}
298298
299299 Sub-questions and answers:
300300 { answers }
0 commit comments