MCPcopy Index your code
hub / github.com/TanStack/ai / Chat

Function Chat

packages/ai-react-ui/src/chat.tsx:65–95  ·  view source on GitHub ↗
({
  children,
  className,
  connection,
  initialMessages,
  id,
  body,
  onResponse,
  onChunk,
  onFinish,
  onError,
}: ChatProps)

Source from the content-addressed store, hash-verified

63 * ```
64 */
65export function Chat({
66 children,
67 className,
68 connection,
69 initialMessages,
70 id,
71 body,
72 onResponse,
73 onChunk,
74 onFinish,
75 onError,
76}: ChatProps) {
77 const chat = useChat({
78 connection,
79 ...(initialMessages !== undefined ? { initialMessages } : {}),
80 ...(id !== undefined ? { id } : {}),
81 ...(body !== undefined ? { body } : {}),
82 ...(onResponse !== undefined ? { onResponse } : {}),
83 ...(onChunk !== undefined ? { onChunk } : {}),
84 ...(onFinish !== undefined ? { onFinish } : {}),
85 ...(onError !== undefined ? { onError } : {}),
86 })
87
88 return (
89 <ChatContext.Provider value={chat}>
90 <div className={className} data-chat-root>
91 {children}
92 </div>
93 </ChatContext.Provider>
94 )
95}

Callers

nothing calls this directly

Calls 1

useChatFunction · 0.90

Tested by

no test coverage detected