Skip to content

AI Prompt Functions

Info

New in Atfinity 17.

Two places render Jinja for an AI model rather than for a document: the Jinja prompt of an AI Prompt rule action, and the problem description of an AI Case Check. Both get one extra function on top of the functions available everywhere else. It is not available in an ADX document template.

document_text(file_information_value, position=None)

Puts the extracted text of an uploaded document into the prompt, so the model can read what a document says rather than only the values captured beside it. It takes a file information, and optionally which of that information's files to read:

The passport reads: {{ document_text(p.passport_copy) }}
Flag if the name on it differs from {{ p.first_name }} {{ p.last_name }}.
Argument Constraint
file_information_value A file information. A value that holds no file contributes no text.
position Which file to read, counting from 1 in upload order. Left out, it reads the file uploaded last. A position past the number of uploaded files contributes no text. A position below 1 is reported as a configuration inconsistency.

When the text is not there yet

Extraction runs after a file is uploaded, so a prompt can be rendered before the text exists. The two callers handle that differently.

An AI Case Check does not run at all. It waits while extraction is still running, reports that it is waiting for a document when the case has no document to read, and is otherwise marked as not run, saying the documents it reads have not been read yet. It never reaches the model on a description whose document text is missing.

An AI Prompt rule action has no such guard. It sends the prompt with the document text left empty, and the model answers on whatever else the prompt contains, so guard the rule's own condition if that is not what you want.