Download script.js from VethaNarayananG/MultiModel-AI-Router: direct link, hf CLI and curl.
- Browser
- Download file 2.34 kB
-
https://huggingface.co/spaces/VethaNarayananG/MultiModel-AI-Router/resolve/91d37c4d65f33412a7b7e5bbeb6476700fa5388e/script.js
- Command line
-
hf download hf://spaces/VethaNarayananG/MultiModel-AI-Router@91d37c4d65f33412a7b7e5bbeb6476700fa5388e/script.js
-
curl -L -o script.js https://huggingface.co/spaces/VethaNarayananG/MultiModel-AI-Router/resolve/91d37c4d65f33412a7b7e5bbeb6476700fa5388e/script.js
2.34 kB
| const keywords = { | |
| image: [ | |
| "image", | |
| "draw", | |
| "paint", | |
| "picture", | |
| "photo", | |
| "art", | |
| "illustration", | |
| "generate image" | |
| ], | |
| translation: [ | |
| "translate", | |
| "translation", | |
| "convert language" | |
| ], | |
| summary: [ | |
| "summarize", | |
| "summary", | |
| "shorten" | |
| ], | |
| code: [ | |
| "code", | |
| "python", | |
| "java", | |
| "cpp", | |
| "c++", | |
| "program" | |
| ], | |
| speech: [ | |
| "speech", | |
| "voice", | |
| "audio" | |
| ], | |
| ocr: [ | |
| "ocr", | |
| "scan", | |
| "extract text" | |
| ], | |
| caption: [ | |
| "caption", | |
| "describe image" | |
| ] | |
| }; | |
| function detectModel(prompt){ | |
| prompt = prompt.toLowerCase(); | |
| for(let task in keywords){ | |
| for(let word of keywords[task]){ | |
| if(prompt.includes(word)){ | |
| return task; | |
| } | |
| } | |
| } | |
| return "text"; | |
| } | |
| document.getElementById("generateBtn").onclick=function(){ | |
| const prompt=document.getElementById("prompt").value; | |
| const task=detectModel(prompt); | |
| let model=""; | |
| let output=""; | |
| switch(task){ | |
| case "image": | |
| model="Stable Diffusion XL"; | |
| output="πΌ Image Generation Model Selected"; | |
| break; | |
| case "translation": | |
| model="NLLB-200"; | |
| output="π Translation Model Selected"; | |
| break; | |
| case "summary": | |
| model="BART"; | |
| output="π Summarization Model Selected"; | |
| break; | |
| case "code": | |
| model="Code Llama"; | |
| output="π» Code Generation Model Selected"; | |
| break; | |
| case "speech": | |
| model="Whisper"; | |
| output="π€ Speech Recognition Model Selected"; | |
| break; | |
| case "ocr": | |
| model="TrOCR"; | |
| output="π· OCR Model Selected"; | |
| break; | |
| case "caption": | |
| model="BLIP"; | |
| output="πΌ Image Captioning Model Selected"; | |
| break; | |
| default: | |
| model="Gemma 3"; | |
| output="π¬ Text Generation Model Selected"; | |
| } | |
| document.getElementById("model").innerHTML=model; | |
| document.getElementById("output").innerHTML=output; | |
| } |