How to use this model in next js?

#90
by shreyassihasane - opened

I want to use this model for ai chat bot like for my app in next js 14

me too :")

oh, I found a way to do it:

const hf = new HfInference("yourToken")

async function Generate(){
for await (const output of hf.textGenerationStream({
model: "mistralai/Mistral-7B-Instruct-v0.2",
inputs: 'how to feel you?',
parameters: { max_new_tokens: 250 }
})) {
console.log(// ${output.token.text} //, output.generated_text);
}
}

return (




);

the final result returns the full text

(sorry i don't know how to write code in comments)

Sign up or log in to comment