@ekwo-ai/ 读取文档
一名读者收到发票。 结构化电子发票——CII、UBL、PDF
载有Factur-X或ZUGFERD XML的正文。 照片或一张
普通PDF 由视觉模型读取 你们 电话,与JSON计划
此软件包发布时, 请检查它的答案 。 两者
以相同的EN 16931格式抵达 ReceivedInvoice,成为同一购买
草案.
麻省理工学院. 没有数据库,没有网络,没有模式调用: 软件包读取字节和 JSON,并返回对象.
npm install @ekwo-ai/document-reading
如何一个产品链
import {
READING_VERSION,
purchaseDraftOf,
readStructured,
readingOf,
readingPrompt,
readingSchema,
} from '@ekwo-ai/document-reading';
// 1. A structured e-invoice is read exactly, and no model is called.
const structured = await readStructured(bytes);
let invoice = structured?.invoice;
// 2. Anything else is read by a vision model: one call, one schema.
if (invoice === undefined) {
const answer = await yourModel({
system: readingPrompt(),
file: bytes, // the image or the PDF, as your provider takes it
format: { type: 'json_schema', schema: readingSchema() },
});
const reading = readingOf(JSON.parse(answer.text));
// reading is undefined when the page is not a purchase document.
invoice = reading?.invoice;
log({ reading: READING_VERSION, missing: reading?.missing, rejected: reading?.rejected });
}
// 3. The draft of a purchase, in the columns of Ekwo OS.
if (invoice !== undefined) {
const draft = purchaseDraftOf(invoice);
// Choose the supplier, the account and the tax in your books, then create_document.
}
模型呼叫,它的钥匙, 它的超时 和测量停留在 产品. 此软件包名称不包含提供者, 也不包含任何秘密; 计划是 简单的 JSON 方案,每个对象和所需的所有财产都关闭 主要提供者的结构化产出.
确切路径 : readStructured(bytes, options?)
以第一个字节向 XML 显示一个PDF,以根向 UBL 显示 CII,以及
读取 readFacturX() 编号 : readCii() 联 合 国
@ekwo-ai/factur-x 或者说 readUbl() 联 合 国
@ekwo-ai/peppol-ubl返回
{ invoice, violations },或 undefined 用于保存不的文件
电子发票——一张照片,没有XML的PDF,不是发票的XML,
一个超过极限的文件——所以来电者是用相反的方式读取. 读者
当文件需要时,会导入它们.
模式路径 : readingSchema(), (中文(简体) ), readingPrompt(), (中文(简体) ), readingOf()
模特儿被告知 复制,永远不要计算,然后 倒数空出 而不是猜测。它返回打印的:
- 页面是什么:
invoice, (中文(简体) ),credit_note, (中文(简体) ),receipt(已支付),或other(读作一无所取); - 数字、发行、到期日期和纳税点日期以及货币 作为 打印 ——在页上打印出无,从不打印出货币的空白 国家;
- 供应商和客户:法定名称和商品名称、增值税标识符, 登记号、地址;
- 参考资料(客户、订单、合同、发票、信用证) (a) 发票期、IBAN、BIC、付款范围和条款;
- 每行:名称、说明、数量、印刷单位及其联合国/欧洲经委会 建议20 代码、净价格、净金额、增值税类别(UNTDID 5305) 及其期限;
- 汇总的每组增值税:类别、税率、基数、税额、金额 包括印刷税;
- 总计:行,不含增值税,增值税,有增值税,预付,应付; 2;
- 信心(
high, (中文(简体) ),medium, (中文(简体) ),low用于每个字段CONFIDENCE_FIELDS,用于每行.
readingOf(answer) 检查成一个 ReceivedInvoice 与
syntax: 'model',并返回旁边:
| 外地 | 它所持有的 |
|---|---|
missing | EN 16931字段要求页面不按路径打印(number, (中文(简体) ), totals.payable, (中文(简体) ), lines[2].net_amount) (中文(简体) ). 每个都是 '' 在发票中. |
rejected | 模型中填满了非外形的东西的字段——这个日期是没有一天的,是用文字表示的速度. 各入虚空. |
violations | EN 16931的算术显示印刷数字断裂,仅在所读数字全部被读取时检查. |
confidence | 按字段和行lines[n], (中文(简体) ), null 模特儿说没什么用. |
taxInclusiveByGroup | 按增值税类别,包括按EN 16931不携带的页印征税的数额. |
extension | 召者自有田地,未发. |
没有计算、默认或更正任何内容:未打印的总数 保持空位, 单个逗号被读作小数分隔符和任何东西 这不是一个小数 被拒绝.
扩展计划
需要超过发票的呼叫者会增加自己的财产,请参见: 同一电话:
const extension = {
properties: {
meter: { type: 'string', description: 'The meter number, as printed.' },
contract_type: { type: 'string', description: 'The contract type, as printed.' },
},
instructions: 'The meter number is printed near the address of supply.',
};
const schema = readingSchema(extension); // adds a closed `extension` object
const prompt = readingPrompt(extension); // adds the instructions after the package's words
const reading = readingOf<{ meter: string; contract_type: string }>(answer);
reading?.extension; // as the model answered it: check your own fields
发票读了一次,扩展的字段又回到旁边 pDF 从来没有第二次读取.
采购草案: purchaseDraftOf(invoice)
领域 documents 财务报告和审定财务报表 document_lines ekwo 操作系统,从任一路径:
doc_type(单位:千美元)purchase_invoice或者说purchase_credit_note,日期,日期,日期 供应商编号为supplier_reference, (中文(简体) ),currency_code(没有它在哪里) 参考文献,payment_reference, (中文(简体) ),payee_iban· ;- 在联系人或 添加;
- 每行一行,然后每行一行津贴(负数)或收费
整个文件,每个文件及其
unit_code,其增值税类别和税率.
一行保留其数量、单位代码和价格,按其数额计算
其货币的十进制 amount_untaxed 计算
1234 kWh × 0.1834 = 226.3156,哪个回合 226.32 已打印过.
否则,它是一个单位(C62(按金额计算,发票是自己的)
数字输入 attributes (单位:千美元)invoiced_quantity, (中文(简体) ), invoiced_unit_code, (中文(简体) ),
invoiced_net_price) (中文(简体) ). 一行的时期进入 attributes 作为
period_start 财务报告和审定财务报表 period_end;发票的期间为每行
并返回为 invoicing_period。 。 。 .
供货商、账户和税收由打电话者自行选择 书籍和乡村包:这个包没有图表,也没有费率.
许可证
麻省理工学院. 见 LICENSE。 。 。 .