mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
chore: delegate response text parsing to one location
This commit is contained in:
parent
a0c94715ce
commit
84b104e65f
5 changed files with 22 additions and 23 deletions
|
|
@ -1,10 +1,9 @@
|
|||
const express = require('express');
|
||||
const crypto = require('crypto');
|
||||
const router = express.Router();
|
||||
const { titleConvo, getCitations, citeText, askBing } = require('../../app/');
|
||||
const { titleConvo, askBing } = require('../../app/');
|
||||
const { saveMessage, getConvoTitle, saveConvo } = require('../../models');
|
||||
const { handleError, sendMessage, createOnProgress, handleText } = require('./handlers');
|
||||
const citationRegex = /\[\^\d+?\^]/g;
|
||||
|
||||
router.post('/', async (req, res) => {
|
||||
const {
|
||||
|
|
@ -129,12 +128,7 @@ const ask = async ({
|
|||
response.parentMessageId =
|
||||
overrideParentMessageId || response.parentMessageId || userMessageId;
|
||||
|
||||
const links = getCitations(response);
|
||||
response.text =
|
||||
citeText(response) +
|
||||
(links?.length > 0 && hasCitations ? `\n<small>${links}</small>` : '');
|
||||
response.text = await handleText(response.text);
|
||||
|
||||
response.text = await handleText(response, true);
|
||||
await saveMessage(response);
|
||||
await saveConvo({ ...response, model, chatGptLabel: null, promptPrefix: null, ...convo });
|
||||
sendMessage(res, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue