fix: debounce title request and handle error with default title

This commit is contained in:
Danny Avila 2023-03-15 12:47:30 -04:00
parent 96ca783517
commit 2fd50c99b8
7 changed files with 70 additions and 100 deletions

View file

@ -1,9 +1,15 @@
const express = require('express');
const crypto = require('crypto');
const router = express.Router();
const { titleConvo, getCitations, citeText, askBing } = require('../../app/');
const { getCitations, citeText, askBing } = require('../../app/');
const { saveMessage, getConvoTitle, saveConvo } = require('../../models');
const { handleError, sendMessage, createOnProgress, handleText } = require('./handlers');
const {
handleError,
sendMessage,
createOnProgress,
genTitle,
handleText
} = require('./handlers');
const citationRegex = /\[\^\d+?\^]/g;
router.post('/', async (req, res) => {
@ -146,13 +152,7 @@ const ask = async ({
res.end();
if (userParentMessageId == '00000000-0000-0000-0000-000000000000') {
const title = await titleConvo({
model,
message: text,
response: JSON.stringify(response?.text)
});
console.log('CONVERSATION TITLE', title);
const title = await genTitle({ model, text, response });
await saveConvo({
conversationId,