mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 00:27:24 +00:00
Fix handling of empty assistant messages
This commit is contained in:
3 files changed
+23
-47
No files matched your search
@@ -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();
|
||||
}
|
||||
Reference in new issue
Block a user