Find answers from the community

e
emepyc
Offline, last seen 4 months ago
Joined September 25, 2024
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?
2 comments
L
e
Hi - I'm trying to understand the different types of nodes in llama_index.
I have a set of nodes coming from SentenceSplitter and I'm trying to synthesize using get_response_synthesizer:
Plain Text
query = "<query>"
nodes = SentenceSplitter().get_nodes_from_documents(documents)
synthesizer = get_response_synthesizer(response_mode="compact")
synthesizer.synthesize(query, nodes)

This gives me the error:
Plain Text
AttributeError: 'TextNode' object has no attribute 'node'

Does anyone know why is this error happening?
2 comments
e
L
Hi all! I have started looking at llama_index, read the docs, familiarised with the concepts etc. I have started to implement a demo that loads some csv data into a dataframe using PandasQueryEngine (from the llama-hub). It works well so far, but I want it to enhance it so I can ask questions about the document and more generally to the OpenAI model for more general / follow up questions. I haven't found a clear example on how to do this. Do you know of any tutorial or notebook showing how to achieve this?
4 comments
e
L
E