This commit is contained in:
dsyoon
2025-08-18 16:01:06 +09:00
parent f3355d8b69
commit 7832f2c384
7 changed files with 28 additions and 18 deletions

View File

@@ -4,6 +4,7 @@ import DevChatInput from '../tools/dev_chatbot/ChatInput.jsx';
import { marked } from 'marked';
marked.setOptions({ mangle:false, headerIds:false });
import { fetchOpenAIChat, fetchOpenAIImage, classifyRequest } from '../services/openaiService';
import { API_BASE_URL } from '../config';
// === Chat History Panel 컴포넌트 추가 ===
function ChatHistoryPanel({ toolId }) {
@@ -51,7 +52,7 @@ function FileSidebar() {
const loadFiles = async () => {
try {
const res = await fetch('http://localhost:8010/files');
const res = await fetch(`${API_BASE_URL}/files`);
const data = await res.json();
setFiles(data.files || []);
} catch (_) {}
@@ -63,7 +64,7 @@ function FileSidebar() {
const handleDelete = async (fname) => {
if (!window.confirm(`${fname} 파일을 삭제하시겠습니까?`)) return;
await fetch(`http://localhost:8010/file?filename=${encodeURIComponent(fname)}`, { method: 'DELETE' });
await fetch(`${API_BASE_URL}/file?filename=${encodeURIComponent(fname)}`, { method: 'DELETE' });
loadFiles();
};
@@ -72,7 +73,7 @@ function FileSidebar() {
if (!files.length) return;
const formData = new FormData();
files.forEach((f) => formData.append('files', f));
await fetch('http://localhost:8010/upload_pdf', { method: 'POST', body: formData });
await fetch(`${API_BASE_URL}/upload_pdf`, { method: 'POST', body: formData });
loadFiles();
};
@@ -270,7 +271,7 @@ export default function ChatPage() {
const formData = new FormData();
formData.append('message', userMsg.content);
formData.append('tool_id', activeTool.id);
const res = await fetch('http://localhost:8010/chat', { method: 'POST', body: formData });
const res = await fetch(`${API_BASE_URL}/chat`, { method: 'POST', body: formData });
const data = await res.json();
botContent = data.response;
}
@@ -364,7 +365,7 @@ function DocTranslationSidebar() {
const loadFiles = async () => {
try {
const res = await fetch('http://localhost:8010/doc_translation/files');
const res = await fetch(`${API_BASE_URL}/doc_translation/files`);
const data = await res.json();
setFiles(Array.isArray(data) ? data : []);
} catch (_) {}
@@ -385,7 +386,7 @@ function DocTranslationSidebar() {
const formData = new FormData();
files.forEach((f) => formData.append('files', f));
try {
await fetch('http://localhost:8010/doc_translation/upload_doc', { method: 'POST', body: formData });
await fetch(`${API_BASE_URL}/doc_translation/upload_doc`, { method: 'POST', body: formData });
} finally {
document.body.removeChild(input);
loadFiles();
@@ -396,12 +397,12 @@ function DocTranslationSidebar() {
const handleDelete = async (serverFilename) => {
if (!window.confirm(`${extractRealFilename(serverFilename)} 파일을 삭제하시겠습니까?`)) return;
await fetch(`http://localhost:8010/doc_translation/files/${encodeURIComponent(serverFilename)}`, { method: 'DELETE' });
await fetch(`${API_BASE_URL}/doc_translation/files/${encodeURIComponent(serverFilename)}`, { method: 'DELETE' });
loadFiles();
};
const handleDownload = async (filename) => {
const res = await fetch(`http://localhost:8010/doc_translation/download/${encodeURIComponent(filename)}`);
const res = await fetch(`${API_BASE_URL}/doc_translation/download/${encodeURIComponent(filename)}`);
if (!res.ok) return alert('다운로드 실패');
const blob = await res.blob();
const url = URL.createObjectURL(blob);
@@ -478,7 +479,7 @@ function DocTranslationChat() {
// ChatPage 공통 /chat 엔드포인트의 문서번역 분기와 동일 동작을 위해 model 전달
form.append('tool_id', 'doc_translation');
form.append('model', model === 'internal' ? 'internal' : 'gpt-4o');
const res = await fetch('http://localhost:8010/chat', { method: 'POST', body: form });
const res = await fetch(`${API_BASE_URL}/chat`, { method: 'POST', body: form });
const data = await res.json();
const botContent = data.response;
setMessages((prev) => {