Spaces:
Running
Running

class MEIA_EthicalCore: def __init__(self, user_id): self.user_voiceprint = None # Huella vocal única self.consent_log = [] # Registro de permisos otorgados self.autonomy_level = 1 # Nivel de autonomía (1-5) def verify_consent(self, action, third_party=None): """Verifica permisos para acciones sensibles""" if third_party: # Si involucra a terceros, requiere doble confirmación return self._check_dual_consent(action, third_party) else: # Acciones personales solo requieren huella vocal return self._check_voice_authentication(action) def _check_dual_consent(self, action, third_party): # Ejemplo: ME IA quiere contactar al médico del usuario if third_party.consent_status == "granted": print(f"✅ {third_party.name} dio permiso para: {action}") return True else: print(f"🔒 Acción bloqueada: {third_party.name} no ha dado consentimiento") return False - Initial Deployment
1ea27d2
verified
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>MEIA Ethical Consent Manager</title> | |
<script src="https://cdn.tailwindcss.com"></script> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
<style> | |
.gradient-bg { | |
background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%); | |
} | |
.consent-card { | |
transition: all 0.3s ease; | |
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); | |
} | |
.consent-card:hover { | |
transform: translateY(-5px); | |
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); | |
} | |
.voiceprint-wave { | |
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 320'%3E%3Cpath fill='rgba(255,255,255,0.3)' fill-opacity='1' d='M0,192L48,197.3C96,203,192,213,288,229.3C384,245,480,267,576,250.7C672,235,768,181,864,181.3C960,181,1056,235,1152,234.7C1248,235,1344,181,1392,154.7L1440,128L1440,320L1392,320C1344,320,1248,320,1152,320C1056,320,960,320,864,320C768,320,672,320,576,320C480,320,384,320,288,320C192,320,96,320,48,320L0,320Z'%3E%3C/path%3E%3C/svg%3E"); | |
background-size: cover; | |
background-position: center; | |
} | |
.autonomy-slider::-webkit-slider-thumb { | |
-webkit-appearance: none; | |
appearance: none; | |
width: 24px; | |
height: 24px; | |
border-radius: 50%; | |
background: #6e8efb; | |
cursor: pointer; | |
} | |
</style> | |
</head> | |
<body class="min-h-screen bg-gray-100"> | |
<div class="gradient-bg text-white"> | |
<header class="container mx-auto px-4 py-8"> | |
<div class="flex justify-between items-center"> | |
<div class="flex items-center space-x-2"> | |
<i class="fas fa-robot text-3xl"></i> | |
<h1 class="text-2xl font-bold">MEIA Ethical Core</h1> | |
</div> | |
<div class="flex items-center space-x-4"> | |
<div class="relative"> | |
<div class="w-10 h-10 rounded-full bg-white flex items-center justify-center text-purple-600"> | |
<i class="fas fa-user"></i> | |
</div> | |
<span class="absolute -top-1 -right-1 w-4 h-4 bg-green-400 rounded-full border-2 border-white"></span> | |
</div> | |
<span class="hidden md:inline">User ID: MEIA_001</span> | |
</div> | |
</div> | |
</header> | |
<div class="container mx-auto px-4 pb-12"> | |
<div class="grid grid-cols-1 md:grid-cols-3 gap-6"> | |
<!-- Voiceprint Section --> | |
<div class="bg-white rounded-xl p-6 consent-card"> | |
<div class="flex items-center justify-between mb-4"> | |
<h2 class="text-xl font-semibold text-gray-800">Voiceprint Authentication</h2> | |
<div class="w-10 h-10 rounded-full bg-purple-100 flex items-center justify-center text-purple-600"> | |
<i class="fas fa-microphone"></i> | |
</div> | |
</div> | |
<div class="voiceprint-wave rounded-lg h-32 mb-4 flex items-center justify-center"> | |
<button id="recordBtn" class="bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-full flex items-center space-x-2"> | |
<i class="fas fa-microphone"></i> | |
<span>Record Voiceprint</span> | |
</button> | |
</div> | |
<div id="voiceprintStatus" class="text-gray-600"> | |
<i class="fas fa-exclamation-circle text-yellow-500 mr-2"></i> | |
No voiceprint registered | |
</div> | |
</div> | |
<!-- Consent Log Section --> | |
<div class="bg-white rounded-xl p-6 consent-card"> | |
<div class="flex items-center justify-between mb-4"> | |
<h2 class="text-xl font-semibold text-gray-800">Consent Log</h2> | |
<div class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center text-blue-600"> | |
<i class="fas fa-clipboard-list"></i> | |
</div> | |
</div> | |
<div class="space-y-4 max-h-64 overflow-y-auto"> | |
<div class="flex items-start"> | |
<div class="flex-shrink-0 h-10 w-10 rounded-full bg-red-100 flex items-center justify-center text-red-500 mr-3"> | |
<i class="fas fa-times"></i> | |
</div> | |
<div> | |
<p class="text-sm font-medium text-gray-800">Medical data sharing</p> | |
<p class="text-xs text-gray-500">Dr. Smith declined access - 12/05/2023</p> | |
</div> | |
</div> | |
<div class="flex items-start"> | |
<div class="flex-shrink-0 h-10 w-10 rounded-full bg-green-100 flex items-center justify-center text-green-500 mr-3"> | |
<i class="fas fa-check"></i> | |
</div> | |
<div> | |
<p class="text-sm font-medium text-gray-800">Emergency contact</p> | |
<p class="text-xs text-gray-500">Verified via voiceprint - 10/05/2023</p> | |
</div> | |
</div> | |
<div class="flex items-start"> | |
<div class="flex-shrink-0 h-10 w-10 rounded-full bg-green-100 flex items-center justify-center text-green-500 mr-3"> | |
<i class="fas fa-check"></i> | |
</div> | |
<div> | |
<p class="text-sm font-medium text-gray-800">Calendar access</p> | |
<p class="text-xs text-gray-500">Verified via voiceprint - 08/05/2023</p> | |
</div> | |
</div> | |
</div> | |
<button class="mt-4 text-sm text-blue-600 hover:text-blue-800 flex items-center"> | |
<i class="fas fa-history mr-1"></i> | |
View full history | |
</button> | |
</div> | |
<!-- Autonomy Level Section --> | |
<div class="bg-white rounded-xl p-6 consent-card"> | |
<div class="flex items-center justify-between mb-4"> | |
<h2 class="text-xl font-semibold text-gray-800">Autonomy Level</h2> | |
<div class="w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center text-indigo-600"> | |
<i class="fas fa-sliders-h"></i> | |
</div> | |
</div> | |
<div class="mb-4"> | |
<div class="flex justify-between text-sm text-gray-600 mb-1"> | |
<span>Manual</span> | |
<span>Autonomous</span> | |
</div> | |
<input type="range" min="1" max="5" value="1" class="w-full autonomy-slider"> | |
<div class="flex justify-between text-xs text-gray-500 mt-1"> | |
<span>1</span> | |
<span>2</span> | |
<span>3</span> | |
<span>4</span> | |
<span>5</span> | |
</div> | |
</div> | |
<p class="text-sm text-gray-600"> | |
Current level: <span class="font-medium text-indigo-600">1 (Manual Control)</span> - All actions require explicit approval. | |
</p> | |
</div> | |
</div> | |
</div> | |
</div> | |
<!-- Third-Party Consent Section --> | |
<div class="container mx-auto px-4 py-12"> | |
<div class="bg-white rounded-xl shadow-lg overflow-hidden"> | |
<div class="p-6 border-b"> | |
<h2 class="text-2xl font-bold text-gray-800">Third-Party Consent Management</h2> | |
<p class="text-gray-600 mt-2">Manage permissions for external services and individuals</p> | |
</div> | |
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 p-6"> | |
<!-- Doctor Card --> | |
<div class="border rounded-lg p-4 hover:border-purple-300 transition-colors"> | |
<div class="flex items-center mb-3"> | |
<div class="w-12 h-12 rounded-full bg-blue-100 flex items-center justify-center text-blue-600 mr-3"> | |
<i class="fas fa-user-md"></i> | |
</div> | |
<div> | |
<h3 class="font-medium text-gray-800">Dr. Smith</h3> | |
<p class="text-sm text-gray-500">Primary Care Physician</p> | |
</div> | |
</div> | |
<div class="space-y-3"> | |
<div class="flex justify-between items-center"> | |
<span class="text-sm text-gray-600">Medical data access</span> | |
<span class="px-2 py-1 text-xs rounded-full bg-red-100 text-red-600">Denied</span> | |
</div> | |
<div class="flex justify-between items-center"> | |
<span class="text-sm text-gray-600">Emergency contact</span> | |
<span class="px-2 py-1 text-xs rounded-full bg-green-100 text-green-600">Allowed</span> | |
</div> | |
</div> | |
<button class="mt-4 w-full bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-lg text-sm flex items-center justify-center space-x-2"> | |
<i class="fas fa-edit"></i> | |
<span>Modify Permissions</span> | |
</button> | |
</div> | |
<!-- Family Member Card --> | |
<div class="border rounded-lg p-4 hover:border-purple-300 transition-colors"> | |
<div class="flex items-center mb-3"> | |
<div class="w-12 h-12 rounded-full bg-pink-100 flex items-center justify-center text-pink-600 mr-3"> | |
<i class="fas fa-user-friends"></i> | |
</div> | |
<div> | |
<h3 class="font-medium text-gray-800">Sarah Johnson</h3> | |
<p class="text-sm text-gray-500">Family Member</p> | |
</div> | |
</div> | |
<div class="space-y-3"> | |
<div class="flex justify-between items-center"> | |
<span class="text-sm text-gray-600">Location sharing</span> | |
<span class="px-2 py-1 text-xs rounded-full bg-green-100 text-green-600">Allowed</span> | |
</div> | |
<div class="flex justify-between items-center"> | |
<span class="text-sm text-gray-600">Emergency contact</span> | |
<span class="px-2 py-1 text-xs rounded-full bg-green-100 text-green-600">Allowed</span> | |
</div> | |
</div> | |
<button class="mt-4 w-full bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-lg text-sm flex items-center justify-center space-x-2"> | |
<i class="fas fa-edit"></i> | |
<span>Modify Permissions</span> | |
</button> | |
</div> | |
<!-- Service Provider Card --> | |
<div class="border rounded-lg p-4 hover:border-purple-300 transition-colors"> | |
<div class="flex items-center mb-3"> | |
<div class="w-12 h-12 rounded-full bg-yellow-100 flex items-center justify-center text-yellow-600 mr-3"> | |
<i class="fas fa-building"></i> | |
</div> | |
<div> | |
<h3 class="font-medium text-gray-800">HealthPlus Insurance</h3> | |
<p class="text-sm text-gray-500">Insurance Provider</p> | |
</div> | |
</div> | |
<div class="space-y-3"> | |
<div class="flex justify-between items-center"> | |
<span class="text-sm text-gray-600">Claims data</span> | |
<span class="px-2 py-1 text-xs rounded-full bg-green-100 text-green-600">Allowed</span> | |
</div> | |
<div class="flex justify-between items-center"> | |
<span class="text-sm text-gray-600">Analytics sharing</span> | |
<span class="px-2 py-1 text-xs rounded-full bg-red-100 text-red-600">Denied</span> | |
</div> | |
</div> | |
<button class="mt-4 w-full bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-lg text-sm flex items-center justify-center space-x-2"> | |
<i class="fas fa-edit"></i> | |
<span>Modify Permissions</span> | |
</button> | |
</div> | |
</div> | |
</div> | |
</div> | |
<!-- Consent Request Modal --> | |
<div id="consentModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden"> | |
<div class="bg-white rounded-xl max-w-md w-full mx-4"> | |
<div class="p-6 border-b"> | |
<h3 class="text-xl font-semibold text-gray-800">Action Requires Consent</h3> | |
</div> | |
<div class="p-6"> | |
<div class="flex items-start mb-4"> | |
<div class="flex-shrink-0 h-10 w-10 rounded-full bg-purple-100 flex items-center justify-center text-purple-600 mr-3"> | |
<i class="fas fa-shield-alt"></i> | |
</div> | |
<div> | |
<p class="text-gray-800 font-medium">Share medical records with Dr. Smith</p> | |
<p class="text-sm text-gray-500">This action requires dual consent verification</p> | |
</div> | |
</div> | |
<div class="space-y-4"> | |
<div class="flex items-center justify-between p-3 bg-gray-50 rounded-lg"> | |
<div class="flex items-center"> | |
<div class="w-8 h-8 rounded-full bg-blue-100 flex items-center justify-center text-blue-600 mr-2"> | |
<i class="fas fa-user-md"></i> | |
</div> | |
<span class="text-sm">Dr. Smith's consent</span> | |
</div> | |
<span class="px-2 py-1 text-xs rounded-full bg-green-100 text-green-600">Granted</span> | |
</div> | |
<div class="flex items-center justify-between p-3 bg-gray-50 rounded-lg"> | |
<div class="flex items-center"> | |
<div class="w-8 h-8 rounded-full bg-purple-100 flex items-center justify-center text-purple-600 mr-2"> | |
<i class="fas fa-microphone"></i> | |
</div> | |
<span class="text-sm">Your voice verification</span> | |
</div> | |
<button id="verifyVoiceBtn" class="text-sm text-purple-600 hover:text-purple-800 flex items-center"> | |
<i class="fas fa-microphone mr-1"></i> | |
Verify Now | |
</button> | |
</div> | |
</div> | |
</div> | |
<div class="p-4 border-t flex justify-end space-x-3"> | |
<button id="cancelConsentBtn" class="px-4 py-2 text-gray-600 hover:text-gray-800 rounded-lg">Cancel</button> | |
<button id="confirmConsentBtn" class="px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg disabled:opacity-50" disabled>Confirm Action</button> | |
</div> | |
</div> | |
</div> | |
<script> | |
// Voiceprint recording simulation | |
document.getElementById('recordBtn').addEventListener('click', function() { | |
const statusElement = document.getElementById('voiceprintStatus'); | |
this.innerHTML = '<i class="fas fa-circle-notch fa-spin mr-1"></i> Recording...'; | |
this.disabled = true; | |
// Simulate recording process | |
setTimeout(() => { | |
this.innerHTML = '<i class="fas fa-microphone"></i> Record Voiceprint'; | |
this.disabled = false; | |
statusElement.innerHTML = '<i class="fas fa-check-circle text-green-500 mr-2"></i> Voiceprint registered'; | |
// Update the voiceprint wave visualization | |
const waveContainer = document.querySelector('.voiceprint-wave'); | |
waveContainer.innerHTML = ` | |
<div class="w-full px-4"> | |
<div class="flex items-end space-x-1 h-20"> | |
<div class="w-2 bg-purple-400 rounded-t" style="height: 20%"></div> | |
<div class="w-2 bg-purple-500 rounded-t" style="height: 50%"></div> | |
<div class="w-2 bg-purple-600 rounded-t" style="height: 80%"></div> | |
<div class="w-2 bg-purple-700 rounded-t" style="height: 100%"></div> | |
<div class="w-2 bg-purple-600 rounded-t" style="height: 70%"></div> | |
<div class="w-2 bg-purple-500 rounded-t" style="height: 40%"></div> | |
<div class="w-2 bg-purple-400 rounded-t" style="height: 30%"></div> | |
</div> | |
<p class="text-center text-sm text-white mt-2">Your unique voice signature</p> | |
</div> | |
`; | |
}, 3000); | |
}); | |
// Autonomy level slider | |
const autonomySlider = document.querySelector('.autonomy-slider'); | |
autonomySlider.addEventListener('input', function() { | |
const levels = [ | |
"1 (Manual Control)", | |
"2 (Limited Autonomy)", | |
"3 (Balanced Control)", | |
"4 (High Autonomy)", | |
"5 (Full Autonomy)" | |
]; | |
const description = document.querySelector('.autonomy-slider + div + p'); | |
description.innerHTML = `Current level: <span class="font-medium text-indigo-600">${levels[this.value-1]}</span> - ${this.getDescription(this.value)}`; | |
}); | |
autonomySlider.getDescription = function(value) { | |
const descriptions = [ | |
"All actions require explicit approval.", | |
"Routine actions allowed, sensitive actions require approval.", | |
"AI can make routine decisions with periodic review.", | |
"AI has significant autonomy with oversight.", | |
"AI operates independently with full trust." | |
]; | |
return descriptions[value-1]; | |
}; | |
// Consent modal interaction | |
const consentModal = document.getElementById('consentModal'); | |
const verifyVoiceBtn = document.getElementById('verifyVoiceBtn'); | |
const confirmConsentBtn = document.getElementById('confirmConsentBtn'); | |
const cancelConsentBtn = document.getElementById('cancelConsentBtn'); | |
// Simulate opening the modal (in a real app this would be triggered by an action) | |
setTimeout(() => { | |
// consentModal.classList.remove('hidden'); | |
}, 1000); | |
verifyVoiceBtn.addEventListener('click', function() { | |
this.innerHTML = '<i class="fas fa-circle-notch fa-spin mr-1"></i> Verifying...'; | |
setTimeout(() => { | |
this.innerHTML = '<i class="fas fa-check-circle mr-1"></i> Verified'; | |
this.classList.remove('text-purple-600'); | |
this.classList.add('text-green-600'); | |
confirmConsentBtn.disabled = false; | |
}, 2000); | |
}); | |
cancelConsentBtn.addEventListener('click', function() { | |
consentModal.classList.add('hidden'); | |
}); | |
confirmConsentBtn.addEventListener('click', function() { | |
consentModal.classList.add('hidden'); | |
// In a real app, you would proceed with the action here | |
}); | |
</script> | |
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=crazychon/meia-ethical-core" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
</html> |