@runnerpro/backend 1.13.38 → 1.13.40
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.
|
@@ -222,7 +222,7 @@ const sendMessage = (req, res, { sendNotification, firebaseMessaging, isClient }
|
|
|
222
222
|
if (!isClient) {
|
|
223
223
|
[text] = yield Promise.all([
|
|
224
224
|
// Cambiar el tono del texto a uno neutro y corregir la ortografía
|
|
225
|
-
cambiarTonoEntrenadorNeutro(text
|
|
225
|
+
cambiarTonoEntrenadorNeutro(text),
|
|
226
226
|
// Si es entrenador, se marca leído cuando se envía un mensaje
|
|
227
227
|
getPreferredLanguageForChat({ text, idCliente, isClient }),
|
|
228
228
|
]);
|
|
@@ -404,9 +404,7 @@ const markReadMessage = ({ isClient, idCliente }) => __awaiter(void 0, void 0, v
|
|
|
404
404
|
if (!isClient)
|
|
405
405
|
yield (0, saveResponseTime_1.saveResponseTime)(idCliente);
|
|
406
406
|
});
|
|
407
|
-
const cambiarTonoEntrenadorNeutro = (text
|
|
408
|
-
if (idCliente !== 'sJzhGqaJcddq96x80hZAlPJ6pET2')
|
|
409
|
-
return text;
|
|
407
|
+
const cambiarTonoEntrenadorNeutro = (text) => __awaiter(void 0, void 0, void 0, function* () {
|
|
410
408
|
try {
|
|
411
409
|
const textCorregido = yield (0, prompt_1.sendPrompt)(`
|
|
412
410
|
Actúa como un sistema automático de corrección y estandarización de texto para una aplicación de fitness. Tu única función es procesar un mensaje y devolver una única versión mejorada.
|
package/lib/cjs/prompt/index.js
CHANGED
|
@@ -10,12 +10,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.sendPrompt = void 0;
|
|
13
|
-
const
|
|
13
|
+
const vertexai_1 = require("@google-cloud/vertexai");
|
|
14
14
|
function sendPrompt(prompt) {
|
|
15
15
|
var _a, _b, _c;
|
|
16
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
// Inicializa el cliente de Vertex AI
|
|
18
|
-
const vertex_ai = new VertexAI({
|
|
18
|
+
const vertex_ai = new vertexai_1.VertexAI({
|
|
19
19
|
project: process.env.PROJECT_ID, // Reemplaza con tu ID de proyecto de Google Cloud
|
|
20
20
|
location: 'europe-west8', // Reemplaza con tu región
|
|
21
21
|
});
|
|
@@ -30,22 +30,17 @@ function sendPrompt(prompt) {
|
|
|
30
30
|
topK: 20,
|
|
31
31
|
},
|
|
32
32
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return ((_c = parts[0]) === null || _c === void 0 ? void 0 : _c.text) || '';
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
throw error;
|
|
48
|
-
}
|
|
33
|
+
const resp = yield generativeModel.generateContent(prompt);
|
|
34
|
+
// Early return si no hay candidates
|
|
35
|
+
const candidate = (_a = resp.response.candidates) === null || _a === void 0 ? void 0 : _a[0];
|
|
36
|
+
if (!candidate)
|
|
37
|
+
return '';
|
|
38
|
+
// Early return si no hay parts
|
|
39
|
+
const parts = (_b = candidate.content) === null || _b === void 0 ? void 0 : _b.parts;
|
|
40
|
+
if (!parts || parts.length === 0)
|
|
41
|
+
return '';
|
|
42
|
+
// Return del texto si existe
|
|
43
|
+
return ((_c = parts[0]) === null || _c === void 0 ? void 0 : _c.text) || '';
|
|
49
44
|
});
|
|
50
45
|
}
|
|
51
46
|
exports.sendPrompt = sendPrompt;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAkBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAuBpD,CAAC;AAgcF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/index.ts"],"names":[],"mappings":"AAEA,iBAAe,UAAU,CAAC,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/index.ts"],"names":[],"mappings":"AAEA,iBAAe,UAAU,CAAC,MAAM,EAAE,MAAM,mBAgCvC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|