ToolRetrieverRouterQueryEngine.query
method working with FunctionTool
? Because it tries to call a query_engine
attribute in FunctionTool
which doesn't exist... More details in the thread.def my_fn_a(param_a: int, param_b: str) -> str: """This is a fisrt test function.""" return "The result is {} and {}.".format(param_a, param_b) def my_fn_b(param_a: int, param_b: str) -> str: """This is a second test function.""" return "The result is {} and {}.".format(param_a, param_b) transaction_tools = [ FunctionTool.from_defaults(fn=my_fn_a), FunctionTool.from_defaults(fn=my_fn_b), ] tool_mapping = SimpleToolNodeMapping.from_objects(transaction_tools) transations_tool_index = ObjectIndex.from_objects( transaction_tools, tool_mapping, VectorStoreIndex, ) transactions_router_query_engine = ToolRetrieverRouterQueryEngine(transations_tool_index.as_retriever(similarity_top_k=1)) transactions_router_query_engine.query("The result is 1 and a.") # AttributeError: 'FunctionTool' object has no attribute 'query_engine'
ToolRetrieverRouterQueryEngine
to RouterQueryEngine
s query_engine_tools
FnRetrieverOpenAIAgent
using the transations_tool_index
, then I could pass this created agent
to a new QueryEngineTool
, that is the type accepted by the RouterQueryEngine
.transactions_agent = FnRetrieverOpenAIAgent.from_retriever( transations_tool_index.as_retriever(), verbose=True ) query_engine = RouterQueryEngine( selector=PydanticSingleSelector.from_defaults(), query_engine_tools=[ QueryEngineTool(query_engine=transactions_agent), q_tool, ], )