Fix handling of empty assistant messages

This commit is contained in:
Alex Gleason committed 2025-09-22 11:26:13 -05:00
1 parent 02750c9b5c
commit 893d2e66ab
3 files changed
+23 -47

No files matched your search

-21
View File
@@ -1,21 +0,0 @@
import OpenAI from "openai";
export function assistantContentEmpty(
content: OpenAI.ChatCompletionAssistantMessageParam['content'],
): boolean {
if (!content) return true;
const text: string[] = [];
if (typeof content === 'string') {
text.push(content);
} else if (Array.isArray(content)) {
for (const part of content) {
if (part.type === 'text') {
text.push(part.text);
}
}
}
const result = text.join('\n\n');
return !result.trim();
}