@wix/legends-platform-sdk 1.14.0 → 1.15.0
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 +44 -13
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -109,7 +109,7 @@ const { status, join, leave } = useConversation({
|
|
|
109
109
|
|--------|------|-------------|
|
|
110
110
|
| `status` | `'pending' \| 'created' \| 'destroying' \| 'destroyed' \| 'exceeded' \| 'inactivity-timeout' \| 'voice-not-found' \| 'initialization-error' \| 'error'` | Current conversation state |
|
|
111
111
|
| `join()` | `() => void` | Start the conversation |
|
|
112
|
-
| `leave()` | `(
|
|
112
|
+
| `leave()` | `(destroy?: boolean) => Promise<void>` | End the conversation |
|
|
113
113
|
|
|
114
114
|
#### `useMicrophone()`
|
|
115
115
|
|
|
@@ -153,29 +153,60 @@ const status = useConversationStatus();
|
|
|
153
153
|
const { elapsed, remaining } = useConversationTimer();
|
|
154
154
|
```
|
|
155
155
|
|
|
156
|
-
#### `useTools(
|
|
156
|
+
#### `useTools()`
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
Read the list of tool calls executed by the SDK. To register tool handlers, pass a `tools` registry to `LegendsPlatform`.
|
|
159
159
|
|
|
160
160
|
```tsx
|
|
161
|
-
import { useTools } from '@wix/legends-platform-sdk';
|
|
162
|
-
|
|
163
|
-
const tools =
|
|
164
|
-
get_weather: {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
return { temperature: data.temp };
|
|
168
|
-
},
|
|
161
|
+
import { LegendsPlatform, useTools, type ToolsRegistry } from '@wix/legends-platform-sdk';
|
|
162
|
+
|
|
163
|
+
const tools: ToolsRegistry = {
|
|
164
|
+
get_weather: async ({ city }) => {
|
|
165
|
+
const data = await fetchWeather(city as string);
|
|
166
|
+
return { temperature: data.temp };
|
|
169
167
|
},
|
|
170
|
-
}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
function ToolLog() {
|
|
171
|
+
const calls = useTools(); // returns ToolCallSnapshot[]
|
|
172
|
+
return <pre>{JSON.stringify(calls, null, 2)}</pre>;
|
|
173
|
+
}
|
|
171
174
|
|
|
172
175
|
return (
|
|
173
176
|
<LegendsPlatform ... tools={tools}>
|
|
174
|
-
|
|
177
|
+
<ToolLog />
|
|
175
178
|
</LegendsPlatform>
|
|
176
179
|
);
|
|
177
180
|
```
|
|
178
181
|
|
|
182
|
+
#### `useTextChatStream(options)`
|
|
183
|
+
|
|
184
|
+
Streaming counterpart to `useTextChat`. Sends messages over SSE and drips the assistant reply into `streamingText` at a steady rate via `requestAnimationFrame`.
|
|
185
|
+
|
|
186
|
+
```tsx
|
|
187
|
+
const { messages, send } = useTextChatStream({
|
|
188
|
+
streamUrl: '/api/chat/stream',
|
|
189
|
+
onError: (err) => console.error(err),
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// messages[n].streamStatus === 'streaming' while the reply is in-flight
|
|
193
|
+
await send({ message: 'Hello' });
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
#### `useSpeechActivityDetector(options)`
|
|
197
|
+
|
|
198
|
+
Acoustic speech onset/offset detector driven by `AudioWorkletNode`. Useful for measuring end-to-end latency or building custom VAD UI.
|
|
199
|
+
|
|
200
|
+
```tsx
|
|
201
|
+
useSpeechActivityDetector({
|
|
202
|
+
source: 'user',
|
|
203
|
+
thresholdRms: 0.015,
|
|
204
|
+
hangoverMs: 300,
|
|
205
|
+
onSpeechStart: (timestampMs) => console.log('started', timestampMs),
|
|
206
|
+
onSpeechEnd: (timestampMs) => console.log('ended', timestampMs),
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
|
|
179
210
|
---
|
|
180
211
|
|
|
181
212
|
## Advanced: Custom Service
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.15.0",
|
|
3
3
|
"name": "@wix/legends-platform-sdk",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"wallaby": {
|
|
104
104
|
"autoDetect": true
|
|
105
105
|
},
|
|
106
|
-
"falconPackageHash": "
|
|
106
|
+
"falconPackageHash": "15066ab5e2566736853757bb8084e283c4d4d3c86998579c919f5c4c"
|
|
107
107
|
}
|