Skip to content

AI View Enhancement

Doggy provides an AI-driven view enhancement system. Through an intent-recognition master agent plus six scenario sub-agents, natural-language requirements are automatically classified and routed to the appropriate sub-agent for view generation, with async task execution and real-time progress push.

Overview

The AI view enhancement system lives in src/Service/AI/Orchestrator/, built on the LlmRole/LlmProvider system:

User requirement (natural language)
  → IntentAgent (intent-recognition master agent)
    → FormViewSubAgent   Form views
    → InfoViewSubAgent   Information display views
    → ReportViewSubAgent Report views
    → LandingViewSubAgent Landing page views
    → EmailViewSubAgent  Business email views
    → GeneralViewSubAgent General views

Architecture

Intent-Recognition Master Agent

IntentAgent classifies user requirements via LLM and routes to the appropriate sub-agent:

php
// src/Service/AI/Orchestrator/IntentAgent.php
class IntentAgent
{
    public function classify(string $userMessage): string
    {
        // Returns intent type: form / info / report / landing / email / general
    }
}

Scenario Sub-Agents

Each sub-agent extends AbstractViewSubAgent and implements ViewSubAgentInterface:

Sub-AgentIntentScenario
FormViewSubAgentformForm pages
InfoViewSubAgentinfoInformation display pages
ReportViewSubAgentreportReport/statistics pages
LandingViewSubAgentlandingLanding/marketing pages
EmailViewSubAgentemailBusiness emails
GeneralViewSubAgentgeneralGeneral pages

Async Tasks

View enhancement runs asynchronously via Symfony Messenger to avoid blocking requests:

php
// src/Message/EnhanceViewMessage.php
class EnhanceViewMessage
{
    public function __construct(
        public readonly string $viewId,
        public readonly string $prompt,
    ) {}
}

The EnhanceViewMessageHandler then:

  • Creates an AiViewEnhanceTask to track task status
  • Invokes the sub-agent to generate the view
  • Updates AiOperationLog to record operations
  • Pushes task progress via Mercure

Real-Time Progress

Task progress is pushed via Mercure SSE; the frontend subscribes with EventSource:

javascript
const url = new URL('/.well-known/mercure', window.location.origin);
url.searchParams.append('topic', `/user/${userId}/ai-task`);
const eventSource = new EventSource(url);
eventSource.onmessage = (event) => {
    const data = JSON.parse(event.data);
    // Update task progress
};

Entity Model

EntityDescription
AiChatSessionAI session (cross-request context)
AiChatMessageSession message
AiOperationLogAI operation log
AiViewEnhanceTaskView enhancement task status

Call Flow

User creates/edits a view
  → Enters natural-language requirement
  → POST /api/admin/platform/view-ai-task
  → IntentAgent classifies intent
  → Routes to the sub-agent
  → Async execution (EnhanceViewMessage)
  → Generates view files
  → Pushes progress via Mercure

LLM Configuration

Supports DeepSeek models' deep-thinking mode and reasoning strength adjustment:

bash
# .env
DEEPSEEK_MODEL_ID=deepseek-reasoner
DEEPSEEK_REASONING_EFFORT=medium  # low / medium / high

View Editor Integration

The AI enhancement component is integrated into the view creation page (_ai_enhance_component.html.twig):

  • AI-assisted editing when creating views
  • Enhancement actions on the view detail page (view_detail.html.twig)
  • View deletion confirmation dialog
FileResponsibility
IntentAgent.phpIntent-recognition master agent
ViewEnhanceAgentOrchestrator.phpEnhancement orchestrator
ViewSubAgentChatRouter.phpSub-agent chat routing
AbstractViewSubAgent.phpSub-agent abstract base
EnhanceViewMessage.phpAsync task message
EnhanceViewMessageHandler.phpAsync task handler
ViewAiTaskApiController.phpAI task API
AiViewEnhanceTask.phpTask status entity

Open Source under MIT | Copyright © 2026 Doggy