Spaces:
Sleeping
Sleeping
Download web/src/hooks/chatContext.ts from TBM99/CoverageCheck: direct link, hf CLI and curl.
- Browser
- Download file 758 Bytes
-
https://huggingface.co/spaces/TBM99/CoverageCheck/resolve/main/web/src/hooks/chatContext.ts
- Command line
-
hf download hf://spaces/TBM99/CoverageCheck/web/src/hooks/chatContext.ts
-
curl -L -o chatContext.ts https://huggingface.co/spaces/TBM99/CoverageCheck/resolve/main/web/src/hooks/chatContext.ts
758 Bytes
| 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 | |
| } | |