Spaces:
Sleeping
Sleeping
File size: 10,117 Bytes
9cf8b0f 28f9176 9cf8b0f 28f9176 9cf8b0f 28f9176 9cf8b0f 28f9176 9cf8b0f 28f9176 9cf8b0f 28f9176 9cf8b0f 28f9176 9cf8b0f 28f9176 9cf8b0f 28f9176 9cf8b0f 28f9176 9cf8b0f 28f9176 9cf8b0f 28f9176 9cf8b0f 28f9176 9cf8b0f 28f9176 9cf8b0f 28f9176 9cf8b0f 28f9176 9cf8b0f 28f9176 9cf8b0f 28f9176 9cf8b0f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
<!-- Replace your existing AI assistant section with this enhanced version -->
<div id="ai-assistant" style="display: none; margin-top: 20px; background: rgba(255,255,255,0.1); padding: 20px; border-radius: 10px;">
<h3>🧠 PiForge AI Pro (DeepSeek Powered)</h3>
<!-- AI Mode Selector -->
<div style="margin-bottom: 15px; display: flex; gap: 10px; align-items: center;">
<label style="font-size: 14px;">
<input type="checkbox" id="advanced-ai" checked> Advanced AI Mode
</label>
<button onclick="clearAIChat()" style="padding: 5px 10px; background: #ff6b35; border: none; border-radius: 3px; color: white; font-size: 12px;">Clear Chat</button>
</div>
<!-- Enhanced Chat Interface -->
<div id="chat-messages" style="height: 250px; overflow-y: auto; margin-bottom: 15px; padding: 15px; background: rgba(0,0,0,0.3); border-radius: 8px; border: 1px solid rgba(255,255,255,0.1);"></div>
<!-- Quick Action Buttons -->
<div style="display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 15px;">
<button onclick="quickQuestion('How do I optimize my Pi mining?')" style="padding: 8px 12px; background: rgba(76,175,80,0.3); border: 1px solid #4CAF50; border-radius: 5px; color: white; font-size: 12px;">Mining Help</button>
<button onclick="quickQuestion('Pi SDK authentication code example')" style="padding: 8px 12px; background: rgba(33,150,243,0.3); border: 1px solid #2196F3; border-radius: 5px; color: white; font-size: 12px;">SDK Code</button>
<button onclick="quickQuestion('Explain ethical scoring algorithm')" style="padding: 8px 12px; background: rgba(255,107,53,0.3); border: 1px solid #ff6b35; border-radius: 5px; color: white; font-size: 12px;">Ethical Scoring</button>
</div>
<!-- Input Area -->
<div style="display: flex; gap: 10px;">
<input type="text" id="ai-question" placeholder="Ask DeepSeek about Pi development, code, or strategy..." style="flex: 1; padding: 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.3); background: rgba(255,255,255,0.1); color: white;">
<button onclick="askDeepSeekPro()" style="padding: 12px 20px; background: #2196F3; border: none; border-radius: 8px; color: white; font-weight: bold;">Ask DeepSeek</button>
</div>
<!-- Status Indicator -->
<div id="ai-status" style="margin-top: 10px; font-size: 12px; opacity: 0.7;"></div>
</div>
<script>
// Enhanced AI functionality
let aiConversationHistory = [];
async function askDeepSeekPro() {
const question = document.getElementById('ai-question').value;
const chat = document.getElementById('chat-messages');
const useAdvanced = document.getElementById('advanced-ai').checked;
const status = document.getElementById('ai-status');
if (!question.trim()) return;
// Add user message
const userMessageId = 'user-' + Date.now();
chat.innerHTML += `
<div id="${userMessageId}" style="text-align: right; margin: 15px 0;">
<div style="display: inline-block; background: rgba(76,175,80,0.3); padding: 10px 15px; border-radius: 15px; max-width: 80%; border: 1px solid rgba(76,175,80,0.5);">
<b>You:</b> ${question}
</div>
</div>
`;
// Show loading with mode indicator
const loadingId = 'loading-' + Date.now();
const modeText = useAdvanced ? 'DeepSeek Pro' : 'Standard AI';
chat.innerHTML += `
<div id="${loadingId}" style="text-align: left; margin: 15px 0;">
<div style="display: inline-block; background: rgba(255,255,255,0.1); padding: 10px 15px; border-radius: 15px; border: 1px dashed rgba(255,255,255,0.3);">
<i>${modeText} is thinking...</i>
</div>
</div>
`;
status.textContent = useAdvanced ? 'Using DeepSeek Pro API...' : 'Using standard AI...';
chat.scrollTop = chat.scrollHeight;
try {
const response = await fetch('https://onenoly11-piforge.hf.space/run/predict', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
data: [question, aiConversationHistory, useAdvanced]
})
});
const data = await response.json();
// Remove loading
document.getElementById(loadingId).remove();
// Add AI response
if (data && data.data && data.data[0]) {
const aiResponse = data.data[0];
chat.innerHTML += `
<div style="text-align: left; margin: 15px 0;">
<div style="display: inline-block; background: rgba(33,150,243,0.2); padding: 15px; border-radius: 15px; max-width: 85%; border: 1px solid rgba(33,150,243,0.4);">
<b>🤖 DeepSeek${useAdvanced ? ' Pro' : ''}:</b> ${aiResponse}
</div>
</div>
`;
// Update conversation history
aiConversationHistory.push([question, aiResponse]);
status.textContent = `Response received (${modeText})`;
} else {
throw new Error('No data received');
}
} catch (error) {
document.getElementById(loadingId).remove();
chat.innerHTML += `
<div style="text-align: left; margin: 15px 0;">
<div style="display: inline-block; background: rgba(255,107,53,0.2); padding: 15px; border-radius: 15px; border: 1px solid rgba(255,107,53,0.4);">
<b>🤖 DeepSeek:</b> ${getEnhancedFallbackResponse(question)}
</div>
</div>
`;
status.textContent = 'Using enhanced fallback response';
}
document.getElementById('ai-question').value = '';
chat.scrollTop = chat.scrollHeight;
// Auto-clear status after 3 seconds
setTimeout(() => {
status.textContent = 'Ready for questions';
}, 3000);
}
function quickQuestion(question) {
document.getElementById('ai-question').value = question;
askDeepSeekPro();
}
function clearAIChat() {
document.getElementById('chat-messages').innerHTML = '';
aiConversationHistory = [];
document.getElementById('ai-status').textContent = 'Chat cleared';
// Add welcome message back
setTimeout(() => {
showAIAssistant();
}, 500);
}
function getEnhancedFallbackResponse(question) {
const lowerQ = question.toLowerCase();
if (lowerQ.includes('mining') || lowerQ.includes('pi coin')) {
return `**Pi Mining Optimization:**
- Mine daily at consistent times
- Maintain and grow your security circle
- Use Pi apps like PiForge for bonus rates
- Engage with the Pi community
- Stay updated with Pi Network news
Current mining rates adjust based on network participation and lockup commitments.`;
}
else if (lowerQ.includes('sdk') || lowerQ.includes('authenticate') || lowerQ.includes('code')) {
return `**Pi SDK Implementation:**
\`\`\`javascript
// Initialize Pi SDK
await Pi.init({ version: "2.0", sandbox: true });
// Authenticate user
const scopes = ['username', 'payments'];
const authResult = await Pi.authenticate(scopes, onIncompletePaymentFound);
// Create payment
const payment = await Pi.createPayment({
amount: 0.1,
memo: "Example payment",
metadata: { type: 'boost' }
});
\`\`\`
Always test in sandbox mode first and follow Pi's security guidelines.`;
}
else if (lowerQ.includes('ethical') || lowerQ.includes('scoring') || lowerQ.includes('resonance')) {
return `**Ethical Scoring System:**
PiForge evaluates projects on multiple dimensions:
- **Transparency** (25%): Clear goals and open communication
- **Community Value** (30%): Benefits to Pi ecosystem
- **Technical Soundness** (20%): Feasible implementation
- **Sustainability** (25%): Long-term viability
Projects scoring 691+ resonance receive 15% mining boosts.`;
}
else if (lowerQ.includes('boost') || lowerQ.includes('bonus')) {
return `**Mining Boost Activation:**
- Achieve 691+ ethical resonance score
- Authenticate with Pi Wallet
- Complete ethical audit process
- Boost applies for 24 hours
- Can be reactivated after cooldown
Current boost: +15% mining rate`;
}
else {
return `I can provide detailed help with:
- **Pi Network Development**: SDK integration, authentication, payments
- **Mining Strategies**: Optimization, boost activation, best practices
- **Ethical Scoring**: Algorithm details, resonance calculation, improvements
- **Technical Implementation**: Code examples, architecture, security
What specific area would you like to explore in detail?`;
}
}
// Enhanced AI assistant show function
function showAIAssistant() {
const aiAssistant = document.getElementById('ai-assistant');
if (aiAssistant) {
aiAssistant.style.display = 'block';
const chat = document.getElementById('chat-messages');
chat.innerHTML = `
<div style="text-align: left; margin: 15px 0;">
<div style="display: inline-block; background: rgba(33,150,243,0.2); padding: 15px; border-radius: 15px; border: 1px solid rgba(33,150,243,0.4);">
<b>🤖 DeepSeek Pro:</b> Welcome! I'm your advanced AI assistant with full DeepSeek capabilities.
I can help with Pi Network development, code examples, mining optimization, and ethical scoring algorithms.
What would you like to explore today?
</div>
</div>
`;
document.getElementById('ai-status').textContent = 'Advanced AI ready - Full DeepSeek access enabled';
}
}
</script> |