Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

ui-components.tsx

65 lines1.8 KB

1import { createChatHook } from '@tanstack/ai-react/ui'
2import { chatOptions } from '@/chat/options'
3import { chatContext, interruptContext, partContext } from '@/chat/ui-context'
4import { BookStayApproval, BookStayTool } from './book-stay-tool'
5import { ConfirmPaymentTool } from './confirm-payment-tool'
6import { ChatPromptInput } from './input'
7import { ChatLayout } from './layout'
8import { ChatQueueItem } from './queue-item'
9import { ChooseBudget } from './choose-budget'
10import { FallbackInterrupt } from './fallback-interrupt'
11import { FallbackPart } from './fallback-part'
12import { LookupPlaceTool } from './lookup-place-tool'
13import {
14 AudioPart,
15 DocumentPart,
16 ImagePart,
17 ToolResultPart,
18 UIResourcePart,
19 VideoPart,
20} from './media-parts'
21import { ChatMessage } from './message'
22import { StructuredOutputPart } from './structured-output'
23import { TextPart } from './text-part'
24import { ThinkingPart } from './thinking-part'
25​
26export const { useAppChat, useChatContext } = createChatHook({
27 options: chatOptions,
28 context: {
29 chatContext,
30 partContext,
31 interruptContext,
32 },
33 components: {
34 layout: ChatLayout,
35 message: ChatMessage,
36 input: ChatPromptInput,
37 queue: ChatQueueItem,
38 },
39 partsComponents: {
40 text: TextPart,
41 thinking: ThinkingPart,
42 structuredOutput: StructuredOutputPart,
43 image: ImagePart,
44 audio: AudioPart,
45 video: VideoPart,
46 document: DocumentPart,
47 toolResult: ToolResultPart,
48 uiResource: UIResourcePart,
49 fallback: FallbackPart,
50 },
51 toolsComponents: {
52 lookupPlace: LookupPlaceTool,
53 bookStay: BookStayTool,
54 confirmPayment: ConfirmPaymentTool,
55 },
56 interruptsComponents: {
57 tools: {
58 bookStay: BookStayApproval,
59 },
60 generic: {
61 chooseBudget: ChooseBudget,
62 fallback: FallbackInterrupt,
63 },
64 },
65})