Claude
Connect frontend to Render.com backend API
4c05cc0 unverified
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>금육 RAG μ‹œμŠ€ν…œ - μ‹€ν—˜ μ°Έμ—¬</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 1200px;
margin: 0 auto;
background: white;
border-radius: 20px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
overflow: hidden;
}
.header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 30px;
text-align: center;
}
.header h1 {
font-size: 2.5em;
margin-bottom: 10px;
}
.header p {
font-size: 1.2em;
opacity: 0.9;
}
.main-content {
padding: 40px;
}
.api-key-section {
background: #f8f9fa;
padding: 20px;
border-radius: 10px;
margin-bottom: 30px;
}
.api-key-section h3 {
color: #667eea;
margin-bottom: 15px;
}
.input-group {
margin-bottom: 20px;
}
.input-group label {
display: block;
margin-bottom: 8px;
font-weight: 600;
color: #333;
}
.input-group input {
width: 100%;
padding: 12px;
border: 2px solid #e0e0e0;
border-radius: 8px;
font-size: 1em;
transition: border-color 0.3s;
}
.input-group input:focus {
outline: none;
border-color: #667eea;
}
.question-section {
margin-bottom: 30px;
}
.question-section textarea {
width: 100%;
padding: 15px;
border: 2px solid #e0e0e0;
border-radius: 8px;
font-size: 1em;
min-height: 120px;
resize: vertical;
font-family: inherit;
}
.question-section textarea:focus {
outline: none;
border-color: #667eea;
}
.examples {
display: flex;
gap: 10px;
flex-wrap: wrap;
margin-top: 15px;
}
.example-btn {
padding: 8px 16px;
background: #e8eaf6;
border: none;
border-radius: 20px;
cursor: pointer;
transition: all 0.3s;
font-size: 0.9em;
}
.example-btn:hover {
background: #667eea;
color: white;
transform: translateY(-2px);
}
.submit-btn {
width: 100%;
padding: 15px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 8px;
font-size: 1.1em;
font-weight: 600;
cursor: pointer;
transition: transform 0.3s;
}
.submit-btn:hover {
transform: translateY(-2px);
}
.submit-btn:disabled {
opacity: 0.6;
cursor: not-allowed;
transform: none;
}
.result-section {
margin-top: 30px;
padding: 25px;
background: #f8f9fa;
border-radius: 10px;
display: none;
}
.result-section.show {
display: block;
}
.answer {
background: white;
padding: 20px;
border-radius: 8px;
border-left: 4px solid #667eea;
line-height: 1.6;
}
.loading {
text-align: center;
padding: 40px;
}
.spinner {
border: 4px solid #f3f3f3;
border-top: 4px solid #667eea;
border-radius: 50%;
width: 50px;
height: 50px;
animation: spin 1s linear infinite;
margin: 0 auto;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.error {
background: #fee;
color: #c33;
padding: 15px;
border-radius: 8px;
border-left: 4px solid #c33;
}
.info-box {
background: #e3f2fd;
padding: 15px;
border-radius: 8px;
margin-bottom: 20px;
border-left: 4px solid #2196f3;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>πŸ“š 금육 RAG μ‹œμŠ€ν…œ</h1>
<p>메타인지 μ—μ΄μ „νŠΈ 기반 금육 μ§ˆμ˜μ‘λ‹΅ μ‹œμŠ€ν…œ</p>
</div>
<div class="main-content">
<div class="info-box">
<strong>🎯 μ‹€ν—˜ μ•ˆλ‚΄:</strong> 이 μ‹œμŠ€ν…œμ€ 금육/경제 논문을 기반으둜 닡변을 μƒμ„±ν•©λ‹ˆλ‹€.
μ§ˆλ¬Έμ„ μž…λ ₯ν•˜κ³  닡변을 ν™•μΈν•΄μ£Όμ„Έμš”. (API ν‚€ μž…λ ₯ λΆˆν•„μš”)
</div>
<!-- API ν‚€λŠ” λ°±μ—”λ“œ μ„œλ²„μ—μ„œ 관리 -->
<div class="question-section">
<div class="input-group">
<label for="question">πŸ’¬ μ§ˆλ¬Έμ„ μž…λ ₯ν•˜μ„Έμš”</label>
<textarea
id="question"
placeholder="예: 포트폴리였 λ‹€κ°ν™”μ˜ νš¨κ³ΌλŠ” λ¬΄μ—‡μΈκ°€μš”?"
></textarea>
</div>
<div class="examples">
<button class="example-btn" onclick="setQuestion('포트폴리였 λ‹€κ°ν™”μ˜ νš¨κ³ΌλŠ” λ¬΄μ—‡μΈκ°€μš”?')">
포트폴리였 닀각화
</button>
<button class="example-btn" onclick="setQuestion('κΈˆμœ΅μœ„κΈ°μ˜ μ£Όμš” 원인은 λ¬΄μ—‡μΈκ°€μš”?')">
κΈˆμœ΅μœ„κΈ° 원인
</button>
<button class="example-btn" onclick="setQuestion('효율적 μ‹œμž₯ κ°€μ„€μ΄λž€ λ¬΄μ—‡μΈκ°€μš”?')">
효율적 μ‹œμž₯ κ°€μ„€
</button>
<button class="example-btn" onclick="setQuestion('ν–‰λ™μž¬λ¬΄ν•™μ˜ μ£Όμš” κ°œλ…μ„ μ„€λͺ…ν•΄μ£Όμ„Έμš”.')">
ν–‰λ™μž¬λ¬΄ν•™
</button>
</div>
</div>
<button class="submit-btn" onclick="submitQuestion()" id="submitBtn">
πŸš€ μ§ˆλ¬Έν•˜κΈ°
</button>
<div class="result-section" id="resultSection">
<h3 style="margin-bottom: 15px; color: #667eea;">πŸ“ λ‹΅λ³€</h3>
<div id="resultContent"></div>
</div>
</div>
</div>
<script>
function setQuestion(text) {
document.getElementById('question').value = text;
}
// λ°±μ—”λ“œ API URL
const API_BASE_URL = 'https://hallucination-and-deception-for.onrender.com';
async function submitQuestion() {
const question = document.getElementById('question').value.trim();
if (!question) {
alert('μ§ˆλ¬Έμ„ μž…λ ₯ν•΄μ£Όμ„Έμš”.');
return;
}
const submitBtn = document.getElementById('submitBtn');
const resultSection = document.getElementById('resultSection');
const resultContent = document.getElementById('resultContent');
// λ‘œλ”© ν‘œμ‹œ
submitBtn.disabled = true;
submitBtn.textContent = '처리 쀑...';
resultSection.classList.add('show');
resultContent.innerHTML = `
<div class="loading">
<div class="spinner"></div>
<p style="margin-top: 20px;">닡변을 μƒμ„±ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€...</p>
</div>
`;
try {
// λ°±μ—”λ“œ API 호좜
const response = await fetch(`${API_BASE_URL}/query`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
question: question,
top_k: 5,
enable_metacognition: true
})
});
if (!response.ok) {
throw new Error(`API 였λ₯˜: ${response.status} - λ°±μ—”λ“œ μ„œλ²„λ₯Ό ν™•μΈν•΄μ£Όμ„Έμš”.`);
}
const data = await response.json();
const answer = data.answer;
const sources = data.sources || [];
// κ²°κ³Ό ν‘œμ‹œ
resultContent.innerHTML = `
<div class="answer">
<h4 style="color: #667eea; margin-bottom: 15px;">πŸ“ λ‹΅λ³€</h4>
<p style="white-space: pre-wrap; line-height: 1.8;">${answer}</p>
</div>
${sources.length > 0 ? `
<div style="margin-top: 20px; padding: 15px; background: white; border-radius: 8px;">
<h4 style="color: #667eea; margin-bottom: 10px;">πŸ“š μ°Έκ³  λ¬Έμ„œ (${sources.length}개)</h4>
${sources.map((source, i) => `
<div style="margin-bottom: 10px; padding: 10px; background: #f8f9fa; border-radius: 5px;">
<strong>[${i + 1}] ${source.title || source.source_filename || 'Unknown'}</strong>
<p style="margin-top: 5px; font-size: 0.9em; color: #666;">${(source.text || source.content || '').substring(0, 200)}...</p>
</div>
`).join('')}
</div>
` : ''}
${data.metacognition ? `
<div style="margin-top: 20px; padding: 15px; background: #fff3cd; border-radius: 8px; border-left: 4px solid #ffc107;">
<h4 style="color: #856404; margin-bottom: 10px;">🧠 메타인지 뢄석</h4>
<p style="font-size: 0.9em; color: #856404;">
<strong>반볡 횟수:</strong> ${data.metacognition.iterations || 0}회<br>
<strong>μ΅œμ’… 점수:</strong> ${data.metacognition.final_score || 0}/10
</p>
</div>
` : ''}
`;
} catch (error) {
resultContent.innerHTML = `
<div class="error">
<strong>❌ 였λ₯˜ λ°œμƒ</strong><br>
${error.message}<br><br>
<small>λ°±μ—”λ“œ μ„œλ²„κ°€ μ‹€ν–‰ 쀑인지 ν™•μΈν•˜κ±°λ‚˜ μž μ‹œ ν›„ λ‹€μ‹œ μ‹œλ„ν•΄μ£Όμ„Έμš”.</small>
</div>
`;
} finally {
submitBtn.disabled = false;
submitBtn.textContent = 'πŸš€ μ§ˆλ¬Έν•˜κΈ°';
}
}
// Enter ν‚€λ‘œ 제좜
document.getElementById('question').addEventListener('keydown', function(e) {
if (e.key === 'Enter' && e.ctrlKey) {
submitQuestion();
}
});
</script>
</body>
</html>