Find answers from the community

Updated 8 months ago

I construct my tools by doing the

I construct my tools by doing the following:
Plain Text
# create a set of tools on top of the query engine
query_engine_tools = [
    QueryEngineTool(
        query_engine=recursive_query_engine,
        metadata=ToolMetadata(
            name = 'document_type_finder',
            description = (
                '''
                This tool finds the type of document and outputs the answer. 
                This tool will look for obvious features in the document such as words like "invoice" or "tax invoice" for invoice and words like "purchase order", "sales order" for purchase order.
                Finally, this tool only outputs answer as "invoice" or "purchase order"
                '''
            )
        )
    ),
    QueryEngineTool(
        query_engine=recursive_query_engine,
        metadata=ToolMetadata(
            name = 'document_origin_finder',
            description = (
                '''
                This tool finds the country of origin of the document
                This finder will first identify the country of origin of the document sender by looking into its company name, address, or any other relevant information to derive the origin of country.
                Finally, this tool format the answer following to ISO 3166-1 alpha-3 and outputs it.
                '''
            )
        )
    )
]

# create a RAG ReAct QueryEngineTool agent
agent = ReActAgent.from_tools(tools=query_engine_tools, llm=llm, verbose=True)

response = agent.chat(
    '''
    What is the document type and origin? Use any of the tools provided to you.
    '''
)

I am not sure why but the agent thought process and answer is always about no document provided.

Plain Text
# output
>>>Thought: The user has not provided the document text for analysis. I need to ask for the document text to proceed with the analysis using the appropriate tool.
Answer: Could you please provide the text of the document you would like me to analyze for its type and origin?
L
d
g
6 comments
If you are using openai, I wouldn't use a react agent (use openai agent)

secondly, I think the thought process here is just related to your tool descriptions. From the descriptions, it seems like you need to provide some specific document name in order to use those tools. Tweak the descriptions and it should be better
wut now i find htis out
What do you mean by providing some specific document name? There's usually no title for document for purchase orders and invoices. Perhaps you mean including a brief description about the document and who is it from?
you should Purchase_orders or purchase_Invoice mroe specific
Ok let me try that
I'm thinking if there's any way for the tools to help me interpret whether is it purchase order or invoice kind of document type. Then based of what document type, the agent decides which tool to use
Add a reply
Sign up and join the conversation on Discord