Spaces:
Running
Running
File size: 656 Bytes
4d678a9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
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;
}
|