@runnerpro/backend 1.13.31 → 1.13.33

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.
@@ -416,7 +416,10 @@ const cambiarTonoEntrenadorNeutro = (text, idCliente) => __awaiter(void 0, void
416
416
  try {
417
417
  console.time('sendPrompt');
418
418
  // Prompt simplificado para testing
419
- const textCorregido = yield (0, prompt_1.sendPrompt)(`Corrige este texto: ${text}`);
419
+ const textCorregido = yield (0, prompt_1.sendPrompt)(`Corrige este texto: ${text}`, {
420
+ maxOutputTokens: 1500, // Suficiente para thoughtsTokenCount + respuesta real
421
+ timeout: 15000,
422
+ });
420
423
  console.log('textCorregido', textCorregido);
421
424
  console.timeEnd('sendPrompt');
422
425
  return textCorregido;
@@ -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({
@@ -19,59 +20,31 @@ function sendPrompt(prompt, options = {}) {
19
20
  location: 'europe-west8', // Reemplaza con tu región
20
21
  });
21
22
  // Selecciona el modelo de Gemini más rápido
22
- const model = 'gemini-2.5-flash'; // Flash es más rápido que Pro
23
+ const model = 'gemini-2.5-flash-lite-preview-06-17'; // Flash es más rápido que Pro
23
24
  // Configura el modelo generativo con parámetros optimizados para velocidad
24
25
  const generativeModel = vertex_ai.preview.getGenerativeModel({
25
26
  model: model,
26
27
  generationConfig: {
27
- maxOutputTokens: options.maxOutputTokens || 512,
28
28
  temperature: options.temperature || 0.3,
29
29
  topP: options.topP || 0.8,
30
30
  topK: options.topK || 20,
31
31
  },
32
32
  });
33
- console.log('prompt', prompt);
34
- console.log('generativeModel', generativeModel);
35
33
  try {
36
34
  const resp = yield generativeModel.generateContent(prompt);
37
- // Debug completo de la respuesta
38
- console.log('=== RESPUESTA COMPLETA ===');
39
- console.log('resp completo:', JSON.stringify(resp, null, 2));
40
- console.log('=== RESPONSE ===');
41
- console.log('resp.response:', JSON.stringify(resp.response, null, 2));
42
- console.log('=== CANDIDATES ===');
43
- console.log('candidates:', resp.response.candidates);
44
- if (resp.response.candidates && resp.response.candidates[0]) {
45
- console.log('=== PRIMER CANDIDATE ===');
46
- console.log('candidate[0]:', JSON.stringify(resp.response.candidates[0], null, 2));
47
- const content = resp.response.candidates[0].content;
48
- console.log('=== CONTENT ===');
49
- console.log('content:', JSON.stringify(content, null, 2));
50
- // Asumiendo que la respuesta es de tipo texto
51
- console.log('=== PARTS ===');
52
- console.log('content.parts:', content.parts);
53
- if (content.parts && content.parts.length > 0) {
54
- console.log('parts[0]:', JSON.stringify(content.parts[0], null, 2));
55
- if (content.parts[0].text) {
56
- console.log('text encontrado:', content.parts[0].text);
57
- return content.parts[0].text;
58
- }
59
- else {
60
- console.log('ERROR: parts[0].text es undefined');
61
- }
62
- }
63
- else {
64
- console.log('ERROR: content.parts está undefined o vacío');
65
- }
66
- }
67
- else {
68
- console.log('ERROR: No hay candidates en la respuesta');
69
- }
70
- return '';
35
+ // Early return si no hay candidates
36
+ const candidate = (_a = resp.response.candidates) === null || _a === void 0 ? void 0 : _a[0];
37
+ if (!candidate)
38
+ return '';
39
+ // Early return si no hay parts
40
+ const parts = (_b = candidate.content) === null || _b === void 0 ? void 0 : _b.parts;
41
+ if (!parts || parts.length === 0)
42
+ return '';
43
+ // Return del texto si existe
44
+ return ((_c = parts[0]) === null || _c === void 0 ? void 0 : _c.text) || '';
71
45
  }
72
46
  catch (error) {
73
- console.error('Error al enviar el prompt:', error);
74
- throw error; // Re-throw para que el código que llama pueda manejar el error
47
+ throw error;
75
48
  }
76
49
  });
77
50
  }
@@ -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;AAsbF,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,gBAqExE;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,gBAoCxE;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.31",
3
+ "version": "1.13.33",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"