tango-app-api-audio-analytics 1.0.22 → 1.0.24
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/package.json
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "tango-app-api-audio-analytics",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "audioAnalytics",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"start": "nodemon --exec \"eslint --fix . && node app.js\""
|
|
9
|
-
},
|
|
10
|
-
"engines": {
|
|
11
|
-
"node": ">=18.10.0"
|
|
12
|
-
},
|
|
13
|
-
"author": "praveenraj",
|
|
14
|
-
"license": "ISC",
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"@aws-sdk/client-secrets-manager": "^3.1003.0",
|
|
17
|
-
"@google/generative-ai": "^0.24.1",
|
|
18
|
-
"aws-sdk": "^2.1693.0",
|
|
19
|
-
"body-parser": "^2.2.2",
|
|
20
|
-
"cors": "^2.8.6",
|
|
21
|
-
"dotenv": "^17.3.1",
|
|
22
|
-
"express": "^5.2.1",
|
|
23
|
-
"json2csv": "^6.0.0-alpha.2",
|
|
24
|
-
"mongodb": "^6.21.0",
|
|
25
|
-
"nodemon": "^3.1.14",
|
|
26
|
-
"tango-api-schema": "^2.5.62",
|
|
27
|
-
"tango-app-api-middleware": "^3.6.18",
|
|
28
|
-
"winston": "^3.19.0",
|
|
29
|
-
"winston-daily-rotate-file": "^5.0.0"
|
|
30
|
-
},
|
|
31
|
-
"devDependencies": {
|
|
32
|
-
"eslint": "^8.57.1",
|
|
33
|
-
"eslint-config-google": "^0.14.0",
|
|
34
|
-
"eslint-config-semistandard": "^17.0.0",
|
|
35
|
-
"eslint-config-standard": "^17.1.0",
|
|
36
|
-
"eslint-plugin-import": "^2.32.0",
|
|
37
|
-
"eslint-plugin-promise": "^6.6.0"
|
|
38
|
-
}
|
|
39
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "tango-app-api-audio-analytics",
|
|
3
|
+
"version": "1.0.24",
|
|
4
|
+
"description": "audioAnalytics",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "nodemon --exec \"eslint --fix . && node app.js\""
|
|
9
|
+
},
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=18.10.0"
|
|
12
|
+
},
|
|
13
|
+
"author": "praveenraj",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@aws-sdk/client-secrets-manager": "^3.1003.0",
|
|
17
|
+
"@google/generative-ai": "^0.24.1",
|
|
18
|
+
"aws-sdk": "^2.1693.0",
|
|
19
|
+
"body-parser": "^2.2.2",
|
|
20
|
+
"cors": "^2.8.6",
|
|
21
|
+
"dotenv": "^17.3.1",
|
|
22
|
+
"express": "^5.2.1",
|
|
23
|
+
"json2csv": "^6.0.0-alpha.2",
|
|
24
|
+
"mongodb": "^6.21.0",
|
|
25
|
+
"nodemon": "^3.1.14",
|
|
26
|
+
"tango-api-schema": "^2.5.62",
|
|
27
|
+
"tango-app-api-middleware": "^3.6.18",
|
|
28
|
+
"winston": "^3.19.0",
|
|
29
|
+
"winston-daily-rotate-file": "^5.0.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"eslint": "^8.57.1",
|
|
33
|
+
"eslint-config-google": "^0.14.0",
|
|
34
|
+
"eslint-config-semistandard": "^17.0.0",
|
|
35
|
+
"eslint-config-standard": "^17.1.0",
|
|
36
|
+
"eslint-plugin-import": "^2.32.0",
|
|
37
|
+
"eslint-plugin-promise": "^6.6.0"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -456,6 +456,9 @@ Only return the JSON array, no other text.`;
|
|
|
456
456
|
// ======================= CHAT STREAM API =======================
|
|
457
457
|
|
|
458
458
|
const CHAT_STREAM_API = 'http://65.2.124.154:8000/api/chat/stream';
|
|
459
|
+
const AUDIO_STREAM_API = 'http://65.2.124.154:8000/api/chat/audio';
|
|
460
|
+
const EYE_TEST_STREAM_API = 'http://65.2.124.154:8000/api/chat/pet';
|
|
461
|
+
|
|
459
462
|
|
|
460
463
|
/**
|
|
461
464
|
* Chat Stream API - Streams response from external AI chat API
|
|
@@ -473,6 +476,8 @@ export async function chatStream( req, res ) {
|
|
|
473
476
|
sessionTimezone,
|
|
474
477
|
message,
|
|
475
478
|
config,
|
|
479
|
+
|
|
480
|
+
|
|
476
481
|
} = req.body;
|
|
477
482
|
|
|
478
483
|
logger.info( { message: 'Received chat stream request', userId, sessionId, message } );
|
|
@@ -488,7 +493,7 @@ export async function chatStream( req, res ) {
|
|
|
488
493
|
};
|
|
489
494
|
/* eslint-enable camelcase */
|
|
490
495
|
|
|
491
|
-
logger.info( { message: 'Calling external chat stream API', payload } );
|
|
496
|
+
logger.info( { message: 'Calling external chat stream API', payload, EYE_TEST_STREAM_API } );
|
|
492
497
|
|
|
493
498
|
// Set SSE headers
|
|
494
499
|
res.setHeader( 'Content-Type', 'text/event-stream' );
|
|
@@ -505,7 +510,6 @@ export async function chatStream( req, res ) {
|
|
|
505
510
|
},
|
|
506
511
|
body: JSON.stringify( payload ),
|
|
507
512
|
} );
|
|
508
|
-
|
|
509
513
|
if ( !response.ok ) {
|
|
510
514
|
logger.error( `External Chat Stream API error: ${response.status} ${response.statusText}` );
|
|
511
515
|
res.write( `data: ${JSON.stringify( { error: `External API error: ${response.statusText}` } )}\n\n` );
|
|
@@ -537,7 +541,7 @@ export async function chatStream( req, res ) {
|
|
|
537
541
|
export async function aiStreamResponse( req, res ) {
|
|
538
542
|
try {
|
|
539
543
|
/* eslint-disable camelcase */
|
|
540
|
-
const { user_id, session_id, session_date, session_timezone, message, config } = req.body;
|
|
544
|
+
const { user_id, session_id, session_date, session_timezone, message, config, analyticsType } = req.body;
|
|
541
545
|
|
|
542
546
|
logger.info( { message: 'Received ai-stream-response request', user_id, session_id } );
|
|
543
547
|
|
|
@@ -553,11 +557,12 @@ export async function aiStreamResponse( req, res ) {
|
|
|
553
557
|
date_range: config.date_range,
|
|
554
558
|
selected_products: config.selected_products,
|
|
555
559
|
selected_model: config.selected_model,
|
|
560
|
+
selected_cohorts: config.selected_cohorts,
|
|
556
561
|
},
|
|
557
562
|
};
|
|
558
563
|
/* eslint-enable camelcase */
|
|
559
564
|
|
|
560
|
-
const response = await fetch( CHAT_STREAM_API, {
|
|
565
|
+
const response = await fetch( analyticsType === 'audio'? AUDIO_STREAM_API: analyticsType === 'eyetest'? EYE_TEST_STREAM_API: CHAT_STREAM_API, {
|
|
561
566
|
method: 'POST',
|
|
562
567
|
headers: {
|
|
563
568
|
'Content-Type': 'application/json',
|
|
@@ -566,7 +571,7 @@ export async function aiStreamResponse( req, res ) {
|
|
|
566
571
|
},
|
|
567
572
|
body: JSON.stringify( payload ),
|
|
568
573
|
} );
|
|
569
|
-
|
|
574
|
+
logger.info( { message: 'Called external stream API', status: response } );
|
|
570
575
|
if ( !response.ok ) {
|
|
571
576
|
logger.error( response, `External Chat Stream API error: ${response.status} ${response.statusText}` );
|
|
572
577
|
return res.sendError( `External API error: ${response.statusText}`, response.status );
|
|
@@ -40,6 +40,8 @@ export const getConversationsList = async ( req, res ) => {
|
|
|
40
40
|
limit,
|
|
41
41
|
offset,
|
|
42
42
|
isExport,
|
|
43
|
+
_id,
|
|
44
|
+
name,
|
|
43
45
|
} = req.body;
|
|
44
46
|
|
|
45
47
|
// Validation
|
|
@@ -75,6 +77,8 @@ export const getConversationsList = async ( req, res ) => {
|
|
|
75
77
|
isExport,
|
|
76
78
|
limit,
|
|
77
79
|
offset,
|
|
80
|
+
_id,
|
|
81
|
+
name,
|
|
78
82
|
} );
|
|
79
83
|
|
|
80
84
|
// conversations = exportResponse.conversations || [];
|
|
@@ -115,6 +119,8 @@ export const getConversationsList = async ( req, res ) => {
|
|
|
115
119
|
searchValue,
|
|
116
120
|
limit,
|
|
117
121
|
offset,
|
|
122
|
+
_id,
|
|
123
|
+
name,
|
|
118
124
|
} );
|
|
119
125
|
// conversations = lambdaResponse.conversations || [];
|
|
120
126
|
// totalCount = lambdaResponse.totalCount || conversations.length;
|
|
@@ -72,12 +72,15 @@ export async function getConversationsListFromLambda( params ) {
|
|
|
72
72
|
storeId: params.storeId,
|
|
73
73
|
clientId: params.clientId,
|
|
74
74
|
cohort_id: params?.cohortType?.[0],
|
|
75
|
+
_id: params?._id,
|
|
76
|
+
name: params?.name,
|
|
75
77
|
isAI: params.isAI,
|
|
76
78
|
analyticsType: params.analyticsType,
|
|
77
79
|
searchValue: params.searchValue,
|
|
78
80
|
limit: params.limit,
|
|
79
81
|
offset: params.offset,
|
|
80
82
|
};
|
|
83
|
+
console.log( payload );
|
|
81
84
|
const response = await axios.post( `${LAMBDA_ENDPOINT.cohortConversationList}/conversations/list`, payload, {
|
|
82
85
|
timeout: 30000,
|
|
83
86
|
} );
|