Skip to content

Agents, RAG & Public Chat Widget

AI provides a complete Retrieval-Augmented Generation (RAG) and tool-calling agent runtime for both internal admin workflows and public-facing visitor chat.

Vector Stores & Semantic Indexing (ai:index)

Section titled “Vector Stores & Semantic Indexing (ai:index)”

Choose your vector store backend in Setup -> AI -> Routing & Governance -> Vector Storage:

Vector Store Class Storage Backend Best For
SqliteVectorStore (default) site/assets/cache/ai/vectors.sqlite (ai_vectors) Zero-infrastructure single-server ProcessWire sites.
NeuronFileVectorStore Local filesystem JSON/vector index Small catalogs without SQLite vector needs.
QdrantVectorStore External Qdrant HTTP server (SSRF-validated) Large multi-million-chunk catalogs and multi-node deployments.
InMemoryVectorStore Ephemeral PHP memory Automatic backend whenever Ai::fake() is active in automated tests.

Index ProcessWire pages or Entries records synchronously or through VectorIndexQueue:

Terminal window
php vendor/bin/wire ai:index --type=pages --template=yacht --limit=200 --queue --json
php vendor/bin/wire ai:index --type=entries --blueprint=charter-routes --force --json

Tool-Calling Agents (AgentRunner & AbstractAssistant)

Section titled “Tool-Calling Agents (AgentRunner & AbstractAssistant)”

Scaffold a version-controlled PHP assistant in site/ai/assistants/ with make:assistant:

Terminal window
php vendor/bin/wire make:assistant AegeanConcierge --task=writing --tier=balanced --title="Aegean Concierge"

Extend Totoglu\Ai\Assistant\AbstractAssistant (see site/modules/Ai/examples/real-world/aegean-concierge-assistant.php) and run it programmatically via AgentRunner:

$ai = Ai::requireInstance($wire);
$reply = $ai->runAgent('aegean-concierge', 'Which 4-cabin gulets depart from Gocek in July?', [
'locale' => 'en',
'maxSteps' => 4,
]);
echo $reply->text();

Extending CapabilityRegistry (AiCapabilityProviderInterface)

Section titled “Extending CapabilityRegistry (AiCapabilityProviderInterface)”

Agents and MCP clients discover tools through CapabilityRegistry. Three providers ship out of the box:

  • PagesCapabilityProvider: Read/search ProcessWire pages respecting $page->viewable() and allowed templates.
  • EntriesCapabilityProvider: Query and inspect Entries blueprints respecting entry permissions.
  • KnowledgeCapabilityProvider: Perform semantic vector similarity search over indexed content.

Register your own domain tools (such as live charter availability lookup) by implementing AiCapabilityProviderInterface, tagging each tool with a RiskClass (read, propose, write, destructive), and hooking Ai::registerCapabilities (see site/modules/Ai/examples/real-world/custom-capability-provider.php).

Public Visitor Chat Widget (ChatWidgetRenderer & PublicChatEndpoint)

Section titled “Public Visitor Chat Widget (ChatWidgetRenderer & PublicChatEndpoint)”

Enable visitor chat in Setup -> AI -> Routing & Governance -> Frontend Visitor Chat, choose a grounded public assistant (such as knowledge-assistant or aegean-concierge), and render the self-contained frontend widget (dist/AiChatFrontend.{js,css}) in your template:

<?php echo $this->wire()->ai->renderChatWidget([
'assistant' => 'knowledge-assistant',
'title' => 'Aegean Voyages Concierge',
'placeholder' => 'Ask about yachts, routes, or Gocek departures...',
]); ?>

PublicChatEndpoint automatically serves three rate-limited JSON/SSE routes:

Endpoint Purpose
POST /_ai/chat Standard JSON request/response visitor chat turn.
POST /_ai/chat/stream Server-Sent Events (SSE) token-by-token streaming response.
POST /_ai/chat/feedback Records thumbs-up/thumbs-down visitor ratings surfaced on the Overview dashboard.

Next steps