@runnerpro/backend 1.13.0 → 1.13.2

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.
@@ -38,6 +38,7 @@ const saveResponseTime_1 = require("../saveResponseTime");
38
38
  const fluent_ffmpeg_1 = __importDefault(require("fluent-ffmpeg"));
39
39
  const ffmpeg_static_1 = __importDefault(require("ffmpeg-static"));
40
40
  const ffprobe_static_1 = __importDefault(require("ffprobe-static"));
41
+ const prompt_1 = require("../../prompt");
41
42
  fluent_ffmpeg_1.default.setFfmpegPath(ffmpeg_static_1.default);
42
43
  fluent_ffmpeg_1.default.setFfprobePath(ffprobe_static_1.default.path);
43
44
  const conversationRoute = (_a) => {
@@ -223,7 +224,7 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, isClient }
223
224
  // Si es entrenador, se marca leído cuando se envía un mensaje
224
225
  yield markReadMessage({ isClient, idCliente });
225
226
  // Cambiar el tono del texto a uno neutro y corregir la ortografía
226
- text = cambiarTonoEntrenadorNeutro(text);
227
+ text = yield cambiarTonoEntrenadorNeutro(text);
227
228
  }
228
229
  // Devuelve el texto en el otro idioma si el cliente no habla español y el idioma del cliente
229
230
  const { textSpanish, textPreferredLanguage, preferredLanguage } = yield getPreferredLanguageForChat({
@@ -399,9 +400,15 @@ const markReadMessage = ({ isClient, idCliente }) => __awaiter(void 0, void 0, v
399
400
  if (!isClient)
400
401
  yield (0, saveResponseTime_1.saveResponseTime)(idCliente);
401
402
  });
402
- const cambiarTonoEntrenadorNeutro = (text) => {
403
- return text;
404
- };
403
+ const cambiarTonoEntrenadorNeutro = (text) => __awaiter(void 0, void 0, void 0, function* () {
404
+ const textCorregido = yield (0, prompt_1.sendPrompt)(`
405
+ Eres un asistente de IA que cambia el tono de los mensajes de un entrenador a uno neutro y corrige la ortografía.
406
+ El mensaje es: ${text}
407
+ El mensaje corregido es:
408
+ `);
409
+ console.log('textCorregido', textCorregido);
410
+ return textCorregido;
411
+ });
405
412
  const resizeImage = (data, filePath, mimetype) => __awaiter(void 0, void 0, void 0, function* () {
406
413
  if (mimetype.includes('webp'))
407
414
  return data;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
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',
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, _b;
24
+ const chat = getVertexChat();
25
+ const result = yield chat.sendMessage(message);
26
+ return ((_b = (_a = result.response.candidates[0].content) === null || _a === void 0 ? void 0 : _a.parts[0]) === null || _b === void 0 ? void 0 : _b.text) || '';
27
+ });
28
+ exports.sendPrompt = sendPrompt;
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAuBpD,CAAC;AAgaF,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;AAsaF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ declare const getVertexChat: () => import("@google-cloud/vertexai").ChatSessionPreview;
2
+ declare const sendPrompt: (message: any) => Promise<string>;
3
+ export { getVertexChat, sendPrompt };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,mCAIf,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.13.0",
3
+ "version": "1.13.2",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"