Automatically generate titles for conversations from history

This commit is contained in:
sabaimran
2024-11-08 16:02:34 -08:00
parent 7159b0b735
commit 807687a0ac
6 changed files with 84 additions and 5 deletions

View File

@@ -319,6 +319,23 @@ export async function packageFilesForUpload(files: FileList): Promise<FormData>
return formData;
}
export function generateNewTitle(conversationId: string, setTitle: (title: string) => void) {
fetch(`/api/chat/title?conversation_id=${conversationId}`, {
method: "POST",
})
.then((res) => {
if (!res.ok) throw new Error(`Failed to call API with error ${res.statusText}`);
return res.json();
})
.then((data) => {
setTitle(data.title);
})
.catch((err) => {
console.error(err);
return;
});
}
export function uploadDataForIndexing(
files: FileList,
setWarning: (warning: string) => void,