@trillet-ai/web-sdk 1.5.1 → 1.5.2
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/dist/index.js +4 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -236,24 +236,22 @@ export class TrilletAgent extends EventEmitter {
|
|
|
236
236
|
return this.currentTranscript;
|
|
237
237
|
}
|
|
238
238
|
sendTextMessage(text) {
|
|
239
|
-
var _a, _b;
|
|
240
239
|
if (this.config.mode !== 'text') {
|
|
241
240
|
console.warn('Cannot send text message in voice mode.');
|
|
242
241
|
return;
|
|
243
242
|
}
|
|
244
|
-
|
|
243
|
+
const room = this.sdk.getRoom();
|
|
244
|
+
if (!room || !this.sdk.isConnected) {
|
|
245
245
|
this.emit('error', new Error('Not connected. Cannot send message.'));
|
|
246
246
|
return;
|
|
247
247
|
}
|
|
248
|
-
|
|
249
|
-
const encoder = new TextEncoder();
|
|
250
|
-
(_a = this.sdk.getRoom()) === null || _a === void 0 ? void 0 : _a.localParticipant.publishData(encoder.encode(JSON.stringify(payload)), { reliable: true });
|
|
248
|
+
room.localParticipant.sendText(text);
|
|
251
249
|
this.transcripts.push({
|
|
252
250
|
role: 'user',
|
|
253
251
|
text,
|
|
254
252
|
isFinal: true,
|
|
255
253
|
timestamp: new Date(),
|
|
256
|
-
participantId:
|
|
254
|
+
participantId: room.localParticipant.identity,
|
|
257
255
|
});
|
|
258
256
|
this.emit('transcriptUpdate', this.transcripts);
|
|
259
257
|
}
|