@runnerpro/backend 1.15.6 → 1.16.0

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.
@@ -292,8 +292,18 @@ const updateSenderView = ({ userid, idCliente, idMessage }) => __awaiter(void 0,
292
292
  let idSenderView;
293
293
  if (cliente.idEntrenadorPrincipal === userid)
294
294
  idSenderView = cliente.idEntrenadorPrincipal;
295
- else
296
- idSenderView = Math.random() < 0.4 ? cliente.idEntrenadorPrincipal : cliente.idEntrenadorSecundario; // 40% entrenador principal o 60% entrenador secundario
295
+ else {
296
+ const [prevMessage] = yield (0, index_1.query)('SELECT [ID SENDER VIEW], [ID SENDER], [ID CLIENTE] FROM [CHAT MESSAGE] WHERE [ID] != ? AND [ID CLIENTE] = ? ORDER BY [ID] DESC LIMIT 1', [idMessage, idCliente]);
297
+ // Si el mensaje anterior es del cliente o no tiene idSenderView, se elige un entrenador al azar
298
+ if (prevMessage.idSender === prevMessage.idCliente || !prevMessage.idSenderView) {
299
+ // 40% entrenador principal o 60% entrenador secundario;
300
+ idSenderView = Math.random() < 0.4 ? cliente.idEntrenadorPrincipal : cliente.idEntrenadorSecundario;
301
+ }
302
+ else {
303
+ // Si el mensaje anterior es del entrenador, se pone el mismo entrenador que el mensaje anterior
304
+ idSenderView = prevMessage.idSenderView;
305
+ }
306
+ }
297
307
  yield (0, index_1.query)('UPDATE [CHAT MESSAGE] SET [ID SENDER VIEW] = ? WHERE [ID] = ?', [idSenderView, idMessage]);
298
308
  });
299
309
  exports.updateSenderView = updateSenderView;
@@ -315,7 +325,7 @@ const sendEmoji = (req, res, { sendNotification, firebaseMessaging, isClient })
315
325
  sendNotification({
316
326
  firebaseMessaging,
317
327
  idCliente,
318
- body: `Rubén ha reaccionado a un mensaje '${emoji}'`,
328
+ body: `El entrenador ha reaccionado a un mensaje '${emoji}'`,
319
329
  screen: common_1.NOTIFICATION_SCREEN_TYPES.CHAT,
320
330
  });
321
331
  }
@@ -512,7 +522,7 @@ Sigue estas reglas estrictamente:
512
522
  **TAREA ACTUAL**
513
523
  **Texto Original:** ${text}
514
524
  **Texto Corregido:**
515
- `);
525
+ `, 'LITE');
516
526
  textCorregido = textCorregido.replace(/[¡¿]/g, '');
517
527
  // Eliminar el último punto de las frases
518
528
  textCorregido = textCorregido.trim().replace(/\.$/, '');
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.sendPrompt = void 0;
13
13
  const vertexai_1 = require("@google-cloud/vertexai");
14
- function sendPrompt(prompt) {
14
+ function sendPrompt(prompt, model = 'FLASH') {
15
15
  var _a, _b, _c;
16
16
  return __awaiter(this, void 0, void 0, function* () {
17
17
  // Inicializa el cliente de Vertex AI
@@ -20,10 +20,16 @@ function sendPrompt(prompt) {
20
20
  location: 'europe-west8', // Reemplaza con tu región
21
21
  });
22
22
  // Selecciona el modelo de Gemini más rápido
23
- const model = 'gemini-2.0-flash-lite';
23
+ let modelGemini;
24
+ if (model === 'LITE')
25
+ modelGemini = 'gemini-2.5-flash-lite';
26
+ else if (model === 'FLASH')
27
+ modelGemini = 'gemini-2.5-flash';
28
+ else if (model === 'PRO')
29
+ modelGemini = 'gemini-2.5-pro';
24
30
  // Configura el modelo generativo con parámetros optimizados para velocidad
25
31
  const generativeModel = vertex_ai.preview.getGenerativeModel({
26
- model: model,
32
+ model: modelGemini,
27
33
  generationConfig: {
28
34
  temperature: 0.3,
29
35
  topP: 0.8,
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SA0BpD,CAAC;AA6PF,QAAA,MAAM,gBAAgB;;;;mBAQrB,CAAC;AAsRF,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SA0BpD,CAAC;AA6PF,QAAA,MAAM,gBAAgB;;;;mBAkBrB,CAAC;AAsRF,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,CAAC"}
@@ -1,3 +1,3 @@
1
- declare function sendPrompt(prompt: string): Promise<string>;
1
+ declare function sendPrompt(prompt: string, model?: string): Promise<string>;
2
2
  export { sendPrompt };
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/index.ts"],"names":[],"mappings":"AAEA,iBAAe,UAAU,CAAC,MAAM,EAAE,MAAM,mBAgCvC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/index.ts"],"names":[],"mappings":"AAEA,iBAAe,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,MAAgB,mBAsChE;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.15.6",
3
+ "version": "1.16.0",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"