|
10 | 10 | ) |
11 | 11 | from llama_index.core.agent.workflow import ReActAgent |
12 | 12 | from llama_index.core.workflow import Context |
13 | | -from llama_index.core.tools import QueryEngineTool, ToolMetadata |
| 13 | +from llama_index.core.tools import QueryEngineTool |
14 | 14 | from llama_index.embeddings.bedrock import BedrockEmbedding |
15 | 15 | from llama_index.llms.bedrock_converse import BedrockConverse |
16 | 16 |
|
@@ -71,9 +71,10 @@ def create_query_engine_tool(query_engine, name, description): |
71 | 71 | Returns: |
72 | 72 | QueryEngineTool: A tool that can be used by the ReActAgent. |
73 | 73 | """ |
74 | | - return QueryEngineTool( |
| 74 | + return QueryEngineTool.from_defaults( |
75 | 75 | query_engine=query_engine, |
76 | | - metadata=ToolMetadata(name=name, description=description), |
| 76 | + name=name, |
| 77 | + description=description, |
77 | 78 | ) |
78 | 79 |
|
79 | 80 |
|
@@ -109,22 +110,20 @@ async def main(): |
109 | 110 | ] |
110 | 111 |
|
111 | 112 | # Create a ReActAgent with the query engine tools |
112 | | - # Using ReActAgent from workflow module |
113 | 113 | agent = ReActAgent( |
114 | 114 | tools=query_engine_tools, |
115 | 115 | llm=Settings.llm, |
116 | 116 | verbose=True, |
117 | 117 | ) |
118 | 118 |
|
119 | | - # Create a context to store the conversation history/session state |
| 119 | + # Create a context to hold this session/state |
120 | 120 | ctx = Context(agent) |
121 | 121 |
|
122 | 122 | # Use the agent to answer a question |
123 | 123 | print("Starting agent query...") |
124 | 124 | print("=" * 60) |
125 | | - response = await agent.run( |
126 | | - "Compare revenue growth of Uber and Lyft from 2020 to 2021", ctx=ctx |
127 | | - ) |
| 125 | + handler = agent.run("Compare revenue growth of Uber and Lyft from 2020 to 2021", ctx=ctx) |
| 126 | + response = await handler |
128 | 127 | print(str(response)) |
129 | 128 |
|
130 | 129 |
|
|
0 commit comments