@runnerpro/backend 1.13.32 → 1.13.34
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.
package/lib/cjs/prompt/index.js
CHANGED
|
@@ -17,10 +17,10 @@ function sendPrompt(prompt, options = {}) {
|
|
|
17
17
|
// Inicializa el cliente de Vertex AI
|
|
18
18
|
const vertex_ai = new VertexAI({
|
|
19
19
|
project: process.env.PROJECT_ID, // Reemplaza con tu ID de proyecto de Google Cloud
|
|
20
|
-
location: '
|
|
20
|
+
location: 'us-central1', // Mejor disponibilidad para modelos Gemini 2.5
|
|
21
21
|
});
|
|
22
22
|
// Selecciona el modelo de Gemini más rápido
|
|
23
|
-
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
|
|
24
24
|
// Configura el modelo generativo con parámetros optimizados para velocidad
|
|
25
25
|
const generativeModel = vertex_ai.preview.getGenerativeModel({
|
|
26
26
|
model: model,
|
|
@@ -30,31 +30,20 @@ function sendPrompt(prompt, options = {}) {
|
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
}
|
|
54
|
-
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) || '';
|
|
55
45
|
}
|
|
56
46
|
catch (error) {
|
|
57
|
-
console.error('Error al enviar el prompt:', error);
|
|
58
47
|
throw error;
|
|
59
48
|
}
|
|
60
49
|
});
|
|
@@ -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,
|
|
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"}
|