mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +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
|
|
@ -3,7 +3,7 @@ const crypto = require('crypto');
|
|||
const router = express.Router();
|
||||
const { titleConvo, getCitations, citeText, askSydney } = require('../../app/');
|
||||
const { saveMessage, saveConvo, getConvoTitle } = require('../../models');
|
||||
const { handleError, sendMessage } = require('./handlers');
|
||||
const { handleError, sendMessage, createOnProgress } = require('./handlers');
|
||||
const citationRegex = /\[\^\d+?\^]/g;
|
||||
|
||||
router.post('/', async (req, res) => {
|
||||
|
|
@ -68,17 +68,10 @@ const ask = async ({
|
|||
sendMessage(res, { message: userMessage, created: true });
|
||||
|
||||
try {
|
||||
let tokens = '';
|
||||
const progressCallback = async (partial) => {
|
||||
tokens += partial === text ? '' : partial;
|
||||
// tokens = appendCode(tokens);
|
||||
tokens = citeText(tokens, true);
|
||||
sendMessage(res, { text: tokens, message: true, parentMessageId: overrideParentMessageId || userMessageId });
|
||||
};
|
||||
|
||||
const progressCallback = createOnProgress();
|
||||
let response = await askSydney({
|
||||
text,
|
||||
progressCallback,
|
||||
onProgress: progressCallback.call(null, model, {res, text, parentMessageId: overrideParentMessageId || userMessageId }),
|
||||
convo: {
|
||||
parentMessageId: userParentMessageId,
|
||||
conversationId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue