Create models.js
Browse files
models.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
async function queryHF(model, prompt){
|
| 2 |
+
|
| 3 |
+
const response = await fetch(
|
| 4 |
+
`https://api-inference.huggingface.co/models/${model}`,
|
| 5 |
+
{
|
| 6 |
+
method:"POST",
|
| 7 |
+
|
| 8 |
+
headers:{
|
| 9 |
+
"Authorization":"Bearer "+HF_TOKEN,
|
| 10 |
+
"Content-Type":"application/json"
|
| 11 |
+
},
|
| 12 |
+
|
| 13 |
+
body:JSON.stringify({
|
| 14 |
+
inputs:prompt
|
| 15 |
+
})
|
| 16 |
+
}
|
| 17 |
+
);
|
| 18 |
+
|
| 19 |
+
return await response.json();
|
| 20 |
+
|
| 21 |
+
}
|