Spaces:
Sleeping
Sleeping
| <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> | |