From ea8768003b9d7d2198e52c953692c675edf046b3 Mon Sep 17 00:00:00 2001 From: hailin Date: Mon, 23 Jun 2025 13:16:17 +0800 Subject: [PATCH] . --- apps/blogai/app/[locale]/morphic/action.tsx | 21 +++++++++++---------- apps/blogai/app/[locale]/morphic/layout.tsx | 10 ++++------ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/apps/blogai/app/[locale]/morphic/action.tsx b/apps/blogai/app/[locale]/morphic/action.tsx index 3f64f5a..9e9b9ab 100644 --- a/apps/blogai/app/[locale]/morphic/action.tsx +++ b/apps/blogai/app/[locale]/morphic/action.tsx @@ -1,4 +1,3 @@ -// ai-config.ts import { StreamableValue, createAI, @@ -66,10 +65,12 @@ async function submit(formData?: FormData, skip?: boolean) { answer = fullResponse errorOccurred = hasError } + streamText.done() if (!errorOccurred) { await querySuggestor(uiStream, messages) + uiStream.append(
@@ -91,12 +92,7 @@ async function submit(formData?: FormData, skip?: boolean) { } } -const initialAIState: { - role: 'user' | 'assistant' | 'system' | 'function' | 'tool' - content: string - id?: string - name?: string -}[] = [] +const initialAIState: ExperimentalMessage[] = [] const initialUIState: { id: number @@ -104,8 +100,13 @@ const initialUIState: { component: React.ReactNode }[] = [] -export const AI = createAI({ +export const { + AIProvider, + useAIState, + useUIState, + useActions +} = createAI({ actions: { submit }, - initialUIState, - initialAIState + initialAIState, + initialUIState }) diff --git a/apps/blogai/app/[locale]/morphic/layout.tsx b/apps/blogai/app/[locale]/morphic/layout.tsx index 6d765b0..7a733f4 100644 --- a/apps/blogai/app/[locale]/morphic/layout.tsx +++ b/apps/blogai/app/[locale]/morphic/layout.tsx @@ -1,6 +1,6 @@ import type { Metadata, Viewport } from 'next' import { Inter as FontSans } from 'next/font/google' -import { AI } from './action' +import { AIProvider } from './action' // ⬅️ 正确导入 import '../../globals.css' import { cn } from '@/lib/utils' import { ThemeProvider } from '@/components/mpv2/theme-provider' @@ -44,9 +44,7 @@ export default function RootLayout({ }: Readonly<{ children: React.ReactNode }>) { - return ( - {/*
*/} - - {children} - + + {children} + {/*