"use client"; import React, { useState, useEffect } from "react"; import { Card, CardHeader, CardContent } from "../ui/Card"; import { Button } from "../ui/Button"; import { Input } from "../ui/Input"; interface AgentConfig { systemMessage: string; model: string; temperature: number; maxTokens: number; topP: number; frequencyPenalty: number; presencePenalty: number; } const defaultConfig: AgentConfig = { systemMessage: "당신은 친절하고 도움이 되는 AI 어시스턴트입니다.", model: "gpt-3.5-turbo", temperature: 0.7, maxTokens: 1000, topP: 1.0, frequencyPenalty: 0.0, presencePenalty: 0.0, }; export function ConfigManager() { const [config, setConfig] = useState(defaultConfig); const [loading, setLoading] = useState(false); const [saving, setSaving] = useState(false); const loadConfig = async () => { setLoading(true); try { const response = await fetch("/api/rag/config"); const data = await response.json(); if (data.success) { setConfig({ ...defaultConfig, ...data.config }); } } catch (error) { console.error("설정 로드 오류:", error); } finally { setLoading(false); } }; const saveConfig = async () => { setSaving(true); try { const response = await fetch("/api/rag/config", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(config), }); const data = await response.json(); if (data.success) { alert("설정이 저장되었습니다."); } else { alert("설정 저장 실패: " + data.error); } } catch (error) { console.error("설정 저장 오류:", error); alert("설정 저장 중 오류가 발생했습니다."); } finally { setSaving(false); } }; const resetConfig = async () => { if (!confirm("설정을 초기화하시겠습니까?")) return; setConfig(defaultConfig); alert("설정이 초기화되었습니다. 저장 버튼을 눌러 적용하세요."); }; useEffect(() => { loadConfig(); }, []); const handleInputChange = ( field: keyof AgentConfig, value: string | number ) => { setConfig((prev) => ({ ...prev, [field]: value })); }; return (

⚙️ AI 설정 관리

AI 모델의 동작 방식을 조정할 수 있습니다.

{loading ? (

설정을 로드하는 중...

) : (
{/* 시스템 메시지 */}