Skip to content

Instantly share code, notes, and snippets.

@Barqawiz
Created August 1, 2023 13:13
Show Gist options
  • Save Barqawiz/dc501574bedf5b3fb38ab54a7a9a95c6 to your computer and use it in GitHub Desktop.
Save Barqawiz/dc501574bedf5b3fb38ab54a7a9a95c6 to your computer and use it in GitHub Desktop.
// When copying the code to the same file, ensure removing the repeated imports
const { Chatbot, ChatGPTInput, ChatGPTMessage } = require('intellinode');
app.get('/chatgpt', async (req, res) => {
const chatbot = new Chatbot(process.env.OPENAI_API_KEY, 'openai');
const system = 'You are a helpful assistant.';
const input = new ChatGPTInput(system);
input.addUserMessage(req.query.message);
const responses = await chatbot.chat(input);
res.json({ responses });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment