@runnerpro/backend 1.13.13 → 1.13.14

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.
@@ -9,39 +9,37 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.sendPrompt = exports.getVertexChat = void 0;
13
- const vertexai_1 = require("@google-cloud/vertexai");
14
- const getVertexChat = () => {
15
- const vertexAI = new vertexai_1.VertexAI({ project: process.env.GCP_PROYECT_ID, location: 'us-central1' });
16
- const generativeModel = vertexAI.preview.getGenerativeModel({
17
- model: 'gemini-2.5-flash-preview-05-20',
18
- });
19
- return generativeModel.startChat({});
20
- };
21
- exports.getVertexChat = getVertexChat;
22
- const sendPrompt = (message) => __awaiter(void 0, void 0, void 0, function* () {
23
- var _a;
24
- try {
25
- const chat = getVertexChat();
26
- const result = yield chat.sendMessage(message);
27
- // Verificar que la respuesta tiene la estructura esperada
28
- if (!result.response.candidates || result.response.candidates.length === 0) {
29
- throw new Error('No se recibieron candidatos en la respuesta');
12
+ exports.sendPrompt = void 0;
13
+ const { VertexAI } = require('@google-cloud/vertexai');
14
+ // Inicializa el cliente de Vertex AI
15
+ const vertex_ai = new VertexAI({
16
+ project: 'glass-timing-393523', // Reemplaza con tu ID de proyecto de Google Cloud
17
+ location: 'us-central1', // Reemplaza con tu región
18
+ });
19
+ // Selecciona el modelo de Gemini
20
+ const model = 'gemini-2.5-flash-preview-05-20'; // O cualquier otro modelo de Gemini disponible
21
+ // Configura el modelo generativo
22
+ const generativeModel = vertex_ai.preview.getGenerativeModel({
23
+ model: model,
24
+ });
25
+ function sendPrompt(prompt) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ console.log(`Enviando prompt: "${prompt}"`);
28
+ try {
29
+ const resp = yield generativeModel.generateContent(prompt);
30
+ const content = resp.response.candidates[0].content;
31
+ // Asumiendo que la respuesta es de tipo texto
32
+ if (content.parts && content.parts.length > 0 && content.parts[0].text) {
33
+ console.log('Respuesta de Gemini:');
34
+ console.log(content.parts[0].text);
35
+ }
36
+ else {
37
+ console.log('No se recibió una respuesta de texto válida.');
38
+ }
30
39
  }
31
- const candidate = result.response.candidates[0];
32
- if (!candidate.content || !candidate.content.parts || candidate.content.parts.length === 0) {
33
- throw new Error('La respuesta no tiene contenido válido');
40
+ catch (error) {
41
+ console.error('Error al enviar el prompt:', error);
34
42
  }
35
- return ((_a = candidate.content.parts[0]) === null || _a === void 0 ? void 0 : _a.text) || '';
36
- }
37
- catch (error) {
38
- console.error('Error en sendPrompt:', error);
39
- console.error('Detalles del error:', {
40
- message: error.message,
41
- stack: error.stack,
42
- name: error.name,
43
- });
44
- throw error; // Re-lanzar el error para que puedas manejarlo donde llames a sendPrompt
45
- }
46
- });
43
+ });
44
+ }
47
45
  exports.sendPrompt = sendPrompt;
@@ -1,4 +1,3 @@
1
- declare const getVertexChat: () => import("@google-cloud/vertexai").ChatSessionPreview;
2
- declare const sendPrompt: (message: string) => Promise<string>;
3
- export { getVertexChat, sendPrompt };
1
+ declare function sendPrompt(prompt: any): Promise<void>;
2
+ export { sendPrompt };
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/index.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,aAAa,2DAQlB,CAAC;AAEF,QAAA,MAAM,UAAU,YAAmB,MAAM,KAAG,QAAQ,MAAM,CAyBzD,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/index.ts"],"names":[],"mappings":"AAgBA,iBAAe,UAAU,CAAC,MAAM,KAAA,iBAiB/B;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.13",
3
+ "version": "1.13.14",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"