@runnerpro/backend 1.13.36 → 1.13.38
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.
|
@@ -220,31 +220,25 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, isClient }
|
|
|
220
220
|
const idCliente = isClient ? req.session.userid : req.body.idCliente;
|
|
221
221
|
let idWorkout, type = 1;
|
|
222
222
|
if (!isClient) {
|
|
223
|
-
console.time('promise all 1');
|
|
224
223
|
[text] = yield Promise.all([
|
|
225
224
|
// Cambiar el tono del texto a uno neutro y corregir la ortografía
|
|
226
225
|
cambiarTonoEntrenadorNeutro(text, idCliente),
|
|
227
226
|
// Si es entrenador, se marca leído cuando se envía un mensaje
|
|
228
227
|
getPreferredLanguageForChat({ text, idCliente, isClient }),
|
|
229
228
|
]);
|
|
230
|
-
console.timeEnd('promise all 1');
|
|
231
229
|
}
|
|
232
230
|
// Devuelve el texto en el otro idioma si el cliente no habla español y el idioma del cliente
|
|
233
|
-
console.time('getPreferredLanguageForChat');
|
|
234
231
|
const { textSpanish, textPreferredLanguage, preferredLanguage } = yield getPreferredLanguageForChat({
|
|
235
232
|
text,
|
|
236
233
|
idCliente,
|
|
237
234
|
isClient,
|
|
238
235
|
});
|
|
239
|
-
console.timeEnd('getPreferredLanguageForChat');
|
|
240
236
|
// Enviado cuando es un mensaje de comentario sobre intelligence
|
|
241
237
|
if (newMessage) {
|
|
242
238
|
type = 6;
|
|
243
239
|
idWorkout = newMessage.idWorkout;
|
|
244
240
|
}
|
|
245
|
-
console.time('query');
|
|
246
241
|
const [message] = yield (0, index_1.query)('INSERT INTO [CHAT MESSAGE] ([ID CLIENTE], [ID SENDER], [TEXT], [TEXT PREFERRED LANGUAGE], [PREFERRED LANGUAGE], [REPLY MESSAGE ID], [ID WORKOUT], [TYPE]) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING [ID]', [isClient ? userid : idCliente, userid, textSpanish, textPreferredLanguage, preferredLanguage, replyMessageId, idWorkout, type]);
|
|
247
|
-
console.timeEnd('query');
|
|
248
242
|
res.send({ idMessage: message.id, text: textSpanish });
|
|
249
243
|
if (!isClient) {
|
|
250
244
|
sendNotification({
|
|
@@ -414,34 +408,32 @@ const cambiarTonoEntrenadorNeutro = (text, idCliente) => __awaiter(void 0, void
|
|
|
414
408
|
if (idCliente !== 'sJzhGqaJcddq96x80hZAlPJ6pET2')
|
|
415
409
|
return text;
|
|
416
410
|
try {
|
|
417
|
-
console.time('sendPrompt');
|
|
418
411
|
const textCorregido = yield (0, prompt_1.sendPrompt)(`
|
|
419
412
|
Actúa como un sistema automático de corrección y estandarización de texto para una aplicación de fitness. Tu única función es procesar un mensaje y devolver una única versión mejorada.
|
|
420
413
|
|
|
421
414
|
Sigue estas reglas estrictamente:
|
|
422
415
|
1. Corrige todos los errores ortográficos y gramaticales.
|
|
423
|
-
2. Ajusta el tono para que sea
|
|
424
|
-
3. NO
|
|
425
|
-
4. NO
|
|
426
|
-
5.
|
|
416
|
+
2. Ajusta el tono para que sea cercano y amable, pero manteniendo siempre un lenguaje profesional. No debe sonar ni robótico ni demasiado coloquial.
|
|
417
|
+
3. NO añadas información, ideas o frases que no estuvieran implícitas en el mensaje original. Tu trabajo es reformular, no añadir contenido.
|
|
418
|
+
4. NO ofrezcas múltiples opciones.
|
|
419
|
+
5. NO incluyas explicaciones, comentarios ni viñetas.
|
|
427
420
|
6. NO uses caracteres especiales para dar estilo al texto (como * para negrita/cursiva o _). El resultado debe ser siempre texto plano.
|
|
421
|
+
7. Tu respuesta DEBE ser únicamente el texto final corregido.
|
|
428
422
|
|
|
429
423
|
---
|
|
430
424
|
**EJEMPLO 1**
|
|
431
425
|
**Texto Original:** "hey, mñn no te olvides d entrenar el hombro, no agas el vago q te veo. Y bebe awua"
|
|
432
|
-
**Texto Corregido:** "Hola
|
|
426
|
+
**Texto Corregido:** "¡Hola! Para mañana, recuerda entrenar hombro. Mantén la intensidad y no olvides hidratarte."
|
|
433
427
|
---
|
|
434
428
|
**EJEMPLO 2**
|
|
435
|
-
**Texto Original:** "
|
|
436
|
-
**Texto Corregido:** "Hola,
|
|
429
|
+
**Texto Original:** "Llegas tarde ala sesion de oy"
|
|
430
|
+
**Texto Corregido:** "Hola, te escribo sobre la sesión de hoy. Avísame si va todo bien."
|
|
437
431
|
---
|
|
438
432
|
|
|
439
433
|
**TAREA ACTUAL**
|
|
440
434
|
**Texto Original:** ${text}
|
|
441
435
|
**Texto Corregido:**
|
|
442
436
|
`);
|
|
443
|
-
console.log('textCorregido', textCorregido);
|
|
444
|
-
console.timeEnd('sendPrompt');
|
|
445
437
|
return textCorregido;
|
|
446
438
|
}
|
|
447
439
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAmBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAuBpD,CAAC;
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAmBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAuBpD,CAAC;AAkcF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|