@runnerpro/backend 1.18.6 → 1.19.1
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/chat/api/conversation.js +6 -4
- package/lib/cjs/index.js +3 -2
- package/lib/cjs/mediaProcessing/index.js +13 -5
- package/lib/cjs/prompt/index.js +64 -93
- package/lib/cjs/types/chat/api/conversation.d.ts.map +1 -1
- package/lib/cjs/types/index.d.ts +2 -2
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/cjs/types/mediaProcessing/index.d.ts +1 -1
- package/lib/cjs/types/mediaProcessing/index.d.ts.map +1 -1
- package/lib/cjs/types/prompt/index.d.ts +42 -32
- package/lib/cjs/types/prompt/index.d.ts.map +1 -1
- package/package.json +3 -2
|
@@ -592,7 +592,9 @@ const markReadMessage = ({ isClient, idCliente }) => __awaiter(void 0, void 0, v
|
|
|
592
592
|
*/
|
|
593
593
|
const corregirOrtografia = (text) => __awaiter(void 0, void 0, void 0, function* () {
|
|
594
594
|
try {
|
|
595
|
-
let textCorregido = yield (0, prompt_1.
|
|
595
|
+
let { text: textCorregido } = yield (0, prompt_1.generateText)({
|
|
596
|
+
model: (0, prompt_1.createGoogleModel)('LITE'),
|
|
597
|
+
system: `Actúa como un corrector de estilo nativo de España (castellano).
|
|
596
598
|
Instrucciones estrictas:
|
|
597
599
|
- Vocabulario: Sustituye términos latinos por sus equivalentes en España (ej: celular -> móvil, computadora -> ordenador, video -> vídeo, costo -> coste, chequear -> comprobar, entreno -> entrenamiento).
|
|
598
600
|
- Ortografía: Corrige cualquier falta ortográfica o de acentuación.
|
|
@@ -600,9 +602,9 @@ Instrucciones estrictas:
|
|
|
600
602
|
- Formato: Entrega texto plano y limpio. NO uses asteriscos (*), negritas, ni símbolos de Markdown. Solo texto y emojis.
|
|
601
603
|
- Tono: Mantén la energía y la intención del entrenador, pero asegúrate de que suene 100% nativo de España.
|
|
602
604
|
|
|
603
|
-
Devuelve SOLO el texto corregido final
|
|
604
|
-
|
|
605
|
-
|
|
605
|
+
Devuelve SOLO el texto corregido final.`,
|
|
606
|
+
prompt: text,
|
|
607
|
+
});
|
|
606
608
|
textCorregido = textCorregido.replace(/[¡¿]/g, '');
|
|
607
609
|
textCorregido = textCorregido.trim().replace(/\.$/, '');
|
|
608
610
|
return textCorregido;
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.reprocessRecentMedia = exports.processMediaFile = exports.describeImage = exports.transcribeAudio = exports.updateSenderView = exports.
|
|
3
|
+
exports.reprocessRecentMedia = exports.processMediaFile = exports.describeImage = exports.transcribeAudio = exports.updateSenderView = exports.createGoogleModel = exports.generateText = exports.saveResponseTime = exports.getPlanificacionPrueba7dias = exports.sendWorkoutToWatch = exports.getDefaultWorkoutImage = exports.generateShareMap = exports.reduceSizeImage = exports.getLetter = exports.getNumberByLetter = exports.appendSheet = exports.writeSheet = exports.findCellByValue = exports.readSheet = exports.NOTION_DATABASES_ID = exports.notionEditPage = exports.notionAddPage = exports.notionGetDatabase = exports.notionGetUsers = exports.getCountNotificaciones = exports.chatExposed = exports.chatApi = exports.chat = exports.getExerciseTranslatedDescription = exports.useTranslation = exports.LANGUAGES = exports.translate = exports.CHANNEL_SLACK = exports.notifySlack = exports.fetchIA = exports.err = exports.sendMail = exports.pool = exports.toPgArray = exports.batchQuery = exports.longRunningQuery = exports.queryWithClient = exports.query = exports.sleep = exports.sendNotification = void 0;
|
|
4
4
|
const sendNotification_1 = require("./sendNotification");
|
|
5
5
|
Object.defineProperty(exports, "sendNotification", { enumerable: true, get: function () { return sendNotification_1.sendNotification; } });
|
|
6
6
|
const sleep_1 = require("./sleep");
|
|
@@ -57,7 +57,8 @@ Object.defineProperty(exports, "getPlanificacionPrueba7dias", { enumerable: true
|
|
|
57
57
|
const saveResponseTime_1 = require("./chat/saveResponseTime");
|
|
58
58
|
Object.defineProperty(exports, "saveResponseTime", { enumerable: true, get: function () { return saveResponseTime_1.saveResponseTime; } });
|
|
59
59
|
const prompt_1 = require("./prompt");
|
|
60
|
-
Object.defineProperty(exports, "
|
|
60
|
+
Object.defineProperty(exports, "generateText", { enumerable: true, get: function () { return prompt_1.generateText; } });
|
|
61
|
+
Object.defineProperty(exports, "createGoogleModel", { enumerable: true, get: function () { return prompt_1.createGoogleModel; } });
|
|
61
62
|
const conversation_1 = require("./chat/api/conversation");
|
|
62
63
|
Object.defineProperty(exports, "updateSenderView", { enumerable: true, get: function () { return conversation_1.updateSenderView; } });
|
|
63
64
|
const mediaProcessing_1 = require("./mediaProcessing");
|
|
@@ -86,7 +86,7 @@ const transcribeAudio = (fileBuffer, mimetype) => __awaiter(void 0, void 0, void
|
|
|
86
86
|
});
|
|
87
87
|
exports.transcribeAudio = transcribeAudio;
|
|
88
88
|
/**
|
|
89
|
-
* Genera una descripción de una imagen usando Gemini (
|
|
89
|
+
* Genera una descripción de una imagen usando Gemini (Vercel AI SDK)
|
|
90
90
|
* Contextualizada para una aplicación de fitness/entrenamiento
|
|
91
91
|
*
|
|
92
92
|
* @param fileBuffer - Buffer del archivo de imagen
|
|
@@ -101,11 +101,19 @@ exports.transcribeAudio = transcribeAudio;
|
|
|
101
101
|
*/
|
|
102
102
|
const describeImage = (fileBuffer, mimetype) => __awaiter(void 0, void 0, void 0, function* () {
|
|
103
103
|
try {
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
const { text } = yield (0, index_1.generateText)({
|
|
105
|
+
model: (0, index_1.createGoogleModel)('PRO'),
|
|
106
|
+
messages: [
|
|
107
|
+
{
|
|
108
|
+
role: 'user',
|
|
109
|
+
content: [
|
|
110
|
+
{ type: 'file', data: fileBuffer, mediaType: mimetype },
|
|
111
|
+
{ type: 'text', text: IMAGE_DESCRIPTION_PROMPT },
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
],
|
|
107
115
|
});
|
|
108
|
-
return
|
|
116
|
+
return text || '[Imagen no analizable]';
|
|
109
117
|
}
|
|
110
118
|
catch (error) {
|
|
111
119
|
// eslint-disable-next-line no-console
|
package/lib/cjs/prompt/index.js
CHANGED
|
@@ -9,110 +9,81 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
13
|
-
const
|
|
12
|
+
exports.createGoogleModel = exports.generateText = void 0;
|
|
13
|
+
const ai_1 = require("ai");
|
|
14
|
+
const google_1 = require("@ai-sdk/google");
|
|
15
|
+
const AI_MODELS = {
|
|
16
|
+
LITE: 'gemini-3.1-flash-lite-preview',
|
|
17
|
+
FLASH: 'gemini-3-flash-preview',
|
|
18
|
+
PRO: 'gemini-3.1-pro-preview',
|
|
19
|
+
};
|
|
20
|
+
const MAX_RETRIES = 1;
|
|
21
|
+
/**
|
|
22
|
+
* Crea una instancia del modelo de Google Gemini con la API key configurada
|
|
23
|
+
*
|
|
24
|
+
* @param modelKey - Clave del modelo: 'LITE' (rápido/barato), 'FLASH' (equilibrado), 'PRO' (potente)
|
|
25
|
+
* @returns Instancia del modelo configurado para usar con generateText
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const model = createGoogleModel('LITE');
|
|
30
|
+
* const { text } = await generateText({ model, prompt: 'Hola' });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
function createGoogleModel(modelKey = 'FLASH') {
|
|
34
|
+
return (0, google_1.google)(AI_MODELS[modelKey]);
|
|
35
|
+
}
|
|
36
|
+
exports.createGoogleModel = createGoogleModel;
|
|
14
37
|
/**
|
|
15
|
-
*
|
|
16
|
-
* Soporta contenido multimodal (
|
|
38
|
+
* Wrapper de generateText del Vercel AI SDK con retry automático (1 reintento)
|
|
39
|
+
* Soporta texto simple, system prompt y contenido multimodal (imágenes, audio)
|
|
17
40
|
*
|
|
18
|
-
* @param
|
|
19
|
-
* @
|
|
20
|
-
* @param systemPrompt - Instrucciones de sistema opcionales
|
|
21
|
-
* @param media - Contenido multimedia opcional (audio o imagen)
|
|
22
|
-
* @returns Promise<string> - Respuesta generada por la IA
|
|
41
|
+
* @param options - Opciones del Vercel AI SDK: model, system, prompt, messages, temperature, etc.
|
|
42
|
+
* @returns Promise<{ text: string }> - Texto generado por la IA
|
|
23
43
|
*
|
|
24
44
|
* @example
|
|
25
45
|
* ```typescript
|
|
26
46
|
* // Solo texto
|
|
27
|
-
* const
|
|
47
|
+
* const { text } = await generateText({
|
|
48
|
+
* model: createGoogleModel('LITE'),
|
|
49
|
+
* prompt: 'Traduce al inglés: Hola mundo',
|
|
50
|
+
* });
|
|
28
51
|
*
|
|
29
|
-
* // Con
|
|
30
|
-
* const
|
|
31
|
-
*
|
|
32
|
-
* '
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* );
|
|
52
|
+
* // Con system prompt
|
|
53
|
+
* const { text } = await generateText({
|
|
54
|
+
* model: createGoogleModel('FLASH'),
|
|
55
|
+
* system: 'Eres un corrector ortográfico',
|
|
56
|
+
* prompt: 'ola como estas',
|
|
57
|
+
* });
|
|
36
58
|
*
|
|
37
|
-
* //
|
|
38
|
-
* const
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
59
|
+
* // Multimodal (imagen)
|
|
60
|
+
* const { text } = await generateText({
|
|
61
|
+
* model: createGoogleModel('PRO'),
|
|
62
|
+
* messages: [{
|
|
63
|
+
* role: 'user',
|
|
64
|
+
* content: [
|
|
65
|
+
* { type: 'file', data: imageBuffer, mimeType: 'image/jpeg' },
|
|
66
|
+
* { type: 'text', text: 'Describe esta imagen' },
|
|
67
|
+
* ],
|
|
68
|
+
* }],
|
|
69
|
+
* });
|
|
44
70
|
* ```
|
|
45
71
|
*/
|
|
46
|
-
function
|
|
47
|
-
var _a, _b, _c, _d;
|
|
72
|
+
function generateText(options) {
|
|
48
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
modelGemini = 'gemini-2.5-pro'; // Modelo más potente y estable
|
|
60
|
-
else
|
|
61
|
-
modelGemini = 'gemini-2.5-flash';
|
|
62
|
-
// Configura el modelo generativo
|
|
63
|
-
const generativeModel = vertex_ai.preview.getGenerativeModel({
|
|
64
|
-
model: modelGemini,
|
|
65
|
-
generationConfig: {
|
|
66
|
-
temperature: media ? 0.1 : 0.3, // Menor temperatura para transcripciones
|
|
67
|
-
topP: 0.8,
|
|
68
|
-
topK: 20,
|
|
69
|
-
},
|
|
70
|
-
systemInstruction: systemPrompt
|
|
71
|
-
? {
|
|
72
|
-
role: 'system',
|
|
73
|
-
parts: [{ text: systemPrompt }],
|
|
74
|
-
}
|
|
75
|
-
: undefined,
|
|
76
|
-
});
|
|
77
|
-
// ✅ Construir contenido según si hay media o no
|
|
78
|
-
let content;
|
|
79
|
-
if (media) {
|
|
80
|
-
// Contenido multimodal (audio/imagen + texto)
|
|
81
|
-
content = {
|
|
82
|
-
contents: [
|
|
83
|
-
{
|
|
84
|
-
role: 'user',
|
|
85
|
-
parts: [
|
|
86
|
-
{
|
|
87
|
-
inlineData: {
|
|
88
|
-
mimeType: media.mimetype,
|
|
89
|
-
data: media.buffer.toString('base64'),
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
text: prompt,
|
|
94
|
-
},
|
|
95
|
-
],
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
// Solo texto
|
|
102
|
-
content = prompt;
|
|
74
|
+
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
|
75
|
+
try {
|
|
76
|
+
const { text } = yield (0, ai_1.generateText)(options);
|
|
77
|
+
return { text: text.trim() };
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
if (attempt < MAX_RETRIES)
|
|
81
|
+
continue;
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
103
84
|
}
|
|
104
|
-
//
|
|
105
|
-
|
|
106
|
-
// Early return si no hay candidates
|
|
107
|
-
const candidate = (_a = resp.response.candidates) === null || _a === void 0 ? void 0 : _a[0];
|
|
108
|
-
if (!candidate)
|
|
109
|
-
return '';
|
|
110
|
-
// Early return si no hay parts
|
|
111
|
-
const parts = (_b = candidate.content) === null || _b === void 0 ? void 0 : _b.parts;
|
|
112
|
-
if (!parts || parts.length === 0)
|
|
113
|
-
return '';
|
|
114
|
-
// Return del texto si existe
|
|
115
|
-
return ((_d = (_c = parts[0]) === null || _c === void 0 ? void 0 : _c.text) === null || _d === void 0 ? void 0 : _d.trim()) || '';
|
|
85
|
+
// Fallback (nunca debería llegar aquí)
|
|
86
|
+
throw new Error('generateText: reintentos agotados');
|
|
116
87
|
});
|
|
117
88
|
}
|
|
118
|
-
exports.
|
|
89
|
+
exports.generateText = generateText;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAmBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SA0BpD,CAAC;AA0EF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,QAAA,MAAM,uBAAuB,qCAAkC,GAAG,iBAwCjE,CAAC;AAmGF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,QAAA,MAAM,WAAW,0EAAuE,GAAG,kBAkE1F,CAAC;AAEF,QAAA,MAAM,gBAAgB;;;;mBAqBrB,CAAC;
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAmBA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SA0BpD,CAAC;AA0EF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,QAAA,MAAM,uBAAuB,qCAAkC,GAAG,iBAwCjE,CAAC;AAmGF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,QAAA,MAAM,WAAW,0EAAuE,GAAG,kBAkE1F,CAAC;AAEF,QAAA,MAAM,gBAAgB;;;;mBAqBrB,CAAC;AAqRF,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,WAAW,EAAE,uBAAuB,EAAE,CAAC"}
|
package/lib/cjs/types/index.d.ts
CHANGED
|
@@ -15,8 +15,8 @@ import { getDefaultWorkoutImage } from './image/getDefaultWorkoutImage';
|
|
|
15
15
|
import { sendWorkoutToWatch } from './workout/sendToWatch';
|
|
16
16
|
import { getPlanificacionPrueba7dias } from './workout/planificacionPrueba7dias';
|
|
17
17
|
import { saveResponseTime } from './chat/saveResponseTime';
|
|
18
|
-
import {
|
|
18
|
+
import { generateText, createGoogleModel } from './prompt';
|
|
19
19
|
import { updateSenderView } from './chat/api/conversation';
|
|
20
20
|
import { transcribeAudio, describeImage, processMediaFile, reprocessRecentMedia } from './mediaProcessing';
|
|
21
|
-
export { sendNotification, sleep, query, queryWithClient, longRunningQuery, batchQuery, toPgArray, pool, sendMail, err, fetchIA, notifySlack, CHANNEL_SLACK, translate, LANGUAGES, useTranslation, getExerciseTranslatedDescription, chat, chatApi, chatExposed, getCountNotificaciones, notionGetUsers, notionGetDatabase, notionAddPage, notionEditPage, NOTION_DATABASES_ID, readSheet, findCellByValue, writeSheet, appendSheet, getNumberByLetter, getLetter, reduceSizeImage, generateShareMap, getDefaultWorkoutImage, sendWorkoutToWatch, getPlanificacionPrueba7dias, saveResponseTime,
|
|
21
|
+
export { sendNotification, sleep, query, queryWithClient, longRunningQuery, batchQuery, toPgArray, pool, sendMail, err, fetchIA, notifySlack, CHANNEL_SLACK, translate, LANGUAGES, useTranslation, getExerciseTranslatedDescription, chat, chatApi, chatExposed, getCountNotificaciones, notionGetUsers, notionGetDatabase, notionAddPage, notionEditPage, NOTION_DATABASES_ID, readSheet, findCellByValue, writeSheet, appendSheet, getNumberByLetter, getLetter, reduceSizeImage, generateShareMap, getDefaultWorkoutImage, sendWorkoutToWatch, getPlanificacionPrueba7dias, saveResponseTime, generateText, createGoogleModel, updateSenderView, transcribeAudio, describeImage, processMediaFile, reprocessRecentMedia, };
|
|
22
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,gCAAgC,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACjH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAClH,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,gCAAgC,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACjH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAClH,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE3G,OAAO,EACL,gBAAgB,EAChB,KAAK,EACL,KAAK,EACL,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,GAAG,EACH,OAAO,EACP,WAAW,EACX,aAAa,EACb,SAAS,EACT,SAAS,EACT,cAAc,EACd,gCAAgC,EAChC,IAAI,EACJ,OAAO,EACP,WAAW,EACX,sBAAsB,EACtB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,SAAS,EACT,eAAe,EACf,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,2BAA2B,EAC3B,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,oBAAoB,GACrB,CAAC"}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
declare const transcribeAudio: (fileBuffer: Buffer, mimetype: string) => Promise<string>;
|
|
17
17
|
/**
|
|
18
|
-
* Genera una descripción de una imagen usando Gemini (
|
|
18
|
+
* Genera una descripción de una imagen usando Gemini (Vercel AI SDK)
|
|
19
19
|
* Contextualizada para una aplicación de fitness/entrenamiento
|
|
20
20
|
*
|
|
21
21
|
* @param fileBuffer - Buffer del archivo de imagen
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/mediaProcessing/index.ts"],"names":[],"mappings":";AA2BA;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,eAAe,eAAsB,MAAM,YAAY,MAAM,KAAG,QAAQ,MAAM,CA0CnF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,aAAa,eAAsB,MAAM,YAAY,MAAM,KAAG,QAAQ,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/mediaProcessing/index.ts"],"names":[],"mappings":";AA2BA;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,eAAe,eAAsB,MAAM,YAAY,MAAM,KAAG,QAAQ,MAAM,CA0CnF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,aAAa,eAAsB,MAAM,YAAY,MAAM,KAAG,QAAQ,MAAM,CAqBjF,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,QAAA,MAAM,gBAAgB,cAAqB,MAAM,cAAc,MAAM,YAAY,MAAM,KAAG,QAAQ,IAAI,CAkBrG,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,oBAAoB,WAAkB,GAAG;eAAwB,MAAM;YAAU,MAAM;EAwD5F,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -1,45 +1,55 @@
|
|
|
1
|
-
|
|
1
|
+
import { generateText as originalGenerateText } from 'ai';
|
|
2
|
+
type ModelKey = 'LITE' | 'FLASH' | 'PRO';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* Crea una instancia del modelo de Google Gemini con la API key configurada
|
|
5
|
+
*
|
|
6
|
+
* @param modelKey - Clave del modelo: 'LITE' (rápido/barato), 'FLASH' (equilibrado), 'PRO' (potente)
|
|
7
|
+
* @returns Instancia del modelo configurado para usar con generateText
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const model = createGoogleModel('LITE');
|
|
12
|
+
* const { text } = await generateText({ model, prompt: 'Hola' });
|
|
13
|
+
* ```
|
|
4
14
|
*/
|
|
5
|
-
|
|
6
|
-
/** Buffer del archivo (audio o imagen) */
|
|
7
|
-
buffer: Buffer;
|
|
8
|
-
/** Tipo MIME del archivo (ej: 'audio/mpeg', 'image/jpeg') */
|
|
9
|
-
mimetype: string;
|
|
10
|
-
}
|
|
15
|
+
declare function createGoogleModel(modelKey?: ModelKey): import("@ai-sdk/provider").LanguageModelV3;
|
|
11
16
|
/**
|
|
12
|
-
*
|
|
13
|
-
* Soporta contenido multimodal (
|
|
17
|
+
* Wrapper de generateText del Vercel AI SDK con retry automático (1 reintento)
|
|
18
|
+
* Soporta texto simple, system prompt y contenido multimodal (imágenes, audio)
|
|
14
19
|
*
|
|
15
|
-
* @param
|
|
16
|
-
* @
|
|
17
|
-
* @param systemPrompt - Instrucciones de sistema opcionales
|
|
18
|
-
* @param media - Contenido multimedia opcional (audio o imagen)
|
|
19
|
-
* @returns Promise<string> - Respuesta generada por la IA
|
|
20
|
+
* @param options - Opciones del Vercel AI SDK: model, system, prompt, messages, temperature, etc.
|
|
21
|
+
* @returns Promise<{ text: string }> - Texto generado por la IA
|
|
20
22
|
*
|
|
21
23
|
* @example
|
|
22
24
|
* ```typescript
|
|
23
25
|
* // Solo texto
|
|
24
|
-
* const
|
|
26
|
+
* const { text } = await generateText({
|
|
27
|
+
* model: createGoogleModel('LITE'),
|
|
28
|
+
* prompt: 'Traduce al inglés: Hola mundo',
|
|
29
|
+
* });
|
|
25
30
|
*
|
|
26
|
-
* // Con
|
|
27
|
-
* const
|
|
28
|
-
*
|
|
29
|
-
* '
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* );
|
|
31
|
+
* // Con system prompt
|
|
32
|
+
* const { text } = await generateText({
|
|
33
|
+
* model: createGoogleModel('FLASH'),
|
|
34
|
+
* system: 'Eres un corrector ortográfico',
|
|
35
|
+
* prompt: 'ola como estas',
|
|
36
|
+
* });
|
|
33
37
|
*
|
|
34
|
-
* //
|
|
35
|
-
* const
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
38
|
+
* // Multimodal (imagen)
|
|
39
|
+
* const { text } = await generateText({
|
|
40
|
+
* model: createGoogleModel('PRO'),
|
|
41
|
+
* messages: [{
|
|
42
|
+
* role: 'user',
|
|
43
|
+
* content: [
|
|
44
|
+
* { type: 'file', data: imageBuffer, mimeType: 'image/jpeg' },
|
|
45
|
+
* { type: 'text', text: 'Describe esta imagen' },
|
|
46
|
+
* ],
|
|
47
|
+
* }],
|
|
48
|
+
* });
|
|
41
49
|
* ```
|
|
42
50
|
*/
|
|
43
|
-
declare function
|
|
44
|
-
|
|
51
|
+
declare function generateText(options: Parameters<typeof originalGenerateText>[0]): Promise<{
|
|
52
|
+
text: string;
|
|
53
|
+
}>;
|
|
54
|
+
export { generateText, createGoogleModel };
|
|
45
55
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,oBAAoB,EAAE,MAAM,IAAI,CAAC;AAG1D,KAAK,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;AAUzC;;;;;;;;;;;GAWG;AACH,iBAAS,iBAAiB,CAAC,QAAQ,GAAE,QAAkB,8CAEtD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,iBAAe,YAAY,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAa1G;AAED,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runnerpro/backend",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.1",
|
|
4
4
|
"description": "A collection of common backend functions",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./lib/cjs/index.js"
|
|
@@ -65,11 +65,12 @@
|
|
|
65
65
|
"uuidv4": "^6.2.13"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
+
"@ai-sdk/google": "^3.0.43",
|
|
68
69
|
"@google-cloud/speech": "^7.2.1",
|
|
69
70
|
"@google-cloud/storage": "^7.11.3",
|
|
70
71
|
"@google-cloud/translate": "^8.3.0",
|
|
71
|
-
"@google-cloud/vertexai": "^1.4.0",
|
|
72
72
|
"@notionhq/client": "^2.2.15",
|
|
73
|
+
"ai": "^6.0.116",
|
|
73
74
|
"exifr": "^7.1.3",
|
|
74
75
|
"ffmpeg-static": "^5.2.0",
|
|
75
76
|
"ffprobe-static": "^3.1.0",
|