const API_BASE_URL = 'http://localhost:8000/api/v1'; // Ethics Evaluation document.getElementById('ethics-form').addEventListener('submit', async (e) => { e.preventDefault(); const decision = document.getElementById('decision').value; try { const response = await fetch(`${API_BASE_URL}/ethics/evaluate`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ decision }), }); const result = await response.json(); displayEthicsResult(result); } catch (error) { console.error('Error:', error); alert('An error occurred while evaluating ethics.'); } }); function displayEthicsResult(result) { const resultDiv = document.getElementById('ethics-result'); resultDiv.innerHTML = `
Decision Score: ${result.decision_score}
Explanation: ${result.explanation}
Concerns:
Improvement Suggestions:
No results found.
'; return; } resultsDiv.innerHTML = results.map(entry => `${entry.content}
Tags: ${entry.tags.join(', ')}
Author: ${entry.author_id}
Created: ${new Date(entry.created_at).toLocaleString()}