Skip to content

Commit 92cc528

Browse files
committed
only use query engine if index is not None
1 parent 346bce5 commit 92cc528

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

templates/components/multiagent/python/app/examples/researcher.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def _create_query_engine_tool() -> QueryEngineTool:
1414
"""
1515
index = get_index()
1616
if index is None:
17-
raise ValueError("Index not found. Please create an index first.")
17+
return None
1818
top_k = int(os.getenv("TOP_K", 0))
1919
query_engine = index.as_query_engine(
2020
**({"similarity_top_k": top_k} if top_k != 0 else {})
@@ -35,11 +35,12 @@ def _get_research_tools() -> QueryEngineTool:
3535
Researcher take responsibility for retrieving information.
3636
Try init wikipedia or duckduckgo tool if available.
3737
"""
38+
tools = []
39+
query_engine_tool = _create_query_engine_tool()
40+
if query_engine_tool is not None:
41+
tools.append(query_engine_tool)
3842
researcher_tool_names = ["duckduckgo", "wikipedia.WikipediaToolSpec"]
39-
# Always include the query engine tool
40-
tools = [_create_query_engine_tool()]
4143
configured_tools = ToolFactory.from_env(map_result=True)
42-
print(configured_tools)
4344
for tool_name, tool in configured_tools.items():
4445
if tool_name in researcher_tool_names:
4546
tools.extend(tool)

0 commit comments

Comments
 (0)