mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
reorganize dirs for dockerize
This commit is contained in:
parent
6ae154cc42
commit
fca546af63
38 changed files with 1056 additions and 1970 deletions
55
api/app/bingai.js
Normal file
55
api/app/bingai.js
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
require('dotenv').config();
|
||||
const { KeyvFile } = require('keyv-file');
|
||||
|
||||
const askBing = async ({ text, progressCallback, convo }) => {
|
||||
const { BingAIClient } = (await import('@waylaidwanderer/chatgpt-api'));
|
||||
|
||||
const bingAIClient = new BingAIClient({
|
||||
// "_U" cookie from bing.com
|
||||
userToken: process.env.BING_TOKEN,
|
||||
// If the above doesn't work, provide all your cookies as a string instead
|
||||
// cookies: '',
|
||||
debug: false,
|
||||
store: new KeyvFile({ filename: './api/data/cache.json' })
|
||||
});
|
||||
|
||||
let options = {
|
||||
onProgress: async (partialRes) => await progressCallback(partialRes),
|
||||
};
|
||||
|
||||
if (convo) {
|
||||
options = { ...options, ...convo };
|
||||
}
|
||||
|
||||
const res = await bingAIClient.sendMessage(text, options
|
||||
);
|
||||
|
||||
return res;
|
||||
|
||||
// Example response for reference
|
||||
// {
|
||||
// conversationSignature: 'wwZ2GC/qRgEqP3VSNIhbPGwtno5RcuBhzZFASOM+Sxg=',
|
||||
// conversationId: '51D|BingProd|026D3A4017554DE6C446798144B6337F4D47D5B76E62A31F31D0B1D0A95ED868',
|
||||
// clientId: '914800201536527',
|
||||
// invocationId: 1,
|
||||
// conversationExpiryTime: '2023-02-15T21:48:46.2892088Z',
|
||||
// response: 'Hello, this is Bing. Nice to meet you. 😊',
|
||||
// details: {
|
||||
// text: 'Hello, this is Bing. Nice to meet you. 😊',
|
||||
// author: 'bot',
|
||||
// createdAt: '2023-02-15T15:48:43.0631898+00:00',
|
||||
// timestamp: '2023-02-15T15:48:43.0631898+00:00',
|
||||
// messageId: '9d0c9a80-91b1-49ab-b9b1-b457dc3fe247',
|
||||
// requestId: '5b252ef8-4f09-4c08-b6f5-4499d2e12fba',
|
||||
// offense: 'None',
|
||||
// adaptiveCards: [ [Object] ],
|
||||
// sourceAttributions: [],
|
||||
// feedback: { tag: null, updatedOn: null, type: 'None' },
|
||||
// contentOrigin: 'DeepLeo',
|
||||
// privacy: null,
|
||||
// suggestedResponses: [ [Object], [Object], [Object] ]
|
||||
// }
|
||||
// }
|
||||
};
|
||||
|
||||
module.exports = { askBing };
|
||||
Loading…
Add table
Add a link
Reference in a new issue