Support gated models (#8)
Browse files- Support gated models (19538ae70ae5dda844587ac3f37388412001a308)
Co-authored-by: Smaug Leterrible <AliceThirty@users.noreply.huggingface.co>
- index.html +30 -6
index.html
CHANGED
|
@@ -76,19 +76,24 @@
|
|
| 76 |
"Q8_0": 8.5,
|
| 77 |
}
|
| 78 |
|
| 79 |
-
async function modelConfig(hf_model) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
let config = await fetch(
|
| 81 |
-
`https://huggingface.co/${hf_model}/raw/main/config.json
|
| 82 |
).then(r => r.json())
|
| 83 |
let model_size = 0
|
| 84 |
try {
|
| 85 |
-
model_size = (await fetch(`https://huggingface.co/${hf_model}/resolve/main/model.safetensors.index.json
|
| 86 |
if (isNaN(model_size)) {
|
| 87 |
throw new Erorr("no size in safetensors metadata")
|
| 88 |
}
|
| 89 |
} catch (e) {
|
| 90 |
try {
|
| 91 |
-
model_size = (await fetch(`https://huggingface.co/${hf_model}/resolve/main/pytorch_model.bin.index.json
|
| 92 |
if (isNaN(model_size)) {
|
| 93 |
throw new Erorr("no size in pytorch metadata")
|
| 94 |
}
|
|
@@ -157,7 +162,7 @@
|
|
| 157 |
|
| 158 |
async function calculateSizes(format) {
|
| 159 |
try {
|
| 160 |
-
const model_config = await modelConfig(document.getElementById("modelsearch").value)
|
| 161 |
const context = parseInt(document.getElementById("contextsize").value)
|
| 162 |
let bsz = 512
|
| 163 |
let cache_bit = 16
|
|
@@ -204,10 +209,29 @@
|
|
| 204 |
LLM Model, Can I run it?
|
| 205 |
</h1>
|
| 206 |
<p>
|
| 207 |
-
|
| 208 |
</p>
|
|
|
|
| 209 |
<div class="flex flex-col gap-10">
|
| 210 |
<div class="w-auto flex flex-col gap-4">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
<!-- GPU Selector -->
|
| 212 |
<div
|
| 213 |
class="relative"
|
|
|
|
| 76 |
"Q8_0": 8.5,
|
| 77 |
}
|
| 78 |
|
| 79 |
+
async function modelConfig(hf_model, hf_token) {
|
| 80 |
+
auth = hf_token == "" ? {} : {
|
| 81 |
+
headers: {
|
| 82 |
+
'Authorization': `Bearer ${hf_token}`
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
let config = await fetch(
|
| 86 |
+
`https://huggingface.co/${hf_model}/raw/main/config.json`, auth
|
| 87 |
).then(r => r.json())
|
| 88 |
let model_size = 0
|
| 89 |
try {
|
| 90 |
+
model_size = (await fetch(`https://huggingface.co/${hf_model}/resolve/main/model.safetensors.index.json`, auth).then(r => r.json()))["metadata"]["total_size"] / 2
|
| 91 |
if (isNaN(model_size)) {
|
| 92 |
throw new Erorr("no size in safetensors metadata")
|
| 93 |
}
|
| 94 |
} catch (e) {
|
| 95 |
try {
|
| 96 |
+
model_size = (await fetch(`https://huggingface.co/${hf_model}/resolve/main/pytorch_model.bin.index.json`, auth).then(r => r.json()))["metadata"]["total_size"] / 2
|
| 97 |
if (isNaN(model_size)) {
|
| 98 |
throw new Erorr("no size in pytorch metadata")
|
| 99 |
}
|
|
|
|
| 162 |
|
| 163 |
async function calculateSizes(format) {
|
| 164 |
try {
|
| 165 |
+
const model_config = await modelConfig(document.getElementById("modelsearch").value, document.getElementById("hf_token").value)
|
| 166 |
const context = parseInt(document.getElementById("contextsize").value)
|
| 167 |
let bsz = 512
|
| 168 |
let cache_bit = 16
|
|
|
|
| 209 |
LLM Model, Can I run it?
|
| 210 |
</h1>
|
| 211 |
<p>
|
| 212 |
+
To support gated or private repos, you need to <a href="https://huggingface.co/settings/tokens" style="color: #4444ff"><b>create an authentification token</b></a>, to check the box <span style="color: #6e1818"><b>"Read access to contents of all public gated repos you can access"</b></span> and then enter the token in the field below.
|
| 213 |
</p>
|
| 214 |
+
|
| 215 |
<div class="flex flex-col gap-10">
|
| 216 |
<div class="w-auto flex flex-col gap-4">
|
| 217 |
+
<!-- Huggingface Authentification Token -->
|
| 218 |
+
<div
|
| 219 |
+
class="relative"
|
| 220 |
+
x-data="{
|
| 221 |
+
results: null,
|
| 222 |
+
query: null
|
| 223 |
+
}"
|
| 224 |
+
>
|
| 225 |
+
<label
|
| 226 |
+
for="gpusearch"
|
| 227 |
+
class="absolute -top-2 left-2 inline-block bg-white px-1 text-xs font-medium text-gray-900"
|
| 228 |
+
>Huggingface Token (optional)</label
|
| 229 |
+
>
|
| 230 |
+
<input
|
| 231 |
+
class="block w-full rounded-md border-0 p-3 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
|
| 232 |
+
id="hf_token"
|
| 233 |
+
/>
|
| 234 |
+
</div>
|
| 235 |
<!-- GPU Selector -->
|
| 236 |
<div
|
| 237 |
class="relative"
|