@erdoai/ui 0.1.20 → 0.1.23

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 CHANGED
@@ -227,27 +227,36 @@ import { DatasetChart } from '@erdoai/ui';
227
227
 
228
228
  ## Hooks
229
229
 
230
- ### useInvocation
230
+ ### useThread
231
231
 
232
- Invoke agents with streaming support:
232
+ Manage a thread and send messages with streaming support:
233
233
 
234
234
  ```tsx
235
235
  const {
236
- result, // Current result state
237
- isStreaming, // Whether streaming is in progress
238
- error, // Any error that occurred
239
- invoke, // Function to start invocation
240
- } = useInvocation({
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: (result) => console.log('Complete:', result),
245
+ onFinish: () => console.log('Message complete'),
243
246
  onError: (error) => console.error('Error:', error),
244
247
  });
245
248
 
246
- // Invoke an agent
247
- await invoke('data-analyst', {
248
- query: 'Analyze our sales data',
249
- threadId: 'thread-123',
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