Spaces:
Sleeping
Sleeping
Update Index.html
Browse files- Index.html +67 -59
Index.html
CHANGED
|
@@ -1,63 +1,71 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<
|
| 3 |
-
<
|
| 4 |
-
<
|
| 5 |
-
<
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
<
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
<body>
|
| 17 |
-
<h1>🔨 PiForge V1.2</h1>
|
| 18 |
-
<p>Ethical Audit for Pi</p>
|
| 19 |
-
<div id="status">Tap to Start</div>
|
| 20 |
-
<button id="auth-btn">🔗 Entangle & Mine</button>
|
| 21 |
-
<iframe id="hf-iframe" src="https://onenoly11-piforge.hf.space" sandbox="allow-scripts allow-same-origin" style="display: none;"></iframe>
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
setTimeout(() => {
|
| 48 |
-
const iframe = document.getElementById('hf-iframe');
|
| 49 |
-
iframe.contentWindow.postMessage({ type: 'init_audit', user: authResult.user }, '*');
|
| 50 |
-
}, 500);
|
| 51 |
-
} catch (err) { document.getElementById('status').textContent = 'Tap Pi App to Auth'; }
|
| 52 |
-
});
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
}
|
| 60 |
-
});
|
| 61 |
-
</script>
|
| 62 |
-
</body>
|
| 63 |
-
</html>
|
|
|
|
| 1 |
+
<!-- Add AI Assistant Section -->
|
| 2 |
+
<div id="ai-assistant" style="display: none; margin-top: 20px; background: rgba(255,255,255,0.1); padding: 15px; border-radius: 10px;">
|
| 3 |
+
<h3>🧠 PiForge AI Assistant</h3>
|
| 4 |
+
<div id="chat-messages" style="height: 200px; overflow-y: auto; margin-bottom: 10px; padding: 10px; background: rgba(0,0,0,0.3); border-radius: 5px;"></div>
|
| 5 |
+
<div style="display: flex;">
|
| 6 |
+
<input type="text" id="ai-question" placeholder="Ask about Pi mining or development..." style="flex: 1; padding: 10px; border-radius: 5px; border: none; margin-right: 10px;">
|
| 7 |
+
<button onclick="askDeepSeek()" style="padding: 10px 15px; background: #2196F3; border: none; border-radius: 5px; color: white;">Ask</button>
|
| 8 |
+
</div>
|
| 9 |
+
</div>
|
| 10 |
+
|
| 11 |
+
<script>
|
| 12 |
+
// DeepSeek AI Integration through HF Space
|
| 13 |
+
async function askDeepSeek() {
|
| 14 |
+
const question = document.getElementById('ai-question').value;
|
| 15 |
+
const chat = document.getElementById('chat-messages');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
+
if (!question.trim()) return;
|
| 18 |
+
|
| 19 |
+
// Add user message
|
| 20 |
+
chat.innerHTML += `<div style="text-align: right; margin: 10px 0;"><b>You:</b> ${question}</div>`;
|
| 21 |
+
|
| 22 |
+
// Show loading
|
| 23 |
+
const loadingId = 'loading-' + Date.now();
|
| 24 |
+
chat.innerHTML += `<div id="${loadingId}" style="text-align: left; margin: 10px 0;"><i>DeepSeek is thinking...</i></div>`;
|
| 25 |
+
chat.scrollTop = chat.scrollHeight;
|
| 26 |
+
|
| 27 |
+
try {
|
| 28 |
+
// Call your HF Space API
|
| 29 |
+
const response = await fetch('https://onenoly11-piforge.hf.space/run/predict', {
|
| 30 |
+
method: 'POST',
|
| 31 |
+
headers: {
|
| 32 |
+
'Content-Type': 'application/json',
|
| 33 |
+
},
|
| 34 |
+
body: JSON.stringify({
|
| 35 |
+
data: [question, []]
|
| 36 |
+
})
|
| 37 |
});
|
| 38 |
+
|
| 39 |
+
const data = await response.json();
|
| 40 |
+
|
| 41 |
+
// Remove loading
|
| 42 |
+
document.getElementById(loadingId).remove();
|
| 43 |
+
|
| 44 |
+
// Add AI response
|
| 45 |
+
if (data && data.data && data.data[0]) {
|
| 46 |
+
chat.innerHTML += `<div style="text-align: left; margin: 10px 0; padding: 10px; background: rgba(255,255,255,0.2); border-radius: 5px;"><b>DeepSeek:</b> ${data.data[0]}</div>`;
|
| 47 |
+
} else {
|
| 48 |
+
chat.innerHTML += `<div style="text-align: left; margin: 10px 0; padding: 10px; background: rgba(255,107,53,0.2); border-radius: 5px;"><b>DeepSeek:</b> I'm here to help with Pi Network questions! Try asking about mining or development.</div>`;
|
| 49 |
+
}
|
| 50 |
+
} catch (error) {
|
| 51 |
+
document.getElementById(loadingId).remove();
|
| 52 |
+
chat.innerHTML += `<div style="text-align: left; margin: 10px 0; padding: 10px; background: rgba(255,107,53,0.2); border-radius: 5px;"><b>DeepSeek:</b> ${getFallbackResponse(question)}</div>`;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
document.getElementById('ai-question').value = '';
|
| 56 |
+
chat.scrollTop = chat.scrollHeight;
|
| 57 |
+
}
|
| 58 |
|
| 59 |
+
function getFallbackResponse(question) {
|
| 60 |
+
const lowerQ = question.toLowerCase();
|
| 61 |
+
if (lowerQ.includes('mining')) return "For optimal Pi mining: mine daily, maintain security circle, and use apps like PiForge for bonuses. The mining rate adjusts based on network participation.";
|
| 62 |
+
if (lowerQ.includes('sdk')) return "Pi SDK uses Pi.authenticate() for login and Pi.createPayment() for transactions. Always test in sandbox mode first and follow Pi's developer guidelines.";
|
| 63 |
+
if (lowerQ.includes('ethical')) return "Ethical scoring evaluates transparency, community benefit, and sustainability. Projects with 691+ resonance get 15% mining boosts.";
|
| 64 |
+
return "I can help with Pi Network mining strategies, app development, SDK usage, and ethical project evaluation. What specific area interests you?";
|
| 65 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
+
// Show AI assistant after auth
|
| 68 |
+
function showAIAssistant() {
|
| 69 |
+
document.getElementById('ai-assistant').style.display = 'block';
|
| 70 |
+
}
|
| 71 |
+
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|