Download script.js from VethaNarayananG/MultiModel-AI-Router: direct link, hf CLI and curl.
- Browser
- Download file 860 Bytes
-
https://huggingface.co/spaces/VethaNarayananG/MultiModel-AI-Router/resolve/main/script.js
- Command line
-
hf download hf://spaces/VethaNarayananG/MultiModel-AI-Router/script.js
-
curl -L -o script.js https://huggingface.co/spaces/VethaNarayananG/MultiModel-AI-Router/resolve/main/script.js
860 Bytes
| document.getElementById("generateBtn").onclick = async function(){ | |
| const prompt = document.getElementById("prompt").value; | |
| const task = detectTask(prompt); | |
| let modelName = MODELS[task]; | |
| if(!modelName){ | |
| modelName = MODELS.text; | |
| } | |
| document.getElementById("model").innerHTML = modelName; | |
| document.getElementById("output").innerHTML = "Generating..."; | |
| const result = await queryHF(modelName,prompt); | |
| if(Array.isArray(result)){ | |
| if(result[0].generated_text){ | |
| document.getElementById("output").innerHTML = | |
| result[0].generated_text; | |
| }else{ | |
| document.getElementById("output").innerHTML = | |
| JSON.stringify(result); | |
| } | |
| }else{ | |
| document.getElementById("output").innerHTML = | |
| JSON.stringify(result,null,2); | |
| } | |
| } |