Batch processing
Many jobs are the same task repeated over a list: read each invoice, summarise each email, classify each row. In NappAI you do not need a loop: you turn on Batch Mode in the component and it runs once for each item of the list it receives.
In this video, a flow processes the twelve supplier invoices in a folder: it reads each PDF, extracts its data with an agent, checks it with Python, and leaves a spreadsheet and a summary for accounting.
How it works
- Batch Mode is in the tab of the same name of every component that supports it. When it is on, the component shows the Batch Input input: that is where you connect the list.
- Each field can be Fixed (the same value for every item) or Mapped: you write a key of the item between braces, for example
{path}, and each run takes that item’s value. You can also mix text and keys:{Invoice {number} from {supplier}}. - After a run, the Previous execution panel shows a real item with its keys: drag one onto the field and it becomes mapped.
- Parallel Executions sets how many items are processed at a time (3 by default).
- The output of a batch component is another list, with one result per item. The next component can carry on in batch or take the whole list, for example to create a spreadsheet or write a summary.
The example in the video
- Storage Files, List Files operation: the PDFs in the
files/october-invoicesfolder of your storage. It returns a list. - Storage Files with Batch Mode, Get File operation: File Path mapped to
{path}and Content set to Text. It reads each PDF as text. - Agent with Batch Mode and structured output (Output Format tab): from each text it always returns the same fields (supplier, tax ID, number, date, category, net amount, VAT and total).
- Python Code with Batch Mode: it checks that the net amount plus VAT gives the total, that VAT is 21 % and that the invoice belongs to the month, and adds a
statusfield. - Two branches with the whole list: XLS Writer creates the spreadsheet and Storage Files (Upload Files) saves it in the same folder; Data to JSON and a Prompt hand every invoice to a second Agent, which writes the summary.
Show node outputs, in a component’s settings, shows its output as a table: one row per item.
Tips
- Try it first with a few items and look at the output table of each step.
- Calculations and checks are better in Python Code; leave to the agent what needs understanding the text.