onenoly11 commited on
Commit
ba6c008
·
verified ·
1 Parent(s): 66d535a

Update Index.html

Browse files
Files changed (1) hide show
  1. Index.html +67 -59
Index.html CHANGED
@@ -1,63 +1,71 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
6
- <title>PiForge</title>
7
- <link rel="manifest" href="data:application/manifest+json;base64,[base64-encoded manifest below]">
8
- <style>
9
- body { font-family: -apple-system, sans-serif; background: linear-gradient(red, yellow); color: white; text-align: center; margin: 0; padding: 20px; touch-action: manipulation; }
10
- #iframe-container { width: 100%; height: 70vh; border: none; }
11
- #status { margin: 10px; padding: 15px; background: rgba(0,0,0,0.5); border-radius: 10px; font-size: 16px; }
12
- button { background: #ff6b35; color: white; border: none; padding: 15px 30px; border-radius: 10px; cursor: pointer; font-size: 18px; min-height: 50px; width: 90%; margin: 10px auto; display: block; }
13
- @media (max-width: 414px) { button { font-size: 20px; padding: 20px; } } /* iPhone boost */
14
- </style>
15
- </head>
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
- <!-- Inline Pi SDK & Integration (no external loads for iPhone speed) -->
24
- <script>
25
- // Pi SDK (lite version for iOS)
26
- window.Pi = { init: async (opts) => { /* Simulate init for demo; real: load via Pi app */ return { version: '2.0' }; }, authenticate: async (scopes) => ({ user: { username: 'iPhoneUser' } }) };
27
-
28
- document.addEventListener('DOMContentLoaded', () => {
29
- document.getElementById('status').textContent = 'Pi Ready on iPhone!';
30
- document.getElementById('auth-btn').style.display = 'block';
31
- // Touch gesture for viz swipe
32
- let touchStartX = 0;
33
- document.addEventListener('touchstart', e => touchStartX = e.touches[0].clientX);
34
- document.addEventListener('touchend', e => {
35
- const deltaX = e.changedTouches[0].clientX - touchStartX;
36
- if (Math.abs(deltaX) > 50) { /* Swipe to trigger resonance */ alert('Resonance Activated! +15% Boost'); }
37
- });
 
 
 
 
 
38
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
- document.getElementById('auth-btn').addEventListener('touchstart', async (e) => { // Touch-optimized
41
- e.preventDefault();
42
- try {
43
- const authResult = await Pi.authenticate(['username']);
44
- document.getElementById('status').textContent = `Hi, ${authResult.user.username}! Audit Loading...`;
45
- document.getElementById('hf-iframe').style.display = 'block';
46
- // Post to HF (iPhone-safe)
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
- window.addEventListener('message', (event) => {
55
- if (event.data.type === 'ethical_audit_complete' && event.data.results.resonance >= 691) {
56
- document.getElementById('status').textContent = `Score: ${event.data.results.ethical_score} | Boost: +15% Mining!`;
57
- // iPhone haptic feedback (if supported)
58
- if (navigator.vibrate) navigator.vibrate(200);
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>