Skip to content

LLM 설정

Doggy는 그래픽 기반의 LLM 설정 관리 시스템을 제공하며, 다중 업체, 다중 모델, 다중 역할의 유연한 설정과 런타임 동적 전환을 지원하여 AI 기능에 통일된 모델 지원을 제공합니다.

개요

LLM 설정 시스템은 src/Service/Platform/Llm/에 있으며 Symfony AI Bundle의 Platform 설계 개념을 참고했습니다:

  • 다중 업체 지원: OpenAI, Azure, Anthropic, Ollama, 커스텀 OpenAI 호환 게이트웨이
  • 그래픽 관리: YAML 설정이 아닌 백엔드 인터페이스에서 동적 관리
  • 역할 분리: 설정과 용도가 분리되고 역할이 모델에 바인딩
  • 키 암호화: API Key를 암호화 저장, 프론트엔드에서 접근 불가

데이터 모델

LlmProvider (업체 설정)

필드타입설명
namestring표시 이름, 예: "GPT-4o"
providerstring업체 식별자: openai / anthropic / azure / ollama / custom
modelstring모델 이름: gpt-4o / claude-3-5-sonnet / ...
apiKeyencryptedAPI Key(암호화 저장)
apiEndpointstring인터페이스 주소(선택 사항)
optionsJSON추가 파라미터: temperature, max_tokens, top_p 등
isEnabledboolean활성화 여부
sortOrderint정렬 순서

LlmRole (역할/용도)

필드타입설명
codestring역할 코드: view_editor / entity_generation / workflow_analysis / query_assistant / chat / coding
labelstring표시 이름
providerIdUUID바인딩된 모델 설정
systemPrompttext해당 역할의 시스템 프롬프트
optionsJSON역할 수준 파라미터 오버라이드
isEnabledboolean활성화 여부

역할 용도 계획

역할 code용도추천 모델
view_editor뷰 디자이너 AI 어시스턴트gpt-4o / claude-3.5-sonnet
entity_generationAI 보조 엔티티 생성gpt-4o-mini
workflow_analysis워크플로 분석 및 제안gpt-4o
query_assistant자연어 → 데이터 쿼리gpt-4o-mini
chat범용 AI 대화 어시스턴트gpt-4o-mini
coding코드 생성(Twig/JS/PHP)gpt-4o / claude-3.5-sonnet

호출 체인

LlmRouter::chatByRole(roleCode, messages, opts)
  ├─ LlmRole(code) 조회 → 바인딩된 LlmProvider 가져오기
  ├─ LlmGatewayFactory::create(provider) → 어댑터 인스턴스화
  ├─ API Key 복호화 (LlmEncryptor)
  └─ LLM API 호출 (도구 호출, 스트리밍 응답 지원)

LlmGatewayFactory

LlmProvider.provider 필드에 따라 어댑터를 자동 라우팅합니다:

provider어댑터설명
openaiOpenAiGatewayOpenAI 호환 인터페이스
anthropicAnthropicGatewayAnthropic Claude API
azureAzureGatewayAzure OpenAI
ollamaOllamaGateway로컬 Ollama
customCustomGateway커스텀 OpenAI 호환 게이트웨이

장애 조치

LlmRouterchatByRoleWithFallback을 지원하며 메인 업체가 실패하면 자동으로 예비 모델로 다운그레이드합니다.

관리 인터페이스

진입점: 시스템 설정 → LLM 설정(/admin/platform/llm-config)

목록 페이지

  • 업체 카드 형태 표시, 하나의 업체가 여러 모델 변형에 대응 가능
  • 해당 모델이 바인딩된 역할/용도를 직접 표시
  • 토글 스위치로 활성화/비활성화
  • 드래그 앤 드롭 정렬

편집 폼

  • 이름, 업체, 모델, API Key(암호화 저장), 인터페이스 주소
  • 역할 관리(LlmRoleType): 역할 코드, 시스템 프롬프트, 모델 바인딩

키 암호화

LlmEncryptor는 플랫폼 암호화 키로 API Key를 암호화/복호화하며, 키는 서버에만 저장되고 프론트엔드는 원본 Key에 접근할 수 없습니다:

php
// 저장 시
$encrypted = $llmEncryptor->encrypt($apiKey);

// 호출 시
$apiKey = $llmEncryptor->decrypt($provider->getApiKey());

AI 어시스턴트와 통합

AI 어시스턴트(AI 어시스턴트 참조)는 LlmRole/LlmProvider 체계를 재사용합니다:

프론트엔드 → POST /api/admin/ai/chat
  → LlmRouter.chatByRole(roleCode, messages)
    → LlmRole 조회 → LlmGatewayFactory → LLM API
  • API Key는 서버에만 저장(데이터베이스 암호화 저장)
  • 모델 전환은 관리 인터페이스에서 완료, 코드 수정 불필요
  • 다중 업체는 LlmGatewayFactory가 자동 라우팅

관련 파일

파일역할
src/Service/Platform/Llm/LlmGatewayInterface.php게이트웨이 인터페이스
src/Service/Platform/Llm/LlmGatewayFactory.php어댑터 팩토리
src/Service/Platform/Llm/LlmRouter.php역할 라우팅 + 장애 조치
src/Service/Platform/Llm/ModelRegistry.php모델 레지스트리
src/Service/Platform/LlmEncryptor.phpAPI Key 암호화/복호화
src/Entity/Platform/LlmProvider.php업체 설정 엔티티
src/Entity/Platform/LlmRole.php역할 설정 엔티티
src/Controller/Admin/Platform/LlmConfigController.php관리 인터페이스 컨트롤러

MIT 라이선스 오픈소스 | Copyright © 2026 Doggy