Download the PHP package blue-hex/laravel-docling-rag without Composer

On this page you can find all versions of the php package blue-hex/laravel-docling-rag. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-docling-rag

Document RAG for Laravel via Docling-serve, with Gotenberg as a conversion fallback

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Turns uploaded documents into cited, embeddable chunks backed by Postgres/pgvector, and exposes hybrid search to any laravel/ai agent. The package owns conversion, chunking, embedding, storage, and retrieval. The host app keeps its domain models, tenancy, auth, and agents.

Requirements

This package does not manage containers. Point config at URLs you already run. If you need help in getting started with Docker Compose, refer to the sample configuration below.

Sample Docker Compose

Installation

Enable the Gotenberg fallback and publish the example Compose file:

After embeddings land, build the search indexes (HNSW + GIN) at a time you choose — see Search indexes for why the timing matters:

Check Docling, Gotenberg (if enabled), and pgvector:

Configuration

Publish config/docling-rag.php and set:

An example Compose file ships as docker-compose.example.yml (docling-serve, plus gotenberg under the gotenberg profile).

Usage

Add the trait to the host model that owns documents:

Ingest a file. Re-uploads of the same bytes for the same owner are idempotent:

Native Docling formats (PDF, Office, HTML, Markdown, images, …) go straight to docling-serve hybrid chunking, streamed from disk rather than buffered into memory. Anything else goes through Gotenberg → PDF when enabled; otherwise ingestion raises UnsupportedFormatException. A .markdown extension is resubmitted to Docling as .md automatically — Docling only recognises .md, so this is transparent to callers.

Docling request options

config('docling-rag.docling.request_options') sets the default fields sent to Docling on every ingest — OCR, table mode, page range, tokenizer, anything from docling-serve's /v1/chunk/hybrid/file/async schema, keyed by its exact field name (convert_*, chunking_*):

Override per ingest — merged over the config default, per-call wins:

Options are not persisted — a manual re-ingest of a previously failed document (Rag::ingest() called again with the same bytes) needs options passed again if you want anything other than the config default.

Ownership and scoping

Every document is stored against a polymorphic owner, and both ingestion and search are scoped to a single owner — retrieval's WHERE is exactly owner_type = ? AND owner_id = ?. The package has no concept of a user; it trusts the owner you pass. That has two consequences worth internalising:

Tracking ingestion

Ingestion runs on the queue and moves a RagDocument through a status lifecycle:

The package fires two events, both carrying the RagDocument. They mark the terminal states — the document has finished, one way or the other:

Both are dispatched from queued jobs, so your listeners run in the worker — the right place for credits, tracing, notifications, or broadcasting to the UI:

Prefer a dedicated listener class for anything non-trivial:

Register it in your EventServiceProvider (or via auto-discovery) as you would any Laravel event.

For a live progress bar — the interim converting/chunking/embedding steps — there is no per-step event; read the column instead. Poll RagDocument::find($id)->status (a DocumentStatus enum) from your frontend, or broadcast each change yourself from the terminal listeners above. $document->status->isInFlight() is true for every non-terminal state.

Change embedding models with a deliberate re-embed, never a live mix:

Retrieval

Rag::search() runs hybrid search — vector and full-text retrievers fused with Reciprocal Rank Fusion in a single Postgres round-trip — scoped to one owner. It returns ChunkResults carrying the text, page_no, heading_path, content_type, and a fused score.

Narrow with metadata filters, cap the results, and enable rerank per call via config:

Search refuses to run when the configured embedding.model no longer matches the stored vectors (ModelMismatchException) — migrate with rag:reembed.

The SearchDocuments tool

Register the drop-in tool on your own agent. The package owns the tool description — how to phrase standalone queries, when to re-search, and that answers must cite page_no. The host binds the owner to scope it and keeps its own credits, tracing, and tenancy:

Test host agents without a vector database — Rag::fake() swaps search for canned results and records every call:

Search indexes

Rag::search() works with no indexes at all — Postgres falls back to a sequential scan, which is fine for a few hundred chunks. At real volume, rag:index is what keeps retrieval fast:

It creates the two indexes the hybrid query relies on, one per retriever:

Run it after embeddings land. Embedding happens asynchronously on the queue, so embedding is null until those jobs finish — there is nothing to index before then, and an index in place only adds write cost to every insert.

Run it at a time you choose. Building an HNSW index reads every vector and is CPU- and memory-heavy on a large table, so it is a deliberate command rather than a migration or a per-upload hook: run it once after a bulk ingest, off-peak, and rebuild after an rag:reembed that changes the model or dimensions. It uses CREATE INDEX IF NOT EXISTS, so re-running it is safe and idempotent.

Testing

The fast suite uses SQLite, Http::fake(), and Embeddings::fake(). Search correctness (RRF ordering, owner scoping, filters) needs real pgvector — those tests are tagged integration and skip unless RAG_PG_HOST (and the other RAG_PG_* vars) point at a Postgres + pgvector database. Set DOCLING_LIVE_URL to run the opt-in live Docling contract test.

Versioning

This package follows Semantic Versioning 2.0. The first public release is 0.1.0. While the major version is 0, the public API is not frozen.

The contract is the Rag facade, HasRagDocuments, SearchDocuments::for(), ChunkResult properties, the two events, published config keys, and the rag_documents / rag_chunks schema. Internal jobs, Docling HTTP details, and retrieval SQL may change in a patch.

Composer has no version field. Packagist reads git tags. Cut a tag named 0.1.0 (no v prefix) and a GitHub Release whose name is 0.1.0 so CHANGELOG stays in Keep a Changelog form. Submit the GitHub repo to Packagist once; later tags sync on their own.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-docling-rag with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
gotenberg/gotenberg-php Version ^2.25
illuminate/contracts Version ^12.0||^13.0
laravel/ai Version ^0.11
spatie/laravel-package-tools Version ^1.16
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package blue-hex/laravel-docling-rag contains the following files

Loading the files please wait ...