scrimba
Note at 1:08
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Note at 1:08
AboutCommentsNotes
Note at 1:08
Expand for more info
index.js
run
preview
console
import { HfInference } from '@huggingface/inference'

document.getElementById('window-container').addEventListener('click', async function () {



const hf = new HfInference(process.env.HF_TOKEN)
const response = await hf.textGeneration({
inputs: 'tell me a christmas joke?',
max_length: 20,
temperature: 0.7,
role: "assistant",
model: "HuggingFaceH4/zephyr-7b-beta",
})

console.log(response)

document.getElementById("joke-display").innerHTML = response.generated_text

document.querySelector('.left-door').style = "animation: left-open 0.3s forwards"
document.querySelector('.right-door').style = "animation: right-open 0.3s forwards"
document.querySelector('.joke-display').style = "animation: display-joke 0.3s forwards"
})
Console
{generated_text:
"tell me a christmas joke? Sure, here's a Christmas joke for you: Why did the snowman have to go to the doctor? Answer: Because he was feeling a little frosty! I hope that made you smile! Merry Christmas!"
}
,
/index.html
LIVE