mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-05 10:08:52 +01:00
chore: refactor progressCB to one place, fix sydney, and sanitize html
This commit is contained in:
parent
9a17e94f8f
commit
2e20b28c4d
12 changed files with 351 additions and 69 deletions
|
|
@ -1,7 +1,7 @@
|
|||
require('dotenv').config();
|
||||
const { KeyvFile } = require('keyv-file');
|
||||
|
||||
const askBing = async ({ text, progressCallback, convo }) => {
|
||||
const askBing = async ({ text, onProgress, convo }) => {
|
||||
const { BingAIClient } = (await import('@waylaidwanderer/chatgpt-api'));
|
||||
|
||||
const bingAIClient = new BingAIClient({
|
||||
|
|
@ -14,10 +14,7 @@ const askBing = async ({ text, progressCallback, convo }) => {
|
|||
proxy: process.env.PROXY || null,
|
||||
});
|
||||
|
||||
let options = {
|
||||
onProgress: async (partialRes) => await progressCallback(partialRes),
|
||||
};
|
||||
|
||||
let options = { onProgress };
|
||||
if (convo) {
|
||||
options = { ...options, ...convo };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ const clientOptions = {
|
|||
proxy: process.env.PROXY || null,
|
||||
};
|
||||
|
||||
const browserClient = async ({ text, progressCallback, convo }) => {
|
||||
const browserClient = async ({ text, onProgress, convo }) => {
|
||||
const { ChatGPTBrowserClient } = await import('@waylaidwanderer/chatgpt-api');
|
||||
|
||||
const store = {
|
||||
|
|
@ -18,10 +18,7 @@ const browserClient = async ({ text, progressCallback, convo }) => {
|
|||
};
|
||||
|
||||
const client = new ChatGPTBrowserClient(clientOptions, store);
|
||||
|
||||
let options = {
|
||||
onProgress: async (partialRes) => await progressCallback(partialRes)
|
||||
};
|
||||
let options = { onProgress };
|
||||
|
||||
if (!!convo.parentMessageId && !!convo.conversationId) {
|
||||
options = { ...options, ...convo };
|
||||
|
|
|
|||
|
|
@ -9,17 +9,14 @@ const clientOptions = {
|
|||
debug: false
|
||||
};
|
||||
|
||||
const askClient = async ({ text, progressCallback, convo }) => {
|
||||
const askClient = async ({ text, onProgress, convo }) => {
|
||||
const ChatGPTClient = (await import('@waylaidwanderer/chatgpt-api')).default;
|
||||
const store = {
|
||||
store: new KeyvFile({ filename: './data/cache.json' })
|
||||
};
|
||||
|
||||
const client = new ChatGPTClient(process.env.OPENAI_KEY, clientOptions, store);
|
||||
|
||||
let options = {
|
||||
onProgress: async (partialRes) => await progressCallback(partialRes)
|
||||
};
|
||||
let options = { onProgress };
|
||||
|
||||
if (!!convo.parentMessageId && !!convo.conversationId) {
|
||||
options = { ...options, ...convo };
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
require('dotenv').config();
|
||||
const { KeyvFile } = require('keyv-file');
|
||||
|
||||
const askSydney = async ({ text, progressCallback, convo }) => {
|
||||
const askSydney = async ({ text, onProgress, convo }) => {
|
||||
const { BingAIClient } = (await import('@waylaidwanderer/chatgpt-api'));
|
||||
|
||||
const sydneyClient = new BingAIClient({
|
||||
|
|
@ -15,10 +15,10 @@ const askSydney = async ({ text, progressCallback, convo }) => {
|
|||
|
||||
let options = {
|
||||
jailbreakConversationId: true,
|
||||
onProgress: async (partialRes) => await progressCallback(partialRes),
|
||||
onProgress,
|
||||
};
|
||||
|
||||
if (convo.parentMessageId) {
|
||||
if (convo.jailbreakConversationId) {
|
||||
options = { ...options, jailbreakConversationId: convo.jailbreakConversationId, parentMessageId: convo.parentMessageId };
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue