This commit is contained in:
parent
c50c7eeab5
commit
ea8768003b
|
|
@ -1,4 +1,3 @@
|
||||||
// ai-config.ts
|
|
||||||
import {
|
import {
|
||||||
StreamableValue,
|
StreamableValue,
|
||||||
createAI,
|
createAI,
|
||||||
|
|
@ -66,10 +65,12 @@ async function submit(formData?: FormData, skip?: boolean) {
|
||||||
answer = fullResponse
|
answer = fullResponse
|
||||||
errorOccurred = hasError
|
errorOccurred = hasError
|
||||||
}
|
}
|
||||||
|
|
||||||
streamText.done()
|
streamText.done()
|
||||||
|
|
||||||
if (!errorOccurred) {
|
if (!errorOccurred) {
|
||||||
await querySuggestor(uiStream, messages)
|
await querySuggestor(uiStream, messages)
|
||||||
|
|
||||||
uiStream.append(
|
uiStream.append(
|
||||||
<Section title="Follow-up">
|
<Section title="Follow-up">
|
||||||
<FollowupPanel />
|
<FollowupPanel />
|
||||||
|
|
@ -91,12 +92,7 @@ async function submit(formData?: FormData, skip?: boolean) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialAIState: {
|
const initialAIState: ExperimentalMessage[] = []
|
||||||
role: 'user' | 'assistant' | 'system' | 'function' | 'tool'
|
|
||||||
content: string
|
|
||||||
id?: string
|
|
||||||
name?: string
|
|
||||||
}[] = []
|
|
||||||
|
|
||||||
const initialUIState: {
|
const initialUIState: {
|
||||||
id: number
|
id: number
|
||||||
|
|
@ -104,8 +100,13 @@ const initialUIState: {
|
||||||
component: React.ReactNode
|
component: React.ReactNode
|
||||||
}[] = []
|
}[] = []
|
||||||
|
|
||||||
export const AI = createAI({
|
export const {
|
||||||
|
AIProvider,
|
||||||
|
useAIState,
|
||||||
|
useUIState,
|
||||||
|
useActions
|
||||||
|
} = createAI({
|
||||||
actions: { submit },
|
actions: { submit },
|
||||||
initialUIState,
|
initialAIState,
|
||||||
initialAIState
|
initialUIState
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import type { Metadata, Viewport } from 'next'
|
import type { Metadata, Viewport } from 'next'
|
||||||
import { Inter as FontSans } from 'next/font/google'
|
import { Inter as FontSans } from 'next/font/google'
|
||||||
import { AI } from './action'
|
import { AIProvider } from './action' // ⬅️ 正确导入
|
||||||
import '../../globals.css'
|
import '../../globals.css'
|
||||||
import { cn } from '@/lib/utils'
|
import { cn } from '@/lib/utils'
|
||||||
import { ThemeProvider } from '@/components/mpv2/theme-provider'
|
import { ThemeProvider } from '@/components/mpv2/theme-provider'
|
||||||
|
|
@ -44,9 +44,7 @@ export default function RootLayout({
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
}>) {
|
}>) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
||||||
<ThemeProvider
|
<ThemeProvider
|
||||||
attribute="class"
|
attribute="class"
|
||||||
defaultTheme="system"
|
defaultTheme="system"
|
||||||
|
|
@ -54,9 +52,9 @@ export default function RootLayout({
|
||||||
disableTransitionOnChange
|
disableTransitionOnChange
|
||||||
>
|
>
|
||||||
{/* <Header /> */}
|
{/* <Header /> */}
|
||||||
<AI>
|
<AIProvider>
|
||||||
{children}
|
{children}
|
||||||
</AI>
|
</AIProvider>
|
||||||
{/* <Footer /> */}
|
{/* <Footer /> */}
|
||||||
</ThemeProvider>
|
</ThemeProvider>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue