Skip to content

An AI-powered search engine with a generative UI

Refactor createAI function in action.tsx

Yoshiki Miura08eca6b16f68
diff --git a/app/action.tsx b/app/action.tsx
index 1b334461..94ef6e9d 100644
--- a/app/action.tsx
+++ b/app/action.tsx
@@ -269,23 +269,13 @@ export const AI = createAI<AIState, UIState>({
const title =
JSON.parse(messages[0].content)?.input?.substring(0, 100) || 'Untitled'
- // Add an end message to the chat, to prevent excessive refreshes
- const modifiedMessages = [
- ...messages,
- {
- id: nanoid(),
- role: 'assistant',
- content: 'end'
- } as AIMessage
- ]
-
const chat: Chat = {
id: chatId,
createdAt,
userId,
path,
title,
- messages: modifiedMessages
+ messages
}
await saveChat(chat)
}