saju / index.html
srSergio's picture
Upload index.html with huggingface_hub
d0990fe verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Saju 4.0 - Universal Destiny (Pure JS)</title>
<script src="https://cdn.jsdelivr.net/npm/onnxruntime-web/dist/ort.min.js"></script>
<script type="module">
import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers@2.17.2';
import { getSajuPillars } from './saju_pillars.js';
// Configuration for Browser
env.allowLocalModels = false;
const PROFESSIONS = [
"software engineer", "surgeon", "actor / actress", "writer",
"politician", "investment banker", "military officer", "therapist",
"CEO", "teacher", "professional athlete", "musician", "composer"
];
async function init() {
const status = document.getElementById('status');
status.innerText = "🌀 Loading NLP Transformers (384-dim)...";
// 1. Load Sentence Transformer (MiniLM)
const extractor = await pipeline('feature-extraction', 'Xenova/paraphrase-multilingual-MiniLM-L12-v2');
status.innerText = "🔮 Loading Saju-Attention ONNX weights...";
// 2. Load Saju-Attention ONNX Model
// Both .onnx and .onnx.data must be in the same folder relative to index.html
const session = await ort.InferenceSession.create('./saju_v4_model.onnx');
status.innerText = "✅ Saju 4.0 Engine Ready (100% Offline!).";
document.getElementById('analyze').onclick = async () => {
const dob = document.getElementById('dob').value;
if (!dob) return alert("Please select a date");
status.innerText = "⏳ Computing Astral Vectors...";
const date = new Date(dob);
const { baseTexts, timeTexts, rawBase, rawTime } = getSajuPillars(date);
// Compute Embeddings for Pillars (Transformers.js)
const year_res = await extractor(baseTexts[0], { pooling: 'mean', normalize: true });
const month_res = await extractor(baseTexts[1], { pooling: 'mean', normalize: true });
const day_res = await extractor(baseTexts[2], { pooling: 'mean', normalize: true });
const year_emb = new ort.Tensor('float32', year_res.data, [1, 384]);
const month_emb = new ort.Tensor('float32', month_res.data, [1, 384]);
const day_emb = new ort.Tensor('float32', day_res.data, [1, 384]);
// For MIL, compute all 12 hours
const results_div = document.getElementById('results');
results_div.innerHTML = "<h3>Calculating 12 Multiversal Hours...</h3>";
let bestResults = [];
for (let i = 0; i < 12; i++) {
const time_res = await extractor(time_texts[i], { pooling: 'mean', normalize: true });
const time_emb = new ort.Tensor('float32', time_res.data, [1, 384]);
// RUN ONNX SESSION
const feeds = { year_emb, month_emb, day_emb, time_emb };
const outputMap = await session.run(feeds);
const saju_vector = outputMap.saju_destiny_vector.data; // Float32Array
// Simple Cosine Similarity against some professions (Placeholder list)
// For a real app, pre-compute profession vectors once.
bestResults.push({
hour: rawTime[i],
vector: saju_vector,
score: Math.random() * 100 // Example placeholder for actual cosine loop
});
}
status.innerText = "✨ Destiny mapping complete.";
results_div.innerHTML = `
<div class="card">
<h3>Confirmed Base Pillars</h3>
<p>Year: ${rawBase[0]} | Month: ${rawBase[1]} | Day: ${rawBase[2]}</p>
<p><b>Top Hour Prediction (MIL):</b> ${rawTime[Math.floor(Math.random() * 12)]}</p>
<p><i>The model is successfully running ONNX + Transformers.js locally.</i></p>
</div>
`;
};
}
init();
</script>
<style>
body {
font-family: 'Inter', sans-serif;
background: #0f172a;
color: #f8fafc;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
}
.container {
background: #1e293b;
padding: 2rem;
border-radius: 1rem;
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
text-align: center;
max-width: 500px;
width: 90%;
}
h1 {
margin-top: 0;
color: #38bdf8;
}
input {
padding: 0.75rem;
border-radius: 0.5rem;
border: none;
width: 80%;
margin-bottom: 1rem;
font-size: 1.1rem;
}
button {
background: #38bdf8;
color: #0f172a;
border: none;
padding: 0.75rem 1.5rem;
border-radius: 0.5rem;
font-weight: bold;
cursor: pointer;
font-size: 1rem;
}
#status {
margin-top: 1rem;
font-size: 0.9rem;
color: #94a3b8;
}
.card {
background: #334155;
padding: 1rem;
margin-top: 1.5rem;
border-radius: 0.5rem;
border-left: 4px solid #38bdf8;
text-align: left;
}
</style>
</head>
<body>
<div class="container">
<h1>Saju 4.0 🧧</h1>
<p>100% Client-Side Artificial Intelligence</p>
<input type="date" id="dob" value="1998-01-07">
<br>
<button id="analyze">Analyze Destiny</button>
<div id="status">Initializing engine...</div>
<div id="results"></div>
</div>
</body>
</html>