mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 00:27:24 +00:00
21 lines
486 B
TypeScript
21 lines
486 B
TypeScript
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();
|
|
} |