From 86f7313923d85c18db27154d4000e0cc07b211f5 Mon Sep 17 00:00:00 2001 From: Jing Hua Date: Wed, 26 Apr 2023 15:25:36 +0800 Subject: [PATCH] fix: chatgpt import --- src/types/export.ts | 4 ++-- src/utils/import.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/types/export.ts b/src/types/export.ts index e32b75f..f275ee7 100644 --- a/src/types/export.ts +++ b/src/types/export.ts @@ -14,12 +14,12 @@ export type OpenAIChat = { mapping: { [key: string]: { id: string; - message: { + message?: { author: { role: Role; }; content: { - parts: string[]; + parts?: string[]; }; } | null; parent: string | null; diff --git a/src/utils/import.ts b/src/utils/import.ts index 8a43bf1..4224a3d 100644 --- a/src/utils/import.ts +++ b/src/utils/import.ts @@ -102,7 +102,7 @@ export const convertOpenAIToBetterChatGPTFormat = ( // Extract message if it exists if (node.message) { const { role } = node.message.author; - const content = node.message.content.parts.join(''); + const content = node.message.content.parts?.join('') || ''; if (content.length > 0) messages.push({ role, content }); }