项目简介
Documind
是一种先进的文档处理工具,利用人工智能从 PDF 中提取结构化数据。它旨在处理 PDF 转换、提取相关信息以及按照可自定义模式指定的格式设置结果。
这个存储库是建立在 Zerox 之上的 - https://github.com/getomni-ai/zerox 。Zerox 的 MIT 许可证包含在核心文件夹中,并且也在根许可证文件中提到。
特征
尝试托管版本🚀
documind
托管版本的演示即将推出供您试用!托管版本通过完全托管的 API 提供无缝体验,因此您可以跳过设置并立即开始提取数据。
要完全访问托管服务,请请求访问权限,我们将为您进行设置。
要求
在使用
documind
之前,请确保安装了以下软件依赖项:
系统依赖
在继续之前,请在您的系统上安装两者:
brew install ghostscript graphicsmagick
sudo apt-get update
sudo apt-get install -y ghostscript graphicsmagick
Node.js 和 NPM
确保您的系统上安装了 Node.js (v18+) 和 NPM。
安装
您可以通过 npm 安装
documind
:
环境设置
documind
需要
.env
文件来存储敏感信息,例如您的 OpenAI API 密钥。
Create an
.env
file in your project directory and add the following:
在项目目录中创建一个
.env
文件并添加以下内容:
OPENAI_API_KEY=your_openai_api_key
用法
基本示例
首先,导入
documind
并定义您的架构。该架构概述了
documind
应在每个文档中查找哪些信息。这是一个快速入门的设置。
1. 定义模式
该架构是一个对象数组,其中每个对象定义:
银行对账单的示例架构:
const schema = [
{
name: "accountNumber",
type: "string",
description: "The account number of the bank statement."
},
{
name: "openingBalance",
type: "number",
description: "The opening balance of the account."
},
{
name: "transactions",
type: "array",
description: "List of transactions in the account.",
children: [
{
name: "date",
type: "string",
description: "Transaction date."
},
{
name: "creditAmount",
type: "number",
description: "Credit Amount of the transaction."
},
{
name: "debitAmount",
type: "number",
description: "Debit Amount of the transaction."
},
{
name: "description",
type: "string",
description: "Transaction description."
}
]
},
{
name: "closingBalance",
type: "number",
description: "The closing balance of the account."
}
];
2.运行documind
使用
documind
通过传递文件 URL 和架构来处理 PDF。
import { extract } from 'documind';
const runExtraction = async () => {
const result = await extract({
file: 'https://bank_statement.pdf',
schema
});
console.log("Extracted Data:", result);
};
runExtraction();