@restnfeel/agentc-starter-kit
Version:
한국어 기업용 CMS 모듈 - Task Master AI와 함께 빠르게 웹사이트를 구현할 수 있는 재사용 가능한 컴포넌트 시스템
78 lines (75 loc) • 6.57 kB
JavaScript
"use client";
import { jsxs, jsx } from 'react/jsx-runtime';
import { useState, useEffect } from 'react';
import { Card, CardHeader, CardContent } from '../ui/Card.js';
import { Button } from '../ui/Button.js';
import { Input } from '../ui/Input.js';
const defaultConfig = {
systemMessage: "당신은 친절하고 도움이 되는 AI 어시스턴트입니다.",
model: "gpt-3.5-turbo",
temperature: 0.7,
maxTokens: 1000,
topP: 1.0,
frequencyPenalty: 0.0,
presencePenalty: 0.0,
};
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, value) => {
setConfig((prev) => ({ ...prev, [field]: value }));
};
return (jsxs(Card, { children: [jsx(CardHeader, { children: jsxs("div", { className: "flex items-center justify-between", children: [jsxs("div", { children: [jsx("h3", { className: "text-lg font-semibold", children: "\u2699\uFE0F AI \uC124\uC815 \uAD00\uB9AC" }), jsx("p", { className: "text-sm text-gray-600", children: "AI \uBAA8\uB378\uC758 \uB3D9\uC791 \uBC29\uC2DD\uC744 \uC870\uC815\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4." })] }), jsxs("div", { className: "flex space-x-2", children: [jsx(Button, { onClick: resetConfig, variant: "outline", size: "sm", children: "\uCD08\uAE30\uD654" }), jsx(Button, { onClick: saveConfig, disabled: saving, size: "sm", children: saving ? "저장 중..." : "저장" })] })] }) }), jsx(CardContent, { children: loading ? (jsxs("div", { className: "text-center py-8", children: [jsx("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto" }), jsx("p", { className: "mt-2 text-gray-600", children: "\uC124\uC815\uC744 \uB85C\uB4DC\uD558\uB294 \uC911..." })] })) : (jsxs("div", { className: "space-y-6", children: [jsxs("div", { children: [jsx("label", { className: "block text-sm font-medium text-gray-700 mb-2", children: "\uC2DC\uC2A4\uD15C \uBA54\uC2DC\uC9C0" }), jsx("textarea", { value: config.systemMessage, onChange: (e) => handleInputChange("systemMessage", e.target.value), className: "w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500", rows: 4, placeholder: "AI\uC758 \uC5ED\uD560\uACFC \uD589\uB3D9 \uBC29\uC2DD\uC744 \uC124\uBA85\uD558\uC138\uC694..." }), jsx("p", { className: "text-xs text-gray-500 mt-1", children: "AI\uAC00 \uC5B4\uB5BB\uAC8C \uD589\uB3D9\uD574\uC57C \uD558\uB294\uC9C0 \uC124\uBA85\uD569\uB2C8\uB2E4." })] }), jsxs("div", { children: [jsx("label", { className: "block text-sm font-medium text-gray-700 mb-2", children: "\uBAA8\uB378" }), jsxs("select", { value: config.model, onChange: (e) => handleInputChange("model", e.target.value), className: "w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500", children: [jsx("option", { value: "gpt-3.5-turbo", children: "GPT-3.5 Turbo" }), jsx("option", { value: "gpt-4", children: "GPT-4" }), jsx("option", { value: "gpt-4-turbo", children: "GPT-4 Turbo" })] })] }), jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [jsx("div", { children: jsx(Input, { label: "Temperature", type: "number", min: "0", max: "2", step: "0.1", value: config.temperature, onChange: (e) => handleInputChange("temperature", parseFloat(e.target.value)), helperText: "\uCC3D\uC758\uC131 (0=\uC77C\uAD00\uC801, 2=\uCC3D\uC758\uC801)" }) }), jsx("div", { children: jsx(Input, { label: "Max Tokens", type: "number", min: "1", max: "4000", value: config.maxTokens, onChange: (e) => handleInputChange("maxTokens", parseInt(e.target.value)), helperText: "\uCD5C\uB300 \uC751\uB2F5 \uAE38\uC774" }) }), jsx("div", { children: jsx(Input, { label: "Top P", type: "number", min: "0", max: "1", step: "0.1", value: config.topP, onChange: (e) => handleInputChange("topP", parseFloat(e.target.value)), helperText: "\uB2E8\uC5B4 \uC120\uD0DD \uB2E4\uC591\uC131" }) }), jsx("div", { children: jsx(Input, { label: "Frequency Penalty", type: "number", min: "-2", max: "2", step: "0.1", value: config.frequencyPenalty, onChange: (e) => handleInputChange("frequencyPenalty", parseFloat(e.target.value)), helperText: "\uBC18\uBCF5 \uB2E8\uC5B4 \uC5B5\uC81C" }) }), jsx("div", { children: jsx(Input, { label: "Presence Penalty", type: "number", min: "-2", max: "2", step: "0.1", value: config.presencePenalty, onChange: (e) => handleInputChange("presencePenalty", parseFloat(e.target.value)), helperText: "\uC0C8\uB85C\uC6B4 \uC8FC\uC81C \uC7A5\uB824" }) })] }), jsxs("div", { className: "mt-6 p-4 bg-gray-50 rounded-lg", children: [jsx("h4", { className: "text-sm font-medium text-gray-700 mb-2", children: "\uC124\uC815 \uBBF8\uB9AC\uBCF4\uAE30" }), jsx("pre", { className: "text-xs text-gray-600 overflow-x-auto", children: JSON.stringify(config, null, 2) })] })] })) })] }));
}
export { ConfigManager };
//# sourceMappingURL=config-manager.js.map