An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
Add check for 'answer' message type in AI state
Yoshiki Miura21a3f33cafd7
diff --git a/app/actions.tsx b/app/actions.tsxindex 7e756271..9ee6db02 100644--- a/app/actions.tsx+++ b/app/actions.tsx@@ -268,6 +268,11 @@ export const AI = createAI<AIState, UIState>({unstable_onSetAIState: async ({ state, done }) => {'use server'+ // Check if there is any message of type 'answer' in the state messages+ if (!state.messages.some(e => e.type === 'answer')) {+ return+ }+const { chatId, messages } = stateconst createdAt = new Date()const userId = 'anonymous'