tango-app-api-audio-analytics 1.0.25 → 1.0.26

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,235 +1,235 @@
1
- #!/bin/bash
2
-
3
- # Cohort API Test Examples
4
- # This file contains curl commands to test all cohort API endpoints
5
-
6
- BASE_URL="https://testtangoretail-api.tangoeye.ai/v3/audio-analitics"
7
- COHORT_ID="cohort_photochromatic_001"
8
- CLIENT_ID="11"
9
-
10
- # ==================== Helper Function ====================
11
- print_section() {
12
- echo ""
13
- echo "=================================="
14
- echo "$1"
15
- echo "=================================="
16
- }
17
-
18
- # ==================== 1. CREATE COHORT ====================
19
- print_section "1. CREATE COHORT"
20
-
21
- curl -X POST "$BASE_URL/cohorts" \
22
- -H "Content-Type: application/json" \
23
- -d '{
24
- "clientId": "11",
25
- "cohortId": "cohort_photochromatic_001",
26
- "cohortName": "Photochromatic",
27
- "cohortDescription": "A strict evaluation of the photochromatic sales journey, focusing on pitch quality, technical accuracy, and customer sentiment",
28
- "metrics": [
29
- {
30
- "metricId": "pitch_quality_001",
31
- "metricName": "Standard Pitch Quality",
32
- "metricDescription": "Identify which specific value propositions were explicitly used by the staff",
33
- "hasContext": true,
34
- "isNumneric": false,
35
- "contexts": [
36
- {
37
- "contextName": "ONE_GLASS_ALL_NEEDS",
38
- "priority": 2,
39
- "description": "Convenience of one pair for all lighting"
40
- },
41
- {
42
- "contextName": "TRAVEL_CONVENIENCE",
43
- "priority": 2,
44
- "description": "Specific benefits for bikers/commuters"
45
- },
46
- {
47
- "contextName": "LIGHT_ADAPTATION",
48
- "priority": 2,
49
- "description": "Technical explanation of UV reaction"
50
- },
51
- {
52
- "contextName": "REDUCES_EYE_STRAIN",
53
- "priority": 2,
54
- "description": "Glare and fatigue protection"
55
- }
56
- ]
57
- },
58
- {
59
- "metricId": "technical_depth_score_001",
60
- "metricName": "Technical Depth Score",
61
- "metricDescription": "A numeric evaluation of the staff'\''s product knowledge during the pitch",
62
- "hasContext": true,
63
- "isNumneric": true,
64
- "contexts": [
65
- {
66
- "minValue": 0,
67
- "maxValue": 100
68
- }
69
- ]
70
- },
71
- {
72
- "metricId": "customer_sentiment_001",
73
- "metricName": "Initial Customer Sentiment",
74
- "metricDescription": "The immediate reaction of the customer when the lens was introduced",
75
- "hasContext": true,
76
- "isNumneric": false,
77
- "contexts": [
78
- {
79
- "contextName": "POSITIVE",
80
- "priority": 2,
81
- "description": "High interest or curiosity"
82
- },
83
- {
84
- "contextName": "NEUTRAL",
85
- "priority": 1,
86
- "description": "Acknowledgment or price-focused only"
87
- },
88
- {
89
- "contextName": "NEGATIVE",
90
- "priority": 0,
91
- "description": "Dismissive or disinterested"
92
- }
93
- ]
94
- },
95
- {
96
- "metricId": "staff_responsiveness_001",
97
- "metricName": "Staff Responsiveness",
98
- "metricDescription": "How effectively were customer doubts addressed?",
99
- "hasContext": true,
100
- "isNumneric": false,
101
- "contexts": [
102
- {
103
- "contextName": "FULLY_RESPONSIVE",
104
- "priority": 2,
105
- "description": "All doubts cleared with evidence"
106
- },
107
- {
108
- "contextName": "PARTIALLY_RESPONSIVE",
109
- "priority": 1,
110
- "description": "Some doubts addressed, others ignored"
111
- },
112
- {
113
- "contextName": "UNRESPONSIVE",
114
- "priority": 0,
115
- "description": "Customer doubts were dismissed"
116
- }
117
- ]
118
- },
119
- {
120
- "metricId": "sales_outcome_001",
121
- "metricName": "Final Sales Outcome",
122
- "metricDescription": "The final commitment level reached at the end of the conversation",
123
- "hasContext": true,
124
- "isNumneric": false,
125
- "contexts": [
126
- {
127
- "contextName": "BOUGHT_PHOTOCHROMATIC",
128
- "priority": 2,
129
- "description": "Customer agreed to the upgrade"
130
- },
131
- {
132
- "contextName": "BOUGHT_SOMETHING_ELSE",
133
- "priority": 0,
134
- "description": "Bought standard lenses/frames only"
135
- },
136
- {
137
- "contextName": "NO_SALE",
138
- "priority": 0,
139
- "description": "No purchase commitment"
140
- }
141
- ]
142
- },
143
- {
144
- "metricId": "pitch_timing_summary_001",
145
- "metricName": "Pitch Timing & Context",
146
- "metricDescription": "Narrative summary of when and how the pitch was introduced",
147
- "hasContext": false,
148
- "isNumneric": false
149
- }
150
- ]
151
- }'
152
-
153
- # ==================== 2. GET COHORT BY ID ====================
154
- print_section "2. GET COHORT BY ID"
155
-
156
- curl -X GET "$BASE_URL/cohorts/$COHORT_ID" \
157
- -H "Content-Type: application/json"
158
-
159
- # ==================== 3. GET COHORTS BY CLIENT ====================
160
- print_section "3. GET COHORTS BY CLIENT"
161
-
162
- curl -X GET "$BASE_URL/cohorts/client/$CLIENT_ID?limit=10&offset=0" \
163
- -H "Content-Type: application/json"
164
-
165
- # ==================== 4. SEARCH COHORTS ====================
166
- print_section "4. SEARCH COHORTS"
167
-
168
- curl -X POST "$BASE_URL/cohorts/search" \
169
- -H "Content-Type: application/json" \
170
- -d '{
171
- "clientId": "11",
172
- "cohortName": "Photochrom",
173
- "limit": 10,
174
- "offset": 0
175
- }'
176
-
177
- # ==================== 5. UPDATE COHORT ====================
178
- print_section "5. UPDATE COHORT"
179
-
180
- # Note: Replace DOCUMENT_ID with actual ID returned from create
181
- DOCUMENT_ID="550e8400-e29b-41d4-a716-446655440000"
182
-
183
- curl -X PUT "$BASE_URL/cohorts/$DOCUMENT_ID" \
184
- -H "Content-Type: application/json" \
185
- -d '{
186
- "cohortName": "Updated Photochromatic",
187
- "cohortDescription": "Updated description for photochromatic cohort"
188
- }'
189
-
190
- # ==================== 6. GET COHORT ANALYTICS ====================
191
- print_section "6. GET COHORT ANALYTICS"
192
-
193
- curl -X GET "$BASE_URL/cohorts/$COHORT_ID/analytics" \
194
- -H "Content-Type: application/json"
195
-
196
- # ==================== 7. DELETE COHORT ====================
197
- print_section "7. DELETE COHORT"
198
-
199
- # Note: Replace DOCUMENT_ID with actual ID
200
- curl -X DELETE "$BASE_URL/cohorts/$DOCUMENT_ID" \
201
- -H "Content-Type: application/json"
202
-
203
- # ==================== VALIDATION TESTS ====================
204
- print_section "VALIDATION TESTS"
205
-
206
- echo "Testing invalid cohort name (too short):"
207
- curl -X POST "$BASE_URL/cohorts" \
208
- -H "Content-Type: application/json" \
209
- -d '{
210
- "clientId": "11",
211
- "cohortId": "invalid_test",
212
- "cohortName": "AB",
213
- "cohortDescription": "This should fail because name is too short"
214
- }'
215
-
216
- echo ""
217
- echo "Testing missing required field:"
218
- curl -X POST "$BASE_URL/cohorts" \
219
- -H "Content-Type: application/json" \
220
- -d '{
221
- "clientId": "11",
222
- "cohortId": "invalid_test",
223
- "cohortName": "Valid Name"
224
- }'
225
-
226
- echo ""
227
- echo "Testing invalid cohortId (special characters):"
228
- curl -X POST "$BASE_URL/cohorts" \
229
- -H "Content-Type: application/json" \
230
- -d '{
231
- "clientId": "11",
232
- "cohortId": "invalid@test",
233
- "cohortName": "Valid Name",
234
- "cohortDescription": "This should fail because cohortId has invalid characters"
235
- }'
1
+ #!/bin/bash
2
+
3
+ # Cohort API Test Examples
4
+ # This file contains curl commands to test all cohort API endpoints
5
+
6
+ BASE_URL="https://testtangoretail-api.tangoeye.ai/v3/audio-analitics"
7
+ COHORT_ID="cohort_photochromatic_001"
8
+ CLIENT_ID="11"
9
+
10
+ # ==================== Helper Function ====================
11
+ print_section() {
12
+ echo ""
13
+ echo "=================================="
14
+ echo "$1"
15
+ echo "=================================="
16
+ }
17
+
18
+ # ==================== 1. CREATE COHORT ====================
19
+ print_section "1. CREATE COHORT"
20
+
21
+ curl -X POST "$BASE_URL/cohorts" \
22
+ -H "Content-Type: application/json" \
23
+ -d '{
24
+ "clientId": "11",
25
+ "cohortId": "cohort_photochromatic_001",
26
+ "cohortName": "Photochromatic",
27
+ "cohortDescription": "A strict evaluation of the photochromatic sales journey, focusing on pitch quality, technical accuracy, and customer sentiment",
28
+ "metrics": [
29
+ {
30
+ "metricId": "pitch_quality_001",
31
+ "metricName": "Standard Pitch Quality",
32
+ "metricDescription": "Identify which specific value propositions were explicitly used by the staff",
33
+ "hasContext": true,
34
+ "isNumneric": false,
35
+ "contexts": [
36
+ {
37
+ "contextName": "ONE_GLASS_ALL_NEEDS",
38
+ "priority": 2,
39
+ "description": "Convenience of one pair for all lighting"
40
+ },
41
+ {
42
+ "contextName": "TRAVEL_CONVENIENCE",
43
+ "priority": 2,
44
+ "description": "Specific benefits for bikers/commuters"
45
+ },
46
+ {
47
+ "contextName": "LIGHT_ADAPTATION",
48
+ "priority": 2,
49
+ "description": "Technical explanation of UV reaction"
50
+ },
51
+ {
52
+ "contextName": "REDUCES_EYE_STRAIN",
53
+ "priority": 2,
54
+ "description": "Glare and fatigue protection"
55
+ }
56
+ ]
57
+ },
58
+ {
59
+ "metricId": "technical_depth_score_001",
60
+ "metricName": "Technical Depth Score",
61
+ "metricDescription": "A numeric evaluation of the staff'\''s product knowledge during the pitch",
62
+ "hasContext": true,
63
+ "isNumneric": true,
64
+ "contexts": [
65
+ {
66
+ "minValue": 0,
67
+ "maxValue": 100
68
+ }
69
+ ]
70
+ },
71
+ {
72
+ "metricId": "customer_sentiment_001",
73
+ "metricName": "Initial Customer Sentiment",
74
+ "metricDescription": "The immediate reaction of the customer when the lens was introduced",
75
+ "hasContext": true,
76
+ "isNumneric": false,
77
+ "contexts": [
78
+ {
79
+ "contextName": "POSITIVE",
80
+ "priority": 2,
81
+ "description": "High interest or curiosity"
82
+ },
83
+ {
84
+ "contextName": "NEUTRAL",
85
+ "priority": 1,
86
+ "description": "Acknowledgment or price-focused only"
87
+ },
88
+ {
89
+ "contextName": "NEGATIVE",
90
+ "priority": 0,
91
+ "description": "Dismissive or disinterested"
92
+ }
93
+ ]
94
+ },
95
+ {
96
+ "metricId": "staff_responsiveness_001",
97
+ "metricName": "Staff Responsiveness",
98
+ "metricDescription": "How effectively were customer doubts addressed?",
99
+ "hasContext": true,
100
+ "isNumneric": false,
101
+ "contexts": [
102
+ {
103
+ "contextName": "FULLY_RESPONSIVE",
104
+ "priority": 2,
105
+ "description": "All doubts cleared with evidence"
106
+ },
107
+ {
108
+ "contextName": "PARTIALLY_RESPONSIVE",
109
+ "priority": 1,
110
+ "description": "Some doubts addressed, others ignored"
111
+ },
112
+ {
113
+ "contextName": "UNRESPONSIVE",
114
+ "priority": 0,
115
+ "description": "Customer doubts were dismissed"
116
+ }
117
+ ]
118
+ },
119
+ {
120
+ "metricId": "sales_outcome_001",
121
+ "metricName": "Final Sales Outcome",
122
+ "metricDescription": "The final commitment level reached at the end of the conversation",
123
+ "hasContext": true,
124
+ "isNumneric": false,
125
+ "contexts": [
126
+ {
127
+ "contextName": "BOUGHT_PHOTOCHROMATIC",
128
+ "priority": 2,
129
+ "description": "Customer agreed to the upgrade"
130
+ },
131
+ {
132
+ "contextName": "BOUGHT_SOMETHING_ELSE",
133
+ "priority": 0,
134
+ "description": "Bought standard lenses/frames only"
135
+ },
136
+ {
137
+ "contextName": "NO_SALE",
138
+ "priority": 0,
139
+ "description": "No purchase commitment"
140
+ }
141
+ ]
142
+ },
143
+ {
144
+ "metricId": "pitch_timing_summary_001",
145
+ "metricName": "Pitch Timing & Context",
146
+ "metricDescription": "Narrative summary of when and how the pitch was introduced",
147
+ "hasContext": false,
148
+ "isNumneric": false
149
+ }
150
+ ]
151
+ }'
152
+
153
+ # ==================== 2. GET COHORT BY ID ====================
154
+ print_section "2. GET COHORT BY ID"
155
+
156
+ curl -X GET "$BASE_URL/cohorts/$COHORT_ID" \
157
+ -H "Content-Type: application/json"
158
+
159
+ # ==================== 3. GET COHORTS BY CLIENT ====================
160
+ print_section "3. GET COHORTS BY CLIENT"
161
+
162
+ curl -X GET "$BASE_URL/cohorts/client/$CLIENT_ID?limit=10&offset=0" \
163
+ -H "Content-Type: application/json"
164
+
165
+ # ==================== 4. SEARCH COHORTS ====================
166
+ print_section "4. SEARCH COHORTS"
167
+
168
+ curl -X POST "$BASE_URL/cohorts/search" \
169
+ -H "Content-Type: application/json" \
170
+ -d '{
171
+ "clientId": "11",
172
+ "cohortName": "Photochrom",
173
+ "limit": 10,
174
+ "offset": 0
175
+ }'
176
+
177
+ # ==================== 5. UPDATE COHORT ====================
178
+ print_section "5. UPDATE COHORT"
179
+
180
+ # Note: Replace DOCUMENT_ID with actual ID returned from create
181
+ DOCUMENT_ID="550e8400-e29b-41d4-a716-446655440000"
182
+
183
+ curl -X PUT "$BASE_URL/cohorts/$DOCUMENT_ID" \
184
+ -H "Content-Type: application/json" \
185
+ -d '{
186
+ "cohortName": "Updated Photochromatic",
187
+ "cohortDescription": "Updated description for photochromatic cohort"
188
+ }'
189
+
190
+ # ==================== 6. GET COHORT ANALYTICS ====================
191
+ print_section "6. GET COHORT ANALYTICS"
192
+
193
+ curl -X GET "$BASE_URL/cohorts/$COHORT_ID/analytics" \
194
+ -H "Content-Type: application/json"
195
+
196
+ # ==================== 7. DELETE COHORT ====================
197
+ print_section "7. DELETE COHORT"
198
+
199
+ # Note: Replace DOCUMENT_ID with actual ID
200
+ curl -X DELETE "$BASE_URL/cohorts/$DOCUMENT_ID" \
201
+ -H "Content-Type: application/json"
202
+
203
+ # ==================== VALIDATION TESTS ====================
204
+ print_section "VALIDATION TESTS"
205
+
206
+ echo "Testing invalid cohort name (too short):"
207
+ curl -X POST "$BASE_URL/cohorts" \
208
+ -H "Content-Type: application/json" \
209
+ -d '{
210
+ "clientId": "11",
211
+ "cohortId": "invalid_test",
212
+ "cohortName": "AB",
213
+ "cohortDescription": "This should fail because name is too short"
214
+ }'
215
+
216
+ echo ""
217
+ echo "Testing missing required field:"
218
+ curl -X POST "$BASE_URL/cohorts" \
219
+ -H "Content-Type: application/json" \
220
+ -d '{
221
+ "clientId": "11",
222
+ "cohortId": "invalid_test",
223
+ "cohortName": "Valid Name"
224
+ }'
225
+
226
+ echo ""
227
+ echo "Testing invalid cohortId (special characters):"
228
+ curl -X POST "$BASE_URL/cohorts" \
229
+ -H "Content-Type: application/json" \
230
+ -d '{
231
+ "clientId": "11",
232
+ "cohortId": "invalid@test",
233
+ "cohortName": "Valid Name",
234
+ "cohortDescription": "This should fail because cohortId has invalid characters"
235
+ }'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-audio-analytics",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "description": "audioAnalytics",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -24,6 +24,7 @@
24
24
  "mongodb": "^6.21.0",
25
25
  "nodemon": "^3.1.14",
26
26
  "tango-api-schema": "^2.5.62",
27
+ "tango-app-api-audio-analytics": "^1.0.24",
27
28
  "tango-app-api-middleware": "^3.6.18",
28
29
  "winston": "^3.19.0",
29
30
  "winston-daily-rotate-file": "^5.0.0"
@@ -458,6 +458,7 @@ Only return the JSON array, no other text.`;
458
458
  const CHAT_STREAM_API = 'http://65.2.124.154:8000/api/chat/stream';
459
459
  const AUDIO_STREAM_API = 'http://65.2.124.154:8000/api/chat/audio';
460
460
  const EYE_TEST_STREAM_API = 'http://65.2.124.154:8000/api/chat/pet';
461
+ // const CONVERSATION_STREAM_API = 'http://65.2.124.154:8000/api/chat/audio';
461
462
 
462
463
 
463
464
  /**
@@ -562,7 +563,7 @@ export async function aiStreamResponse( req, res ) {
562
563
  };
563
564
  /* eslint-enable camelcase */
564
565
 
565
- const response = await fetch( analyticsType === 'audio'? AUDIO_STREAM_API: analyticsType === 'eyetest'? EYE_TEST_STREAM_API: CHAT_STREAM_API, {
566
+ const response = await fetch( analyticsType === 'audio'? AUDIO_STREAM_API:analyticsType === 'transcript'? AUDIO_STREAM_API: analyticsType === 'eyetest'? EYE_TEST_STREAM_API: CHAT_STREAM_API, {
566
567
  method: 'POST',
567
568
  headers: {
568
569
  'Content-Type': 'application/json',
@@ -571,6 +572,7 @@ export async function aiStreamResponse( req, res ) {
571
572
  },
572
573
  body: JSON.stringify( payload ),
573
574
  } );
575
+ logger.info( { message: 'Called external stream API', status: response } );
574
576
  if ( !response.ok ) {
575
577
  logger.error( response, `External Chat Stream API error: ${response.status} ${response.statusText}` );
576
578
  return res.sendError( `External API error: ${response.statusText}`, response.status );