Skip to content

Commit cf54005

Browse files
committed
fix: update deprecated methods
1 parent 3585f6f commit cf54005

3 files changed

Lines changed: 3193 additions & 10 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ cython_debug/
165165
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166166
# and can be added to the global gitignore or merged into this file. For a more nuclear
167167
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
168-
#.idea/
168+
.idea/
169169

170170
# Ruff stuff:
171171
.ruff_cache/

samples/travel-helper-RAG-agent/main.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import time
33

44
from 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
66
from llama_index.core.response_synthesizers.type import ResponseMode
77
from llama_index.core.tools import QueryEngineTool, ToolMetadata
88
from llama_index.core.workflow import (
@@ -24,7 +24,7 @@
2424
company_policy_files_directory = "sample_data/company_policies"
2525
personal_preferences_files_directory = "sample_data/personal_preferences"
2626

27-
llm = UiPathOpenAI()
27+
llm = UiPathOpenAI(model="gpt-4o-2024-11-20")
2828
uipath = 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

Comments
 (0)