Find answers from the community

Updated 4 months ago

Hi all - I probably have a concept

At a glance
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:
Plain Text
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:

Plain Text
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?
e
L
2 comments
What I think I need is to create a query engine that just returns the Documents loaded by Papers/Pubmed? (ie, not based on any queried Index πŸ€” )?
If you want to use an agent, you can put the function tool directly in an agent

OpenAIAgent.from_tools([pubmed_tool], verbose=True)
Add a reply
Sign up and join the conversation on Discord