Download the PHP package solution-forest/ai-kit-core without Composer
On this page you can find all versions of the php package solution-forest/ai-kit-core. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download solution-forest/ai-kit-core
More information about solution-forest/ai-kit-core
Files in solution-forest/ai-kit-core
Package ai-kit-core
Short Description Core of ai-kit: document ingestion, chunking, extraction, vector retrieval (sqlite-vec + pgvector), and RAG agents built on the official Laravel AI SDK.
License MIT
Informations about the package ai-kit-core
ai-kit-core
The engine of the ai-kit suite — document ingestion, chunking, extraction, vector retrieval, and RAG agents for Laravel, built on the official Laravel AI SDK.
composer require → php artisan ai-kit:install → a grounded, cited RAG assistant over your own documents — with no external vector database required.
- Two vector drivers behind one contract: SQLite (zero-infra, default) and pgvector (production).
- Two RAG modes via one config flag: tool (agentic) and inject (classic).
- Ingest PDF, Word (.docx), Excel (.xlsx), HTML, Markdown, plain text, and URLs.
- Provider-agnostic — OpenAI, Anthropic, OpenRouter, Gemini, Groq, Mistral, … (anything the AI SDK supports).
- Fully testable offline — no API keys needed in CI.
Why ai-kit?
Building a grounded, cited RAG chatbot over your own documents in Laravel means wiring together a dozen moving parts: parsing PDFs/Word/Excel, chunking text, generating embeddings, running a vector store, similarity search, prompt orchestration, streaming, citations, conversation history, and cost tracking.
ai-kit does all of that for you — on the official Laravel AI SDK, with no
external vector database. composer require → php artisan ai-kit:install →
a working, source-cited assistant in under 30 minutes. Then expose it however
you like: a Livewire chat widget, an admin panel, a JSON API, a CLI, or an MCP
server for AI agents.
Architecture
One core, four faces. Every surface calls the same service layer, so RAG behaviour is identical whether a user chats in the browser, you script the CLI, another service hits the API, or an AI agent connects over MCP.
Requirements
- PHP 8.3+
- Laravel 12 or 13
laravel/ai^0.9
Install
The installer:
- Publishes
config/ai-kit.php+ migrations (including the AI SDK's conversation tables). - Interactively asks for your AI provider config (chat + embeddings provider/model/key) and writes it to
.env. - Scaffolds
App\Ai\SupportAgent(extendsRagAgent). - Runs migrations.
- Optionally seeds a demo knowledge base.
Then set your keys (the installer adds the scaffold; fill in the value):
Quick start
Or from the CLI:
How ingestion works
- Synchronous (
sync: true) — runs inline; used byai-kit:demoand CLI. No queue worker needed. - Queued (default) — dispatches a chained
ExtractText → ChunkDocument → EmbedChunksbatch; document status movespending → processing → indexed(orfailed).
Every chunk stores its raw embedding and the embedding model name, so re-indexing with a different model is detectable and you can switch drivers without re-embedding blindly.
Supported document types
| Type | Extractor | Notes |
|---|---|---|
.txt .md .csv |
PlainTextExtractor |
|
.html |
HtmlExtractor |
strips script/style/boilerplate |
.pdf |
PdfExtractor |
via smalot/pdfparser |
.docx |
WordExtractor |
zero-dependency (zipped XML) |
.xlsx |
ExcelExtractor |
zero-dependency; extracts text cells |
| URL | fetch + HtmlExtractor |
createFromUrl / ai-kit:ingest-url |
Legacy binary .doc / .xls are not supported.
Two RAG modes
config('ai-kit.mode'):
tool(default) — the agent gets aSearchKnowledgeBasetool and decides when/what to search (agentic RAG; supports multi-hop). Requires a model with reliable tool-calling.inject— no tool;ContextInjectorretrieves and prepends context to the prompt before the model runs (classic RAG). Grounding never depends on the model choosing to search — safer with small models.
Both consume the same Retriever contract.
Two vector drivers
config('ai-kit.retrieval.driver'):
sqlite(default) — uses the sqlite-vec (vec1) extension when present, otherwise an exact pure-PHP cosine scan (correct everywhere, zero setup — ideal for demos and small/medium corpora). Optional extension path:AI_KIT_SQLITE_VEC_PATH.pgvector— avectorcolumn indexed with HNSW/IVFFlat, searched with the<=>cosine operator. Scales to millions of chunks.
Building agents
RagAgent reads config and wires the configured chat provider/model into every prompt() / stream():
Customise instructions by extending it (the installer scaffolds this):
Point AI_KIT_AGENT=App\Ai\SupportAgent at it. The default instructions are strict-grounded (search-first, refuse-if-unsupported, cite by document title).
Conversation persistence & token usage
When a prompt runs for an authenticated participant (->forUser($user) / ->continue($id, $user)), the AI SDK persists the exchange to agent_conversations / agent_conversation_messages, including per-message token usage. Aggregate it with UsageStats:
Cost is estimated from config('ai-kit.pricing') ($ per 1M tokens, per model) using the active chat model's rate.
Multi-tenancy
Every table has a nullable tenant_id. Scope models + retrieval:
Enable with AI_KIT_TENANCY=true.
Contracts (swap any layer)
| Contract | Default | Bind your own via the container |
|---|---|---|
Retriever / VectorIndex |
SqliteVecRetriever / PgVectorRetriever |
custom store |
Embedder |
AiSdkEmbedder |
e.g. a local embedder |
Chunker |
RecursiveTextChunker |
custom splitting |
TextExtractor |
ExtractorManager |
add extractors |
Configuration reference
config/ai-kit.php: mode, default_collection, agent (class + instructions), chat (provider/model/fallback/streaming), embeddings (provider/model/dimensions/cache/timeout), chunking (size/overlap), retrieval (driver/top_k/min_score/sqlite/pgvector), ingestion (queue/embed_batch), tenancy, database (connection/prefix), features (dashboard/token_usage), pricing. Every value has an env() override.
Commands
| Command | Purpose |
|---|---|
ai-kit:install |
Publish config/migrations, configure AI providers, scaffold agent |
ai-kit:demo |
Seed a demo collection + 3 sample docs (sync) |
ai-kit:ingest {path} --collection= |
Ingest a file or directory |
ai-kit:ingest-url {url} --collection= |
Fetch + ingest a web page |
Headless surfaces (CLI · HTTP API · MCP)
Everything the Filament panel does is reachable without Filament. All four
surfaces call the same service layer (ChatService, CollectionService,
DocumentService), so behaviour is identical everywhere.
CLI
| Command | Purpose |
|---|---|
ai-kit:collection {list\|new\|show\|delete} |
Manage knowledge bases (--json) |
ai-kit:document {list\|chunks\|reindex\|delete} |
Manage documents (--collection, --json) |
ai-kit:search {query} --collection= |
Raw retrieval, no LLM (--json) |
ai-kit:chat {collection} |
Interactive grounded chat REPL |
ai-kit:conversation {list\|show} |
Conversation log + token usage (--json) |
ai-kit:stats |
Documents/chunks/tokens/cost (--json) |
HTTP API (optional)
Enable with AI_KIT_API=true. Locked behind auth by default
(config('ai-kit.api.middleware') = ['api','auth:sanctum']); set your own guard,
or ['api'] for public. Prefix: AI_KIT_API_PREFIX (default api/ai-kit).
MCP server (optional)
Expose ai-kit to MCP clients (Claude Desktop, IDE agents). Requires
composer require laravel/mcp, then AI_KIT_MCP=true. Tools: search_knowledge_base,
ask_knowledge_base, list_collections, ingest_url. Serve over stdio:
Set AI_KIT_MCP_WEB=true to also register an HTTP transport route
(config('ai-kit.mcp.web_route'), guarded by mcp.web_middleware).
Examples
HTTP API (Bearer auth by default):
MCP — point a client (e.g. Claude Desktop) at the stdio server:
Programmatic (any surface, same result):
Testing
The suite runs offline with no API keys — LLM calls use the AI SDK's fakes, embeddings use a deterministic in-memory double.
The ai-kit suite
One core, four faces — the Livewire UI, CLI, HTTP API, and MCP server all
call the same service layer (ChatService, CollectionService,
DocumentService), so behaviour is identical everywhere.
| Package | Purpose |
|---|---|
| solution-forest/ai-kit-core (this) | Ingestion, retrieval, agents + CLI, HTTP API, MCP |
| solution-forest/ai-kit-ui-livewire | Livewire 4 chat component |
| solution-forest/ai-kit-filament | Filament v5 admin panel |
ai-kit-ui-livewire and ai-kit-filament are optional; core is fully usable headless.
License
MIT © SolutionForest
All versions of ai-kit-core with dependencies
illuminate/contracts Version ^12.0|^13.0
illuminate/database Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0
illuminate/http Version ^12.0|^13.0
illuminate/bus Version ^12.0|^13.0
laravel/ai Version ^0.9
laravel/prompts Version ^0.3.6
smalot/pdfparser Version ^2.7