(options?: {
id?: string
threadId?: string
connection?: ConnectConnectionAdapter
tools?: ReadonlyArray<AnyClientTool>
initialMessages?: Array<UIMessage>
mountDevtools?: boolean
devtoolsName?: string
})
| 103 | }) |
| 104 | |
| 105 | function createClient(options?: { |
| 106 | id?: string |
| 107 | threadId?: string |
| 108 | connection?: ConnectConnectionAdapter |
| 109 | tools?: ReadonlyArray<AnyClientTool> |
| 110 | initialMessages?: Array<UIMessage> |
| 111 | mountDevtools?: boolean |
| 112 | devtoolsName?: string |
| 113 | }) { |
| 114 | const client = new ChatClient({ |
| 115 | id: options?.id ?? 'chat-1', |
| 116 | threadId: options?.threadId ?? 'thread-1', |
| 117 | connection: options?.connection ?? createMockConnectionAdapter(), |
| 118 | ...(options?.tools ? { tools: options.tools } : {}), |
| 119 | ...(options?.initialMessages |
| 120 | ? { initialMessages: options.initialMessages } |
| 121 | : {}), |
| 122 | devtools: { |
| 123 | ...(options?.devtoolsName ? { name: options.devtoolsName } : {}), |
| 124 | framework: 'react', |
| 125 | hookName: 'useChat', |
| 126 | }, |
| 127 | }) |
| 128 | if (options?.mountDevtools ?? true) { |
| 129 | client.mountDevtools() |
| 130 | } |
| 131 | return client |
| 132 | } |
| 133 | |
| 134 | function createRunTrackingAdapter( |
| 135 | chunkSets: Array<Array<StreamChunk>>, |
no test coverage detected