@runnerpro/backend 1.21.7 → 1.21.9
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/index.js +11 -1
- package/lib/cjs/prompt/ai.js +15 -8
- package/lib/cjs/prompt/azureModel.js +47 -0
- package/lib/cjs/prompt/constants.js +34 -1
- package/lib/cjs/prompt/googleModel.js +29 -7
- package/lib/cjs/prompt/index.js +12 -1
- package/lib/cjs/prompt/llmCacheStore.js +102 -0
- package/lib/cjs/prompt/modelPricing.js +13 -0
- package/lib/cjs/types/index.d.ts +2 -2
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/cjs/types/prompt/ai.d.ts.map +1 -1
- package/lib/cjs/types/prompt/azureModel.d.ts +17 -0
- package/lib/cjs/types/prompt/azureModel.d.ts.map +1 -0
- package/lib/cjs/types/prompt/constants.d.ts +9 -1
- package/lib/cjs/types/prompt/constants.d.ts.map +1 -1
- package/lib/cjs/types/prompt/googleModel.d.ts +12 -1
- package/lib/cjs/types/prompt/googleModel.d.ts.map +1 -1
- package/lib/cjs/types/prompt/index.d.ts +4 -3
- package/lib/cjs/types/prompt/index.d.ts.map +1 -1
- package/lib/cjs/types/prompt/llmCacheStore.d.ts +26 -0
- package/lib/cjs/types/prompt/llmCacheStore.d.ts.map +1 -0
- package/lib/cjs/types/prompt/modelPricing.d.ts.map +1 -1
- package/package.json +2 -1
package/lib/cjs/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createGoogleModel = exports.generateText = exports.generateObject = exports.reprocessRecentMedia = exports.processMediaFile = exports.describeImage = exports.transcribeAudio = exports.updateSenderView = exports.saveResponseTime = exports.getZone = exports.saveDoneStructuraWorkout = exports.saveWorkoutLaps = exports.saveWorkoutAplication = 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
|
-
exports.calculateCost = exports.MODEL_PRICING = exports.AISTUDIO_PREFIX = exports.BEDROCK_CLAUDE_HAIKU = exports.BEDROCK_CLAUDE_SONNET_4 = exports.BEDROCK_CLAUDE_SONNET_4_5 = exports.BEDROCK_CLAUDE_OPUS_4_1 = exports.BEDROCK_CLAUDE_OPUS_4_5 = exports.BEDROCK_CLAUDE_SONNET = exports.BEDROCK_CLAUDE_OPUS = exports.FALLBACK_MODELS = exports.PRODUCTION_MODELS = exports.GOOGLE_MODELS = exports.AI_MODELS = exports.MODEL_TIER = exports.runWithModels = exports.runWithCostTracking = exports.createBedrockModelFromString = exports.createGoogleModelFromString = void 0;
|
|
4
|
+
exports.calculateCost = exports.MODEL_PRICING = exports.AISTUDIO_PREFIX = exports.BEDROCK_CLAUDE_HAIKU = exports.BEDROCK_CLAUDE_SONNET_4 = exports.BEDROCK_CLAUDE_SONNET_4_5 = exports.BEDROCK_CLAUDE_OPUS_4_1 = exports.BEDROCK_CLAUDE_OPUS_4_5 = exports.BEDROCK_CLAUDE_SONNET = exports.BEDROCK_CLAUDE_OPUS = exports.FALLBACK_MODELS = exports.PRODUCTION_MODELS = exports.AZURE_PRIMARY_MODELS = exports.AZURE_GPT_5_4_NANO = exports.AZURE_GPT_5_4_MINI = exports.AZURE_GPT_5_5 = exports.AZURE_GPT_5_4_NANO_DEPLOYMENT = exports.AZURE_GPT_5_4_MINI_DEPLOYMENT = exports.AZURE_GPT_5_5_DEPLOYMENT = exports.AZURE_PREFIX = exports.GOOGLE_MODELS = exports.AI_MODELS = exports.MODEL_TIER = exports.runWithModels = exports.runWithCostTracking = exports.createModelFromString = exports.createAzureModelFromString = exports.createBedrockModelFromString = exports.createGoogleModelFromString = void 0;
|
|
5
5
|
const sendNotification_1 = require("./sendNotification");
|
|
6
6
|
Object.defineProperty(exports, "sendNotification", { enumerable: true, get: function () { return sendNotification_1.sendNotification; } });
|
|
7
7
|
const sleep_1 = require("./sleep");
|
|
@@ -78,11 +78,21 @@ Object.defineProperty(exports, "generateText", { enumerable: true, get: function
|
|
|
78
78
|
Object.defineProperty(exports, "createGoogleModel", { enumerable: true, get: function () { return prompt_1.createGoogleModel; } });
|
|
79
79
|
Object.defineProperty(exports, "createGoogleModelFromString", { enumerable: true, get: function () { return prompt_1.createGoogleModelFromString; } });
|
|
80
80
|
Object.defineProperty(exports, "createBedrockModelFromString", { enumerable: true, get: function () { return prompt_1.createBedrockModelFromString; } });
|
|
81
|
+
Object.defineProperty(exports, "createAzureModelFromString", { enumerable: true, get: function () { return prompt_1.createAzureModelFromString; } });
|
|
82
|
+
Object.defineProperty(exports, "createModelFromString", { enumerable: true, get: function () { return prompt_1.createModelFromString; } });
|
|
81
83
|
Object.defineProperty(exports, "runWithCostTracking", { enumerable: true, get: function () { return prompt_1.runWithCostTracking; } });
|
|
82
84
|
Object.defineProperty(exports, "runWithModels", { enumerable: true, get: function () { return prompt_1.runWithModels; } });
|
|
83
85
|
Object.defineProperty(exports, "MODEL_TIER", { enumerable: true, get: function () { return prompt_1.MODEL_TIER; } });
|
|
84
86
|
Object.defineProperty(exports, "AI_MODELS", { enumerable: true, get: function () { return prompt_1.AI_MODELS; } });
|
|
85
87
|
Object.defineProperty(exports, "GOOGLE_MODELS", { enumerable: true, get: function () { return prompt_1.GOOGLE_MODELS; } });
|
|
88
|
+
Object.defineProperty(exports, "AZURE_PREFIX", { enumerable: true, get: function () { return prompt_1.AZURE_PREFIX; } });
|
|
89
|
+
Object.defineProperty(exports, "AZURE_GPT_5_5_DEPLOYMENT", { enumerable: true, get: function () { return prompt_1.AZURE_GPT_5_5_DEPLOYMENT; } });
|
|
90
|
+
Object.defineProperty(exports, "AZURE_GPT_5_4_MINI_DEPLOYMENT", { enumerable: true, get: function () { return prompt_1.AZURE_GPT_5_4_MINI_DEPLOYMENT; } });
|
|
91
|
+
Object.defineProperty(exports, "AZURE_GPT_5_4_NANO_DEPLOYMENT", { enumerable: true, get: function () { return prompt_1.AZURE_GPT_5_4_NANO_DEPLOYMENT; } });
|
|
92
|
+
Object.defineProperty(exports, "AZURE_GPT_5_5", { enumerable: true, get: function () { return prompt_1.AZURE_GPT_5_5; } });
|
|
93
|
+
Object.defineProperty(exports, "AZURE_GPT_5_4_MINI", { enumerable: true, get: function () { return prompt_1.AZURE_GPT_5_4_MINI; } });
|
|
94
|
+
Object.defineProperty(exports, "AZURE_GPT_5_4_NANO", { enumerable: true, get: function () { return prompt_1.AZURE_GPT_5_4_NANO; } });
|
|
95
|
+
Object.defineProperty(exports, "AZURE_PRIMARY_MODELS", { enumerable: true, get: function () { return prompt_1.AZURE_PRIMARY_MODELS; } });
|
|
86
96
|
Object.defineProperty(exports, "PRODUCTION_MODELS", { enumerable: true, get: function () { return prompt_1.PRODUCTION_MODELS; } });
|
|
87
97
|
Object.defineProperty(exports, "FALLBACK_MODELS", { enumerable: true, get: function () { return prompt_1.FALLBACK_MODELS; } });
|
|
88
98
|
Object.defineProperty(exports, "BEDROCK_CLAUDE_OPUS", { enumerable: true, get: function () { return prompt_1.BEDROCK_CLAUDE_OPUS; } });
|
package/lib/cjs/prompt/ai.js
CHANGED
|
@@ -15,8 +15,8 @@ const node_async_hooks_1 = require("node:async_hooks");
|
|
|
15
15
|
const modelPricing_1 = require("./modelPricing");
|
|
16
16
|
const constants_1 = require("./constants");
|
|
17
17
|
const googleModel_1 = require("./googleModel");
|
|
18
|
-
const bedrockModel_1 = require("./bedrockModel");
|
|
19
18
|
const slack_1 = require("../slack");
|
|
19
|
+
const llmCacheStore_1 = require("./llmCacheStore");
|
|
20
20
|
const MIN_RETRIES = 1;
|
|
21
21
|
// ✅ Detección de Chain-of-Thought (CoT) que se cuela en la respuesta final del modelo
|
|
22
22
|
const COT_HTML_TAG = /<\/?(thinking|thought|reasoning)\b/i;
|
|
@@ -49,14 +49,8 @@ function shouldUseAlternateModel(error) {
|
|
|
49
49
|
msg.includes('resource exhausted') ||
|
|
50
50
|
msg.includes('too many'));
|
|
51
51
|
}
|
|
52
|
-
function isBedrockModel(modelName) {
|
|
53
|
-
return modelName === constants_1.BEDROCK_CLAUDE_OPUS || modelName.includes('anthropic.') || modelName.startsWith('amazon.');
|
|
54
|
-
}
|
|
55
52
|
function createFallbackModel(modelName) {
|
|
56
|
-
|
|
57
|
-
return (0, bedrockModel_1.createBedrockModelFromString)(modelName);
|
|
58
|
-
}
|
|
59
|
-
return (0, googleModel_1.createGoogleModelFromString)(modelName);
|
|
53
|
+
return (0, googleModel_1.createModelFromString)(modelName);
|
|
60
54
|
}
|
|
61
55
|
function extractModelName(model) {
|
|
62
56
|
var _a;
|
|
@@ -211,6 +205,17 @@ function generateObject(options) {
|
|
|
211
205
|
return __awaiter(this, void 0, void 0, function* () {
|
|
212
206
|
let lastError;
|
|
213
207
|
let currentOptions = options;
|
|
208
|
+
// [llm-cache] cache-aside: HIT → output guardado sin llamar al modelo (opt-out con options.cache === false)
|
|
209
|
+
const co = currentOptions;
|
|
210
|
+
const useCache = co.cache !== false;
|
|
211
|
+
const schemaSig = useCache ? (0, llmCacheStore_1.schemaSignature)(co.schema) : null;
|
|
212
|
+
let cacheKey = null;
|
|
213
|
+
if (useCache) {
|
|
214
|
+
cacheKey = (0, llmCacheStore_1.llmCacheKey)({ system: co.system, prompt: co.prompt, schemaSig, temperature: co.temperature });
|
|
215
|
+
const hit = yield (0, llmCacheStore_1.lookup)(cacheKey);
|
|
216
|
+
if (hit !== null && hit !== undefined)
|
|
217
|
+
return { object: hit, cost: { inputTokens: 0, outputTokens: 0, cost: 0 } };
|
|
218
|
+
}
|
|
214
219
|
const fallbackNames = ((_a = currentOptions.model) === null || _a === void 0 ? void 0 : _a._fallbackModelNames) || [];
|
|
215
220
|
const maxAttempts = (1 + fallbackNames.length) * (1 + MIN_RETRIES);
|
|
216
221
|
let transientRetries = 0;
|
|
@@ -223,6 +228,8 @@ function generateObject(options) {
|
|
|
223
228
|
const tracker = costTrackingStorage.getStore();
|
|
224
229
|
if (tracker)
|
|
225
230
|
tracker.push(cost);
|
|
231
|
+
if (useCache && cacheKey)
|
|
232
|
+
(0, llmCacheStore_1.store)(cacheKey, { modelName, system: co.system, prompt: co.prompt, schemaSig, temperature: co.temperature, output: object });
|
|
226
233
|
return { object, cost };
|
|
227
234
|
}
|
|
228
235
|
catch (error) {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAzureModelFromString = void 0;
|
|
4
|
+
const azure_1 = require("@ai-sdk/azure");
|
|
5
|
+
/**
|
|
6
|
+
* Crea el provider de Azure OpenAI con autenticación por API Key.
|
|
7
|
+
*
|
|
8
|
+
* Variables de entorno:
|
|
9
|
+
* - AZURE_BASE_URL: endpoint del recurso hasta "/openai" (ej:
|
|
10
|
+
* https://<name>.cognitiveservices.azure.com/openai). Alternativa: AZURE_RESOURCE_NAME
|
|
11
|
+
* para recursos con dominio clásico *.openai.azure.com.
|
|
12
|
+
* - AZURE_API_KEY: clave del recurso.
|
|
13
|
+
* - AZURE_API_VERSION: versión de la API. Para los recursos nuevos (Cognitive Services /
|
|
14
|
+
* modelos GPT-5.x) usar "preview" → enruta a la API v1 (/openai/v1/responses).
|
|
15
|
+
*
|
|
16
|
+
* @returns Provider de Azure configurado
|
|
17
|
+
*/
|
|
18
|
+
function getAzureProvider() {
|
|
19
|
+
const apiVersion = process.env.AZURE_API_VERSION;
|
|
20
|
+
const baseURL = process.env.AZURE_BASE_URL;
|
|
21
|
+
return (0, azure_1.createAzure)(Object.assign(Object.assign({ apiKey: process.env.AZURE_API_KEY }, (baseURL ? { baseURL } : { resourceName: process.env.AZURE_RESOURCE_NAME })), (apiVersion ? { apiVersion } : {})));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Crea una instancia del modelo de Azure OpenAI a partir del nombre del deployment.
|
|
25
|
+
* Etiqueta el objeto con _productionModelName (nombre limpio, sin el prefijo "azure:")
|
|
26
|
+
* para el cálculo de costes.
|
|
27
|
+
*
|
|
28
|
+
* @param deploymentName - Nombre del deployment en Azure (ej: 'gpt-5')
|
|
29
|
+
* @returns Instancia del modelo de Azure compatible con AI SDK
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const model = createAzureModelFromString('gpt-5');
|
|
34
|
+
* const { text } = await generateText({ model, prompt });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
function createAzureModelFromString(deploymentName) {
|
|
38
|
+
const azure = getAzureProvider();
|
|
39
|
+
// .responses() → API v1 de Azure (/openai/v1/responses), la única que admiten los
|
|
40
|
+
// recursos nuevos de Cognitive Services y los modelos GPT-5.x. El chat completions
|
|
41
|
+
// clásico (/openai/deployments/.../chat/completions) devuelve 400 en estos recursos.
|
|
42
|
+
const model = azure.responses(deploymentName);
|
|
43
|
+
model._productionModelName = deploymentName;
|
|
44
|
+
model._fallbackModelNames = [];
|
|
45
|
+
return model;
|
|
46
|
+
}
|
|
47
|
+
exports.createAzureModelFromString = createAzureModelFromString;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runWithModels = exports.AISTUDIO_PREFIX = exports.MODEL_TIER = exports.BEDROCK_CLAUDE_HAIKU = exports.BEDROCK_CLAUDE_SONNET_4 = exports.BEDROCK_CLAUDE_SONNET_4_5 = exports.BEDROCK_CLAUDE_OPUS_4_1 = exports.BEDROCK_CLAUDE_OPUS_4_5 = exports.BEDROCK_CLAUDE_SONNET = exports.BEDROCK_CLAUDE_OPUS = exports.FALLBACK_MODELS = exports.TRIAL_MODELS = exports.FAST_MODELS = exports.SEMI_MODELS = exports.PRODUCTION_MODELS = exports.GOOGLE_MODELS = exports.AI_MODELS = void 0;
|
|
3
|
+
exports.runWithModels = exports.AISTUDIO_PREFIX = exports.MODEL_TIER = exports.BEDROCK_CLAUDE_HAIKU = exports.BEDROCK_CLAUDE_SONNET_4 = exports.BEDROCK_CLAUDE_SONNET_4_5 = exports.BEDROCK_CLAUDE_OPUS_4_1 = exports.BEDROCK_CLAUDE_OPUS_4_5 = exports.BEDROCK_CLAUDE_SONNET = exports.BEDROCK_CLAUDE_OPUS = exports.FALLBACK_MODELS = exports.TRIAL_MODELS = exports.FAST_MODELS = exports.SEMI_MODELS = exports.PRODUCTION_MODELS = exports.AZURE_PRIMARY_MODELS = exports.AZURE_GPT_5_4_NANO = exports.AZURE_GPT_5_4_MINI = exports.AZURE_GPT_5_5 = exports.AZURE_GPT_5_4_NANO_DEPLOYMENT = exports.AZURE_GPT_5_4_MINI_DEPLOYMENT = exports.AZURE_GPT_5_5_DEPLOYMENT = exports.AZURE_PREFIX = exports.GOOGLE_MODELS = exports.AI_MODELS = void 0;
|
|
4
4
|
const node_async_hooks_1 = require("node:async_hooks");
|
|
5
5
|
const modelContextStorage = new node_async_hooks_1.AsyncLocalStorage();
|
|
6
6
|
const BEDROCK_CLAUDE_OPUS = 'us.anthropic.claude-opus-4-6-v1';
|
|
@@ -26,6 +26,39 @@ const GOOGLE_MODELS = {
|
|
|
26
26
|
LITE: 'gemini-3.1-flash-lite-preview',
|
|
27
27
|
};
|
|
28
28
|
exports.GOOGLE_MODELS = GOOGLE_MODELS;
|
|
29
|
+
// Azure OpenAI. El prefijo "azure:" enruta el string al provider de Azure
|
|
30
|
+
// (igual que "aistudio:" enruta a Google AI Studio). Los *_DEPLOYMENT son el nombre
|
|
31
|
+
// del deployment en el recurso de Azure (override por env); los AZURE_GPT_* son el
|
|
32
|
+
// string de enrutado. Se mapean a tiers como Gemini/Claude: PRO el más potente, LITE el más barato.
|
|
33
|
+
const AZURE_PREFIX = 'azure:';
|
|
34
|
+
exports.AZURE_PREFIX = AZURE_PREFIX;
|
|
35
|
+
const AZURE_GPT_5_5_DEPLOYMENT = process.env.AZURE_GPT_5_5_DEPLOYMENT || 'gpt-5.5';
|
|
36
|
+
exports.AZURE_GPT_5_5_DEPLOYMENT = AZURE_GPT_5_5_DEPLOYMENT;
|
|
37
|
+
const AZURE_GPT_5_4_MINI_DEPLOYMENT = process.env.AZURE_GPT_5_4_MINI_DEPLOYMENT || 'gpt-5.4-mini';
|
|
38
|
+
exports.AZURE_GPT_5_4_MINI_DEPLOYMENT = AZURE_GPT_5_4_MINI_DEPLOYMENT;
|
|
39
|
+
const AZURE_GPT_5_4_NANO_DEPLOYMENT = process.env.AZURE_GPT_5_4_NANO_DEPLOYMENT || 'gpt-5.4-nano';
|
|
40
|
+
exports.AZURE_GPT_5_4_NANO_DEPLOYMENT = AZURE_GPT_5_4_NANO_DEPLOYMENT;
|
|
41
|
+
const AZURE_GPT_5_5 = `${AZURE_PREFIX}${AZURE_GPT_5_5_DEPLOYMENT}`;
|
|
42
|
+
exports.AZURE_GPT_5_5 = AZURE_GPT_5_5;
|
|
43
|
+
const AZURE_GPT_5_4_MINI = `${AZURE_PREFIX}${AZURE_GPT_5_4_MINI_DEPLOYMENT}`;
|
|
44
|
+
exports.AZURE_GPT_5_4_MINI = AZURE_GPT_5_4_MINI;
|
|
45
|
+
const AZURE_GPT_5_4_NANO = `${AZURE_PREFIX}${AZURE_GPT_5_4_NANO_DEPLOYMENT}`;
|
|
46
|
+
exports.AZURE_GPT_5_4_NANO = AZURE_GPT_5_4_NANO;
|
|
47
|
+
// Primario Azure por tier (antes que Claude en todos los tiers → Azure > Claude > Gemini).
|
|
48
|
+
// El modelo Claude que el tier resuelve (PRODUCTION_MODELS/FAST_MODELS/... vía AI_MODELS)
|
|
49
|
+
// se conserva como PRIMER fallback.
|
|
50
|
+
//
|
|
51
|
+
// ⚠️ TEMPORAL: la cuenta de Azure solo tiene cuota para gpt-5.4-mini de momento,
|
|
52
|
+
// así que los TRES tiers apuntan a él. Cuando se apruebe cuota de gpt-5.5 y gpt-5.4-nano
|
|
53
|
+
// y se desplieguen en Azure, restaurar el mapeo por tier:
|
|
54
|
+
// PRO → AZURE_GPT_5_5 (frontier)
|
|
55
|
+
// LITE → AZURE_GPT_5_4_NANO (ultra-barato)
|
|
56
|
+
const AZURE_PRIMARY_MODELS = {
|
|
57
|
+
FLASH: AZURE_GPT_5_4_MINI,
|
|
58
|
+
PRO: AZURE_GPT_5_4_MINI,
|
|
59
|
+
LITE: AZURE_GPT_5_4_MINI,
|
|
60
|
+
};
|
|
61
|
+
exports.AZURE_PRIMARY_MODELS = AZURE_PRIMARY_MODELS;
|
|
29
62
|
const PRODUCTION_MODELS = {
|
|
30
63
|
FLASH: BEDROCK_CLAUDE_SONNET,
|
|
31
64
|
PRO: BEDROCK_CLAUDE_OPUS,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createGoogleModelFromString = exports.createGoogleModel = void 0;
|
|
3
|
+
exports.createModelFromString = exports.createGoogleModelFromString = exports.createGoogleModel = void 0;
|
|
4
4
|
const google_vertex_1 = require("@ai-sdk/google-vertex");
|
|
5
5
|
const google_1 = require("@ai-sdk/google");
|
|
6
6
|
const constants_1 = require("./constants");
|
|
7
7
|
const bedrockModel_1 = require("./bedrockModel");
|
|
8
|
+
const azureModel_1 = require("./azureModel");
|
|
8
9
|
const vertex = (0, google_vertex_1.createVertex)({
|
|
9
10
|
project: process.env.GOOGLE_VERTEX_PROJECT || process.env.PROJECT_ID,
|
|
10
11
|
location: process.env.GOOGLE_VERTEX_LOCATION || 'global',
|
|
@@ -38,15 +39,36 @@ function getAIStudioApiKey() {
|
|
|
38
39
|
*/
|
|
39
40
|
function createGoogleModel(modelKey = 'FLASH') {
|
|
40
41
|
var _a;
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
model
|
|
42
|
+
// Primario: Azure gpt-5 en todos los tiers (orden global Azure > Claude > Gemini).
|
|
43
|
+
const primaryName = constants_1.AZURE_PRIMARY_MODELS[modelKey];
|
|
44
|
+
// El modelo Claude que resuelve el tier actual (PRODUCTION/SEMI/FAST/TRIAL vía AI_MODELS)
|
|
45
|
+
// se conserva como PRIMER fallback, manteniendo el control de coste por tier en la cascada.
|
|
46
|
+
const claudeFallbackHead = constants_1.AI_MODELS[modelKey];
|
|
47
|
+
const model = createModelFromString(primaryName);
|
|
48
|
+
model._fallbackModelNames = [claudeFallbackHead, ...((_a = constants_1.FALLBACK_MODELS[modelKey]) !== null && _a !== void 0 ? _a : [])];
|
|
47
49
|
return model;
|
|
48
50
|
}
|
|
49
51
|
exports.createGoogleModel = createGoogleModel;
|
|
52
|
+
/**
|
|
53
|
+
* Router de proveedores: crea una instancia de modelo a partir de un nombre de string,
|
|
54
|
+
* detectando el provider por prefijo/patrón:
|
|
55
|
+
* - "azure:<deployment>" → Azure OpenAI
|
|
56
|
+
* - contiene "anthropic." o empieza por "amazon." → AWS Bedrock
|
|
57
|
+
* - "aistudio:<modelo>" o resto → Google (AI Studio / Vertex)
|
|
58
|
+
*
|
|
59
|
+
* @param modelName - Nombre del modelo, opcionalmente con prefijo de provider
|
|
60
|
+
* @returns Instancia del modelo compatible con AI SDK
|
|
61
|
+
*/
|
|
62
|
+
function createModelFromString(modelName) {
|
|
63
|
+
if (modelName.startsWith(constants_1.AZURE_PREFIX)) {
|
|
64
|
+
return (0, azureModel_1.createAzureModelFromString)(modelName.slice(constants_1.AZURE_PREFIX.length));
|
|
65
|
+
}
|
|
66
|
+
if (modelName.includes('anthropic.') || modelName.startsWith('amazon.')) {
|
|
67
|
+
return (0, bedrockModel_1.createBedrockModelFromString)(modelName);
|
|
68
|
+
}
|
|
69
|
+
return createGoogleModelFromString(modelName);
|
|
70
|
+
}
|
|
71
|
+
exports.createModelFromString = createModelFromString;
|
|
50
72
|
/**
|
|
51
73
|
* Crea una instancia del modelo a partir de un nombre exacto (string).
|
|
52
74
|
* Si el nombre tiene prefijo "aistudio:", usa Google AI Studio (API key).
|
package/lib/cjs/prompt/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateCost = exports.MODEL_PRICING = exports.AISTUDIO_PREFIX = exports.BEDROCK_CLAUDE_HAIKU = exports.BEDROCK_CLAUDE_SONNET_4 = exports.BEDROCK_CLAUDE_SONNET_4_5 = exports.BEDROCK_CLAUDE_OPUS_4_1 = exports.BEDROCK_CLAUDE_OPUS_4_5 = exports.BEDROCK_CLAUDE_SONNET = exports.BEDROCK_CLAUDE_OPUS = exports.FALLBACK_MODELS = exports.TRIAL_MODELS = exports.FAST_MODELS = exports.SEMI_MODELS = exports.PRODUCTION_MODELS = exports.GOOGLE_MODELS = exports.AI_MODELS = exports.runWithModels = exports.MODEL_TIER = exports.createBedrockModelFromString = exports.createGoogleModelFromString = exports.createGoogleModel = exports.runWithCostTracking = exports.generateText = exports.generateObject = void 0;
|
|
3
|
+
exports.calculateCost = exports.MODEL_PRICING = exports.AISTUDIO_PREFIX = exports.BEDROCK_CLAUDE_HAIKU = exports.BEDROCK_CLAUDE_SONNET_4 = exports.BEDROCK_CLAUDE_SONNET_4_5 = exports.BEDROCK_CLAUDE_OPUS_4_1 = exports.BEDROCK_CLAUDE_OPUS_4_5 = exports.BEDROCK_CLAUDE_SONNET = exports.BEDROCK_CLAUDE_OPUS = exports.FALLBACK_MODELS = exports.TRIAL_MODELS = exports.FAST_MODELS = exports.SEMI_MODELS = exports.PRODUCTION_MODELS = exports.AZURE_PRIMARY_MODELS = exports.AZURE_GPT_5_4_NANO = exports.AZURE_GPT_5_4_MINI = exports.AZURE_GPT_5_5 = exports.AZURE_GPT_5_4_NANO_DEPLOYMENT = exports.AZURE_GPT_5_4_MINI_DEPLOYMENT = exports.AZURE_GPT_5_5_DEPLOYMENT = exports.AZURE_PREFIX = exports.GOOGLE_MODELS = exports.AI_MODELS = exports.runWithModels = exports.MODEL_TIER = exports.createModelFromString = exports.createAzureModelFromString = exports.createBedrockModelFromString = exports.createGoogleModelFromString = exports.createGoogleModel = exports.runWithCostTracking = exports.generateText = exports.generateObject = void 0;
|
|
4
4
|
const ai_1 = require("./ai");
|
|
5
5
|
Object.defineProperty(exports, "generateObject", { enumerable: true, get: function () { return ai_1.generateObject; } });
|
|
6
6
|
Object.defineProperty(exports, "generateText", { enumerable: true, get: function () { return ai_1.generateText; } });
|
|
@@ -8,9 +8,18 @@ Object.defineProperty(exports, "runWithCostTracking", { enumerable: true, get: f
|
|
|
8
8
|
const googleModel_1 = require("./googleModel");
|
|
9
9
|
Object.defineProperty(exports, "createGoogleModel", { enumerable: true, get: function () { return googleModel_1.createGoogleModel; } });
|
|
10
10
|
Object.defineProperty(exports, "createGoogleModelFromString", { enumerable: true, get: function () { return googleModel_1.createGoogleModelFromString; } });
|
|
11
|
+
Object.defineProperty(exports, "createModelFromString", { enumerable: true, get: function () { return googleModel_1.createModelFromString; } });
|
|
11
12
|
const constants_1 = require("./constants");
|
|
12
13
|
Object.defineProperty(exports, "AI_MODELS", { enumerable: true, get: function () { return constants_1.AI_MODELS; } });
|
|
13
14
|
Object.defineProperty(exports, "GOOGLE_MODELS", { enumerable: true, get: function () { return constants_1.GOOGLE_MODELS; } });
|
|
15
|
+
Object.defineProperty(exports, "AZURE_PREFIX", { enumerable: true, get: function () { return constants_1.AZURE_PREFIX; } });
|
|
16
|
+
Object.defineProperty(exports, "AZURE_GPT_5_5_DEPLOYMENT", { enumerable: true, get: function () { return constants_1.AZURE_GPT_5_5_DEPLOYMENT; } });
|
|
17
|
+
Object.defineProperty(exports, "AZURE_GPT_5_4_MINI_DEPLOYMENT", { enumerable: true, get: function () { return constants_1.AZURE_GPT_5_4_MINI_DEPLOYMENT; } });
|
|
18
|
+
Object.defineProperty(exports, "AZURE_GPT_5_4_NANO_DEPLOYMENT", { enumerable: true, get: function () { return constants_1.AZURE_GPT_5_4_NANO_DEPLOYMENT; } });
|
|
19
|
+
Object.defineProperty(exports, "AZURE_GPT_5_5", { enumerable: true, get: function () { return constants_1.AZURE_GPT_5_5; } });
|
|
20
|
+
Object.defineProperty(exports, "AZURE_GPT_5_4_MINI", { enumerable: true, get: function () { return constants_1.AZURE_GPT_5_4_MINI; } });
|
|
21
|
+
Object.defineProperty(exports, "AZURE_GPT_5_4_NANO", { enumerable: true, get: function () { return constants_1.AZURE_GPT_5_4_NANO; } });
|
|
22
|
+
Object.defineProperty(exports, "AZURE_PRIMARY_MODELS", { enumerable: true, get: function () { return constants_1.AZURE_PRIMARY_MODELS; } });
|
|
14
23
|
Object.defineProperty(exports, "PRODUCTION_MODELS", { enumerable: true, get: function () { return constants_1.PRODUCTION_MODELS; } });
|
|
15
24
|
Object.defineProperty(exports, "SEMI_MODELS", { enumerable: true, get: function () { return constants_1.SEMI_MODELS; } });
|
|
16
25
|
Object.defineProperty(exports, "FAST_MODELS", { enumerable: true, get: function () { return constants_1.FAST_MODELS; } });
|
|
@@ -31,3 +40,5 @@ Object.defineProperty(exports, "MODEL_PRICING", { enumerable: true, get: functio
|
|
|
31
40
|
Object.defineProperty(exports, "calculateCost", { enumerable: true, get: function () { return modelPricing_1.calculateCost; } });
|
|
32
41
|
const bedrockModel_1 = require("./bedrockModel");
|
|
33
42
|
Object.defineProperty(exports, "createBedrockModelFromString", { enumerable: true, get: function () { return bedrockModel_1.createBedrockModelFromString; } });
|
|
43
|
+
const azureModel_1 = require("./azureModel");
|
|
44
|
+
Object.defineProperty(exports, "createAzureModelFromString", { enumerable: true, get: function () { return azureModel_1.createAzureModelFromString; } });
|
|
@@ -0,0 +1,102 @@
|
|
|
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.store = exports.lookup = exports.llmCacheKey = exports.schemaSignature = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* Caché LLM (cache-aside) para `generateObject`.
|
|
15
|
+
*
|
|
16
|
+
* Antes de cada llamada se busca por (modelo + system + input + schema + temperatura); si existe se
|
|
17
|
+
* devuelve el output guardado SIN llamar al modelo; si no, se llama y se guarda. Una poda periódica
|
|
18
|
+
* (Cron-backend /cron/operations/llmCacheEvict) elimina las entradas de un solo uso rancias.
|
|
19
|
+
*
|
|
20
|
+
* Fail-safe: un único chequeo `to_regclass` desactiva la caché en silencio si la tabla "LLM CACHE" no
|
|
21
|
+
* existe (migración no aplicada) o la BBDD falla. Así nunca rompe ni hace spam de errores.
|
|
22
|
+
*
|
|
23
|
+
* Tabla: ver migración en IA-backend docs/llm-cache-prod/001-llm-cache-table.sql.
|
|
24
|
+
*/
|
|
25
|
+
const node_crypto_1 = require("node:crypto");
|
|
26
|
+
const db_1 = require("../db");
|
|
27
|
+
let _ready = null; // null=sin comprobar, true=tabla disponible, false=desactivada
|
|
28
|
+
function ensureReady() {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
if (_ready !== null)
|
|
31
|
+
return _ready;
|
|
32
|
+
try {
|
|
33
|
+
const rows = yield (0, db_1.query)('SELECT to_regclass(?) AS t', ['"LLM CACHE"']);
|
|
34
|
+
_ready = !!(rows && rows[0] && rows[0].t);
|
|
35
|
+
}
|
|
36
|
+
catch (_a) {
|
|
37
|
+
_ready = false;
|
|
38
|
+
}
|
|
39
|
+
return _ready;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/** Firma ligera del schema (zod) para distinguir llamadas con el mismo prompt pero distinta forma. */
|
|
43
|
+
function schemaSignature(schema) {
|
|
44
|
+
var _a, _b;
|
|
45
|
+
try {
|
|
46
|
+
if (!schema)
|
|
47
|
+
return 'noschema';
|
|
48
|
+
const tn = ((_a = schema === null || schema === void 0 ? void 0 : schema._def) === null || _a === void 0 ? void 0 : _a.typeName) || ((_b = schema === null || schema === void 0 ? void 0 : schema.constructor) === null || _b === void 0 ? void 0 : _b.name) || 'schema';
|
|
49
|
+
let shape = schema === null || schema === void 0 ? void 0 : schema.shape;
|
|
50
|
+
if (!shape && (schema === null || schema === void 0 ? void 0 : schema._def))
|
|
51
|
+
shape = typeof schema._def.shape === 'function' ? schema._def.shape() : schema._def.shape;
|
|
52
|
+
const keys = shape ? Object.keys(shape).sort().join(',') : '';
|
|
53
|
+
return `${tn}:${keys}`;
|
|
54
|
+
}
|
|
55
|
+
catch (_c) {
|
|
56
|
+
return 'schema';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.schemaSignature = schemaSignature;
|
|
60
|
+
/**
|
|
61
|
+
* Clave determinista de una llamada: SYSTEM + INPUT + SCHEMA + TEMPERATURE.
|
|
62
|
+
* NO incluye el modelo a propósito: si esos 4 coinciden, se reutiliza el output guardado (lo haya
|
|
63
|
+
* generado el modelo que sea). Implica que cambiar de modelo NO invalida la caché.
|
|
64
|
+
*/
|
|
65
|
+
function llmCacheKey(opts) {
|
|
66
|
+
var _a;
|
|
67
|
+
const payload = JSON.stringify({
|
|
68
|
+
system: opts.system || '',
|
|
69
|
+
prompt: opts.prompt || '',
|
|
70
|
+
schema: opts.schemaSig || 'noschema',
|
|
71
|
+
temperature: (_a = opts.temperature) !== null && _a !== void 0 ? _a : null,
|
|
72
|
+
});
|
|
73
|
+
return (0, node_crypto_1.createHash)('sha256').update(payload).digest('hex');
|
|
74
|
+
}
|
|
75
|
+
exports.llmCacheKey = llmCacheKey;
|
|
76
|
+
/** HIT: incrementa USE COUNT + LAST USED y devuelve OUTPUT (atómico). null en MISS o ante error. */
|
|
77
|
+
function lookup(key) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
if (!(yield ensureReady()))
|
|
80
|
+
return null;
|
|
81
|
+
try {
|
|
82
|
+
const rows = yield (0, db_1.query)('UPDATE "LLM CACHE" SET "USE COUNT" = "USE COUNT" + 1, "LAST USED AT" = now() WHERE "KEY" = ? RETURNING "OUTPUT"', [key]);
|
|
83
|
+
return rows && rows[0] ? rows[0].output : null;
|
|
84
|
+
}
|
|
85
|
+
catch (_a) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
exports.lookup = lookup;
|
|
91
|
+
/** MISS: inserta (ON CONFLICT cubre la carrera). Fire-and-forget, nunca lanza. */
|
|
92
|
+
function store(key, data) {
|
|
93
|
+
void ensureReady()
|
|
94
|
+
.then((ok) => {
|
|
95
|
+
var _a, _b;
|
|
96
|
+
if (!ok)
|
|
97
|
+
return undefined;
|
|
98
|
+
return (0, db_1.query)('INSERT INTO "LLM CACHE" ("KEY","MODEL","SYSTEM PROMPT","INPUT PROMPT","SCHEMA SIG","TEMPERATURE","OUTPUT") VALUES (?,?,?,?,?,?,?::jsonb) ON CONFLICT ("KEY") DO UPDATE SET "USE COUNT" = "LLM CACHE"."USE COUNT" + 1, "LAST USED AT" = now()', [key, data.modelName || null, data.system || null, data.prompt || null, data.schemaSig || null, (_a = data.temperature) !== null && _a !== void 0 ? _a : null, JSON.stringify((_b = data.output) !== null && _b !== void 0 ? _b : null)]);
|
|
99
|
+
})
|
|
100
|
+
.catch(() => { });
|
|
101
|
+
}
|
|
102
|
+
exports.store = store;
|
|
@@ -7,6 +7,19 @@ const constants_1 = require("./constants");
|
|
|
7
7
|
* Los precios están en USD.
|
|
8
8
|
*/
|
|
9
9
|
const MODEL_PRICING = {
|
|
10
|
+
// ⚠️ Verificar contra la tarifa real de Azure OpenAI para tu región/deployment.
|
|
11
|
+
[constants_1.AZURE_GPT_5_5_DEPLOYMENT]: {
|
|
12
|
+
inputTokenPrice: 5,
|
|
13
|
+
outputTokenPrice: 30,
|
|
14
|
+
},
|
|
15
|
+
[constants_1.AZURE_GPT_5_4_MINI_DEPLOYMENT]: {
|
|
16
|
+
inputTokenPrice: 0.75,
|
|
17
|
+
outputTokenPrice: 4.5,
|
|
18
|
+
},
|
|
19
|
+
[constants_1.AZURE_GPT_5_4_NANO_DEPLOYMENT]: {
|
|
20
|
+
inputTokenPrice: 0.2,
|
|
21
|
+
outputTokenPrice: 1.25,
|
|
22
|
+
},
|
|
10
23
|
[constants_1.GOOGLE_MODELS.FLASH]: {
|
|
11
24
|
inputTokenPrice: 0.5,
|
|
12
25
|
outputTokenPrice: 3,
|
package/lib/cjs/types/index.d.ts
CHANGED
|
@@ -21,6 +21,6 @@ import { getZone } from './workout/paceZone';
|
|
|
21
21
|
import { saveResponseTime } from './chat/saveResponseTime';
|
|
22
22
|
import { updateSenderView } from './chat/api/conversation';
|
|
23
23
|
import { transcribeAudio, describeImage, processMediaFile, reprocessRecentMedia } from './mediaProcessing';
|
|
24
|
-
import { generateObject, generateText, createGoogleModel, createGoogleModelFromString, createBedrockModelFromString, runWithCostTracking, runWithModels, MODEL_TIER, AI_MODELS, GOOGLE_MODELS, PRODUCTION_MODELS, FALLBACK_MODELS, BEDROCK_CLAUDE_OPUS, BEDROCK_CLAUDE_SONNET, BEDROCK_CLAUDE_OPUS_4_5, BEDROCK_CLAUDE_OPUS_4_1, BEDROCK_CLAUDE_SONNET_4_5, BEDROCK_CLAUDE_SONNET_4, BEDROCK_CLAUDE_HAIKU, AISTUDIO_PREFIX, MODEL_PRICING, calculateCost } from './prompt';
|
|
25
|
-
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, saveWorkoutAplication, saveWorkoutLaps, saveDoneStructuraWorkout, getZone, saveResponseTime, updateSenderView, transcribeAudio, describeImage, processMediaFile, reprocessRecentMedia, generateObject, generateText, createGoogleModel, createGoogleModelFromString, createBedrockModelFromString, runWithCostTracking, runWithModels, MODEL_TIER, AI_MODELS, GOOGLE_MODELS, PRODUCTION_MODELS, FALLBACK_MODELS, BEDROCK_CLAUDE_OPUS, BEDROCK_CLAUDE_SONNET, BEDROCK_CLAUDE_OPUS_4_5, BEDROCK_CLAUDE_OPUS_4_1, BEDROCK_CLAUDE_SONNET_4_5, BEDROCK_CLAUDE_SONNET_4, BEDROCK_CLAUDE_HAIKU, AISTUDIO_PREFIX, MODEL_PRICING, calculateCost, };
|
|
24
|
+
import { generateObject, generateText, createGoogleModel, createGoogleModelFromString, createBedrockModelFromString, createAzureModelFromString, createModelFromString, runWithCostTracking, runWithModels, MODEL_TIER, AI_MODELS, GOOGLE_MODELS, AZURE_PREFIX, AZURE_GPT_5_5_DEPLOYMENT, AZURE_GPT_5_4_MINI_DEPLOYMENT, AZURE_GPT_5_4_NANO_DEPLOYMENT, AZURE_GPT_5_5, AZURE_GPT_5_4_MINI, AZURE_GPT_5_4_NANO, AZURE_PRIMARY_MODELS, PRODUCTION_MODELS, FALLBACK_MODELS, BEDROCK_CLAUDE_OPUS, BEDROCK_CLAUDE_SONNET, BEDROCK_CLAUDE_OPUS_4_5, BEDROCK_CLAUDE_OPUS_4_1, BEDROCK_CLAUDE_SONNET_4_5, BEDROCK_CLAUDE_SONNET_4, BEDROCK_CLAUDE_HAIKU, AISTUDIO_PREFIX, MODEL_PRICING, calculateCost } from './prompt';
|
|
25
|
+
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, saveWorkoutAplication, saveWorkoutLaps, saveDoneStructuraWorkout, getZone, saveResponseTime, updateSenderView, transcribeAudio, describeImage, processMediaFile, reprocessRecentMedia, generateObject, generateText, createGoogleModel, createGoogleModelFromString, createBedrockModelFromString, createAzureModelFromString, createModelFromString, runWithCostTracking, runWithModels, MODEL_TIER, AI_MODELS, GOOGLE_MODELS, AZURE_PREFIX, AZURE_GPT_5_5_DEPLOYMENT, AZURE_GPT_5_4_MINI_DEPLOYMENT, AZURE_GPT_5_4_NANO_DEPLOYMENT, AZURE_GPT_5_5, AZURE_GPT_5_4_MINI, AZURE_GPT_5_4_NANO, AZURE_PRIMARY_MODELS, PRODUCTION_MODELS, FALLBACK_MODELS, BEDROCK_CLAUDE_OPUS, BEDROCK_CLAUDE_SONNET, BEDROCK_CLAUDE_OPUS_4_5, BEDROCK_CLAUDE_OPUS_4_1, BEDROCK_CLAUDE_SONNET_4_5, BEDROCK_CLAUDE_SONNET_4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,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,qBAAqB,EACrB,eAAe,EACf,wBAAwB,EACxB,OAAO,EACP,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,2BAA2B,EAC3B,4BAA4B,EAC5B,0BAA0B,EAC1B,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,SAAS,EACT,aAAa,EACb,YAAY,EACZ,wBAAwB,EACxB,6BAA6B,EAC7B,6BAA6B,EAC7B,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,aAAa,GACd,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../../../src/prompt/ai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,IAAI,sBAAsB,EAAE,YAAY,IAAI,oBAAoB,EAAE,MAAM,IAAI,CAAC;AAEpG,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../../../src/prompt/ai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,IAAI,sBAAsB,EAAE,YAAY,IAAI,oBAAoB,EAAE,MAAM,IAAI,CAAC;AAEpG,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAwKhE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,iBAAe,cAAc,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,GAAG,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CAoD/H;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,iBAAe,YAAY,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CA0C5H;AA2ED;;;;;;;;;;;;;;;;;GAiBG;AACH,iBAAe,mBAAmB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,SAAS,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAc5H;AAED,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Crea una instancia del modelo de Azure OpenAI a partir del nombre del deployment.
|
|
3
|
+
* Etiqueta el objeto con _productionModelName (nombre limpio, sin el prefijo "azure:")
|
|
4
|
+
* para el cálculo de costes.
|
|
5
|
+
*
|
|
6
|
+
* @param deploymentName - Nombre del deployment en Azure (ej: 'gpt-5')
|
|
7
|
+
* @returns Instancia del modelo de Azure compatible con AI SDK
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const model = createAzureModelFromString('gpt-5');
|
|
12
|
+
* const { text } = await generateText({ model, prompt });
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
declare function createAzureModelFromString(deploymentName: string): any;
|
|
16
|
+
export { createAzureModelFromString };
|
|
17
|
+
//# sourceMappingURL=azureModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"azureModel.d.ts","sourceRoot":"","sources":["../../../../src/prompt/azureModel.ts"],"names":[],"mappings":"AAyBA;;;;;;;;;;;;;GAaG;AACH,iBAAS,0BAA0B,CAAC,cAAc,EAAE,MAAM,GAAG,GAAG,CAS/D;AAED,OAAO,EAAE,0BAA0B,EAAE,CAAC"}
|
|
@@ -7,6 +7,14 @@ declare const BEDROCK_CLAUDE_SONNET_4_5 = "us.anthropic.claude-sonnet-4-5-202509
|
|
|
7
7
|
declare const BEDROCK_CLAUDE_SONNET_4 = "us.anthropic.claude-sonnet-4-20250514-v1:0";
|
|
8
8
|
declare const BEDROCK_CLAUDE_HAIKU = "us.anthropic.claude-haiku-4-5-20251001-v1:0";
|
|
9
9
|
declare const GOOGLE_MODELS: Record<ModelKey, string>;
|
|
10
|
+
declare const AZURE_PREFIX = "azure:";
|
|
11
|
+
declare const AZURE_GPT_5_5_DEPLOYMENT: string;
|
|
12
|
+
declare const AZURE_GPT_5_4_MINI_DEPLOYMENT: string;
|
|
13
|
+
declare const AZURE_GPT_5_4_NANO_DEPLOYMENT: string;
|
|
14
|
+
declare const AZURE_GPT_5_5: string;
|
|
15
|
+
declare const AZURE_GPT_5_4_MINI: string;
|
|
16
|
+
declare const AZURE_GPT_5_4_NANO: string;
|
|
17
|
+
declare const AZURE_PRIMARY_MODELS: Record<ModelKey, string>;
|
|
10
18
|
declare const PRODUCTION_MODELS: Record<ModelKey, string>;
|
|
11
19
|
declare const SEMI_MODELS: Record<ModelKey, string>;
|
|
12
20
|
declare const FAST_MODELS: Record<ModelKey, string>;
|
|
@@ -46,5 +54,5 @@ declare const AI_MODELS: Record<ModelKey, string>;
|
|
|
46
54
|
* ```
|
|
47
55
|
*/
|
|
48
56
|
declare function runWithModels<T>(modelTier: ModelTierValue, fn: () => Promise<T>): Promise<T>;
|
|
49
|
-
export { ModelKey, ModelTierValue, AI_MODELS, GOOGLE_MODELS, PRODUCTION_MODELS, SEMI_MODELS, FAST_MODELS, TRIAL_MODELS, FALLBACK_MODELS, BEDROCK_CLAUDE_OPUS, BEDROCK_CLAUDE_SONNET, BEDROCK_CLAUDE_OPUS_4_5, BEDROCK_CLAUDE_OPUS_4_1, BEDROCK_CLAUDE_SONNET_4_5, BEDROCK_CLAUDE_SONNET_4, BEDROCK_CLAUDE_HAIKU, MODEL_TIER, AISTUDIO_PREFIX, runWithModels, };
|
|
57
|
+
export { ModelKey, ModelTierValue, AI_MODELS, GOOGLE_MODELS, AZURE_PREFIX, AZURE_GPT_5_5_DEPLOYMENT, AZURE_GPT_5_4_MINI_DEPLOYMENT, AZURE_GPT_5_4_NANO_DEPLOYMENT, AZURE_GPT_5_5, AZURE_GPT_5_4_MINI, AZURE_GPT_5_4_NANO, AZURE_PRIMARY_MODELS, PRODUCTION_MODELS, SEMI_MODELS, FAST_MODELS, TRIAL_MODELS, FALLBACK_MODELS, BEDROCK_CLAUDE_OPUS, BEDROCK_CLAUDE_SONNET, BEDROCK_CLAUDE_OPUS_4_5, BEDROCK_CLAUDE_OPUS_4_1, BEDROCK_CLAUDE_SONNET_4_5, BEDROCK_CLAUDE_SONNET_4, BEDROCK_CLAUDE_HAIKU, MODEL_TIER, AISTUDIO_PREFIX, runWithModels, };
|
|
50
58
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceR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ModelKey): any;
|
|
17
|
+
/**
|
|
18
|
+
* Router de proveedores: crea una instancia de modelo a partir de un nombre de string,
|
|
19
|
+
* detectando el provider por prefijo/patrón:
|
|
20
|
+
* - "azure:<deployment>" → Azure OpenAI
|
|
21
|
+
* - contiene "anthropic." o empieza por "amazon." → AWS Bedrock
|
|
22
|
+
* - "aistudio:<modelo>" o resto → Google (AI Studio / Vertex)
|
|
23
|
+
*
|
|
24
|
+
* @param modelName - Nombre del modelo, opcionalmente con prefijo de provider
|
|
25
|
+
* @returns Instancia del modelo compatible con AI SDK
|
|
26
|
+
*/
|
|
27
|
+
declare function createModelFromString(modelName: string): any;
|
|
17
28
|
/**
|
|
18
29
|
* Crea una instancia del modelo a partir de un nombre exacto (string).
|
|
19
30
|
* Si el nombre tiene prefijo "aistudio:", usa Google AI Studio (API key).
|
|
@@ -29,5 +40,5 @@ declare function createGoogleModel(modelKey?: ModelKey): any;
|
|
|
29
40
|
* ```
|
|
30
41
|
*/
|
|
31
42
|
declare function createGoogleModelFromString(modelName: string): any;
|
|
32
|
-
export { createGoogleModel, createGoogleModelFromString };
|
|
43
|
+
export { createGoogleModel, createGoogleModelFromString, createModelFromString };
|
|
33
44
|
//# sourceMappingURL=googleModel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"googleModel.d.ts","sourceRoot":"","sources":["../../../../src/prompt/googleModel.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"googleModel.d.ts","sourceRoot":"","sources":["../../../../src/prompt/googleModel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmF,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAuB7H;;;;;;;;;;;;;GAaG;AACH,iBAAS,iBAAiB,CAAC,QAAQ,GAAE,QAAkB,GAAG,GAAG,CAW5D;AAED;;;;;;;;;GASG;AACH,iBAAS,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG,CAQrD;AAED;;;;;;;;;;;;;GAaG;AACH,iBAAS,2BAA2B,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG,CAU3D;AAED,OAAO,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { generateObject, generateText, runWithCostTracking } from './ai';
|
|
2
|
-
import { createGoogleModel, createGoogleModelFromString } from './googleModel';
|
|
3
|
-
import { AI_MODELS, GOOGLE_MODELS, PRODUCTION_MODELS, SEMI_MODELS, FAST_MODELS, TRIAL_MODELS, FALLBACK_MODELS, BEDROCK_CLAUDE_OPUS, BEDROCK_CLAUDE_SONNET, BEDROCK_CLAUDE_OPUS_4_5, BEDROCK_CLAUDE_OPUS_4_1, BEDROCK_CLAUDE_SONNET_4_5, BEDROCK_CLAUDE_SONNET_4, BEDROCK_CLAUDE_HAIKU, MODEL_TIER, AISTUDIO_PREFIX, runWithModels } from './constants';
|
|
2
|
+
import { createGoogleModel, createGoogleModelFromString, createModelFromString } from './googleModel';
|
|
3
|
+
import { AI_MODELS, GOOGLE_MODELS, AZURE_PREFIX, AZURE_GPT_5_5_DEPLOYMENT, AZURE_GPT_5_4_MINI_DEPLOYMENT, AZURE_GPT_5_4_NANO_DEPLOYMENT, AZURE_GPT_5_5, AZURE_GPT_5_4_MINI, AZURE_GPT_5_4_NANO, AZURE_PRIMARY_MODELS, PRODUCTION_MODELS, SEMI_MODELS, FAST_MODELS, TRIAL_MODELS, FALLBACK_MODELS, BEDROCK_CLAUDE_OPUS, BEDROCK_CLAUDE_SONNET, BEDROCK_CLAUDE_OPUS_4_5, BEDROCK_CLAUDE_OPUS_4_1, BEDROCK_CLAUDE_SONNET_4_5, BEDROCK_CLAUDE_SONNET_4, BEDROCK_CLAUDE_HAIKU, MODEL_TIER, AISTUDIO_PREFIX, runWithModels } from './constants';
|
|
4
4
|
import { MODEL_PRICING, calculateCost } from './modelPricing';
|
|
5
5
|
import { createBedrockModelFromString } from './bedrockModel';
|
|
6
|
-
|
|
6
|
+
import { createAzureModelFromString } from './azureModel';
|
|
7
|
+
export { generateObject, generateText, runWithCostTracking, createGoogleModel, createGoogleModelFromString, createBedrockModelFromString, createAzureModelFromString, createModelFromString, MODEL_TIER, runWithModels, AI_MODELS, GOOGLE_MODELS, AZURE_PREFIX, AZURE_GPT_5_5_DEPLOYMENT, AZURE_GPT_5_4_MINI_DEPLOYMENT, AZURE_GPT_5_4_NANO_DEPLOYMENT, AZURE_GPT_5_5, AZURE_GPT_5_4_MINI, AZURE_GPT_5_4_NANO, AZURE_PRIMARY_MODELS, PRODUCTION_MODELS, SEMI_MODELS, FAST_MODELS, TRIAL_MODELS, FALLBACK_MODELS, BEDROCK_CLAUDE_OPUS, BEDROCK_CLAUDE_SONNET, BEDROCK_CLAUDE_OPUS_4_5, BEDROCK_CLAUDE_OPUS_4_1, BEDROCK_CLAUDE_SONNET_4_5, BEDROCK_CLAUDE_SONNET_4, BEDROCK_CLAUDE_HAIKU, AISTUDIO_PREFIX, MODEL_PRICING, calculateCost, };
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtG,OAAO,EACL,SAAS,EACT,aAAa,EACb,YAAY,EACZ,wBAAwB,EACxB,6BAA6B,EAC7B,6BAA6B,EAC7B,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,EACvB,oBAAoB,EACpB,UAAU,EACV,eAAe,EACf,aAAa,EACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAEL,cAAc,EACd,YAAY,EACZ,mBAAmB,EAGnB,iBAAiB,EACjB,2BAA2B,EAC3B,4BAA4B,EAC5B,0BAA0B,EAC1B,qBAAqB,EAGrB,UAAU,EACV,aAAa,EAGb,SAAS,EACT,aAAa,EACb,YAAY,EACZ,wBAAwB,EACxB,6BAA6B,EAC7B,6BAA6B,EAC7B,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EAGf,aAAa,EACb,aAAa,GACd,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Firma ligera del schema (zod) para distinguir llamadas con el mismo prompt pero distinta forma. */
|
|
2
|
+
declare function schemaSignature(schema: any): string;
|
|
3
|
+
/**
|
|
4
|
+
* Clave determinista de una llamada: SYSTEM + INPUT + SCHEMA + TEMPERATURE.
|
|
5
|
+
* NO incluye el modelo a propósito: si esos 4 coinciden, se reutiliza el output guardado (lo haya
|
|
6
|
+
* generado el modelo que sea). Implica que cambiar de modelo NO invalida la caché.
|
|
7
|
+
*/
|
|
8
|
+
declare function llmCacheKey(opts: {
|
|
9
|
+
system?: string;
|
|
10
|
+
prompt?: string;
|
|
11
|
+
schemaSig?: string | null;
|
|
12
|
+
temperature?: number | null;
|
|
13
|
+
}): string;
|
|
14
|
+
/** HIT: incrementa USE COUNT + LAST USED y devuelve OUTPUT (atómico). null en MISS o ante error. */
|
|
15
|
+
declare function lookup(key: string): Promise<any | null>;
|
|
16
|
+
/** MISS: inserta (ON CONFLICT cubre la carrera). Fire-and-forget, nunca lanza. */
|
|
17
|
+
declare function store(key: string, data: {
|
|
18
|
+
modelName?: string;
|
|
19
|
+
system?: string;
|
|
20
|
+
prompt?: string;
|
|
21
|
+
schemaSig?: string | null;
|
|
22
|
+
temperature?: number | null;
|
|
23
|
+
output: any;
|
|
24
|
+
}): void;
|
|
25
|
+
export { schemaSignature, llmCacheKey, lookup, store };
|
|
26
|
+
//# sourceMappingURL=llmCacheStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llmCacheStore.d.ts","sourceRoot":"","sources":["../../../../src/prompt/llmCacheStore.ts"],"names":[],"mappings":"AA4BA,sGAAsG;AACtG,iBAAS,eAAe,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,CAW5C;AAED;;;;GAIG;AACH,iBAAS,WAAW,CAAC,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,MAAM,CAQ/H;AAED,oGAAoG;AACpG,iBAAe,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,CAQtD;AAED,kFAAkF;AAClF,iBAAS,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,GAAG,IAAI,CAUrK;AAED,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modelPricing.d.ts","sourceRoot":"","sources":["../../../../src/prompt/modelPricing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"modelPricing.d.ts","sourceRoot":"","sources":["../../../../src/prompt/modelPricing.ts"],"names":[],"mappings":"AAcA,UAAU,UAAU;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,UAAU,UAAU;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,QAAA,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAsD7C,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,iBAAS,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,UAAU,CAmBtG;AAED,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runnerpro/backend",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.9",
|
|
4
4
|
"description": "A collection of common backend functions",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./lib/cjs/index.js"
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@ai-sdk/amazon-bedrock": "^4.0.89",
|
|
66
|
+
"@ai-sdk/azure": "^3.0.74",
|
|
66
67
|
"@ai-sdk/google": "^3.0.43",
|
|
67
68
|
"@ai-sdk/google-vertex": "^4.0.102",
|
|
68
69
|
"@google-cloud/speech": "^7.2.1",
|