fix: pass down id to append
This commit is contained in:
parent
fd99ff634f
commit
92309d77ec
4 changed files with 14 additions and 6 deletions
|
|
@ -1,16 +1,19 @@
|
||||||
|
import { nanoid } from '@/lib/utils'
|
||||||
import { Chat } from '@/components/chat'
|
import { Chat } from '@/components/chat'
|
||||||
import { Header } from '@/components/header'
|
import { Header } from '@/components/header'
|
||||||
|
|
||||||
// export const runtime = 'edge'
|
// export const runtime = 'edge'
|
||||||
export const preferredRegion = 'home'
|
export const preferredRegion = 'home'
|
||||||
|
|
||||||
export default async function IndexPage() {
|
export default function IndexPage() {
|
||||||
|
const id = nanoid()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex min-h-screen flex-col">
|
<div className="flex min-h-screen flex-col">
|
||||||
{/* @ts-ignore */}
|
{/* @ts-ignore */}
|
||||||
<Header />
|
<Header />
|
||||||
<main className="flex-1 bg-muted/50">
|
<main className="flex-1 bg-muted/50">
|
||||||
<Chat />
|
<Chat id={id} />
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export function ChatMessageActions({
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex w-full items-center justify-end transition-opacity group-hover:opacity-100 md:absolute md:-right-10 md:-top-2 md:opacity-0',
|
'flex items-center justify-end transition-opacity group-hover:opacity-100 md:absolute md:-right-10 md:-top-2 md:opacity-0',
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ export interface ChatPanelProps
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ChatPanel({
|
export function ChatPanel({
|
||||||
|
id,
|
||||||
isLoading,
|
isLoading,
|
||||||
stop,
|
stop,
|
||||||
append,
|
append,
|
||||||
|
|
@ -58,8 +59,9 @@ export function ChatPanel({
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-4 border-t bg-background px-4 py-2 shadow-lg sm:rounded-t-xl sm:border md:py-4">
|
<div className="space-y-4 border-t bg-background px-4 py-2 shadow-lg sm:rounded-t-xl sm:border md:py-4">
|
||||||
<PromptForm
|
<PromptForm
|
||||||
onSubmit={value => {
|
onSubmit={async value => {
|
||||||
append({
|
await append({
|
||||||
|
id,
|
||||||
content: value,
|
content: value,
|
||||||
role: 'user'
|
role: 'user'
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,10 @@ export function Chat({ id, initialMessages, className }: ChatProps) {
|
||||||
const { messages, append, reload, stop, isLoading, input, setInput } =
|
const { messages, append, reload, stop, isLoading, input, setInput } =
|
||||||
useChat({
|
useChat({
|
||||||
initialMessages,
|
initialMessages,
|
||||||
|
id,
|
||||||
|
body: {
|
||||||
id
|
id
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue