@mulingai-npm/message-broker 2.15.1 → 2.15.3
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RabbitMQClient } from '../rabbitmq-client';
|
|
2
|
-
import { IMulingstreamTranscriptionInterim, IMulingstreamTranscriptionFinal } from '@mulingai-npm/web-sockets';
|
|
2
|
+
import { IMulingstreamTranscriptionInterim, IMulingstreamTranscriptionFinal, IMulingstreamTranscriptionCorrected } from '@mulingai-npm/web-sockets';
|
|
3
3
|
/**
|
|
4
4
|
* Message broker manager for real-time transcription events
|
|
5
5
|
*
|
|
@@ -9,7 +9,7 @@ import { IMulingstreamTranscriptionInterim, IMulingstreamTranscriptionFinal } fr
|
|
|
9
9
|
export declare class MulingstreamTranscriptionRealtime {
|
|
10
10
|
private client;
|
|
11
11
|
constructor(client: RabbitMQClient);
|
|
12
|
-
/** Initialize
|
|
12
|
+
/** Initialize all exchanges */
|
|
13
13
|
initialize(): Promise<void>;
|
|
14
14
|
/** Publish interim transcription */
|
|
15
15
|
publishInterim(data: IMulingstreamTranscriptionInterim): Promise<void>;
|
|
@@ -17,6 +17,10 @@ export declare class MulingstreamTranscriptionRealtime {
|
|
|
17
17
|
publishFinal(data: IMulingstreamTranscriptionFinal): Promise<void>;
|
|
18
18
|
/** Subscribe to interim transcriptions */
|
|
19
19
|
subscribeInterim(queueName: string, onMessage: (data: IMulingstreamTranscriptionInterim) => Promise<void> | void): Promise<void>;
|
|
20
|
+
/** Publish corrected transcription (SmartTranslate LLM changed the text) */
|
|
21
|
+
publishCorrected(data: IMulingstreamTranscriptionCorrected): Promise<void>;
|
|
22
|
+
/** Subscribe to corrected transcriptions */
|
|
23
|
+
subscribeCorrected(queueName: string, onMessage: (data: IMulingstreamTranscriptionCorrected) => Promise<void> | void): Promise<void>;
|
|
20
24
|
/** Subscribe to final transcriptions */
|
|
21
25
|
subscribeFinal(queueName: string, onMessage: (data: IMulingstreamTranscriptionFinal) => Promise<void> | void): Promise<void>;
|
|
22
26
|
}
|
|
@@ -5,6 +5,8 @@ exports.MulingstreamTranscriptionRealtime = void 0;
|
|
|
5
5
|
const INTERIM_EXCHANGE_NAME = 'mulingstream-transcription-interim';
|
|
6
6
|
// Final transcription exchange (for completed sentences)
|
|
7
7
|
const FINAL_EXCHANGE_NAME = 'mulingstream-transcription-final';
|
|
8
|
+
// Corrected transcription exchange (SmartTranslate LLM changed the text)
|
|
9
|
+
const CORRECTED_EXCHANGE_NAME = 'mulingstream-transcription-corrected';
|
|
8
10
|
const EXCHANGE_TYPE = 'fanout';
|
|
9
11
|
/**
|
|
10
12
|
* Message broker manager for real-time transcription events
|
|
@@ -16,11 +18,12 @@ class MulingstreamTranscriptionRealtime {
|
|
|
16
18
|
constructor(client) {
|
|
17
19
|
this.client = client;
|
|
18
20
|
}
|
|
19
|
-
/** Initialize
|
|
21
|
+
/** Initialize all exchanges */
|
|
20
22
|
async initialize() {
|
|
21
23
|
const channel = this.client.getChannelOrThrow();
|
|
22
24
|
await channel.assertExchange(INTERIM_EXCHANGE_NAME, EXCHANGE_TYPE, { durable: false });
|
|
23
25
|
await channel.assertExchange(FINAL_EXCHANGE_NAME, EXCHANGE_TYPE, { durable: false });
|
|
26
|
+
await channel.assertExchange(CORRECTED_EXCHANGE_NAME, EXCHANGE_TYPE, { durable: false });
|
|
24
27
|
console.log(`MulingstreamTranscriptionRealtime exchanges initialized.`);
|
|
25
28
|
}
|
|
26
29
|
/** Publish interim transcription */
|
|
@@ -52,6 +55,30 @@ class MulingstreamTranscriptionRealtime {
|
|
|
52
55
|
}
|
|
53
56
|
});
|
|
54
57
|
}
|
|
58
|
+
/** Publish corrected transcription (SmartTranslate LLM changed the text) */
|
|
59
|
+
async publishCorrected(data) {
|
|
60
|
+
const channel = this.client.getChannelOrThrow();
|
|
61
|
+
channel.publish(CORRECTED_EXCHANGE_NAME, '', Buffer.from(JSON.stringify(data)));
|
|
62
|
+
}
|
|
63
|
+
/** Subscribe to corrected transcriptions */
|
|
64
|
+
async subscribeCorrected(queueName, onMessage) {
|
|
65
|
+
const channel = this.client.getChannelOrThrow();
|
|
66
|
+
await channel.assertQueue(queueName, { durable: false });
|
|
67
|
+
await channel.bindQueue(queueName, CORRECTED_EXCHANGE_NAME, '');
|
|
68
|
+
await channel.consume(queueName, async (msg) => {
|
|
69
|
+
if (!msg)
|
|
70
|
+
return;
|
|
71
|
+
try {
|
|
72
|
+
const data = JSON.parse(msg.content.toString());
|
|
73
|
+
await onMessage(data);
|
|
74
|
+
channel.ack(msg);
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
console.error(`Error in transcription corrected queue '${queueName}':`, err);
|
|
78
|
+
channel.nack(msg, false, false);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
55
82
|
/** Subscribe to final transcriptions */
|
|
56
83
|
async subscribeFinal(queueName, onMessage) {
|
|
57
84
|
const channel = this.client.getChannelOrThrow();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mulingai-npm/message-broker",
|
|
3
|
-
"version": "2.15.
|
|
3
|
+
"version": "2.15.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"prepublishOnly": "npm run build"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@mulingai-npm/web-sockets": "^1.54.
|
|
20
|
+
"@mulingai-npm/web-sockets": "^1.54.2",
|
|
21
21
|
"amqplib": "^0.10.5"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|