Skip to content

LLM Configuration

Doggy provides a graphical LLM configuration management system supporting flexible configuration across multiple vendors, models, and roles, with runtime dynamic switching — a unified model foundation for AI features.

Overview

The LLM configuration system lives in src/Service/Platform/Llm/, drawing on Symfony AI Bundle's Platform design philosophy:

  • Multiple vendors: OpenAI, Azure, Anthropic, Ollama, custom OpenAI-compatible gateways
  • Graphical management: Dynamic management via admin UI (not YAML config)
  • Role separation: Config decoupled from use; roles bind to models
  • Key encryption: API keys encrypted at rest, never exposed to the frontend

Data Model

LlmProvider (Vendor Config)

FieldTypeDescription
namestringDisplay name, e.g. "GPT-4o"
providerstringVendor: openai / anthropic / azure / ollama / custom
modelstringModel name: gpt-4o / claude-3-5-sonnet / ...
apiKeyencryptedAPI key (encrypted at rest)
apiEndpointstringEndpoint URL (optional)
optionsJSONExtra params: temperature, max_tokens, top_p, etc.
isEnabledbooleanEnabled flag
sortOrderintSort order

LlmRole (Role/Purpose)

FieldTypeDescription
codestringRole code: view_editor / entity_generation / workflow_analysis / query_assistant / chat / coding
labelstringDisplay name
providerIdUUIDBound model config
systemPrompttextSystem prompt for this role
optionsJSONRole-level param overrides
isEnabledbooleanEnabled flag

Role Planning

Role codePurposeRecommended model
view_editorView designer AI assistantgpt-4o / claude-3.5-sonnet
entity_generationAI-assisted entity generationgpt-4o-mini
workflow_analysisWorkflow analysis & suggestionsgpt-4o
query_assistantNatural language → data querygpt-4o-mini
chatGeneral AI chat assistantgpt-4o-mini
codingCode generation (Twig/JS/PHP)gpt-4o / claude-3.5-sonnet

Call Chain

LlmRouter::chatByRole(roleCode, messages, opts)
  ├─ Query LlmRole(code) → get bound LlmProvider
  ├─ LlmGatewayFactory::create(provider) → instantiate adapter
  ├─ Decrypt API key (LlmEncryptor)
  └─ Call LLM API (tool calling, streaming supported)

LlmGatewayFactory

Auto-routes adapters based on LlmProvider.provider:

providerAdapterDescription
openaiOpenAiGatewayOpenAI-compatible API
anthropicAnthropicGatewayAnthropic Claude API
azureAzureGatewayAzure OpenAI
ollamaOllamaGatewayLocal Ollama
customCustomGatewayCustom OpenAI-compatible gateway

Failover

LlmRouter supports chatByRoleWithFallback, automatically degrading to a backup model when the primary vendor fails.

Admin UI

Entry: System Settings → LLM Config (/admin/platform/llm-config)

List Page

  • Vendor card display; one vendor can have multiple model variants
  • Shows roles/usages bound to each model directly
  • Toggle enable/disable
  • Drag-and-drop sorting

Edit Form

  • Name, vendor, model, API key (encrypted), endpoint
  • Role management (LlmRoleType): role code, system prompt, model binding

Key Encryption

LlmEncryptor encrypts/decrypts API keys with the platform encryption key. Keys live only on the server; the frontend never sees the raw key:

php
// Storing
$encrypted = $llmEncryptor->encrypt($apiKey);

// Calling
$apiKey = $llmEncryptor->decrypt($provider->getApiKey());

Integration with the AI Assistant

The AI assistant (see AI Assistant) reuses the LlmRole/LlmProvider system:

Frontend → POST /api/admin/ai/chat
  → LlmRouter.chatByRole(roleCode, messages)
    → Query LlmRole → LlmGatewayFactory → LLM API
  • API keys live only on the server (encrypted in DB)
  • Model switching happens in the admin UI — no code changes needed
  • Multi-vendor routing is automatic via LlmGatewayFactory
FileResponsibility
src/Service/Platform/Llm/LlmGatewayInterface.phpGateway interface
src/Service/Platform/Llm/LlmGatewayFactory.phpAdapter factory
src/Service/Platform/Llm/LlmRouter.phpRole routing + failover
src/Service/Platform/Llm/ModelRegistry.phpModel registry
src/Service/Platform/LlmEncryptor.phpAPI key encryption
src/Entity/Platform/LlmProvider.phpVendor config entity
src/Entity/Platform/LlmRole.phpRole config entity
src/Controller/Admin/Platform/LlmConfigController.phpAdmin UI controller

Open Source under MIT | Copyright © 2026 Doggy