fix(export): preserve system role in ShareGPT exports
System messages were being mapped to 'gpt' instead of 'system', corrupting training data. Both the single-thread and bulk export paths now correctly emit 'system' for system messages.
This commit is contained in:
parent
f719a82755
commit
7b2779136d
1 changed files with 2 additions and 2 deletions
|
|
@ -379,7 +379,7 @@ export async function exportConversationShareGPT(threadId: string): Promise<void
|
||||||
const conversations: Array<{ from: string; value: string }> = [];
|
const conversations: Array<{ from: string; value: string }> = [];
|
||||||
for (const msg of messages) {
|
for (const msg of messages) {
|
||||||
const role = msg.role as string;
|
const role = msg.role as string;
|
||||||
const from = role === "user" ? "human" : "gpt";
|
const from = role === "user" ? "human" : role === "system" ? "system" : "gpt";
|
||||||
const value = messageToText(msg);
|
const value = messageToText(msg);
|
||||||
if (value.trim()) conversations.push({ from, value });
|
if (value.trim()) conversations.push({ from, value });
|
||||||
}
|
}
|
||||||
|
|
@ -461,7 +461,7 @@ async function buildThreadContent(
|
||||||
for (const msg of messages) {
|
for (const msg of messages) {
|
||||||
const role = msg.role as string;
|
const role = msg.role as string;
|
||||||
const value = messageToText(msg);
|
const value = messageToText(msg);
|
||||||
if (value.trim()) conversations.push({ from: role === "user" ? "human" : "gpt", value });
|
if (value.trim()) conversations.push({ from: role === "user" ? "human" : role === "system" ? "system" : "gpt", value });
|
||||||
}
|
}
|
||||||
if (conversations.length === 0) return null;
|
if (conversations.length === 0) return null;
|
||||||
return JSON.stringify({ conversations });
|
return JSON.stringify({ conversations });
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue