@erdoai/ui 0.1.20 → 0.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -13
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +193 -38
- package/dist/index.d.ts +193 -38
- package/dist/index.js +8 -8
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -227,27 +227,36 @@ import { DatasetChart } from '@erdoai/ui';
|
|
|
227
227
|
|
|
228
228
|
## Hooks
|
|
229
229
|
|
|
230
|
-
###
|
|
230
|
+
### useThread
|
|
231
231
|
|
|
232
|
-
|
|
232
|
+
Manage a thread and send messages with streaming support:
|
|
233
233
|
|
|
234
234
|
```tsx
|
|
235
235
|
const {
|
|
236
|
-
|
|
237
|
-
isStreaming,
|
|
238
|
-
error,
|
|
239
|
-
|
|
240
|
-
|
|
236
|
+
thread, // Current thread (null if not yet created)
|
|
237
|
+
isStreaming, // Whether streaming is in progress
|
|
238
|
+
error, // Any error that occurred
|
|
239
|
+
activeMessages, // Messages being streamed (with parsed content)
|
|
240
|
+
sendMessage, // Function to send a message
|
|
241
|
+
cancel, // Function to cancel current message
|
|
242
|
+
} = useThread({
|
|
243
|
+
botKey: 'data-analyst', // Optional: specify which bot to use
|
|
241
244
|
onEvent: (event) => console.log('Event:', event),
|
|
242
|
-
onFinish: (
|
|
245
|
+
onFinish: () => console.log('Message complete'),
|
|
243
246
|
onError: (error) => console.error('Error:', error),
|
|
244
247
|
});
|
|
245
248
|
|
|
246
|
-
//
|
|
247
|
-
await
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
249
|
+
// Send a message (thread is auto-created on first message)
|
|
250
|
+
await sendMessage('Analyze our sales data');
|
|
251
|
+
|
|
252
|
+
// Render streaming content
|
|
253
|
+
{activeMessages.map(msg => (
|
|
254
|
+
<div key={msg.message.id}>
|
|
255
|
+
{msg.contents.map(content => (
|
|
256
|
+
<Content key={content.id} content={content} />
|
|
257
|
+
))}
|
|
258
|
+
</div>
|
|
259
|
+
))}
|
|
251
260
|
```
|
|
252
261
|
|
|
253
262
|
### useDatasetContents
|