Spaces:
Running
Running
| const generate = async (text) => { | |
| const token = 'Your API Token' | |
| const model = 'facebook/musicgen-large' | |
| const prompt = text | |
| const url = `/static-proxy?url=https%3A%2F%2Fapi.huggingface.co%2Fv1%2Fmodels%2F%3Cspan class="hljs-subst">${model}` | |
| const response = await fetch(url, { | |
| method: 'POST', | |
| body: JSON.stringify({ token, prompt }), | |
| headers: { | |
| 'Content-Type': 'application/json' | |
| } | |
| }) | |
| const json = await response.json() | |
| return json.generated_text | |
| } |