定制 whilesmart/eloquent-idp 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

whilesmart/eloquent-idp

Composer 安装命令:

composer require whilesmart/eloquent-idp

包简介

Intelligent document processing for Laravel: turn an uploaded document into structured fields via a swappable, host-agnostic processor chain.

README 文档

README

Intelligent document processing for Laravel: turn an uploaded document (invoice, receipt, statement) into structured fields through a swappable processor chain. Each document is scoped to an owner (a workspace, organization, user) through whilesmart/eloquent-owner-access.

The package is host-agnostic. It does not hard-require an OCR service or an LLM: extraction and enrichment both sit behind contracts with null defaults, so it installs and tests without any external service.

Install

composer require whilesmart/eloquent-idp
php artisan migrate

Routes register automatically under the api prefix with auth:sanctum. Set IDP_REGISTER_ROUTES=false to mount them yourself.

Owning model

Add the trait to whatever owns documents:

use Whilesmart\Idp\Traits\HasDocuments;

class Workspace extends Model
{
    use HasDocuments;
}

$workspace->documents; // MorphMany<Document>

Endpoints

Method Path Purpose
GET /api/documents List (filter by owner_type+owner_id, kind, status)
POST /api/documents/process Create a document from an uploaded file or a source_path, then process it
GET /api/documents/{document} Show
DELETE /api/documents/{document} Soft delete

process accepts an owner (owner_type, owner_id), one of file or source_path, an optional kind, mime, and a schema array hinting the fields to extract.

How processing works

DocumentService::process($document, $contents, $filename, $schema):

  1. Picks the highest-priority DocumentProcessor whose supports($mime, $ext) returns true, or a null baseline when none does.
  2. Runs it to get a structured baseline, plus the raw extraction text when the processor implements ProvidesExtractionContext.
  3. Passes both through the bound ExtractionEnricher to produce the final extracted fields.
  4. Stores extracted, raw_text, status, and fires DocumentProcessed (or DocumentFailed).

Extraction engine

KreuzbergProcessor extracts text and tables via the Kreuzberg service (POST {base_url}/extract). It stays inert until idp.kreuzberg.base_url is set, so nothing hits the network in tests. Point it at a running instance:

KREUZBERG_BASE_URL=http://kreuzberg:8000
KREUZBERG_AUTH_TYPE=bearer
KREUZBERG_AUTH_CREDENTIALS=your-token-here

Register your own processor by resolving the manager and calling register($processor, $priority); a higher priority overrides the built-in engine for a type.

Enrichment

The default NullEnricher returns the baseline unchanged. To complete or validate fields with an LLM, bind your own implementation (the package does not require a specific LLM library):

use Whilesmart\Idp\Contracts\ExtractionEnricher;

$this->app->bind(ExtractionEnricher::class, PrismExtractionEnricher::class);

Events

DocumentProcessed and DocumentFailed carry the Document so the host can bridge results into its own systems.

Status

DocumentStatus: pending, processing, completed, failed. kind is a plain string, so new document kinds need no schema change.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固