← All ivy-agents
IVYXSTUDIO · IVY AGENT
D

Document Q&A

ivy.agent.document-qa · v1.0.0

ivyx

Indexes every PDF in a folder and has a model answer a question from the passages closest to it.

Steps

In the order the agent's file lists them, each with where its inputs come from and the values the file fixes. A branch or a loop is a step too.

  1. 01
    Read the PDFs
    ivy.node.pdf-folder-text

    Extracts the text of every PDF in a folder, returning each document's text with its file name and all of it as one text.

    takes
    folder from the agent's input
    returns
    documents
    Ivy Node
  2. 02
    Clean the text
    ivy.node.text-normalizer

    Cleans text before chunking: Unicode composition, control characters removed, runs of whitespace collapsed, optional lowercasing.

    takes
    text from step 1
    Ivy Node
  3. 03
    Split into passages
    ivy.node.text-chunker

    Splits a long text document into overlapping chunks suitable for embedding and retrieval-augmented generation (RAG).

    takes
    text from step 2
    set
    chunk_size 500
    overlap 100
    Ivy Node
  4. 04
    Index the passages
    ivy.node.kb-index

    Embeds text chunks and stores them in a knowledge-base file that kb-search reads, returning how many chunks it holds.

    takes
    chunks from step 3
    set
    index_path kb/documents.json
    replace true
    returns
    chunks, index_path
    Ivy Node
  5. 05
    Find the closest passages
    ivy.node.kb-search

    Finds the chunks of a knowledge-base file closest in meaning to a question and returns them as context, best first, with their scores.

    takes
    index_path from step 4
    question from the agent's input
    set
    top_k 3
    returns
    sources
    Ivy Node
  6. 06
    Answer from the passages

    Answer the question using only the passages. If the passages do not contain the answer, say that the documents do not say. Answer in one or two sentences.

    takes
    context.question from the agent's input, question
    context.passages from step 5, context
    returns
    answer
    Model turn

What it touches

Collected from what each of its nodes declares, plus the model call when a step is a model turn. A declaration is the author's statement, and it is what policy rules select on.

Writes filesCalls a model

Inputs

FieldTypeDescription
folderrequiredstringThe folder to read PDFs from.
questionrequiredstringThe question to answer from the documents.

Outputs

FieldTypeDescription
answerstringThe model's answer, from the passages only.
sourcesarrayThe passages the answer was given, as {text, score}, best first.
documentsintegerHow many PDFs were read.
chunksintegerHow many passages the index holds.
index_pathstringThe knowledge-base file.

Tests

2 of 2 test cases passed on Oct 4, 2026, in the publisher's own environment, before this version was published. The registry keeps that record; it does not run the cases again.

Requires: python:3.9, a model core, the embedding model, downloaded on first use

  • refund-five-days

    Three policy PDFs: the refund period is read from the refund policy.

    given
    folder data/docs
    question How long does it take to get a refund?
    expects
    documents equals 3
    answer matches (5|[Ff]ive) business days
    index_path matches kb/documents\.json$
  • refund-ten-days

    Another folder states another period, so the answer comes from the folder given.

    given
    folder data/docs-b
    question How long does it take to get a refund?
    expects
    answer matches (10|[Tt]en) business days