@runnerpro/backend 1.13.31 → 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.
@@ -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({
@@ -24,7 +25,6 @@ function sendPrompt(prompt, options = {}) {
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,
@@ -34,44 +34,28 @@ function sendPrompt(prompt, options = {}) {
34
34
  console.log('generativeModel', generativeModel);
35
35
  try {
36
36
  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);
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);
44
40
  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
41
  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
- }
42
+ if (content.parts && content.parts.length > 0 && content.parts[0].text) {
43
+ console.log(' Texto generado exitosamente');
44
+ return content.parts[0].text;
62
45
  }
63
46
  else {
64
- console.log('ERROR: content.parts está undefined o vacío');
47
+ console.log('❌ Error: No hay texto en content.parts');
48
+ console.log('content.parts:', content.parts);
65
49
  }
66
50
  }
67
51
  else {
68
- console.log('ERROR: No hay candidates en la respuesta');
52
+ console.log('❌ Error: No hay candidates en la respuesta');
69
53
  }
70
54
  return '';
71
55
  }
72
56
  catch (error) {
73
57
  console.error('Error al enviar el prompt:', error);
74
- throw error; // Re-throw para que el código que llama pueda manejar el error
58
+ throw error;
75
59
  }
76
60
  });
77
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;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,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.31",
3
+ "version": "1.13.32",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"