Trim whitespace in JSONL export content

Ensures whitespace-only message content is treated as empty and skipped
in JSONL exports, preventing invalid SFT training samples.
This commit is contained in:
Daniel Han 2026-03-31 14:24:52 +00:00
commit b0b6c4daf9

View file

@ -76,7 +76,7 @@ export async function exportAsJSONL(threadId: string): Promise<void> {
// OpenAI chat format -- standard SFT structure, skip empty turns
const chatMessages = messages.flatMap((m) => {
const content = extractText(m.content);
const content = extractText(m.content).trim();
if (!content) return [];
return [{ role: m.role === "user" ? "user" : "assistant", content }];
});