@layer-ai/core 0.5.2 → 0.5.3
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":"postgres.d.ts","sourceRoot":"","sources":["../../../src/lib/db/postgres.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAyB,MAAM,eAAe,CAAC;AAO/E,iBAAS,OAAO,IAAI,EAAE,CAAC,IAAI,CAqB1B;AA0BD,eAAO,MAAM,EAAE;gBAEK,MAAM,WAAW,GAAG,EAAE;0BASZ,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;oBAQnC,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;sBAQ3B,MAAM,gBAAgB,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;6BASrC,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;yBAQnC,MAAM,WAAW,MAAM,aAAa,MAAM,QAAQ,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;kCAQjE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;8BAO1B,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;qBAQnC,MAAM,UAAU,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;iCAS7B,MAAM,YAAY,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;4BAQpD,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;uBAQ7B,MAAM,QAAQ,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../../src/lib/db/postgres.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,KAAK,EAAE,IAAI,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;AAEF,eAAe,OAAO,CAAC"}
|
package/dist/lib/db/postgres.js
CHANGED
|
@@ -94,8 +94,8 @@ export const db = {
|
|
|
94
94
|
return result.rows.map(toCamelCase);
|
|
95
95
|
},
|
|
96
96
|
async createGate(userId, data) {
|
|
97
|
-
const result = await getPool().query(`INSERT INTO gates (user_id, name, description, task_type, model, system_prompt, allow_overrides, temperature, max_tokens, top_p, tags, routing_strategy, fallback_models, cost_weight, latency_weight, quality_weight, reanalysis_period)
|
|
98
|
-
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17) RETURNING *`, [
|
|
97
|
+
const result = await getPool().query(`INSERT INTO gates (user_id, name, description, task_type, model, system_prompt, allow_overrides, temperature, max_tokens, top_p, tags, routing_strategy, fallback_models, cost_weight, latency_weight, quality_weight, reanalysis_period, task_analysis)
|
|
98
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18) RETURNING *`, [
|
|
99
99
|
userId,
|
|
100
100
|
data.name,
|
|
101
101
|
data.description,
|
|
@@ -112,7 +112,8 @@ export const db = {
|
|
|
112
112
|
data.costWeight ?? 0.33,
|
|
113
113
|
data.latencyWeight ?? 0.33,
|
|
114
114
|
data.qualityWeight ?? 0.34,
|
|
115
|
-
data.reanalysisPeriod || 'never'
|
|
115
|
+
data.reanalysisPeriod || 'never',
|
|
116
|
+
data.taskAnalysis ? JSON.stringify(data.taskAnalysis) : null
|
|
116
117
|
]);
|
|
117
118
|
return toCamelCase(result.rows[0]);
|
|
118
119
|
},
|
|
@@ -137,6 +138,7 @@ export const db = {
|
|
|
137
138
|
latency_weight = COALESCE($14, latency_weight),
|
|
138
139
|
quality_weight = COALESCE($15, quality_weight),
|
|
139
140
|
reanalysis_period = COALESCE($16, reanalysis_period),
|
|
141
|
+
task_analysis = COALESCE($17, task_analysis),
|
|
140
142
|
updated_at = NOW()
|
|
141
143
|
WHERE id = $1 RETURNING *`, [
|
|
142
144
|
id,
|
|
@@ -155,6 +157,7 @@ export const db = {
|
|
|
155
157
|
data.latencyWeight,
|
|
156
158
|
data.qualityWeight,
|
|
157
159
|
data.reanalysisPeriod,
|
|
160
|
+
data.taskAnalysis ? JSON.stringify(data.taskAnalysis) : null,
|
|
158
161
|
]);
|
|
159
162
|
return result.rows[0] ? toCamelCase(result.rows[0]) : null;
|
|
160
163
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gates.d.ts","sourceRoot":"","sources":["../../src/routes/gates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AAOpD,QAAA,MAAM,MAAM,EAAE,UAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"gates.d.ts","sourceRoot":"","sources":["../../src/routes/gates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AAOpD,QAAA,MAAM,MAAM,EAAE,UAAqB,CAAC;AA0TpC,eAAe,MAAM,CAAC"}
|
package/dist/routes/gates.js
CHANGED
|
@@ -13,7 +13,7 @@ router.post('/', async (req, res) => {
|
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
15
|
try {
|
|
16
|
-
const { name, description, model, systemPrompt, allowOverrides, temperature, maxTokens, topP, tags, routingStrategy, fallbackModels } = req.body;
|
|
16
|
+
const { name, description, taskType, model, systemPrompt, allowOverrides, temperature, maxTokens, topP, tags, routingStrategy, fallbackModels, costWeight, latencyWeight, qualityWeight, reanalysisPeriod, taskAnalysis } = req.body;
|
|
17
17
|
if (!name || !model) {
|
|
18
18
|
res.status(400).json({ error: 'bad_request', message: 'Missing required fields: name and model' });
|
|
19
19
|
return;
|
|
@@ -30,6 +30,7 @@ router.post('/', async (req, res) => {
|
|
|
30
30
|
const gate = await db.createGate(req.userId, {
|
|
31
31
|
name,
|
|
32
32
|
description,
|
|
33
|
+
taskType,
|
|
33
34
|
model,
|
|
34
35
|
systemPrompt,
|
|
35
36
|
allowOverrides,
|
|
@@ -39,6 +40,11 @@ router.post('/', async (req, res) => {
|
|
|
39
40
|
tags,
|
|
40
41
|
routingStrategy,
|
|
41
42
|
fallbackModels,
|
|
43
|
+
costWeight,
|
|
44
|
+
latencyWeight,
|
|
45
|
+
qualityWeight,
|
|
46
|
+
reanalysisPeriod,
|
|
47
|
+
taskAnalysis,
|
|
42
48
|
});
|
|
43
49
|
res.status(201).json(gate);
|
|
44
50
|
}
|
|
@@ -111,7 +117,7 @@ router.patch('/name/:name', async (req, res) => {
|
|
|
111
117
|
return;
|
|
112
118
|
}
|
|
113
119
|
try {
|
|
114
|
-
const { description, model, systemPrompt, allowOverrides, temperature, maxTokens, topP, tags, routingStrategy, fallbackModels } = req.body;
|
|
120
|
+
const { description, taskType, model, systemPrompt, allowOverrides, temperature, maxTokens, topP, tags, routingStrategy, fallbackModels, costWeight, latencyWeight, qualityWeight, reanalysisPeriod, taskAnalysis } = req.body;
|
|
115
121
|
const existing = await db.getGateByUserAndName(req.userId, req.params.name);
|
|
116
122
|
if (!existing) {
|
|
117
123
|
res.status(404).json({ error: 'not_found', message: 'Gate not found' });
|
|
@@ -123,6 +129,7 @@ router.patch('/name/:name', async (req, res) => {
|
|
|
123
129
|
}
|
|
124
130
|
const updated = await db.updateGate(existing.id, {
|
|
125
131
|
description,
|
|
132
|
+
taskType,
|
|
126
133
|
model,
|
|
127
134
|
systemPrompt,
|
|
128
135
|
allowOverrides,
|
|
@@ -132,6 +139,11 @@ router.patch('/name/:name', async (req, res) => {
|
|
|
132
139
|
tags,
|
|
133
140
|
routingStrategy,
|
|
134
141
|
fallbackModels,
|
|
142
|
+
costWeight,
|
|
143
|
+
latencyWeight,
|
|
144
|
+
qualityWeight,
|
|
145
|
+
reanalysisPeriod,
|
|
146
|
+
taskAnalysis,
|
|
135
147
|
});
|
|
136
148
|
await cache.invalidateGate(req.userId, existing.name);
|
|
137
149
|
res.json(updated);
|
|
@@ -148,7 +160,7 @@ router.patch('/:id', async (req, res) => {
|
|
|
148
160
|
return;
|
|
149
161
|
}
|
|
150
162
|
try {
|
|
151
|
-
const { description, model, systemPrompt, allowOverrides, temperature, maxTokens, topP, tags, routingStrategy, fallbackModels } = req.body;
|
|
163
|
+
const { description, taskType, model, systemPrompt, allowOverrides, temperature, maxTokens, topP, tags, routingStrategy, fallbackModels, costWeight, latencyWeight, qualityWeight, reanalysisPeriod, taskAnalysis } = req.body;
|
|
152
164
|
const existing = await db.getGateById(req.params.id);
|
|
153
165
|
if (!existing) {
|
|
154
166
|
res.status(404).json({ error: 'not_found', message: 'Gate not found' });
|
|
@@ -164,6 +176,7 @@ router.patch('/:id', async (req, res) => {
|
|
|
164
176
|
}
|
|
165
177
|
const updated = await db.updateGate(req.params.id, {
|
|
166
178
|
description,
|
|
179
|
+
taskType,
|
|
167
180
|
model,
|
|
168
181
|
systemPrompt,
|
|
169
182
|
allowOverrides,
|
|
@@ -173,6 +186,11 @@ router.patch('/:id', async (req, res) => {
|
|
|
173
186
|
tags,
|
|
174
187
|
routingStrategy,
|
|
175
188
|
fallbackModels,
|
|
189
|
+
costWeight,
|
|
190
|
+
latencyWeight,
|
|
191
|
+
qualityWeight,
|
|
192
|
+
reanalysisPeriod,
|
|
193
|
+
taskAnalysis,
|
|
176
194
|
});
|
|
177
195
|
await cache.invalidateGate(req.userId, existing.name);
|
|
178
196
|
res.json(updated);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layer-ai/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "Core API routes and services for Layer AI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"nanoid": "^5.0.4",
|
|
37
37
|
"openai": "^4.24.0",
|
|
38
38
|
"pg": "^8.11.3",
|
|
39
|
-
"@layer-ai/sdk": "^0.5.
|
|
39
|
+
"@layer-ai/sdk": "^0.5.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/bcryptjs": "^2.4.6",
|