LibreChat/api/app/clients/sydney.js

37 lines
1 KiB
JavaScript
Raw Normal View History

2023-03-08 19:47:23 -05:00
require('dotenv').config();
const { KeyvFile } = require('keyv-file');
const askSydney = async ({ text, onProgress, convo }) => {
2023-03-21 16:32:32 -04:00
const { BingAIClient } = (await import('@waylaidwanderer/chatgpt-api'));
2023-03-08 19:47:23 -05:00
2023-03-10 12:55:45 -05:00
const sydneyClient = new BingAIClient({
// "_U" cookie from bing.com
2023-03-08 19:47:23 -05:00
userToken: process.env.BING_TOKEN,
2023-03-10 12:55:45 -05:00
// If the above doesn't work, provide all your cookies as a string instead
// cookies: '',
2023-03-08 19:47:23 -05:00
debug: false,
cache: { store: new KeyvFile({ filename: './data/cache.json' }) }
2023-03-10 12:55:45 -05:00
});
2023-03-08 19:47:23 -05:00
let options = {
jailbreakConversationId: true,
onProgress,
2023-03-08 19:47:23 -05:00
};
if (convo.jailbreakConversationId) {
2023-03-10 12:55:45 -05:00
options = { ...options, jailbreakConversationId: convo.jailbreakConversationId, parentMessageId: convo.parentMessageId };
2023-03-08 19:47:23 -05:00
}
console.log('sydney options', options);
2023-03-10 12:55:45 -05:00
const res = await sydneyClient.sendMessage(text, options
);
2023-03-08 19:47:23 -05:00
return res;
// for reference:
// https://github.com/waylaidwanderer/node-chatgpt-api/blob/main/demos/use-bing-client.js
};
module.exports = { askSydney };