#310 — Create a document classification function
Repo: Twill-AI/twill-llm-engine State: closed | Status: done Assignee: meliascosta, Ahmad1809
Created: 2025-09-05 · Updated: 2025-09-29
Description
Caused by: https://twillpayments.atlassian.net/wiki/spaces/TD/pages/431915009/AI+powered+document+processing
In order to understand the documents uploaded by users and feed other features and pipelines. This feature should support classification of PDF, PNG, JPG files. The function also extracts a structured_info (JSON) field for each document that is dependent on the document class. This means this process happens in two steps:
- A first LLM call that extracts the category:
- A second specialized call (PROMT and STRUCTURED OUTPUT JSON SCHEMA)
AC:
- A new module
classifers.pyhas been added to the nlp folder in llm-engine - Possible document classes have been surveyed from sample user data and conversations with @TwillPayments. It should contain (but not be limited to) all of pay engine’s document classes
- A StrEnum class has been added to that module that lists all of the possible documents classes defined above
- An async function has been added to
classifiers.pythat takes a file as input and outputs one of the categories from the StrEnum class - The function also extracts the essence of the document, if it is statement uses specialized schema which already exists for statement analyzer otherwise it will extract all the data it can from the document and returns it as json
- A helper function (or functions) has been added to `
Notes
Add implementation notes, blockers, and context here
Related
Add wikilinks to related people, meetings, or other tickets