UNPKG

@restnfeel/agentc-starter-kit

Version:

한국어 기업용 CMS 모듈 - Task Master AI와 함께 빠르게 웹사이트를 구현할 수 있는 재사용 가능한 컴포넌트 시스템

68 lines (65 loc) 5.54 kB
"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'; function ChunkManager() { const [chunks, setChunks] = useState([]); const [loading, setLoading] = useState(false); const [clearing, setClearing] = useState(false); const loadChunks = async () => { setLoading(true); try { const response = await fetch("/api/rag/chunks"); const data = await response.json(); if (data.success) { setChunks(data.chunks || []); } else { console.error("청크 로드 실패:", data.error); setChunks([]); } } catch (error) { console.error("청크 로드 오류:", error); setChunks([]); } finally { setLoading(false); } }; const clearAllChunks = async () => { if (!confirm("모든 청크를 삭제하시겠습니까? 이 작업은 되돌릴 수 없습니다.")) { return; } setClearing(true); try { const response = await fetch("/api/rag/chunks", { method: "DELETE", }); const data = await response.json(); if (data.success) { setChunks([]); alert("모든 청크가 삭제되었습니다."); } else { alert("청크 삭제 실패: " + data.error); } } catch (error) { console.error("청크 삭제 오류:", error); alert("청크 삭제 중 오류가 발생했습니다."); } finally { setClearing(false); } }; useEffect(() => { loadChunks(); }, []); 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: "\uD83D\uDCC4 \uCCAD\uD06C \uAD00\uB9AC" }), jsx("p", { className: "text-sm text-gray-600", children: "\uC800\uC7A5\uB41C \uBB38\uC11C \uCCAD\uD06C\uB97C \uD655\uC778\uD558\uACE0 \uAD00\uB9AC\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4." })] }), jsxs("div", { className: "flex space-x-2", children: [jsx(Button, { onClick: loadChunks, disabled: loading, variant: "outline", size: "sm", children: loading ? "로딩..." : "새로고침" }), jsx(Button, { onClick: clearAllChunks, disabled: clearing || chunks.length === 0, variant: "destructive", size: "sm", children: clearing ? "삭제 중..." : "전체 삭제" })] })] }) }), 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: "\uCCAD\uD06C\uB97C \uB85C\uB4DC\uD558\uB294 \uC911..." })] })) : chunks.length === 0 ? (jsxs("div", { className: "text-center py-8 text-gray-500", children: [jsx("svg", { className: "w-16 h-16 mx-auto mb-4 text-gray-300", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1, d: "M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" }) }), jsx("p", { className: "text-lg font-medium", children: "\uC800\uC7A5\uB41C \uCCAD\uD06C\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4" }), jsx("p", { className: "text-sm", children: "\uBB38\uC11C\uB97C \uC5C5\uB85C\uB4DC\uD558\uBA74 \uCCAD\uD06C\uAC00 \uC0DD\uC131\uB429\uB2C8\uB2E4." })] })) : (jsxs("div", { className: "space-y-4", children: [jsx("div", { className: "flex items-center justify-between", children: jsxs("p", { className: "text-sm text-gray-600", children: ["\uCD1D ", jsx("span", { className: "font-medium", children: chunks.length }), "\uAC1C\uC758 \uCCAD\uD06C"] }) }), jsx("div", { className: "max-h-96 overflow-y-auto space-y-3", children: chunks.map((chunk, index) => (jsxs("div", { className: "border border-gray-200 rounded-lg p-4 bg-gray-50", children: [jsxs("div", { className: "flex items-start justify-between mb-2", children: [jsxs("div", { className: "flex-1", children: [jsxs("div", { className: "flex items-center space-x-2 mb-1", children: [jsxs("span", { className: "text-xs bg-blue-100 text-blue-800 px-2 py-1 rounded", children: ["#", index + 1] }), chunk.metadata.title && (jsx("span", { className: "text-sm font-medium text-gray-700", children: chunk.metadata.title })), chunk.metadata.chunk_index !== undefined && (jsxs("span", { className: "text-xs text-gray-500", children: ["\uCCAD\uD06C ", chunk.metadata.chunk_index] }))] }), chunk.metadata.source && (jsxs("p", { className: "text-xs text-gray-500 mb-2", children: ["\uCD9C\uCC98: ", chunk.metadata.source] }))] }), jsxs("span", { className: "text-xs text-gray-400", children: [chunk.content.length, " \uBB38\uC790"] })] }), jsx("div", { className: "text-sm text-gray-700 bg-white p-3 rounded border", children: jsx("div", { className: "line-clamp-3", children: chunk.content.length > 200 ? chunk.content.substring(0, 200) + "..." : chunk.content }) })] }, chunk.id))) })] })) })] })); } export { ChunkManager }; //# sourceMappingURL=chunk-manager.js.map