@layer-ai/core 2.0.21 → 2.0.22
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gates.d.ts","sourceRoot":"","sources":["../../../src/routes/v1/gates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AASpD,QAAA,MAAM,MAAM,EAAE,UAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"gates.d.ts","sourceRoot":"","sources":["../../../src/routes/v1/gates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AASpD,QAAA,MAAM,MAAM,EAAE,UAAqB,CAAC;AAwhBpC,eAAe,MAAM,CAAC"}
|
package/dist/routes/v1/gates.js
CHANGED
|
@@ -416,7 +416,7 @@ router.post('/suggestions', async (req, res) => {
|
|
|
416
416
|
return;
|
|
417
417
|
}
|
|
418
418
|
try {
|
|
419
|
-
const { description, costWeight, latencyWeight, qualityWeight } = req.body;
|
|
419
|
+
const { description, costWeight, latencyWeight, qualityWeight, availableProviders } = req.body;
|
|
420
420
|
if (!description) {
|
|
421
421
|
res.status(400).json({ error: 'bad_request', message: 'Gate must have a description for AI recommendations' });
|
|
422
422
|
return;
|
|
@@ -425,6 +425,7 @@ router.post('/suggestions', async (req, res) => {
|
|
|
425
425
|
costWeight: parseFloat(costWeight ?? '0.33'),
|
|
426
426
|
latencyWeight: parseFloat(latencyWeight ?? '0.33'),
|
|
427
427
|
qualityWeight: parseFloat(qualityWeight ?? '0.34'),
|
|
428
|
+
availableProviders: Array.isArray(availableProviders) ? availableProviders : undefined,
|
|
428
429
|
};
|
|
429
430
|
const { analyzeTask } = await import('../../services/task-analysis.js');
|
|
430
431
|
const suggestions = await analyzeTask(description, userPreferences);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-analysis.d.ts","sourceRoot":"","sources":["../../src/services/task-analysis.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,YAAY,EAAmC,MAAM,eAAe,CAAC;AA2D9F,wBAAsB,WAAW,CAC/B,WAAW,EAAE,MAAM,EACnB,eAAe,CAAC,EAAE;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"task-analysis.d.ts","sourceRoot":"","sources":["../../src/services/task-analysis.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,YAAY,EAAmC,MAAM,eAAe,CAAC;AA2D9F,wBAAsB,WAAW,CAC/B,WAAW,EAAE,MAAM,EACnB,eAAe,CAAC,EAAE;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC/B,GACA,OAAO,CAAC,YAAY,CAAC,CA6HvB"}
|
|
@@ -57,6 +57,7 @@ export async function analyzeTask(description, userPreferences) {
|
|
|
57
57
|
const costWeight = userPreferences?.costWeight ?? 0.33;
|
|
58
58
|
const latencyWeight = userPreferences?.latencyWeight ?? 0.33;
|
|
59
59
|
const qualityWeight = userPreferences?.qualityWeight ?? 0.33;
|
|
60
|
+
const availableProviders = userPreferences?.availableProviders;
|
|
60
61
|
let taskType = 'chat';
|
|
61
62
|
try {
|
|
62
63
|
taskType = await detectTaskType(description, anthropic);
|
|
@@ -66,9 +67,17 @@ export async function analyzeTask(description, userPreferences) {
|
|
|
66
67
|
}
|
|
67
68
|
const filteredRegistry = {};
|
|
68
69
|
for (const [key, model] of Object.entries(MODEL_REGISTRY)) {
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
// Filter by task type
|
|
71
|
+
if (model.type !== taskType) {
|
|
72
|
+
continue;
|
|
71
73
|
}
|
|
74
|
+
// Filter by BYOK providers if specified
|
|
75
|
+
if (availableProviders && availableProviders.length > 0) {
|
|
76
|
+
if (!availableProviders.includes(model.provider)) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
filteredRegistry[key] = model;
|
|
72
81
|
}
|
|
73
82
|
const registryContext = JSON.stringify(filteredRegistry, null, 2);
|
|
74
83
|
const prompt = `You are analyzing a task to recommend the best AI models from our registry.
|