tango-app-api-audio-analytics 1.0.29 → 1.0.31
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
|
@@ -7,6 +7,7 @@ const EXTERNAL_STREAM_API = 'http://172.236.179.51:8000/stream';
|
|
|
7
7
|
export async function createCohort( req, res ) {
|
|
8
8
|
try {
|
|
9
9
|
const inputData = req.body;
|
|
10
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
10
11
|
|
|
11
12
|
const cohortId = `cohort_${inputData.clientId}_${randomUUID()}`;
|
|
12
13
|
|
|
@@ -32,7 +33,7 @@ export async function createCohort( req, res ) {
|
|
|
32
33
|
updatedAt: new Date().toISOString(),
|
|
33
34
|
};
|
|
34
35
|
|
|
35
|
-
const result = await insertWithId(
|
|
36
|
+
const result = await insertWithId( openSearch.audioconfig, cohortId, cohortData );
|
|
36
37
|
logger.info( { result } );
|
|
37
38
|
|
|
38
39
|
if ( result && result.body && result.body.result === 'created' ) {
|
|
@@ -50,7 +51,7 @@ export async function createCohort( req, res ) {
|
|
|
50
51
|
export async function createBulkCohort( req, res ) {
|
|
51
52
|
try {
|
|
52
53
|
const { clientId, cohorts } = req.body;
|
|
53
|
-
|
|
54
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
54
55
|
const results = [];
|
|
55
56
|
const failed = [];
|
|
56
57
|
|
|
@@ -68,7 +69,7 @@ export async function createBulkCohort( req, res ) {
|
|
|
68
69
|
updatedAt: new Date().toISOString(),
|
|
69
70
|
};
|
|
70
71
|
|
|
71
|
-
const result = await insertWithId(
|
|
72
|
+
const result = await insertWithId( openSearch.audioconfig, cohortId, cohortData );
|
|
72
73
|
logger.info( { result } );
|
|
73
74
|
|
|
74
75
|
if ( result && result.body && result.body.result === 'created' ) {
|
|
@@ -95,7 +96,7 @@ export async function createBulkCohort( req, res ) {
|
|
|
95
96
|
export async function updateCohort( req, res ) {
|
|
96
97
|
try {
|
|
97
98
|
const { cohortId, ...updateFields } = req.body;
|
|
98
|
-
|
|
99
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
99
100
|
const metrics = updateFields.metrics ?
|
|
100
101
|
updateFields.metrics.map( ( metric ) => ( {
|
|
101
102
|
...metric,
|
|
@@ -119,7 +120,7 @@ export async function updateCohort( req, res ) {
|
|
|
119
120
|
doc_as_upsert: true,
|
|
120
121
|
};
|
|
121
122
|
|
|
122
|
-
const result = await updateOpenSearchData(
|
|
123
|
+
const result = await updateOpenSearchData( openSearch.audioconfig, cohortId, updatePayload );
|
|
123
124
|
logger.info( { result } );
|
|
124
125
|
|
|
125
126
|
if ( result && result.body && result.body.result === 'updated' ) {
|
|
@@ -137,7 +138,7 @@ export async function updateCohort( req, res ) {
|
|
|
137
138
|
export async function deleteCohort( req, res ) {
|
|
138
139
|
try {
|
|
139
140
|
const { cohortId } = req.body;
|
|
140
|
-
|
|
141
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
141
142
|
const updatePayload = {
|
|
142
143
|
doc: {
|
|
143
144
|
isDeleted: true,
|
|
@@ -145,7 +146,7 @@ export async function deleteCohort( req, res ) {
|
|
|
145
146
|
},
|
|
146
147
|
};
|
|
147
148
|
|
|
148
|
-
const result = await updateOpenSearchData(
|
|
149
|
+
const result = await updateOpenSearchData( openSearch.audioconfig, cohortId, updatePayload );
|
|
149
150
|
logger.info( { result } );
|
|
150
151
|
|
|
151
152
|
if ( result && result.body && result.body.result === 'updated' ) {
|
|
@@ -163,14 +164,14 @@ export async function deleteCohort( req, res ) {
|
|
|
163
164
|
export async function getCohort( req, res ) {
|
|
164
165
|
try {
|
|
165
166
|
const { cohortId } = req.params;
|
|
166
|
-
|
|
167
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
167
168
|
const query = {
|
|
168
169
|
query: {
|
|
169
170
|
match: { cohortId },
|
|
170
171
|
},
|
|
171
172
|
};
|
|
172
173
|
|
|
173
|
-
const result = await searchOpenSearchData(
|
|
174
|
+
const result = await searchOpenSearchData( openSearch.audioconfig, query );
|
|
174
175
|
logger.info( { result } );
|
|
175
176
|
|
|
176
177
|
if ( !result || result?.body?.hits?.hits?.length === 0 ) {
|
|
@@ -188,6 +189,7 @@ export async function getCohort( req, res ) {
|
|
|
188
189
|
export async function listCohortsByClient( req, res ) {
|
|
189
190
|
try {
|
|
190
191
|
const { clientId, limit = 10, offset = 0 } = req.query;
|
|
192
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
191
193
|
logger.info( { message: req.query, function: 'listCohortsByClient' } );
|
|
192
194
|
const query = {
|
|
193
195
|
query: {
|
|
@@ -205,7 +207,7 @@ export async function listCohortsByClient( req, res ) {
|
|
|
205
207
|
sort: [ { createdAt: { order: 'desc' } } ],
|
|
206
208
|
};
|
|
207
209
|
|
|
208
|
-
const result = await searchOpenSearchData(
|
|
210
|
+
const result = await searchOpenSearchData( openSearch.audioconfig, query );
|
|
209
211
|
logger.info( { result } );
|
|
210
212
|
|
|
211
213
|
const total = result?.body?.hits?.total?.value || 0;
|
|
@@ -456,10 +458,10 @@ Only return the JSON array, no other text.`;
|
|
|
456
458
|
|
|
457
459
|
// ======================= CHAT STREAM API =======================
|
|
458
460
|
|
|
459
|
-
const CHAT_STREAM_API = 'http://
|
|
460
|
-
const AUDIO_STREAM_API = 'http://
|
|
461
|
-
const EYE_TEST_STREAM_API = 'http://
|
|
462
|
-
const CONVERSATION_STREAM_API = 'http://
|
|
461
|
+
const CHAT_STREAM_API = 'http://13.200.163.127:8000/api/chat/stream';
|
|
462
|
+
const AUDIO_STREAM_API = 'http://13.200.163.127:8000/api/chat/audio/cohort';
|
|
463
|
+
const EYE_TEST_STREAM_API = 'http://13.200.163.127:8000/api/chat/pet';
|
|
464
|
+
const CONVERSATION_STREAM_API = 'http://13.200.163.127:8000/api/chat/audio/transcript';
|
|
463
465
|
|
|
464
466
|
|
|
465
467
|
/**
|