@runnerpro/backend 1.13.30 → 1.13.32

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.
@@ -415,20 +415,17 @@ const cambiarTonoEntrenadorNeutro = (text, idCliente) => __awaiter(void 0, void
415
415
  return text;
416
416
  try {
417
417
  console.time('sendPrompt');
418
- const textCorregido = yield (0, prompt_1.sendPrompt)(`
419
- Actúa como un asistente de comunicación para entrenadores. Tu objetivo es revisar el siguiente mensaje de un entrenador a un cliente. Debes corregir cualquier falta de ortografía y reescribir el texto para que tenga un tono profesional y constructivo.
420
-
421
- * MENSAJE ORIGINAL INICIO *
422
- ${text}
423
- * MENSAJE ORIGINAL FIN *
424
-
425
- Devuelve solo el texto corregido y reescrito, sin añadir explicaciones.
426
- `);
418
+ // Prompt simplificado para testing
419
+ const textCorregido = yield (0, prompt_1.sendPrompt)(`Corrige este texto: ${text}`, {
420
+ maxOutputTokens: 1500, // Suficiente para thoughtsTokenCount + respuesta real
421
+ timeout: 15000,
422
+ });
427
423
  console.log('textCorregido', textCorregido);
428
424
  console.timeEnd('sendPrompt');
429
425
  return textCorregido;
430
426
  }
431
427
  catch (error) {
428
+ console.error('Error completo:', error);
432
429
  return text;
433
430
  }
434
431
  });
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.sendPrompt = void 0;
13
13
  const { VertexAI } = require('@google-cloud/vertexai');
14
14
  function sendPrompt(prompt, options = {}) {
15
+ var _a, _b, _c;
15
16
  return __awaiter(this, void 0, void 0, function* () {
16
17
  // Inicializa el cliente de Vertex AI
17
18
  const vertex_ai = new VertexAI({
@@ -24,8 +25,7 @@ function sendPrompt(prompt, options = {}) {
24
25
  const generativeModel = vertex_ai.preview.getGenerativeModel({
25
26
  model: model,
26
27
  generationConfig: {
27
- maxOutputTokens: options.maxOutputTokens || 512, // Limitar tokens para respuestas más rápidas
28
- temperature: options.temperature || 0.3, // Menor temperatura = más determinístico y rápido
28
+ temperature: options.temperature || 0.3,
29
29
  topP: options.topP || 0.8,
30
30
  topK: options.topK || 20,
31
31
  },
@@ -34,17 +34,28 @@ function sendPrompt(prompt, options = {}) {
34
34
  console.log('generativeModel', generativeModel);
35
35
  try {
36
36
  const resp = yield generativeModel.generateContent(prompt);
37
- console.log('resp', resp.response.candidates[0].content);
38
- const content = resp.response.candidates[0].content;
39
- // Asumiendo que la respuesta es de tipo texto
40
- console.log('content', content.parts);
41
- if (content.parts && content.parts.length > 0 && content.parts[0].text)
42
- return content.parts[0].text;
37
+ console.log('finishReason:', (_a = resp.response.candidates[0]) === null || _a === void 0 ? void 0 : _a.finishReason);
38
+ console.log('thoughtsTokenCount:', (_b = resp.response.usageMetadata) === null || _b === void 0 ? void 0 : _b.thoughtsTokenCount);
39
+ console.log('totalTokenCount:', (_c = resp.response.usageMetadata) === null || _c === void 0 ? void 0 : _c.totalTokenCount);
40
+ if (resp.response.candidates && resp.response.candidates[0]) {
41
+ const content = resp.response.candidates[0].content;
42
+ if (content.parts && content.parts.length > 0 && content.parts[0].text) {
43
+ console.log('✅ Texto generado exitosamente');
44
+ return content.parts[0].text;
45
+ }
46
+ else {
47
+ console.log('❌ Error: No hay texto en content.parts');
48
+ console.log('content.parts:', content.parts);
49
+ }
50
+ }
51
+ else {
52
+ console.log('❌ Error: No hay candidates en la respuesta');
53
+ }
43
54
  return '';
44
55
  }
45
56
  catch (error) {
46
57
  console.error('Error al enviar el prompt:', error);
47
- throw error; // Re-throw para que el código que llama pueda manejar el error
58
+ throw error;
48
59
  }
49
60
  });
50
61
  }
@@ -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;AA0bF,OAAO,EAAE,iBAAiB,EAAE,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;AAybF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/index.ts"],"names":[],"mappings":"AAEA,UAAU,iBAAiB;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,iBAAe,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,gBAsCxE;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/index.ts"],"names":[],"mappings":"AAEA,UAAU,iBAAiB;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,iBAAe,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,gBAiDxE;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.13.30",
3
+ "version": "1.13.32",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"