Download the PHP package hudhaifas/silverstripe-ai without Composer

On this page you can find all versions of the php package hudhaifas/silverstripe-ai. 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 silverstripe-ai

silverstripe-ai

AI-powered features for SilverStripe 5: a context-aware chatbot agent and a human-in-the-loop content generation system.


What you get out of the box


How it works

Agent Widget

Content Widget


Quick start

1. Install

Set your API keys in .env:

2. Configure default models in the CMS

Go to Settings → AI and pick a free-tier model (e.g. gpt-4o-mini) and a paid-tier model (e.g. claude-sonnet-4-5). Models are seeded automatically on dev/build.


What's auto-configured

The module auto-applies these via YAML — no manual setup required:

Component Auto-applied to Purpose
MemberAIExtension Member Credit management, model selection, usage tracking
SiteConfigAIExtension SiteConfig Default model configuration in Settings → AI
API routes /api/ai/agent/*, /api/ai/content/* REST endpoints
Cache backends ChatHistoryInterface, PersistenceInterface Conversation history + HITL state

You only need to create your custom agents, tools, and content extensions.


Agent Widget

1. Create your agent

2. Register the mapping

3. Add the widget to your page

Include $AgentWidget in your template and the JS/CSS loads automatically.

Template example:

The widget reads data-entity-class, data-entity-id, and data-entity-name from the template context.

4. Create tools

Tools are PHP classes that the LLM can call. Each tool defines its name, description, parameters, and execution logic.

Read-only tool (runs immediately):

Write tool (requires HITL approval):

Tools listed in ToolApproval middleware will pause for user confirmation before __invoke() runs.


Content Widget

1. Create a content extension

Extend ContentExtension and implement the four required methods:

2. Apply the extensions

Include $ContentWidget in your template.

Template example:

The content widget requires explicit template variables. Create a method in your controller or use a custom include:

3. Batch generation (skip review)

For bulk operations where you don't want HITL interrupts:


Human-in-the-Loop (HITL)

Agent HITL

HITL is driven by ToolApproval middleware attached to ToolNode::class. No code is needed inside the tool itself — the interrupt is automatic.

When the LLM calls a tool listed in ToolApproval, the agent pauses before executing it and returns a resume_token plus a description of the pending action. The frontend shows a confirmation card. The user approves or rejects. A POST to /api/ai/agent/resume continues the workflow.

The agent's summariseAction() method generates the human-readable description shown in the confirmation card. Override it in your subclass to customise the message per tool.

Content HITL

Generated content always pauses for review (unless skipReview: true). The workflow returns a resumeToken and the generated content. Users can:


API Routes

All endpoints are under /api/ai/:

Endpoint Method Description
/api/ai/agent/chat POST Send a message to the agent
/api/ai/agent/resume POST Resume after HITL approval/rejection
/api/ai/content/generate POST Generate content for an entity
/api/ai/content/resume POST Resume with user decision (approve/edit/reject)
/api/ai/content/save POST Save manually edited content (no AI)

Request/Response formats

Agent chat:

Agent resume:

Content generate:

Content resume:


Storage backends

Out of the box, conversation history and HITL workflow state are stored in SilverStripe's built-in cache pool ( silverstripe-cache/). This works on any shared hosting or server without Redis.

Optional: Redis

If you want persistent history that survives PHP-FPM restarts, or you're running multiple web nodes, swap to Redis:

RedisChatHistory and RedisPersistence require hudhaifas/silverstripe-cache-helpers (which provides the Redis connection).

Custom backend

Both backends are resolved through the SilverStripe Injector, so you can bind any implementation:


Credit system

Each member gets a configurable free monthly credit allowance (default $2.00). When free credits run out, the agent automatically falls back to the free-tier model. Members can purchase additional credits to unlock the paid-tier model.

Admins can override the model per-member and top up credits from the CMS member record.


CMS Admin UI

Model Usage Statistics

Track cost, tokens, and cache metrics per model over time.

Member AI Credits

Manage per-member usage, free/purchased credits, and model overrides.


Prompt caching (Anthropic)

When using an Anthropic model, the static part of your system prompt (getStaticInstructions()) is automatically cached. On repeated requests within 5 minutes, cache hits cost ~90% less than regular input tokens. No configuration needed.


Environment variables

Variable Description Default
OPENAI_API_KEY OpenAI API key
ANTHROPIC_API_KEY Anthropic API key
AI_VERBOSE_LOGGING Log full NeuronAI traces true

Configuration reference

Session locking

By default the controller does not call session_write_close() before dispatching to the agent. If you use PHP file-based sessions and notice other browser tabs blocking during long agent calls, enable this:

Not needed when using database or Redis sessions.


Requirements

Optional:


License

BSD-3-Clause


All versions of silverstripe-ai with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
silverstripe/framework Version ^5.0
neuron-core/neuron-ai Version ^3.0
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 hudhaifas/silverstripe-ai contains the following files

Loading the files please wait ...