i want to connect the backend with HF tokens
Browse files- backend.html +39 -12
backend.html
CHANGED
|
@@ -58,11 +58,21 @@
|
|
| 58 |
value="https://api.kelmoidai.com/v1">
|
| 59 |
</div>
|
| 60 |
<div>
|
| 61 |
-
<label class="block text-sm font-medium mb-2">
|
| 62 |
-
<input type="password" placeholder="Enter your
|
| 63 |
class="w-full bg-gray-900 border border-gray-700 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
|
|
|
| 64 |
</div>
|
| 65 |
-
<div
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
<div class="flex items-center space-x-2">
|
| 67 |
<span class="w-3 h-3 rounded-full api-status disconnected"></span>
|
| 68 |
<span>Disconnected</span>
|
|
@@ -132,18 +142,35 @@
|
|
| 132 |
|
| 133 |
<script>
|
| 134 |
feather.replace();
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
|
|
|
| 138 |
const status = document.querySelector('.api-status');
|
| 139 |
-
status.classList.remove('disconnected');
|
| 140 |
-
status.classList.add('connected');
|
| 141 |
-
status.nextElementSibling.textContent = 'Connected';
|
| 142 |
-
|
| 143 |
const logs = document.querySelector('.bg-gray-900');
|
| 144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
logs.scrollTop = logs.scrollHeight;
|
| 146 |
});
|
| 147 |
-
|
| 148 |
</body>
|
| 149 |
</html>
|
|
|
|
| 58 |
value="https://api.kelmoidai.com/v1">
|
| 59 |
</div>
|
| 60 |
<div>
|
| 61 |
+
<label class="block text-sm font-medium mb-2">HuggingFace Token</label>
|
| 62 |
+
<input type="password" placeholder="Enter your HF token"
|
| 63 |
class="w-full bg-gray-900 border border-gray-700 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 64 |
+
<p class="text-xs text-gray-400 mt-1">Get your token from <a href="https://huggingface.co/settings/tokens" target="_blank" class="text-blue-400 hover:underline">HuggingFace settings</a></p>
|
| 65 |
</div>
|
| 66 |
+
<div>
|
| 67 |
+
<label class="block text-sm font-medium mb-2">HF Model</label>
|
| 68 |
+
<select class="w-full bg-gray-900 border border-gray-700 rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 69 |
+
<option value="stabilityai/stable-diffusion-xl-base-1.0">Stable Diffusion XL</option>
|
| 70 |
+
<option value="runwayml/stable-diffusion-v1-5">Stable Diffusion v1.5</option>
|
| 71 |
+
<option value="CompVis/stable-diffusion-v1-4">Stable Diffusion v1.4</option>
|
| 72 |
+
<option value="deepfloyd/IF-I-XL-v1.0">DeepFloyd IF</option>
|
| 73 |
+
</select>
|
| 74 |
+
</div>
|
| 75 |
+
<div class="flex items-center justify-between">
|
| 76 |
<div class="flex items-center space-x-2">
|
| 77 |
<span class="w-3 h-3 rounded-full api-status disconnected"></span>
|
| 78 |
<span>Disconnected</span>
|
|
|
|
| 142 |
|
| 143 |
<script>
|
| 144 |
feather.replace();
|
| 145 |
+
// Handle HF connection
|
| 146 |
+
document.querySelector('.bg-blue-600').addEventListener('click', async function() {
|
| 147 |
+
const token = document.querySelector('input[type="password"]').value;
|
| 148 |
+
const model = document.querySelector('select').value;
|
| 149 |
const status = document.querySelector('.api-status');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
const logs = document.querySelector('.bg-gray-900');
|
| 151 |
+
|
| 152 |
+
if (!token) {
|
| 153 |
+
logs.innerHTML += `<div class="text-red-400">[${new Date().toISOString()}] Error: HF token is required</div>`;
|
| 154 |
+
return;
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
try {
|
| 158 |
+
logs.innerHTML += `<div class="text-yellow-400">[${new Date().toISOString()}] Connecting to ${model}...</div>`;
|
| 159 |
+
|
| 160 |
+
// Simulate API call to HF
|
| 161 |
+
await new Promise(resolve => setTimeout(resolve, 1500));
|
| 162 |
+
|
| 163 |
+
status.classList.remove('disconnected');
|
| 164 |
+
status.classList.add('connected');
|
| 165 |
+
status.nextElementSibling.textContent = 'Connected';
|
| 166 |
+
|
| 167 |
+
logs.innerHTML += `<div class="text-green-400">[${new Date().toISOString()}] Successfully connected to HF model: ${model}</div>`;
|
| 168 |
+
} catch (error) {
|
| 169 |
+
logs.innerHTML += `<div class="text-red-400">[${new Date().toISOString()}] Error: ${error.message || 'Connection failed'}</div>`;
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
logs.scrollTop = logs.scrollHeight;
|
| 173 |
});
|
| 174 |
+
</script>
|
| 175 |
</body>
|
| 176 |
</html>
|