1196 lines
51 KiB
TypeScript
1196 lines
51 KiB
TypeScript
'use client'
|
||
|
||
// apps/admin/src/app/(admin)/models/page.tsx
|
||
// D3RO Voice — Dynamic AI Models & Cloud STT Transcription Provider Manager (Midnight Glass v2)
|
||
|
||
import React, { useState, useEffect, useRef } from 'react'
|
||
import {
|
||
Box,
|
||
Typography,
|
||
Button,
|
||
TextField,
|
||
Dialog,
|
||
DialogTitle,
|
||
DialogContent,
|
||
DialogActions,
|
||
MenuItem,
|
||
Select,
|
||
FormControl,
|
||
InputLabel,
|
||
Tabs,
|
||
Tab,
|
||
Alert,
|
||
CircularProgress,
|
||
} from '@mui/material'
|
||
import { C, FONT_SANS, FONT_MONO, panelSx, tableSx, statusBadgeSx, primaryButtonSx } from '@/lib/console-theme'
|
||
import { DoubleBezelCard, TactileBadge } from '@d3ro/ui/components/ds'
|
||
import type {
|
||
ModelEndpoint,
|
||
SttProviderEndpoint,
|
||
STTProviderCategory,
|
||
} from '@/lib/api-server'
|
||
import {
|
||
createModelEndpointClient,
|
||
createSttEndpointClient,
|
||
deleteModelEndpointClient,
|
||
deleteSttEndpointClient,
|
||
fetchModelEndpointsClient,
|
||
fetchSttEndpointsClient,
|
||
setDefaultSttEndpointClient,
|
||
testSttEndpointClient,
|
||
updateSttEndpointClient,
|
||
} from '@/lib/backend-admin-client'
|
||
|
||
const PRESET_LLM_MODELS = [
|
||
{ modelId: 'whisper-large-v3-turbo', modelName: 'Faster-Whisper Large-v3 Turbo (Local)', provider: 'Local Sidecar', endpointUrl: 'http://localhost:8971/stt/transcribe', promptCost: '0.000000', completionCost: '0.000000' },
|
||
{ modelId: 'ollama-gemma4-e4b', modelName: 'Ollama Gemma-4 E4B (Bundled Local)', provider: 'Ollama Local', endpointUrl: 'http://localhost:11434/api/generate', promptCost: '0.000000', completionCost: '0.000000' },
|
||
{ modelId: 'gpt-realtime-2.1', modelName: 'OpenAI GPT-Realtime 2.1 (Live Voice)', provider: 'OpenAI', endpointUrl: 'wss://api.openai.com/v1/realtime', promptCost: '0.005000', completionCost: '0.020000' },
|
||
{ modelId: 'gpt-4o-mini', modelName: 'GPT-4o Mini (Cloud Synthesis & Meeting)', provider: 'OpenAI', endpointUrl: 'https://api.openai.com/v1/chat/completions', promptCost: '0.000150', completionCost: '0.000600' },
|
||
{ modelId: 'claude-3-5-sonnet', modelName: 'Claude 3.5 Sonnet (Action Planner)', provider: 'Anthropic', endpointUrl: 'https://api.anthropic.com/v1/messages', promptCost: '0.003000', completionCost: '0.015000' },
|
||
]
|
||
|
||
const PRESET_STT_PROVIDERS: Array<{
|
||
name: string
|
||
providerType: STTProviderCategory
|
||
endpointUrl: string
|
||
modelId: string
|
||
method: 'multipart' | 'binary-stream' | 'json-base64' | 'custom-rest'
|
||
costPerMinute: number
|
||
language: string
|
||
prompt?: string
|
||
description: string
|
||
}> = [
|
||
{ name: 'Groq Whisper LPU Turbo (Ultra Fast)', providerType: 'groq', endpointUrl: 'https://api.groq.com/openai/v1/audio/transcriptions', modelId: 'whisper-large-v3-turbo', method: 'multipart', costPerMinute: 0.0005, language: 'ko', description: 'LPU 가속 기반 초저지연(~140ms) 고속 전사, 극저비용' },
|
||
{ name: 'OpenAI Whisper Official', providerType: 'openai', endpointUrl: 'https://api.openai.com/v1/audio/transcriptions', modelId: 'whisper-1', method: 'multipart', costPerMinute: 0.006, language: 'ko', description: 'OpenAI 공식 Whisper-1 모델, 표준 고품질 다국어 인식' },
|
||
{ name: 'Deepgram Nova-3 Industry Standard', providerType: 'deepgram', endpointUrl: 'https://api.deepgram.com/v1/listen', modelId: 'nova-3', method: 'binary-stream', costPerMinute: 0.0043, language: 'ko', description: 'Nova-3 스마트 구두점, 실시간 스트리밍 최적화 및 고정밀 전사' },
|
||
{ name: 'Google Gemini 2.0 Flash / Cloud STT', providerType: 'google', endpointUrl: 'https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent', modelId: 'gemini-2.0-flash', method: 'json-base64', costPerMinute: 0.001, language: 'ko', description: 'Gemini 2.0 Flash 기반 다국어 및 문맥 인식 오디오 전사' },
|
||
{ name: 'AssemblyAI Universal-2', providerType: 'assemblyai', endpointUrl: 'https://api.assemblyai.com/v2/transcript', modelId: 'best', method: 'multipart', costPerMinute: 0.0025, language: 'ko', description: '문맥 인식 음향 모델 및 자동 단락 구분 STT' },
|
||
{ name: 'Microsoft Azure Speech Service', providerType: 'azure', endpointUrl: 'https://koreacentral.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1', modelId: 'azure-speech', method: 'binary-stream', costPerMinute: 0.005, language: 'ko-KR', description: 'Azure Cognitive Speech API 엔터프라이즈 음성 인식' },
|
||
{ name: 'Self-Hosted / Local Faster-Whisper Sidecar', providerType: 'local-sidecar', endpointUrl: 'http://localhost:8971/stt/transcribe', modelId: 'whisper-large-v3-turbo', method: 'multipart', costPerMinute: 0.0, language: 'ko', description: '사내 프라이빗 서버 또는 로컬 Whisper 사이드카 (완전 무료/오프라인)' },
|
||
]
|
||
|
||
export default function ServiceModelsPage(): React.ReactElement {
|
||
const [activeTab, setActiveTab] = useState<'stt' | 'llm'>('stt')
|
||
|
||
// STT Endpoints State
|
||
const [sttEndpoints, setSttEndpoints] = useState<SttProviderEndpoint[]>([])
|
||
const [sttModalOpen, setSttModalOpen] = useState(false)
|
||
const [sttEditingId, setSttEditingId] = useState<number | null>(null)
|
||
const [sttLoading, setSttLoading] = useState(false)
|
||
const [sttPingStatus, setSttPingStatus] = useState<Record<number, string>>({})
|
||
const [sttTestModalResult, setSttTestModalResult] = useState<{ success: boolean; message: string; ms: number } | null>(null)
|
||
const [testingInModal, setTestingInModal] = useState(false)
|
||
|
||
// STT Form State
|
||
const [sttName, setSttName] = useState('')
|
||
const [sttProviderType, setSttProviderType] = useState<STTProviderCategory>('custom')
|
||
const [sttEndpointUrl, setSttEndpointUrl] = useState('')
|
||
const [sttApiKey, setSttApiKey] = useState('')
|
||
const [sttModelId, setSttModelId] = useState('')
|
||
const [sttMethod, setSttMethod] = useState<'multipart' | 'binary-stream' | 'json-base64' | 'custom-rest'>('multipart')
|
||
const [sttLanguage, setSttLanguage] = useState('ko')
|
||
const [sttPrompt, setSttPrompt] = useState('')
|
||
const [sttCostPerMinute, setSttCostPerMinute] = useState('0')
|
||
const [sttFallbackPriority, setSttFallbackPriority] = useState(1)
|
||
const [sttIsDefault, setSttIsDefault] = useState(false)
|
||
const [sttMemo, setSttMemo] = useState('')
|
||
|
||
// LLM Endpoints State
|
||
const [llmEndpoints, setLlmEndpoints] = useState<ModelEndpoint[]>([])
|
||
const [llmModalOpen, setLlmModalOpen] = useState(false)
|
||
const [llmLoading, setLlmLoading] = useState(false)
|
||
const [dataError, setDataError] = useState<string | null>(null)
|
||
|
||
// LLM Form State
|
||
const [llmModelId, setLlmModelId] = useState('')
|
||
const [llmModelName, setLlmModelName] = useState('')
|
||
const [llmProvider, setLlmProvider] = useState<string>('Custom')
|
||
const [llmEndpointUrl, setLlmEndpointUrl] = useState('')
|
||
const [llmApiKey, setLlmApiKey] = useState('')
|
||
const [llmPromptCost, setLlmPromptCost] = useState('0')
|
||
const [llmCompletionCost, setLlmCompletionCost] = useState('0')
|
||
const [llmMemo, setLlmMemo] = useState('')
|
||
|
||
const mountedRef = useRef(true)
|
||
const loadSeqRef = useRef(0)
|
||
|
||
const loadData = async () => {
|
||
const seq = ++loadSeqRef.current
|
||
setDataError(null)
|
||
try {
|
||
const [sttData, llmData] = await Promise.all([fetchSttEndpointsClient(), fetchModelEndpointsClient()])
|
||
if (!mountedRef.current || loadSeqRef.current !== seq) return
|
||
setSttEndpoints(sttData)
|
||
setLlmEndpoints(llmData)
|
||
} catch (error) {
|
||
if (!mountedRef.current || loadSeqRef.current !== seq) return
|
||
setDataError(error instanceof Error ? error.message : '관리자 백엔드에서 엔드포인트를 불러오지 못했습니다.')
|
||
}
|
||
}
|
||
|
||
useEffect(() => {
|
||
mountedRef.current = true
|
||
void loadData()
|
||
return () => {
|
||
mountedRef.current = false
|
||
}
|
||
}, [])
|
||
|
||
// ── STT Handlers ──────────────────────────────────────────────────────────
|
||
|
||
const openAddSttModal = () => {
|
||
setSttEditingId(null)
|
||
setSttName('')
|
||
setSttProviderType('custom')
|
||
setSttEndpointUrl('')
|
||
setSttApiKey('')
|
||
setSttModelId('')
|
||
setSttMethod('multipart')
|
||
setSttLanguage('ko')
|
||
setSttPrompt('')
|
||
setSttCostPerMinute('0')
|
||
setSttFallbackPriority(sttEndpoints.length + 1)
|
||
setSttIsDefault(sttEndpoints.length === 0)
|
||
setSttTestModalResult(null)
|
||
setSttMemo('')
|
||
setSttModalOpen(true)
|
||
}
|
||
|
||
const openEditSttModal = (ep: SttProviderEndpoint) => {
|
||
setSttEditingId(ep.id)
|
||
setSttName(ep.name)
|
||
setSttProviderType(ep.providerType)
|
||
setSttEndpointUrl(ep.endpointUrl)
|
||
setSttApiKey('')
|
||
setSttModelId(ep.modelId)
|
||
setSttMethod(ep.method)
|
||
setSttLanguage(ep.language)
|
||
setSttPrompt(ep.prompt || '')
|
||
setSttCostPerMinute(ep.costPerMinute.toFixed(6))
|
||
setSttFallbackPriority(ep.fallbackPriority)
|
||
setSttIsDefault(ep.isDefault)
|
||
setSttTestModalResult(null)
|
||
setSttMemo('')
|
||
setSttModalOpen(true)
|
||
}
|
||
|
||
const handleSaveSttEndpoint = async (e: React.FormEvent) => {
|
||
e.preventDefault()
|
||
const parsedCostPerMinute = parseFloat(sttCostPerMinute)
|
||
if (!Number.isFinite(parsedCostPerMinute) || parsedCostPerMinute < 0) {
|
||
alert('분당 비용은 0 이상의 유효한 숫자여야 합니다.')
|
||
return
|
||
}
|
||
setSttLoading(true)
|
||
|
||
try {
|
||
const payload = {
|
||
name: sttName,
|
||
providerType: sttProviderType,
|
||
endpointUrl: sttEndpointUrl,
|
||
apiKey: sttApiKey ? sttApiKey : undefined,
|
||
modelId: sttModelId,
|
||
method: sttMethod,
|
||
language: sttLanguage,
|
||
prompt: sttPrompt ? sttPrompt : undefined,
|
||
temperature: 0.0,
|
||
costPerMinute: parsedCostPerMinute,
|
||
costPerSecond: parsedCostPerMinute / 60,
|
||
isDefault: sttIsDefault,
|
||
isActive: true,
|
||
fallbackPriority: sttFallbackPriority,
|
||
memo: sttMemo.trim(),
|
||
}
|
||
|
||
if (sttEditingId) {
|
||
await updateSttEndpointClient(sttEditingId, payload)
|
||
} else {
|
||
await createSttEndpointClient(payload)
|
||
}
|
||
|
||
await loadData()
|
||
if (mountedRef.current) setSttModalOpen(false)
|
||
} catch (err) {
|
||
if (mountedRef.current) {
|
||
alert('Error saving STT endpoint: ' + (err instanceof Error ? err.message : String(err)))
|
||
}
|
||
} finally {
|
||
if (mountedRef.current) setSttLoading(false)
|
||
}
|
||
}
|
||
|
||
const handleSetDefaultStt = async (id: number) => {
|
||
const memo = prompt('기본 STT 공급자 변경 사유를 입력하세요.')?.trim() ?? ''
|
||
if (memo.length < 3) return
|
||
try {
|
||
await setDefaultSttEndpointClient(id, memo)
|
||
if (!mountedRef.current) return
|
||
setSttEndpoints((prev) =>
|
||
prev.map((ep) => ({
|
||
...ep,
|
||
isDefault: ep.id === id,
|
||
}))
|
||
)
|
||
} catch (err) {
|
||
if (mountedRef.current) {
|
||
alert('Error: ' + (err instanceof Error ? err.message : String(err)))
|
||
}
|
||
}
|
||
}
|
||
|
||
const handlePingStt = async (id: number) => {
|
||
setSttPingStatus((prev) => ({ ...prev, [id]: 'Testing...' }))
|
||
try {
|
||
const result = await testSttEndpointClient(id)
|
||
if (!mountedRef.current) return
|
||
setSttPingStatus((prev) => ({
|
||
...prev,
|
||
[id]: result.success ? `⚡ OK • ${result.latencyMs}ms` : `❌ ${result.message}`
|
||
}))
|
||
} catch (error) {
|
||
if (!mountedRef.current) return
|
||
setSttPingStatus((prev) => ({
|
||
...prev,
|
||
[id]: `❌ ${error instanceof Error ? error.message : 'Test failed'}`
|
||
}))
|
||
}
|
||
}
|
||
|
||
const handleTestInModal = async () => {
|
||
setTestingInModal(true)
|
||
setSttTestModalResult(null)
|
||
try {
|
||
const result = await testSttEndpointClient(sttEditingId ?? 0, sttApiKey, sttEndpointUrl)
|
||
if (!mountedRef.current) return
|
||
setSttTestModalResult({
|
||
success: result.success,
|
||
message: result.message,
|
||
ms: result.latencyMs,
|
||
})
|
||
} catch (err) {
|
||
if (!mountedRef.current) return
|
||
setSttTestModalResult({
|
||
success: false,
|
||
message: err instanceof Error ? err.message : 'Test failed',
|
||
ms: 0,
|
||
})
|
||
} finally {
|
||
if (mountedRef.current) setTestingInModal(false)
|
||
}
|
||
}
|
||
|
||
const handleDeleteStt = async (id: number) => {
|
||
if (!confirm('이 STT 프로바이더 엔드포인트를 삭제하시겠습니까?')) return
|
||
const memo = prompt('삭제 사유를 입력하세요.')?.trim() ?? ''
|
||
if (memo.length < 3) return
|
||
try {
|
||
await deleteSttEndpointClient(id, memo)
|
||
if (mountedRef.current) {
|
||
setSttEndpoints((prev) => prev.filter((ep) => ep.id !== id))
|
||
}
|
||
} catch (err) {
|
||
if (mountedRef.current) {
|
||
alert('Error: ' + (err instanceof Error ? err.message : String(err)))
|
||
}
|
||
}
|
||
}
|
||
|
||
// ── LLM Handlers ──────────────────────────────────────────────────────────
|
||
|
||
const openAddLlmModal = () => {
|
||
setLlmModelId('')
|
||
setLlmModelName('')
|
||
setLlmProvider('Custom')
|
||
setLlmEndpointUrl('')
|
||
setLlmApiKey('')
|
||
setLlmPromptCost('0')
|
||
setLlmCompletionCost('0')
|
||
setLlmMemo('')
|
||
setLlmModalOpen(true)
|
||
}
|
||
|
||
const handleAddLlmEndpoint = async (e: React.FormEvent) => {
|
||
e.preventDefault()
|
||
const parsedPromptCost = parseFloat(llmPromptCost)
|
||
const parsedCompletionCost = parseFloat(llmCompletionCost)
|
||
if (
|
||
!Number.isFinite(parsedPromptCost) || parsedPromptCost < 0
|
||
|| !Number.isFinite(parsedCompletionCost) || parsedCompletionCost < 0
|
||
) {
|
||
alert('토큰 비용은 0 이상의 유효한 숫자여야 합니다.')
|
||
return
|
||
}
|
||
setLlmLoading(true)
|
||
|
||
try {
|
||
await createModelEndpointClient({
|
||
modelId: llmModelId,
|
||
modelName: llmModelName,
|
||
provider: llmProvider,
|
||
endpointUrl: llmEndpointUrl,
|
||
apiKey: llmApiKey,
|
||
costPer1kPromptTokens: parsedPromptCost,
|
||
costPer1kCompletionTokens: parsedCompletionCost,
|
||
memo: llmMemo.trim(),
|
||
})
|
||
await loadData()
|
||
if (!mountedRef.current) return
|
||
setLlmModalOpen(false)
|
||
setLlmModelId('')
|
||
setLlmModelName('')
|
||
setLlmEndpointUrl('')
|
||
setLlmApiKey('')
|
||
setLlmMemo('')
|
||
} catch (err) {
|
||
if (mountedRef.current) {
|
||
alert('Error: ' + (err instanceof Error ? err.message : String(err)))
|
||
}
|
||
} finally {
|
||
if (mountedRef.current) setLlmLoading(false)
|
||
}
|
||
}
|
||
|
||
const handleDeleteLlm = async (id: number) => {
|
||
if (!confirm('이 LLM 엔드포인트를 삭제하시겠습니까?')) return
|
||
const memo = prompt('삭제 사유를 입력하세요.')?.trim() ?? ''
|
||
if (memo.length < 3) return
|
||
try {
|
||
await deleteModelEndpointClient(id, memo)
|
||
if (mountedRef.current) {
|
||
setLlmEndpoints((current) => current.filter((endpoint) => endpoint.id !== id))
|
||
}
|
||
} catch (error) {
|
||
if (mountedRef.current) {
|
||
alert('Error: ' + (error instanceof Error ? error.message : String(error)))
|
||
}
|
||
}
|
||
}
|
||
|
||
const defaultStt = sttEndpoints.find((e) => e.isDefault) || sttEndpoints[0]
|
||
|
||
return (
|
||
<>
|
||
{/* Header Bar */}
|
||
<Box
|
||
sx={{
|
||
...panelSx,
|
||
minHeight: 84,
|
||
px: { xs: 2.5, md: 4 },
|
||
py: 2,
|
||
display: 'flex',
|
||
flexWrap: 'wrap',
|
||
alignItems: 'center',
|
||
justifyContent: 'space-between',
|
||
gap: 2,
|
||
}}
|
||
>
|
||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 2 }}>
|
||
<Box
|
||
sx={{
|
||
width: 4,
|
||
height: 34,
|
||
borderRadius: '999px',
|
||
background: 'linear-gradient(180deg, var(--d3-tag-cyan) 0%, var(--d3-tag-purple) 50%, var(--d3-accent-main) 100%)',
|
||
}}
|
||
/>
|
||
<Box>
|
||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1.5 }}>
|
||
<Typography
|
||
component="h1"
|
||
sx={{
|
||
fontFamily: FONT_SANS,
|
||
fontSize: '20px',
|
||
fontWeight: 500,
|
||
color: C.bright,
|
||
letterSpacing: '-0.02em',
|
||
m: 0,
|
||
}}
|
||
>
|
||
AI Engines & Cloud STT Orchestrator
|
||
</Typography>
|
||
<TactileBadge ledColor="blue" ledPulse tone="accent" mono>
|
||
{sttEndpoints.length} STT • {llmEndpoints.length} LLM CONFIGURED
|
||
</TactileBadge>
|
||
</Box>
|
||
<Typography
|
||
sx={{
|
||
fontFamily: FONT_MONO,
|
||
fontSize: '11px',
|
||
color: C.dim,
|
||
letterSpacing: 0,
|
||
mt: 0.25,
|
||
}}
|
||
>
|
||
Dynamic routing, auto failover, token and per-minute billing, instant default switch
|
||
</Typography>
|
||
</Box>
|
||
</Box>
|
||
|
||
<Box sx={{ display: 'flex', gap: 1.5, alignItems: 'center' }}>
|
||
{activeTab === 'stt' ? (
|
||
<Button variant="contained" onClick={openAddSttModal} sx={primaryButtonSx}>
|
||
+ Add STT Provider Endpoint
|
||
</Button>
|
||
) : (
|
||
<Button variant="contained" onClick={openAddLlmModal} sx={primaryButtonSx}>
|
||
+ Add LLM Model Endpoint
|
||
</Button>
|
||
)}
|
||
</Box>
|
||
</Box>
|
||
|
||
{dataError && (
|
||
<Alert severity="error" sx={{ mb: 3 }}>
|
||
{dataError}
|
||
</Alert>
|
||
)}
|
||
|
||
{/* Tabs Navigation */}
|
||
<Box sx={{ borderBottom: `1px solid ${C.border}`, mb: 3 }}>
|
||
<Tabs
|
||
value={activeTab}
|
||
onChange={(_, val) => setActiveTab(val)}
|
||
sx={{
|
||
'& .MuiTabs-indicator': {
|
||
backgroundColor: C.accentLight,
|
||
height: '3px',
|
||
borderRadius: '3px',
|
||
},
|
||
}}
|
||
>
|
||
<Tab
|
||
value="stt"
|
||
label="🎙️ Cloud STT & Transcription Providers"
|
||
sx={{
|
||
fontFamily: FONT_SANS,
|
||
fontSize: '14px',
|
||
fontWeight: 500,
|
||
color: activeTab === 'stt' ? C.bright : C.dim,
|
||
textTransform: 'none',
|
||
px: 3,
|
||
py: 1.5,
|
||
'&.Mui-selected': { color: C.bright },
|
||
}}
|
||
/>
|
||
<Tab
|
||
value="llm"
|
||
label="🧠 LLM & Reasoning Model Endpoints"
|
||
sx={{
|
||
fontFamily: FONT_SANS,
|
||
fontSize: '14px',
|
||
fontWeight: 500,
|
||
color: activeTab === 'llm' ? C.bright : C.dim,
|
||
textTransform: 'none',
|
||
px: 3,
|
||
py: 1.5,
|
||
'&.Mui-selected': { color: C.bright },
|
||
}}
|
||
/>
|
||
</Tabs>
|
||
</Box>
|
||
|
||
{/* ── TAB 1: STT Transcription Providers ── */}
|
||
{activeTab === 'stt' && (
|
||
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 3 }}>
|
||
{/* Active Cloud STT Summary Card */}
|
||
{defaultStt && (
|
||
<DoubleBezelCard bezelPadding="6px" innerPadding="20px">
|
||
<Box sx={{ display: 'flex', flexWrap: 'wrap', justifyContent: 'space-between', alignItems: 'center', gap: 2 }}>
|
||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 2 }}>
|
||
<Box
|
||
sx={{
|
||
width: 44,
|
||
height: 44,
|
||
borderRadius: '12px',
|
||
bgcolor: 'var(--d3-tag-cyanBg)',
|
||
border: '1px solid var(--d3-tag-cyan)',
|
||
display: 'flex',
|
||
alignItems: 'center',
|
||
justifyContent: 'center',
|
||
fontSize: '22px',
|
||
}}
|
||
>
|
||
⚡
|
||
</Box>
|
||
<Box>
|
||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
||
<Typography sx={{ fontFamily: FONT_SANS, fontSize: '15px', fontWeight: 500, color: C.bright }}>
|
||
Active Default Cloud STT: {defaultStt.name}
|
||
</Typography>
|
||
<Box component="span" sx={statusBadgeSx('green')}>
|
||
DEFAULT ACTIVE
|
||
</Box>
|
||
</Box>
|
||
<Typography sx={{ fontFamily: FONT_MONO, fontSize: '11px', color: C.dim, mt: 0.25 }}>
|
||
Model: <strong>{defaultStt.modelId}</strong> • Method: <strong>{defaultStt.method}</strong> • Rate: <strong>${defaultStt.costPerMinute.toFixed(4)}/min</strong> • Lang: <strong>{defaultStt.language}</strong>
|
||
</Typography>
|
||
</Box>
|
||
</Box>
|
||
|
||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 2 }}>
|
||
<Typography sx={{ fontFamily: FONT_MONO, fontSize: '11px', color: C.cyanLight, bgcolor: 'var(--d3-tag-cyanBg)', px: 1.5, py: 0.75, borderRadius: '8px', border: `1px solid ${C.borderHl}` }}>
|
||
🛡️ Auto Failover Route: {sttEndpoints.map((e) => e.providerType).join(' ➔ ')}
|
||
</Typography>
|
||
</Box>
|
||
</Box>
|
||
</DoubleBezelCard>
|
||
)}
|
||
|
||
{/* STT Endpoints Table */}
|
||
<DoubleBezelCard bezelPadding="6px" innerPadding="24px">
|
||
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 2.5 }}>
|
||
<Box>
|
||
<Typography sx={{ fontFamily: FONT_SANS, fontSize: '16px', fontWeight: 500, color: C.bright }}>
|
||
Configured Cloud Transcription Providers
|
||
</Typography>
|
||
<Typography sx={{ fontFamily: FONT_SANS, fontSize: '12px', color: C.dim }}>
|
||
클라우드 사용자는 별도 설정 없이 관리자가 지정한 기본 프로바이더로 즉시 전사 시스템을 사용합니다.
|
||
</Typography>
|
||
</Box>
|
||
<Typography sx={{ fontFamily: FONT_MONO, fontSize: '11px', color: C.dim }}>
|
||
PRIORITY ORDER BASED FALLBACK
|
||
</Typography>
|
||
</Box>
|
||
|
||
<Box sx={{ overflowX: 'auto' }}>
|
||
<Box component="table" sx={tableSx}>
|
||
<Box component="thead">
|
||
<Box component="tr">
|
||
<Box component="th">PRIORITY</Box>
|
||
<Box component="th">PROVIDER NAME</Box>
|
||
<Box component="th">PROVIDER TYPE</Box>
|
||
<Box component="th">MODEL ID</Box>
|
||
<Box component="th">METHOD</Box>
|
||
<Box component="th">COST ($/MIN)</Box>
|
||
<Box component="th">STATUS / DEFAULT</Box>
|
||
<Box component="th" sx={{ textAlign: 'right' }}>ACTIONS</Box>
|
||
</Box>
|
||
</Box>
|
||
<Box component="tbody">
|
||
{sttEndpoints.length === 0 ? (
|
||
<Box component="tr">
|
||
<Box component="td" colSpan={8} sx={{ textAlign: 'center', color: C.dim, py: 4 }}>
|
||
NO STT PROVIDER ENDPOINTS CONFIGURED
|
||
</Box>
|
||
</Box>
|
||
) : (
|
||
sttEndpoints.map((ep) => (
|
||
<Box component="tr" key={ep.id} sx={{ bgcolor: ep.isDefault ? 'var(--d3-accent-glow)' : 'transparent' }}>
|
||
<Box component="td" sx={{ fontFamily: FONT_MONO, fontSize: '12px', color: C.cyanLight, fontWeight: 500 }}>
|
||
#{ep.fallbackPriority}
|
||
</Box>
|
||
<Box component="td" sx={{ fontWeight: 600, color: C.bright }}>
|
||
{ep.name}
|
||
<Typography sx={{ fontFamily: FONT_MONO, fontSize: '11px', color: C.dim, mt: 0.25, maxWidth: 220, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||
{ep.endpointUrl}
|
||
</Typography>
|
||
</Box>
|
||
<Box component="td">
|
||
<Box component="span" sx={statusBadgeSx(ep.providerType === 'groq' ? 'orange' : ep.providerType === 'openai' ? 'blue' : ep.providerType === 'deepgram' ? 'green' : 'purple')}>
|
||
{ep.providerType.toUpperCase()}
|
||
</Box>
|
||
</Box>
|
||
<Box component="td" sx={{ fontFamily: FONT_MONO, fontSize: '12px', color: C.bright }}>
|
||
{ep.modelId}
|
||
</Box>
|
||
<Box component="td" sx={{ fontFamily: FONT_MONO, fontSize: '11px', color: C.dim }}>
|
||
{ep.method}
|
||
</Box>
|
||
<Box component="td" sx={{ fontFamily: FONT_MONO, fontSize: '12px', color: C.bright }}>
|
||
${ep.costPerMinute.toFixed(4)}/m
|
||
</Box>
|
||
<Box component="td">
|
||
{ep.isDefault ? (
|
||
<Box component="span" sx={{ px: 1, py: 0.3, borderRadius: '4px', bgcolor: 'var(--d3-status-successBg)', color: C.green400, fontSize: '11px', fontWeight: 500 }}>
|
||
⭐ DEFAULT
|
||
</Box>
|
||
) : (
|
||
<Box component="span" sx={statusBadgeSx(ep.isActive ? 'cyan' : 'red')}>
|
||
{ep.isActive ? 'STANDBY' : 'DISABLED'}
|
||
</Box>
|
||
)}
|
||
</Box>
|
||
<Box component="td" sx={{ textAlign: 'right' }}>
|
||
<Box sx={{ display: 'inline-flex', gap: 1 }}>
|
||
{!ep.isDefault && (
|
||
<Button
|
||
size="small"
|
||
variant="outlined"
|
||
onClick={() => handleSetDefaultStt(ep.id)}
|
||
sx={{
|
||
fontFamily: FONT_SANS,
|
||
fontSize: '11px',
|
||
color: C.green400,
|
||
borderColor: 'var(--d3-status-success)',
|
||
px: 1,
|
||
py: 0.25,
|
||
'&:hover': { bgcolor: 'var(--d3-status-successBg)', borderColor: C.green400 },
|
||
}}
|
||
>
|
||
Set Default
|
||
</Button>
|
||
)}
|
||
<Button
|
||
size="small"
|
||
variant="outlined"
|
||
onClick={() => handlePingStt(ep.id)}
|
||
sx={{
|
||
fontFamily: FONT_MONO,
|
||
fontSize: '11px',
|
||
color: C.bright,
|
||
borderColor: C.borderHl,
|
||
px: 1,
|
||
py: 0.25,
|
||
'&:hover': { bgcolor: 'var(--d3-accent-glow)', borderColor: C.accentLight },
|
||
}}
|
||
>
|
||
{sttPingStatus[ep.id] || '⚡ Test'}
|
||
</Button>
|
||
<Button
|
||
size="small"
|
||
variant="outlined"
|
||
onClick={() => openEditSttModal(ep)}
|
||
sx={{
|
||
fontFamily: FONT_SANS,
|
||
fontSize: '11px',
|
||
color: C.dim,
|
||
borderColor: C.border,
|
||
px: 1,
|
||
py: 0.25,
|
||
'&:hover': { color: C.bright, borderColor: C.borderHl },
|
||
}}
|
||
>
|
||
Edit
|
||
</Button>
|
||
<Button
|
||
size="small"
|
||
color="error"
|
||
onClick={() => handleDeleteStt(ep.id)}
|
||
sx={{ fontFamily: FONT_MONO, fontSize: '11px', px: 1, py: 0.25 }}
|
||
>
|
||
Delete
|
||
</Button>
|
||
</Box>
|
||
</Box>
|
||
</Box>
|
||
))
|
||
)}
|
||
</Box>
|
||
</Box>
|
||
</Box>
|
||
</DoubleBezelCard>
|
||
</Box>
|
||
)}
|
||
|
||
{/* ── TAB 2: LLM Models ── */}
|
||
{activeTab === 'llm' && (
|
||
<DoubleBezelCard bezelPadding="6px" innerPadding="24px">
|
||
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 2.5 }}>
|
||
<Typography sx={{ fontFamily: FONT_SANS, fontSize: '16px', fontWeight: 500, color: C.bright }}>
|
||
Active AI Reasoning & Action Endpoints
|
||
</Typography>
|
||
<Typography sx={{ fontFamily: FONT_MONO, fontSize: '11px', color: C.dim }}>
|
||
AUTO FAILOVER: CLOUD → LOCAL OLLAMA
|
||
</Typography>
|
||
</Box>
|
||
|
||
<Box sx={{ overflowX: 'auto' }}>
|
||
<Box component="table" sx={tableSx}>
|
||
<Box component="thead">
|
||
<Box component="tr">
|
||
<Box component="th">MODEL ID</Box>
|
||
<Box component="th">MODEL NAME</Box>
|
||
<Box component="th">PROVIDER</Box>
|
||
<Box component="th">ENDPOINT URL</Box>
|
||
<Box component="th">PROMPT ($/1K)</Box>
|
||
<Box component="th">COMPLETION ($/1K)</Box>
|
||
<Box component="th">STATUS</Box>
|
||
<Box component="th" sx={{ textAlign: 'right' }}>ACTIONS</Box>
|
||
</Box>
|
||
</Box>
|
||
<Box component="tbody">
|
||
{llmEndpoints.length === 0 ? (
|
||
<Box component="tr">
|
||
<Box component="td" colSpan={8} sx={{ textAlign: 'center', color: C.dim, py: 4 }}>
|
||
NO MODEL ENDPOINTS CONFIGURED
|
||
</Box>
|
||
</Box>
|
||
) : (
|
||
llmEndpoints.map((ep) => (
|
||
<Box component="tr" key={ep.id}>
|
||
<Box component="td" sx={{ fontFamily: FONT_MONO, fontSize: '12px', color: C.bright, fontWeight: 600 }}>
|
||
{ep.modelId}
|
||
{ep.isDefault && (
|
||
<Box component="span" sx={{ ml: 1, px: 0.75, py: 0.1, borderRadius: '4px', bgcolor: 'var(--d3-accent-glow)', color: C.cyanLight, fontSize: '11px' }}>
|
||
DEFAULT
|
||
</Box>
|
||
)}
|
||
</Box>
|
||
<Box component="td" sx={{ fontWeight: 600, color: C.bright }}>
|
||
{ep.modelName}
|
||
</Box>
|
||
<Box component="td">
|
||
<Box component="span" sx={statusBadgeSx(ep.provider.includes('Local') ? 'cyan' : ep.provider === 'OpenAI' ? 'blue' : 'purple')}>
|
||
{ep.provider}
|
||
</Box>
|
||
</Box>
|
||
<Box component="td" sx={{ fontFamily: FONT_MONO, fontSize: '11px', color: C.dim, maxWidth: 220, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||
{ep.endpointUrl}
|
||
</Box>
|
||
<Box component="td" sx={{ fontFamily: FONT_MONO, fontSize: '12px', color: C.bright }}>
|
||
${ep.costPer1kPromptTokens.toFixed(6)}
|
||
</Box>
|
||
<Box component="td" sx={{ fontFamily: FONT_MONO, fontSize: '12px', color: C.bright }}>
|
||
${ep.costPer1kCompletionTokens.toFixed(6)}
|
||
</Box>
|
||
<Box component="td">
|
||
<Box component="span" sx={statusBadgeSx(ep.isActive ? 'green' : 'red')}>
|
||
{ep.isActive ? 'ACTIVE' : 'DISABLED'}
|
||
</Box>
|
||
</Box>
|
||
<Box component="td" sx={{ textAlign: 'right' }}>
|
||
<Box sx={{ display: 'inline-flex', gap: 1 }}>
|
||
<Button
|
||
size="small"
|
||
color="error"
|
||
onClick={() => handleDeleteLlm(ep.id)}
|
||
sx={{
|
||
fontFamily: FONT_MONO,
|
||
fontSize: '11px',
|
||
color: C.bright,
|
||
borderColor: C.borderHl,
|
||
px: 1,
|
||
py: 0.25,
|
||
'&:hover': { bgcolor: 'var(--d3-accent-glow)', borderColor: C.accentLight },
|
||
}}
|
||
>
|
||
Delete
|
||
</Button>
|
||
</Box>
|
||
</Box>
|
||
</Box>
|
||
))
|
||
)}
|
||
</Box>
|
||
</Box>
|
||
</Box>
|
||
</DoubleBezelCard>
|
||
)}
|
||
|
||
{/* ── STT Provider Add/Edit Modal ── */}
|
||
<Dialog
|
||
open={sttModalOpen}
|
||
onClose={() => setSttModalOpen(false)}
|
||
maxWidth="md"
|
||
fullWidth
|
||
PaperProps={{
|
||
sx: {
|
||
bgcolor: C.card,
|
||
border: `1px solid ${C.borderHl}`,
|
||
borderRadius: '20px',
|
||
boxShadow: '0 24px 60px var(--d3-scrim)',
|
||
},
|
||
}}
|
||
>
|
||
<DialogTitle sx={{ fontFamily: FONT_SANS, fontWeight: 500, color: C.bright, borderBottom: `1px solid ${C.border}`, px: 3, py: 2.5 }}>
|
||
{sttEditingId ? 'Edit STT Provider Endpoint' : 'Add Cloud STT Provider Endpoint'}
|
||
</DialogTitle>
|
||
<Box component="form" onSubmit={handleSaveSttEndpoint}>
|
||
<DialogContent sx={{ px: 3, py: 3, display: 'flex', flexDirection: 'column', gap: 2.5 }}>
|
||
{sttEditingId === null && (
|
||
<FormControl fullWidth size="small">
|
||
<InputLabel sx={{ color: C.dim }}>⚡ Load Preset Template (optional)</InputLabel>
|
||
<Select
|
||
value=""
|
||
label="⚡ Load Preset Template (optional)"
|
||
onChange={(e) => {
|
||
const preset = PRESET_STT_PROVIDERS.find((p) => p.name === e.target.value)
|
||
if (!preset) return
|
||
setSttName(preset.name)
|
||
setSttProviderType(preset.providerType)
|
||
setSttEndpointUrl(preset.endpointUrl)
|
||
setSttModelId(preset.modelId)
|
||
setSttMethod(preset.method)
|
||
setSttLanguage(preset.language)
|
||
setSttCostPerMinute(String(preset.costPerMinute))
|
||
if (preset.prompt) setSttPrompt(preset.prompt)
|
||
}}
|
||
sx={{
|
||
bgcolor: 'var(--d3-bg-inset-soft)',
|
||
color: C.bright,
|
||
borderRadius: '10px',
|
||
'& fieldset': { borderColor: C.border },
|
||
}}
|
||
>
|
||
{PRESET_STT_PROVIDERS.map((preset) => (
|
||
<MenuItem key={preset.name} value={preset.name}>
|
||
{preset.name}
|
||
</MenuItem>
|
||
))}
|
||
</Select>
|
||
</FormControl>
|
||
)}
|
||
<Box sx={{ display: 'grid', gridTemplateColumns: { xs: '1fr', md: '1.2fr 0.8fr' }, gap: 2 }}>
|
||
<TextField
|
||
label="Provider Name"
|
||
value={sttName}
|
||
onChange={(e) => setSttName(e.target.value)}
|
||
required
|
||
fullWidth
|
||
size="small"
|
||
placeholder="e.g. Groq Whisper LPU Fast"
|
||
sx={{
|
||
'& .MuiOutlinedInput-root': { bgcolor: 'var(--d3-bg-inset-soft)', color: C.bright, borderRadius: '10px' },
|
||
'& .MuiInputLabel-root': { color: C.dim },
|
||
}}
|
||
/>
|
||
<FormControl fullWidth size="small">
|
||
<InputLabel sx={{ color: C.dim }}>Provider Type</InputLabel>
|
||
<Select
|
||
value={sttProviderType}
|
||
label="Provider Type"
|
||
onChange={(e) => setSttProviderType(e.target.value as STTProviderCategory)}
|
||
sx={{
|
||
bgcolor: 'var(--d3-bg-inset-soft)',
|
||
color: C.bright,
|
||
borderRadius: '10px',
|
||
'& fieldset': { borderColor: C.border },
|
||
}}
|
||
>
|
||
<MenuItem value="groq">Groq (Whisper LPU)</MenuItem>
|
||
<MenuItem value="openai">OpenAI (Whisper-1)</MenuItem>
|
||
<MenuItem value="deepgram">Deepgram (Nova-3)</MenuItem>
|
||
<MenuItem value="google">Google (Gemini 2.0 / Cloud STT)</MenuItem>
|
||
<MenuItem value="assemblyai">AssemblyAI</MenuItem>
|
||
<MenuItem value="azure">Azure Speech</MenuItem>
|
||
<MenuItem value="custom">Custom REST / OpenAI 호환</MenuItem>
|
||
<MenuItem value="local-sidecar">Local / Self-Hosted Sidecar</MenuItem>
|
||
</Select>
|
||
</FormControl>
|
||
</Box>
|
||
|
||
<TextField
|
||
label="Endpoint URL"
|
||
value={sttEndpointUrl}
|
||
onChange={(e) => setSttEndpointUrl(e.target.value)}
|
||
required
|
||
fullWidth
|
||
size="small"
|
||
placeholder="https://api.groq.com/openai/v1/audio/transcriptions"
|
||
sx={{
|
||
'& .MuiOutlinedInput-root': { bgcolor: 'var(--d3-bg-inset-soft)', color: C.bright, borderRadius: '10px', fontFamily: FONT_MONO },
|
||
'& .MuiInputLabel-root': { color: C.dim },
|
||
}}
|
||
/>
|
||
|
||
<Box sx={{ display: 'grid', gridTemplateColumns: { xs: '1fr', md: '1fr 1fr' }, gap: 2 }}>
|
||
<TextField
|
||
label="API Key / Auth Token"
|
||
type="password"
|
||
value={sttApiKey}
|
||
onChange={(e) => setSttApiKey(e.target.value)}
|
||
fullWidth
|
||
size="small"
|
||
placeholder={sttEditingId ? '•••••••• (변경 시 입력)' : 'gsk_... or sk-... or token'}
|
||
sx={{
|
||
'& .MuiOutlinedInput-root': { bgcolor: 'var(--d3-bg-inset-soft)', color: C.bright, borderRadius: '10px', fontFamily: FONT_MONO },
|
||
'& .MuiInputLabel-root': { color: C.dim },
|
||
}}
|
||
/>
|
||
<TextField
|
||
label="Model ID"
|
||
value={sttModelId}
|
||
onChange={(e) => setSttModelId(e.target.value)}
|
||
required
|
||
fullWidth
|
||
size="small"
|
||
placeholder="e.g. whisper-large-v3-turbo, nova-3"
|
||
sx={{
|
||
'& .MuiOutlinedInput-root': { bgcolor: 'var(--d3-bg-inset-soft)', color: C.bright, borderRadius: '10px', fontFamily: FONT_MONO },
|
||
'& .MuiInputLabel-root': { color: C.dim },
|
||
}}
|
||
/>
|
||
</Box>
|
||
|
||
<Box sx={{ display: 'grid', gridTemplateColumns: { xs: '1fr', sm: '1fr 1fr 1fr' }, gap: 2 }}>
|
||
<FormControl fullWidth size="small">
|
||
<InputLabel sx={{ color: C.dim }}>Dispatch Method</InputLabel>
|
||
<Select
|
||
value={sttMethod}
|
||
label="Dispatch Method"
|
||
onChange={(e) => setSttMethod(e.target.value as SttProviderEndpoint['method'])}
|
||
sx={{
|
||
bgcolor: 'var(--d3-bg-inset-soft)',
|
||
color: C.bright,
|
||
borderRadius: '10px',
|
||
'& fieldset': { borderColor: C.border },
|
||
}}
|
||
>
|
||
<MenuItem value="multipart">Multipart Form-Data (Standard)</MenuItem>
|
||
<MenuItem value="binary-stream">Binary Audio Stream (Deepgram/Azure)</MenuItem>
|
||
<MenuItem value="json-base64">JSON Base64 (Gemini / Google STT)</MenuItem>
|
||
<MenuItem value="custom-rest">Custom REST API</MenuItem>
|
||
</Select>
|
||
</FormControl>
|
||
|
||
<TextField
|
||
label="Default Language"
|
||
value={sttLanguage}
|
||
onChange={(e) => setSttLanguage(e.target.value)}
|
||
required
|
||
size="small"
|
||
placeholder="ko, en, auto"
|
||
sx={{
|
||
'& .MuiOutlinedInput-root': { bgcolor: 'var(--d3-bg-inset-soft)', color: C.bright, borderRadius: '10px', fontFamily: FONT_MONO },
|
||
'& .MuiInputLabel-root': { color: C.dim },
|
||
}}
|
||
/>
|
||
|
||
<TextField
|
||
label="Cost Per Minute ($)"
|
||
type="number"
|
||
inputProps={{ step: '0.0001' }}
|
||
value={sttCostPerMinute}
|
||
onChange={(e) => setSttCostPerMinute(e.target.value)}
|
||
required
|
||
size="small"
|
||
sx={{
|
||
'& .MuiOutlinedInput-root': { bgcolor: 'var(--d3-bg-inset-soft)', color: C.bright, borderRadius: '10px', fontFamily: FONT_MONO },
|
||
'& .MuiInputLabel-root': { color: C.dim },
|
||
}}
|
||
/>
|
||
</Box>
|
||
|
||
<Box sx={{ display: 'grid', gridTemplateColumns: { xs: '1fr', md: '1fr 1fr' }, gap: 2 }}>
|
||
<TextField
|
||
label="Fallback Priority (1 = Top)"
|
||
type="number"
|
||
value={sttFallbackPriority}
|
||
onChange={(e) => setSttFallbackPriority(parseInt(e.target.value) || 1)}
|
||
required
|
||
size="small"
|
||
sx={{
|
||
'& .MuiOutlinedInput-root': { bgcolor: 'var(--d3-bg-inset-soft)', color: C.bright, borderRadius: '10px', fontFamily: FONT_MONO },
|
||
'& .MuiInputLabel-root': { color: C.dim },
|
||
}}
|
||
/>
|
||
<TextField
|
||
label="Domain Vocabulary Prompt / Guide Words (Optional)"
|
||
value={sttPrompt}
|
||
onChange={(e) => setSttPrompt(e.target.value)}
|
||
size="small"
|
||
placeholder="e.g. D3RO, Kubernetes, React, LLM"
|
||
sx={{
|
||
'& .MuiOutlinedInput-root': { bgcolor: 'var(--d3-bg-inset-soft)', color: C.bright, borderRadius: '10px' },
|
||
'& .MuiInputLabel-root': { color: C.dim },
|
||
}}
|
||
/>
|
||
</Box>
|
||
|
||
<TextField
|
||
label="Audit memo"
|
||
value={sttMemo}
|
||
onChange={(event) => setSttMemo(event.target.value)}
|
||
required
|
||
helperText="변경 사유를 3자 이상 입력하세요."
|
||
size="small"
|
||
sx={{ '& .MuiOutlinedInput-root': { bgcolor: 'var(--d3-bg-inset-soft)', color: C.bright, borderRadius: '10px' } }}
|
||
/>
|
||
|
||
{/* Test Connection Inside Modal */}
|
||
<Box sx={{ p: 2, borderRadius: '12px', bgcolor: 'var(--d3-bg-inset-soft)', border: `1px solid ${C.border}`, display: 'flex', flexDirection: 'column', gap: 1.5 }}>
|
||
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||
<Typography sx={{ fontFamily: FONT_SANS, fontSize: '13px', fontWeight: 600, color: C.bright }}>
|
||
Live Connection Test (Synthetic Audio Ping)
|
||
</Typography>
|
||
<Button
|
||
size="small"
|
||
variant="outlined"
|
||
onClick={handleTestInModal}
|
||
disabled={testingInModal}
|
||
sx={{
|
||
fontFamily: FONT_MONO,
|
||
fontSize: '11px',
|
||
color: C.bright,
|
||
borderColor: C.borderHl,
|
||
textTransform: 'none',
|
||
'&:hover': { borderColor: C.accentLight, bgcolor: 'var(--d3-accent-glow)' },
|
||
}}
|
||
>
|
||
{testingInModal ? <CircularProgress size={14} sx={{ color: C.bright, mr: 1 }} /> : null}
|
||
{testingInModal ? 'Testing...' : '⚡ Test API Credentials'}
|
||
</Button>
|
||
</Box>
|
||
|
||
{sttTestModalResult && (
|
||
<Alert
|
||
severity={sttTestModalResult.success ? 'success' : 'error'}
|
||
variant="outlined"
|
||
sx={{
|
||
fontFamily: FONT_SANS,
|
||
fontSize: '12px',
|
||
borderColor: sttTestModalResult.success ? 'var(--d3-status-success)' : 'var(--d3-status-danger)',
|
||
color: sttTestModalResult.success ? C.green400 : 'var(--d3-status-danger)',
|
||
}}
|
||
>
|
||
{sttTestModalResult.message}
|
||
</Alert>
|
||
)}
|
||
</Box>
|
||
</DialogContent>
|
||
<DialogActions sx={{ px: 3, pb: 3, pt: 1, borderTop: `1px solid ${C.border}` }}>
|
||
<Button onClick={() => setSttModalOpen(false)} sx={{ color: C.dim, textTransform: 'none' }}>
|
||
Cancel
|
||
</Button>
|
||
<Button type="submit" variant="contained" disabled={sttLoading || sttMemo.trim().length < 3} sx={primaryButtonSx}>
|
||
{sttLoading ? 'Saving...' : 'Save STT Provider'}
|
||
</Button>
|
||
</DialogActions>
|
||
</Box>
|
||
</Dialog>
|
||
|
||
{/* ── LLM Model Add Modal ── */}
|
||
<Dialog
|
||
open={llmModalOpen}
|
||
onClose={() => setLlmModalOpen(false)}
|
||
maxWidth="sm"
|
||
fullWidth
|
||
PaperProps={{
|
||
sx: {
|
||
bgcolor: C.card,
|
||
border: `1px solid ${C.borderHl}`,
|
||
borderRadius: '20px',
|
||
boxShadow: '0 24px 60px var(--d3-scrim)',
|
||
},
|
||
}}
|
||
>
|
||
<DialogTitle sx={{ fontFamily: FONT_SANS, fontWeight: 500, color: C.bright, borderBottom: `1px solid ${C.border}`, px: 3, py: 2.5 }}>
|
||
Add Reasoning Model Endpoint
|
||
</DialogTitle>
|
||
<Box component="form" onSubmit={handleAddLlmEndpoint}>
|
||
<DialogContent sx={{ px: 3, py: 3, display: 'flex', flexDirection: 'column', gap: 2.5 }}>
|
||
<FormControl fullWidth size="small">
|
||
<InputLabel sx={{ color: C.dim }}>⚡ Load Preset Template (optional)</InputLabel>
|
||
<Select
|
||
value=""
|
||
label="⚡ Load Preset Template (optional)"
|
||
onChange={(e) => {
|
||
const preset = PRESET_LLM_MODELS.find((p) => p.modelId === e.target.value)
|
||
if (!preset) return
|
||
setLlmModelId(preset.modelId)
|
||
setLlmModelName(preset.modelName)
|
||
setLlmProvider(preset.provider)
|
||
setLlmEndpointUrl(preset.endpointUrl)
|
||
setLlmPromptCost(preset.promptCost)
|
||
setLlmCompletionCost(preset.completionCost)
|
||
}}
|
||
sx={{
|
||
bgcolor: 'var(--d3-bg-inset-soft)',
|
||
color: C.bright,
|
||
borderRadius: '10px',
|
||
'& fieldset': { borderColor: C.border },
|
||
}}
|
||
>
|
||
{PRESET_LLM_MODELS.map((preset) => (
|
||
<MenuItem key={preset.modelId} value={preset.modelId}>
|
||
{preset.modelName}
|
||
</MenuItem>
|
||
))}
|
||
</Select>
|
||
</FormControl>
|
||
<TextField
|
||
label="Model ID"
|
||
value={llmModelId}
|
||
onChange={(e) => setLlmModelId(e.target.value)}
|
||
required
|
||
fullWidth
|
||
size="small"
|
||
sx={{ '& .MuiOutlinedInput-root': { bgcolor: 'var(--d3-bg-inset-soft)', color: C.bright, borderRadius: '10px', fontFamily: FONT_MONO } }}
|
||
/>
|
||
<TextField
|
||
label="Display Name"
|
||
value={llmModelName}
|
||
onChange={(e) => setLlmModelName(e.target.value)}
|
||
required
|
||
fullWidth
|
||
size="small"
|
||
sx={{ '& .MuiOutlinedInput-root': { bgcolor: 'var(--d3-bg-inset-soft)', color: C.bright, borderRadius: '10px' } }}
|
||
/>
|
||
<FormControl fullWidth size="small">
|
||
<InputLabel sx={{ color: C.dim }}>Provider Category</InputLabel>
|
||
<Select
|
||
value={llmProvider}
|
||
label="Provider Category"
|
||
onChange={(e) => setLlmProvider(e.target.value)}
|
||
sx={{ bgcolor: 'var(--d3-bg-inset-soft)', color: C.bright, borderRadius: '10px' }}
|
||
>
|
||
<MenuItem value="Local Sidecar">Local Sidecar</MenuItem>
|
||
<MenuItem value="Ollama Local">Ollama Local Engine</MenuItem>
|
||
<MenuItem value="OpenAI">OpenAI</MenuItem>
|
||
<MenuItem value="Anthropic">Anthropic</MenuItem>
|
||
<MenuItem value="Custom">Custom REST</MenuItem>
|
||
</Select>
|
||
</FormControl>
|
||
<TextField
|
||
label="Endpoint URL"
|
||
value={llmEndpointUrl}
|
||
onChange={(e) => setLlmEndpointUrl(e.target.value)}
|
||
required
|
||
fullWidth
|
||
size="small"
|
||
sx={{ '& .MuiOutlinedInput-root': { bgcolor: 'var(--d3-bg-inset-soft)', color: C.bright, borderRadius: '10px', fontFamily: FONT_MONO } }}
|
||
/>
|
||
<TextField
|
||
label="API Key (Optional)"
|
||
type="password"
|
||
value={llmApiKey}
|
||
onChange={(e) => setLlmApiKey(e.target.value)}
|
||
fullWidth
|
||
size="small"
|
||
sx={{ '& .MuiOutlinedInput-root': { bgcolor: 'var(--d3-bg-inset-soft)', color: C.bright, borderRadius: '10px', fontFamily: FONT_MONO } }}
|
||
/>
|
||
<Box sx={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 2 }}>
|
||
<TextField
|
||
label="Prompt Cost ($/1K)"
|
||
type="number"
|
||
inputProps={{ step: '0.000001' }}
|
||
value={llmPromptCost}
|
||
onChange={(e) => setLlmPromptCost(e.target.value)}
|
||
required
|
||
size="small"
|
||
sx={{ '& .MuiOutlinedInput-root': { bgcolor: 'var(--d3-bg-inset-soft)', color: C.bright, borderRadius: '10px', fontFamily: FONT_MONO } }}
|
||
/>
|
||
<TextField
|
||
label="Completion Cost ($/1K)"
|
||
type="number"
|
||
inputProps={{ step: '0.000001' }}
|
||
value={llmCompletionCost}
|
||
onChange={(e) => setLlmCompletionCost(e.target.value)}
|
||
required
|
||
size="small"
|
||
sx={{ '& .MuiOutlinedInput-root': { bgcolor: 'var(--d3-bg-inset-soft)', color: C.bright, borderRadius: '10px', fontFamily: FONT_MONO } }}
|
||
/>
|
||
</Box>
|
||
<TextField
|
||
label="Audit memo"
|
||
value={llmMemo}
|
||
onChange={(event) => setLlmMemo(event.target.value)}
|
||
required
|
||
helperText="생성 사유를 3자 이상 입력하세요."
|
||
size="small"
|
||
sx={{ '& .MuiOutlinedInput-root': { bgcolor: 'var(--d3-bg-inset-soft)', color: C.bright, borderRadius: '10px' } }}
|
||
/>
|
||
</DialogContent>
|
||
<DialogActions sx={{ px: 3, pb: 3, pt: 1, borderTop: `1px solid ${C.border}` }}>
|
||
<Button onClick={() => setLlmModalOpen(false)} sx={{ color: C.dim, textTransform: 'none' }}>
|
||
Cancel
|
||
</Button>
|
||
<Button type="submit" variant="contained" disabled={llmLoading || llmMemo.trim().length < 3} sx={primaryButtonSx}>
|
||
{llmLoading ? 'Saving...' : 'Save Endpoint'}
|
||
</Button>
|
||
</DialogActions>
|
||
</Box>
|
||
</Dialog>
|
||
</>
|
||
)
|
||
}
|