mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 01:10:14 +01:00
fix: error handling titles, remove openAI req
This commit is contained in:
parent
12cf3405e4
commit
4e616cd2ed
4 changed files with 59 additions and 37 deletions
|
|
@ -2,27 +2,32 @@ require('dotenv').config();
|
|||
const { KeyvFile } = require('keyv-file');
|
||||
|
||||
const askBing = async ({ text, progressCallback, convo }) => {
|
||||
const { BingAIClient } = (await import('@waylaidwanderer/chatgpt-api'));
|
||||
const { BingAIClient } = await import('@waylaidwanderer/chatgpt-api');
|
||||
|
||||
const bingAIClient = new BingAIClient({
|
||||
// "_U" cookie from bing.com
|
||||
const clientOptions = {
|
||||
userToken: process.env.BING_TOKEN,
|
||||
// If the above doesn't work, provide all your cookies as a string instead
|
||||
// cookies: '',
|
||||
debug: false,
|
||||
cache: { store: new KeyvFile({ filename: './data/cache.json' }) }
|
||||
});
|
||||
};
|
||||
|
||||
const cookies = process.env.BING_COOKIES;
|
||||
|
||||
if (cookies?.length > 0) {
|
||||
clientOptions.cookies = cookies;
|
||||
delete clientOptions.userToken;
|
||||
}
|
||||
|
||||
const bingAIClient = new BingAIClient(clientOptions);
|
||||
|
||||
let options = {
|
||||
onProgress: async (partialRes) => await progressCallback(partialRes),
|
||||
onProgress: async (partialRes) => await progressCallback(partialRes)
|
||||
};
|
||||
|
||||
if (convo) {
|
||||
options = { ...options, ...convo };
|
||||
}
|
||||
|
||||
const res = await bingAIClient.sendMessage(text, options
|
||||
);
|
||||
const res = await bingAIClient.sendMessage(text, options);
|
||||
|
||||
return res;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue