Download the PHP package byte5/ai-entry-embeddings without Composer
On this page you can find all versions of the php package byte5/ai-entry-embeddings. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download byte5/ai-entry-embeddings
More information about byte5/ai-entry-embeddings
Files in byte5/ai-entry-embeddings
Package ai-entry-embeddings
Short Description Statamic addon for generating AI vector embeddings from entry content.
License GPL-3.0-or-later
Informations about the package ai-entry-embeddings
AI Entry Embeddings
AI Entry Embeddings is a Statamic addon that automatically extracts content from entries, splits it into meaningful chunks with metadata, and generates vector embeddings using Laravel AI SDK. Designed for building RAG (Retrieval-Augmented Generation) search experiences on top of your Statamic content.
How It Works
When an entry is saved in Statamic:
- The extraction pipeline walks through configured fields, producing
ContentChunkobjects -- each with the extracted text, the originating field handle, a dot-notation path (e.g.page_builder.pricing_block.0), and structured metadata. - Chunks are stored in the
ai_entry_embeddingsPostgreSQL table, replacing any previous chunks for that entry. - A queued job calls the Laravel AI SDK to generate vector embeddings for each chunk and writes them back to the database.
The result is a table of chunk-level embeddings you can query with pgvector for similarity search, knowing exactly which section of which entry matched.
Requirements
- PHP 8.3+
- Statamic 6.0+
- PostgreSQL with the pgvector extension
- A configured embedding provider via Laravel AI (e.g. OpenAI)
Installation
Publish the configuration file:
Run migrations (this will enable the pgvector extension and create the ai_entry_embeddings table):
Configuration
The configuration file is published to config/ai-entry-embeddings.php.
Collections and Fields
You must explicitly list which collections and fields to extract. Nothing is extracted by default -- this prevents accidentally exposing sensitive data to the AI.
To use a custom extractor for a specific field, pass an array of extractor classes:
Embedding Dimensions
This value is used both during migration (to size the database column) and at runtime (when calling the embedding API). Changing it after the initial migration requires a new migration to alter the column size, and all existing embeddings must be regenerated since vectors of different dimensions are incompatible.
Only Published
When enabled (default), draft entries are skipped:
Field Type Extractors
The addon ships with extractors for common Statamic field types:
| Field Type | Extractor | Behavior |
|---|---|---|
text |
ExtractTextField |
Returns the raw string value |
textarea |
ExtractTextField |
Returns the raw string value |
markdown |
ExtractMarkdownField |
Converts Markdown to HTML, then strips to plain text |
bard |
ExtractBardField |
Splits prose and sets into separate chunks |
replicator |
ExtractReplicatorField |
One chunk per set, with nested field extraction |
grid |
ExtractGridField |
One chunk per row, with nested column extraction |
select |
ExtractSelectField |
Returns the option label(s) |
You can override or add mappings in the default_field_extractors config key.
Field types listed in ignored_field_types (e.g. toggle, assets, date) are never extracted.
Extending
Custom Field Extractor
Implement FieldExtractorInterface and return an array of ContentChunk objects:
Register it either globally in config:
Or per-field in a collection:
Events
| Event | When | Payload |
|---|---|---|
ContentExtracted |
Chunks were successfully extracted | ExtractionPayload |
EmptyExtractionCompleted |
Extraction completed with zero chunks | ExtractionPayload |
Control Panel
The addon registers a navigation section under AI Tools in the Statamic control panel, with a landing page and an embeddings overview. Access is gated by the view AI entry embeddings permission.
License
This addon is open-sourced software licensed under the GNU General Public License v3.0 (GPL-3.0). See LICENSE for details.