This commit is contained in:
parent
c50c7eeab5
commit
ea8768003b
|
|
@ -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(
|
||||
<Section title="Follow-up">
|
||||
<FollowupPanel />
|
||||
|
|
@ -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
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
||||
<ThemeProvider
|
||||
attribute="class"
|
||||
defaultTheme="system"
|
||||
|
|
@ -54,9 +52,9 @@ export default function RootLayout({
|
|||
disableTransitionOnChange
|
||||
>
|
||||
{/* <Header /> */}
|
||||
<AI>
|
||||
{children}
|
||||
</AI>
|
||||
<AIProvider>
|
||||
{children}
|
||||
</AIProvider>
|
||||
{/* <Footer /> */}
|
||||
</ThemeProvider>
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue