Skip to content

Commit 7485ab3

Browse files
author
Roman Snapko
committed
Handle empty sanitized messages in chat name generation logic
1 parent 255c757 commit 7485ab3

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

packages/server/api/src/app/ai/chat/ai-chat.service.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
CustomAuthConnectionValue,
1717
ErrorCode,
1818
GeneratedChatName,
19+
isEmpty,
1920
removeConnectionBrackets,
2021
} from '@openops/shared';
2122
import { generateObject, LanguageModel, ModelMessage, UIMessage } from 'ai';
@@ -112,6 +113,10 @@ export async function generateChatName(
112113
const sanitizedMessages: ModelMessage[] =
113114
sanitizeMessagesForChatName(messages);
114115

116+
if (isEmpty(sanitizedMessages.length)) {
117+
return { name: null, isGenerated: false };
118+
}
119+
115120
const result = await generateObject({
116121
model: languageModel,
117122
system: systemPrompt,

0 commit comments

Comments
 (0)