convo-ai-sdk 1.2.2 → 1.2.4
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.d.ts +1 -1
- package/dist/index.js +5 -8
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export declare class ChatClient {
|
|
|
23
23
|
transcriptionKey: string;
|
|
24
24
|
cost_analysis: any;
|
|
25
25
|
} | null>;
|
|
26
|
-
sendTranscriptionMessage(transcriptionText: string, transcriptionKey: string): Promise<void>;
|
|
26
|
+
sendTranscriptionMessage(transcriptionText: string, transcriptionKey: string, modified?: boolean): Promise<void>;
|
|
27
27
|
sendMessage(text: string): Promise<void>;
|
|
28
28
|
toolCall(tool_call: any): Promise<void>;
|
|
29
29
|
sendStreamMessage(message: ChatMessage): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -229,9 +229,8 @@ export class ChatClient {
|
|
|
229
229
|
console.error('Transcribe API endpoint not available.');
|
|
230
230
|
return null;
|
|
231
231
|
}
|
|
232
|
-
const contentType = audioBlob.type || '
|
|
233
|
-
const
|
|
234
|
-
const fileBuffer = Buffer.from(arrayBuffer);
|
|
232
|
+
const contentType = audioBlob.type || 'audio/webm';
|
|
233
|
+
const fileBuffer = await audioBlob.arrayBuffer();
|
|
235
234
|
// 1. Get Presigned URL
|
|
236
235
|
const uploadUrlResponse = await fetch(`${this.config.transcribeApiEndpoint}upload-url?contentType=${contentType}`, {
|
|
237
236
|
method: "GET",
|
|
@@ -244,7 +243,6 @@ export class ChatClient {
|
|
|
244
243
|
}
|
|
245
244
|
const { uploadUrl, key } = await uploadUrlResponse.json();
|
|
246
245
|
// 2. Upload File to S3
|
|
247
|
-
// Note: In Node environment with native fetch, we can pass Buffer directly for PUT body
|
|
248
246
|
const uploadResponse = await fetch(uploadUrl, {
|
|
249
247
|
method: "PUT",
|
|
250
248
|
headers: {
|
|
@@ -255,7 +253,6 @@ export class ChatClient {
|
|
|
255
253
|
if (!uploadResponse.ok) {
|
|
256
254
|
throw new Error(`Failed to upload file to S3: ${uploadResponse.statusText}`);
|
|
257
255
|
}
|
|
258
|
-
console.log("File uploaded successfully, key:", key);
|
|
259
256
|
// transcribe file.
|
|
260
257
|
const response = await fetch(this.config.transcribeApiEndpoint + 'transcribe', {
|
|
261
258
|
method: 'POST',
|
|
@@ -270,20 +267,20 @@ export class ChatClient {
|
|
|
270
267
|
const responseData = await response.json();
|
|
271
268
|
return responseData;
|
|
272
269
|
}
|
|
273
|
-
async sendTranscriptionMessage(transcriptionText, transcriptionKey) {
|
|
270
|
+
async sendTranscriptionMessage(transcriptionText, transcriptionKey, modified = false) {
|
|
274
271
|
if (this.status !== 'connected') {
|
|
275
272
|
console.error('Cannot send transcription message, not connected.');
|
|
276
273
|
return;
|
|
277
274
|
}
|
|
278
275
|
const transcriptionMessage = {
|
|
279
276
|
id: `transcription-${Date.now()}`,
|
|
280
|
-
data: { content: transcriptionText, metadata: { transcriptionKey } },
|
|
277
|
+
data: { content: transcriptionText, metadata: { transcriptionKey, modified } },
|
|
281
278
|
from: 'transcription',
|
|
282
279
|
timestamp: Date.now(),
|
|
283
280
|
};
|
|
284
281
|
this._addMessage(transcriptionMessage);
|
|
285
282
|
this._emit('message', transcriptionMessage);
|
|
286
|
-
this.sendStreamMessage(transcriptionMessage);
|
|
283
|
+
await this.sendStreamMessage(transcriptionMessage);
|
|
287
284
|
}
|
|
288
285
|
async sendMessage(text) {
|
|
289
286
|
if (this.status !== 'connected') {
|