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