fix: chatgpt import

This commit is contained in:
Jing Hua 2023-04-26 15:25:36 +08:00
parent 5fdaa1dbda
commit 86f7313923
2 changed files with 3 additions and 3 deletions

View file

@ -14,12 +14,12 @@ export type OpenAIChat = {
mapping: { mapping: {
[key: string]: { [key: string]: {
id: string; id: string;
message: { message?: {
author: { author: {
role: Role; role: Role;
}; };
content: { content: {
parts: string[]; parts?: string[];
}; };
} | null; } | null;
parent: string | null; parent: string | null;

View file

@ -102,7 +102,7 @@ export const convertOpenAIToBetterChatGPTFormat = (
// Extract message if it exists // Extract message if it exists
if (node.message) { if (node.message) {
const { role } = node.message.author; 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 }); if (content.length > 0) messages.push({ role, content });
} }