mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-21 10:50:14 +01:00
chat methods defined, also test file for library testing
This commit is contained in:
parent
7c4e7ab07a
commit
641dcfad73
2 changed files with 35 additions and 6 deletions
|
|
@ -1,10 +1,12 @@
|
|||
require('dotenv').config();
|
||||
(async () => {
|
||||
|
||||
const ask = async (question) => {
|
||||
const { ChatGPTAPI } = await import('chatgpt');
|
||||
|
||||
const api = new ChatGPTAPI({ apiKey: process.env.OPENAI_KEY });
|
||||
const res = await api.sendMessage(question, {
|
||||
onProgress: (partialRes) => console.log(partialRes.text)
|
||||
});
|
||||
return res;
|
||||
};
|
||||
|
||||
// send a message and wait for the response
|
||||
let res = await api.sendMessage('What is OpenAI?');
|
||||
console.log(res);
|
||||
})();
|
||||
module.exports = { ask };
|
||||
Loading…
Add table
Add a link
Reference in a new issue