Spaces:
Sleeping
Sleeping
File size: 758 Bytes
23d418f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | import { createContext, useContext } from 'react'
import type { SystemId } from '@/lib/types'
import type { useChat } from './useChat'
/** What ChatProvider shares with the pages: the conversation (useChat) and the box's
* settings. In its own file: a file that exports a component should export only
* components (Vite fast refresh). */
export type ChatState = ReturnType<typeof useChat> & {
system: SystemId
setSystem: (s: SystemId) => void
day: string | null
setDay: (d: string | null) => void
}
export const ChatContext = createContext<ChatState | null>(null)
export function useChatContext(): ChatState {
const state = useContext(ChatContext)
if (!state) throw new Error('useChatContext needs a ChatProvider above it')
return state
}
|