async function getChristmasJoke() {
const prompt = 'Tell me a one-line Christmas joke'
const result = await hf.textGeneration({
model: 'tiiuae/falcon-7b-instruct',
inputs: prompt,
})
// const christmasJoke = result.generated_text
const generatedText = result.generated_text
const christmasJoke = generatedText.substr(prompt.length)
return christmasJoke
}
document.getElementById('window-container').addEventListener('click', async function () {
/**
* 🎄 Challenge:
* 1. When clicked, the doors should open
* to reveal a festive joke.
*
* 🎁 hint.md for help!
**/
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"
const jokeDisplay = document.getElementById('joke-display')
jokeDisplay.textContent = "Tell you a Christmas joke..."
jokeDisplay.textContent = await getChristmasJoke()
})
/** uncomment one of these **/
// import OpenAI from "openai"
import { HfInference } from '@huggingface/inference'
const apiKey = process.env.HUGGINGFACE_TOKEN
const hf = new HfInference(apiKey)