chore: refactor titleConvo

This commit is contained in:
Danny Avila 2023-03-15 15:21:04 -04:00
parent a8aad30fc8
commit a0c94715ce
5 changed files with 47 additions and 71 deletions

View file

@ -15,23 +15,6 @@ const sendMessage = (res, message) => {
res.write(`event: message\ndata: ${JSON.stringify(message)}\n\n`);
};
const genTitle = async ({ model, text, response }) => {
let title = 'New Chat';
try {
title = await titleConvo({
model,
message: text,
response: JSON.stringify(response?.text)
});
} catch (e) {
console.error(e);
console.log('There was an issue generating title, see error above');
}
console.log('CONVERSATION TITLE', title);
return title;
};
const createOnProgress = () => {
let i = 0;
let tokens = '';
@ -82,4 +65,4 @@ const handleText = async (input) => {
return text;
};
module.exports = { handleError, sendMessage, createOnProgress, genTitle, handleText };
module.exports = { handleError, sendMessage, createOnProgress, handleText };