Spaces:
Running
Running
Download App.js. from MYSTRO6IX/MYSTROGAD: direct link, hf CLI and curl.
- Browser
- Download file 656 Bytes
-
https://huggingface.co/spaces/MYSTRO6IX/MYSTROGAD/resolve/main/App.js.
- Command line
-
hf download hf://spaces/MYSTRO6IX/MYSTROGAD/App.js.
-
curl -L -o App.js. https://huggingface.co/spaces/MYSTRO6IX/MYSTROGAD/resolve/main/App.js.
656 Bytes
| const API_URL = "https://router.huggingface.co/v1/chat/completions"; | |
| async function generateScript(prompt) { | |
| const response = await fetch(API_URL, { | |
| method: "POST", | |
| headers: { | |
| "Content-Type": "application/json", | |
| "Authorization": "Bearer " + HF_TOKEN | |
| }, | |
| body: JSON.stringify({ | |
| model: "Qwen/Qwen2.5-7B-Instruct", | |
| messages: [ | |
| { | |
| role: "user", | |
| content: prompt | |
| } | |
| ], | |
| max_tokens: 500 | |
| }) | |
| }); | |
| if (!response.ok) { | |
| throw new Error("AI generation failed: " + response.status); | |
| } | |
| const data = await response.json(); | |
| return data.choices[0].message.content; | |
| } | |