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 viewsArchitecture
Intent-Recognition Master Agent
IntentAgent classifies user requirements via LLM and routes to the appropriate sub-agent:
// 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-Agent | Intent | Scenario |
|---|---|---|
FormViewSubAgent | form | Form pages |
InfoViewSubAgent | info | Information display pages |
ReportViewSubAgent | report | Report/statistics pages |
LandingViewSubAgent | landing | Landing/marketing pages |
EmailViewSubAgent | Business emails | |
GeneralViewSubAgent | general | General pages |
Async Tasks
View enhancement runs asynchronously via Symfony Messenger to avoid blocking requests:
// src/Message/EnhanceViewMessage.php
class EnhanceViewMessage
{
public function __construct(
public readonly string $viewId,
public readonly string $prompt,
) {}
}The EnhanceViewMessageHandler then:
- Creates an
AiViewEnhanceTaskto track task status - Invokes the sub-agent to generate the view
- Updates
AiOperationLogto record operations - Pushes task progress via Mercure
Real-Time Progress
Task progress is pushed via Mercure SSE; the frontend subscribes with EventSource:
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
| Entity | Description |
|---|---|
AiChatSession | AI session (cross-request context) |
AiChatMessage | Session message |
AiOperationLog | AI operation log |
AiViewEnhanceTask | View 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 MercureLLM Configuration
Supports DeepSeek models' deep-thinking mode and reasoning strength adjustment:
# .env
DEEPSEEK_MODEL_ID=deepseek-reasoner
DEEPSEEK_REASONING_EFFORT=medium # low / medium / highView 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
Related Files
| File | Responsibility |
|---|---|
IntentAgent.php | Intent-recognition master agent |
ViewEnhanceAgentOrchestrator.php | Enhancement orchestrator |
ViewSubAgentChatRouter.php | Sub-agent chat routing |
AbstractViewSubAgent.php | Sub-agent abstract base |
EnhanceViewMessage.php | Async task message |
EnhanceViewMessageHandler.php | Async task handler |
ViewAiTaskApiController.php | AI task API |
AiViewEnhanceTask.php | Task status entity |