mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
⬇️ refactor: Improve Conversation JSON Export (#10726)
Updated the export logic in the useExportConversation hook to use JSON.stringify without indentation, reducing file size for deeply nested exports. Additionally, ensured safe access to text content by providing a fallback for undefined values.
This commit is contained in:
parent
90f0bcde44
commit
2ccaf6be6d
1 changed files with 3 additions and 7 deletions
|
|
@ -103,7 +103,7 @@ export default function useExportConversation({
|
||||||
if (content.type === ContentTypes.TEXT) {
|
if (content.type === ContentTypes.TEXT) {
|
||||||
// TEXT
|
// TEXT
|
||||||
const textPart = content[ContentTypes.TEXT];
|
const textPart = content[ContentTypes.TEXT];
|
||||||
const text = typeof textPart === 'string' ? textPart : textPart.value;
|
const text = typeof textPart === 'string' ? textPart : (textPart?.value ?? '');
|
||||||
return [sender, text];
|
return [sender, text];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -365,12 +365,8 @@ export default function useExportConversation({
|
||||||
data['messages'] = messages;
|
data['messages'] = messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
exportFromJSON({
|
/** Use JSON.stringify without indentation to minimize file size for deeply nested recursive exports */
|
||||||
data: data,
|
download(JSON.stringify(data), `${filename}.json`, 'application/json');
|
||||||
fileName: filename,
|
|
||||||
extension: 'json',
|
|
||||||
exportType: exportFromJSON.types.json,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const exportConversation = () => {
|
const exportConversation = () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue