Hi all - I probably have a concept misunderstanding and I'd greatly appreciate any help in clariying these concepts for me.
I'm loading some data using a Llama hub loader (
Papers/Pubmed)
I'm then creating a tool using the
FunctionTool
:
from llama_index.tools.function_tool import FunctionTool
def get_pubmed_documents(search_query: str):
"""
Given a search query returns a list of pubmed documents
"""
PubmedReader = download_loader("PubmedReader")
loader = PubmedReader()
return loader.load_data(search_query=search_query)
pubmed_tool = FunctionTool.from_defaults(fn=get_pubmed_documents)
My first question is to understand if this is the right pattern (or an antipattern?) for using loaders that wraps search engines and can be used without indexing or query retrievers.
I'd then like to create an agent that is able to use this Tool when the query is about pubmed artices - I understand a
SubquestionQueryEngine
is the right way to create such types of agents - but my Tool is not a
QueryEngine
:
from llama_index.query_engine import SubQuestionQueryEngine
sub_query_engine = SubQuestionQueryEngine.from_defaults(
query_engine_tools=[...],
verbose=True,
)
How can I use my
pubmed_tool
in an agent able to use it based on the query?