Spaces:
Running
Running
const { Conversation } = require('transformers'); | |
async function main() { | |
// Load the GPT-2 pretrained model | |
const model = await Conversation.load("gpt2"); | |
// Start conversation | |
let context = ""; | |
let userMessage = "Hello, chatbot!"; | |
let response = await model.interact(context, userMessage); | |
console.log("Bot:", response.generated[0].text); | |
// Continue conversation | |
context += userMessage + "\n"; | |
userMessage = "Can you tell me about local businesses?"; | |
response = await model.interact(context, userMessage); | |
console.log("Bot:", response.generated[0].text); | |
// And so on... | |
} | |
main(); | |