LibreChat/app/chatgpt.js

12 lines
337 B
JavaScript
Raw Normal View History

2023-02-04 20:09:02 -05:00
require('dotenv').config();
const ask = async (question) => {
const { ChatGPTAPI } = await import('chatgpt');
2023-02-04 20:09:02 -05:00
const api = new ChatGPTAPI({ apiKey: process.env.OPENAI_KEY });
const res = await api.sendMessage(question, {
onProgress: (partialRes) => console.log(partialRes.text)
});
return res;
};
2023-02-04 20:09:02 -05:00
module.exports = { ask };