@layer-ai/core 0.9.2 → 1.0.0
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/dist/routes/v1/gates.js +2 -2
- package/dist/routes/v2/complete.d.ts.map +1 -1
- package/dist/routes/v2/complete.js +11 -30
- package/dist/routes/v2/tests/test-byok-completion.js +1 -1
- package/dist/routes/v2/tests/test-complete-anthropic.js +4 -4
- package/dist/routes/v2/tests/test-complete-openai.js +7 -7
- package/dist/routes/v2/tests/test-complete-routing.js +5 -5
- package/dist/services/providers/tests/test-anthropic-adapter.js +4 -4
- package/dist/services/providers/tests/test-google-adapter.js +9 -9
- package/dist/services/providers/tests/test-mistral-adapter.js +11 -11
- package/dist/services/providers/tests/test-openai-adapter.js +8 -8
- package/package.json +2 -2
package/dist/routes/v1/gates.js
CHANGED
|
@@ -327,7 +327,7 @@ router.post('/test', async (req, res) => {
|
|
|
327
327
|
try {
|
|
328
328
|
const request = {
|
|
329
329
|
type: 'chat',
|
|
330
|
-
|
|
330
|
+
gateId: finalGate.id,
|
|
331
331
|
model: finalGate.model,
|
|
332
332
|
data: {
|
|
333
333
|
messages,
|
|
@@ -363,7 +363,7 @@ router.post('/test', async (req, res) => {
|
|
|
363
363
|
try {
|
|
364
364
|
const request = {
|
|
365
365
|
type: 'chat',
|
|
366
|
-
|
|
366
|
+
gateId: finalGate.id,
|
|
367
367
|
model: fallbackModel,
|
|
368
368
|
data: {
|
|
369
369
|
messages,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"complete.d.ts","sourceRoot":"","sources":["../../../src/routes/v2/complete.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":"complete.d.ts","sourceRoot":"","sources":["../../../src/routes/v2/complete.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AASpD,QAAA,MAAM,MAAM,EAAE,UAAqB,CAAC;AA+OpC,eAAe,MAAM,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
2
|
import { db } from '../../lib/db/postgres.js';
|
|
3
|
-
import { cache } from '../../lib/db/redis.js';
|
|
4
3
|
import { authenticate } from '../../middleware/auth.js';
|
|
5
4
|
import { callAdapter, normalizeModelId } from '../../lib/provider-factory.js';
|
|
6
5
|
import { OverrideField } from '@layer-ai/sdk';
|
|
@@ -13,29 +12,6 @@ function isOverrideAllowed(allowOverrides, field) {
|
|
|
13
12
|
return false;
|
|
14
13
|
return allowOverrides[field] ?? false;
|
|
15
14
|
}
|
|
16
|
-
async function getGateConfig(userId, gateIdentifier) {
|
|
17
|
-
const isUUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(gateIdentifier);
|
|
18
|
-
let gateConfig = null;
|
|
19
|
-
if (isUUID) {
|
|
20
|
-
gateConfig = await cache.getGateById(userId, gateIdentifier);
|
|
21
|
-
if (!gateConfig) {
|
|
22
|
-
gateConfig = await db.getGateByUserAndId(userId, gateIdentifier);
|
|
23
|
-
if (gateConfig) {
|
|
24
|
-
await cache.setGate(userId, gateConfig.name, gateConfig);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
gateConfig = await cache.getGate(userId, gateIdentifier);
|
|
30
|
-
if (!gateConfig) {
|
|
31
|
-
gateConfig = await db.getGateByUserAndName(userId, gateIdentifier);
|
|
32
|
-
if (gateConfig) {
|
|
33
|
-
await cache.setGate(userId, gateIdentifier, gateConfig);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return gateConfig;
|
|
38
|
-
}
|
|
39
15
|
function resolveFinalRequest(gateConfig, request) {
|
|
40
16
|
const finalRequest = { ...request };
|
|
41
17
|
let finalModel = gateConfig.model;
|
|
@@ -141,18 +117,23 @@ router.post('/', authenticate, async (req, res) => {
|
|
|
141
117
|
let request = null;
|
|
142
118
|
try {
|
|
143
119
|
const rawRequest = req.body;
|
|
144
|
-
if (!rawRequest.
|
|
145
|
-
res.status(400).json({ error: 'bad_request', message: 'Missing required field:
|
|
120
|
+
if (!rawRequest.gateId) {
|
|
121
|
+
res.status(400).json({ error: 'bad_request', message: 'Missing required field: gateId' });
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const isUUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(rawRequest.gateId);
|
|
125
|
+
if (!isUUID) {
|
|
126
|
+
res.status(400).json({ error: 'bad_request', message: 'gateId must be a valid UUID. Gate names are no longer supported.' });
|
|
146
127
|
return;
|
|
147
128
|
}
|
|
148
|
-
gateConfig = await
|
|
129
|
+
gateConfig = await db.getGateByUserAndId(userId, rawRequest.gateId);
|
|
149
130
|
if (!gateConfig) {
|
|
150
|
-
res.status(404).json({ error: 'not_found', message: `Gate "${rawRequest.
|
|
131
|
+
res.status(404).json({ error: 'not_found', message: `Gate with ID "${rawRequest.gateId}" not found` });
|
|
151
132
|
return;
|
|
152
133
|
}
|
|
153
134
|
const requestType = rawRequest.type || gateConfig.taskType || 'chat';
|
|
154
135
|
request = {
|
|
155
|
-
|
|
136
|
+
gateId: rawRequest.gateId,
|
|
156
137
|
type: requestType,
|
|
157
138
|
data: rawRequest.data,
|
|
158
139
|
model: rawRequest.model,
|
|
@@ -171,7 +152,7 @@ router.post('/', authenticate, async (req, res) => {
|
|
|
171
152
|
db.logRequest({
|
|
172
153
|
userId,
|
|
173
154
|
gateId: gateConfig.id,
|
|
174
|
-
gateName:
|
|
155
|
+
gateName: gateConfig.name,
|
|
175
156
|
modelRequested: request.model || gateConfig.model,
|
|
176
157
|
modelUsed: modelUsed,
|
|
177
158
|
promptTokens: result.usage?.promptTokens || 0,
|
|
@@ -12,7 +12,7 @@ import { GoogleAdapter } from '../../../services/providers/google-adapter.js';
|
|
|
12
12
|
// Test user ID from the database
|
|
13
13
|
const TEST_USER_ID = 'ebd64998-465d-4211-ad67-87b4e01ad0da';
|
|
14
14
|
const SIMPLE_REQUEST = {
|
|
15
|
-
|
|
15
|
+
gateId: 'byok-test',
|
|
16
16
|
model: 'gpt-4o-mini',
|
|
17
17
|
type: 'chat',
|
|
18
18
|
data: {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
async function testBasicChat() {
|
|
4
4
|
console.log('Test 1: Basic chat completion with Anthropic\n');
|
|
5
5
|
const request = {
|
|
6
|
-
|
|
6
|
+
gateId: 'test-gate',
|
|
7
7
|
model: 'claude-sonnet-4-5-20250929',
|
|
8
8
|
type: 'chat',
|
|
9
9
|
data: {
|
|
@@ -27,7 +27,7 @@ async function testBasicChat() {
|
|
|
27
27
|
async function testVision() {
|
|
28
28
|
console.log('\n\nTest 2: Vision with Anthropic (not supported in v1)\n');
|
|
29
29
|
const request = {
|
|
30
|
-
|
|
30
|
+
gateId: 'test-gate',
|
|
31
31
|
model: 'claude-sonnet-4-5-20250929',
|
|
32
32
|
type: 'chat',
|
|
33
33
|
data: {
|
|
@@ -49,7 +49,7 @@ async function testVision() {
|
|
|
49
49
|
async function testToolCalls() {
|
|
50
50
|
console.log('\n\nTest 3: Tool calls with Anthropic (not supported in v1)\n');
|
|
51
51
|
const request = {
|
|
52
|
-
|
|
52
|
+
gateId: 'test-gate',
|
|
53
53
|
model: 'claude-sonnet-4-5-20250929',
|
|
54
54
|
type: 'chat',
|
|
55
55
|
data: {
|
|
@@ -86,7 +86,7 @@ async function testToolCalls() {
|
|
|
86
86
|
async function testSystemPrompt() {
|
|
87
87
|
console.log('\n\nTest 4: System prompt and advanced params\n');
|
|
88
88
|
const request = {
|
|
89
|
-
|
|
89
|
+
gateId: 'test-gate',
|
|
90
90
|
model: 'claude-sonnet-4-5-20250929',
|
|
91
91
|
type: 'chat',
|
|
92
92
|
data: {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
async function testBasicChat() {
|
|
4
4
|
console.log('Test 1: Basic chat completion with OpenAI\n');
|
|
5
5
|
const request = {
|
|
6
|
-
|
|
6
|
+
gateId: 'test-gate',
|
|
7
7
|
model: 'gpt-4o-mini',
|
|
8
8
|
type: 'chat',
|
|
9
9
|
data: {
|
|
@@ -26,7 +26,7 @@ async function testBasicChat() {
|
|
|
26
26
|
async function testVision() {
|
|
27
27
|
console.log('\n\nTest 2: Vision with GPT-4o\n');
|
|
28
28
|
const request = {
|
|
29
|
-
|
|
29
|
+
gateId: 'test-gate',
|
|
30
30
|
model: 'gpt-4o',
|
|
31
31
|
type: 'chat',
|
|
32
32
|
data: {
|
|
@@ -49,7 +49,7 @@ async function testVision() {
|
|
|
49
49
|
async function testToolCalls() {
|
|
50
50
|
console.log('\n\nTest 3: Tool calls with GPT-4\n');
|
|
51
51
|
const request = {
|
|
52
|
-
|
|
52
|
+
gateId: 'test-gate',
|
|
53
53
|
model: 'gpt-4o-mini',
|
|
54
54
|
type: 'chat',
|
|
55
55
|
data: {
|
|
@@ -85,7 +85,7 @@ async function testToolCalls() {
|
|
|
85
85
|
async function testImageGeneration() {
|
|
86
86
|
console.log('\n\nTest 4: Image generation with DALL-E\n');
|
|
87
87
|
const request = {
|
|
88
|
-
|
|
88
|
+
gateId: 'test-gate',
|
|
89
89
|
model: 'dall-e-3',
|
|
90
90
|
type: 'image',
|
|
91
91
|
data: {
|
|
@@ -102,7 +102,7 @@ async function testImageGeneration() {
|
|
|
102
102
|
async function testEmbeddings() {
|
|
103
103
|
console.log('\n\nTest 5: Text embeddings\n');
|
|
104
104
|
const request = {
|
|
105
|
-
|
|
105
|
+
gateId: 'test-gate',
|
|
106
106
|
model: 'text-embedding-3-small',
|
|
107
107
|
type: 'embeddings',
|
|
108
108
|
data: {
|
|
@@ -117,7 +117,7 @@ async function testEmbeddings() {
|
|
|
117
117
|
async function testTextToSpeech() {
|
|
118
118
|
console.log('\n\nTest 6: Text-to-speech\n');
|
|
119
119
|
const request = {
|
|
120
|
-
|
|
120
|
+
gateId: 'test-gate',
|
|
121
121
|
model: 'tts-1',
|
|
122
122
|
type: 'tts',
|
|
123
123
|
data: {
|
|
@@ -133,7 +133,7 @@ async function testTextToSpeech() {
|
|
|
133
133
|
async function testResponseFormat() {
|
|
134
134
|
console.log('\n\nTest 7: JSON response format\n');
|
|
135
135
|
const request = {
|
|
136
|
-
|
|
136
|
+
gateId: 'test-gate',
|
|
137
137
|
model: 'gpt-4o-mini',
|
|
138
138
|
type: 'chat',
|
|
139
139
|
data: {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
async function testFallbackRouting() {
|
|
4
4
|
console.log('Test 1: Fallback routing (Anthropic -> OpenAI)\n');
|
|
5
5
|
const request = {
|
|
6
|
-
|
|
6
|
+
gateId: 'test-gate-with-fallback',
|
|
7
7
|
model: 'claude-sonnet-4-5-20250929', // Primary model
|
|
8
8
|
type: 'chat',
|
|
9
9
|
data: {
|
|
@@ -27,7 +27,7 @@ async function testFallbackRouting() {
|
|
|
27
27
|
async function testRoundRobinRouting() {
|
|
28
28
|
console.log('\n\nTest 2: Round-robin routing across providers\n');
|
|
29
29
|
const request = {
|
|
30
|
-
|
|
30
|
+
gateId: 'test-gate-with-round-robin',
|
|
31
31
|
model: 'claude-sonnet-4-5-20250929',
|
|
32
32
|
type: 'chat',
|
|
33
33
|
data: {
|
|
@@ -50,7 +50,7 @@ async function testRoundRobinRouting() {
|
|
|
50
50
|
async function testCrossProviderFallback() {
|
|
51
51
|
console.log('\n\nTest 3: Cross-provider fallback with vision\n');
|
|
52
52
|
const request = {
|
|
53
|
-
|
|
53
|
+
gateId: 'test-gate-vision-fallback',
|
|
54
54
|
model: 'claude-sonnet-4-5-20250929',
|
|
55
55
|
type: 'chat',
|
|
56
56
|
data: {
|
|
@@ -78,7 +78,7 @@ async function testCrossProviderFallback() {
|
|
|
78
78
|
async function testToolCallsFallback() {
|
|
79
79
|
console.log('\n\nTest 4: Fallback routing with tool calls\n');
|
|
80
80
|
const request = {
|
|
81
|
-
|
|
81
|
+
gateId: 'test-gate-tools-fallback',
|
|
82
82
|
model: 'gpt-4o-mini',
|
|
83
83
|
type: 'chat',
|
|
84
84
|
data: {
|
|
@@ -117,7 +117,7 @@ async function testToolCallsFallback() {
|
|
|
117
117
|
async function testCostOptimization() {
|
|
118
118
|
console.log('\n\nTest 5: Cost optimization with round-robin\n');
|
|
119
119
|
const request = {
|
|
120
|
-
|
|
120
|
+
gateId: 'test-gate-cost-optimization',
|
|
121
121
|
model: 'gpt-4o-mini',
|
|
122
122
|
type: 'chat',
|
|
123
123
|
data: {
|
|
@@ -3,7 +3,7 @@ const adapter = new AnthropicAdapter();
|
|
|
3
3
|
async function testChatCompletion() {
|
|
4
4
|
console.log('Testing chat completion...');
|
|
5
5
|
const request = {
|
|
6
|
-
|
|
6
|
+
gateId: 'test-gate',
|
|
7
7
|
model: 'claude-sonnet-4-5-20250929',
|
|
8
8
|
type: 'chat',
|
|
9
9
|
data: {
|
|
@@ -25,7 +25,7 @@ async function testChatCompletion() {
|
|
|
25
25
|
async function testChatWithVision() {
|
|
26
26
|
console.log('Testing chat with vision...');
|
|
27
27
|
const request = {
|
|
28
|
-
|
|
28
|
+
gateId: 'test-gate',
|
|
29
29
|
model: 'claude-sonnet-4-5-20250929',
|
|
30
30
|
type: 'chat',
|
|
31
31
|
data: {
|
|
@@ -50,7 +50,7 @@ async function testToolCalls() {
|
|
|
50
50
|
console.log('Testing tool calls...');
|
|
51
51
|
// Step 1: Initial request with tool available
|
|
52
52
|
const request = {
|
|
53
|
-
|
|
53
|
+
gateId: 'test-gate',
|
|
54
54
|
model: 'claude-sonnet-4-5-20250929',
|
|
55
55
|
type: 'chat',
|
|
56
56
|
data: {
|
|
@@ -91,7 +91,7 @@ async function testToolCalls() {
|
|
|
91
91
|
console.log('Function arguments:', toolCall.function.arguments);
|
|
92
92
|
// Step 2: Send tool response back
|
|
93
93
|
const toolResponseRequest = {
|
|
94
|
-
|
|
94
|
+
gateId: 'test-gate',
|
|
95
95
|
model: 'claude-sonnet-4-5-20250929',
|
|
96
96
|
type: 'chat',
|
|
97
97
|
data: {
|
|
@@ -4,7 +4,7 @@ const adapter = new GoogleAdapter();
|
|
|
4
4
|
async function testChatCompletion() {
|
|
5
5
|
console.log('Testing chat completion...');
|
|
6
6
|
const request = {
|
|
7
|
-
|
|
7
|
+
gateId: 'test-gate',
|
|
8
8
|
model: 'gemini-2.5-flash',
|
|
9
9
|
type: 'chat',
|
|
10
10
|
data: {
|
|
@@ -26,7 +26,7 @@ async function testChatCompletion() {
|
|
|
26
26
|
async function testChatWithVision() {
|
|
27
27
|
console.log('Testing chat with vision...');
|
|
28
28
|
const request = {
|
|
29
|
-
|
|
29
|
+
gateId: 'test-gate',
|
|
30
30
|
model: 'gemini-2.5-flash',
|
|
31
31
|
type: 'chat',
|
|
32
32
|
data: {
|
|
@@ -52,7 +52,7 @@ async function testChatWithVision() {
|
|
|
52
52
|
async function testImageGeneration() {
|
|
53
53
|
console.log('Testing image generation...');
|
|
54
54
|
const request = {
|
|
55
|
-
|
|
55
|
+
gateId: 'test-gate',
|
|
56
56
|
model: 'imagen-4.0-generate-001',
|
|
57
57
|
type: 'image',
|
|
58
58
|
data: {
|
|
@@ -69,7 +69,7 @@ async function testImageGeneration() {
|
|
|
69
69
|
async function testEmbeddings() {
|
|
70
70
|
console.log('Testing embeddings...');
|
|
71
71
|
const request = {
|
|
72
|
-
|
|
72
|
+
gateId: 'test-gate',
|
|
73
73
|
model: 'text-embedding-004',
|
|
74
74
|
type: 'embeddings',
|
|
75
75
|
data: {
|
|
@@ -85,7 +85,7 @@ async function testToolCalling() {
|
|
|
85
85
|
console.log('Testing tool calling...');
|
|
86
86
|
// Step 1: Send message with tools available
|
|
87
87
|
const request = {
|
|
88
|
-
|
|
88
|
+
gateId: 'test-gate',
|
|
89
89
|
model: 'gemini-2.5-flash',
|
|
90
90
|
type: 'chat',
|
|
91
91
|
data: {
|
|
@@ -122,7 +122,7 @@ async function testToolCalling() {
|
|
|
122
122
|
console.log('Function arguments:', toolCall.function.arguments);
|
|
123
123
|
// Step 2: Send tool response back
|
|
124
124
|
const toolResponseRequest = {
|
|
125
|
-
|
|
125
|
+
gateId: 'test-gate',
|
|
126
126
|
model: 'gemini-2.5-flash',
|
|
127
127
|
type: 'chat',
|
|
128
128
|
data: {
|
|
@@ -149,7 +149,7 @@ async function testToolCalling() {
|
|
|
149
149
|
async function testEmbeddingsMultiple() {
|
|
150
150
|
console.log('Testing multiple embeddings...');
|
|
151
151
|
const request = {
|
|
152
|
-
|
|
152
|
+
gateId: 'test-gate',
|
|
153
153
|
model: 'text-embedding-004',
|
|
154
154
|
type: 'embeddings',
|
|
155
155
|
data: {
|
|
@@ -165,7 +165,7 @@ async function testEmbeddingsMultiple() {
|
|
|
165
165
|
async function testTextToSpeech() {
|
|
166
166
|
console.log('Testing text-to-speech...');
|
|
167
167
|
const request = {
|
|
168
|
-
|
|
168
|
+
gateId: 'test-gate',
|
|
169
169
|
model: 'gemini-2.5-flash-preview-tts',
|
|
170
170
|
type: 'tts',
|
|
171
171
|
data: {
|
|
@@ -182,7 +182,7 @@ async function testTextToSpeech() {
|
|
|
182
182
|
async function testVideoGeneration() {
|
|
183
183
|
console.log('Testing video generation (this may take a few minutes)...');
|
|
184
184
|
const request = {
|
|
185
|
-
|
|
185
|
+
gateId: 'test-gate',
|
|
186
186
|
model: 'veo-2.0-generate-001',
|
|
187
187
|
type: 'video',
|
|
188
188
|
data: {
|
|
@@ -6,7 +6,7 @@ const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
|
6
6
|
async function testChatCompletion() {
|
|
7
7
|
console.log('--- Testing Chat Completion ---');
|
|
8
8
|
const request = {
|
|
9
|
-
|
|
9
|
+
gateId: 'test-gate',
|
|
10
10
|
type: 'chat',
|
|
11
11
|
model: 'mistral-small-latest',
|
|
12
12
|
data: {
|
|
@@ -31,7 +31,7 @@ async function testChatCompletion() {
|
|
|
31
31
|
async function testChatWithSystemPrompt() {
|
|
32
32
|
console.log('--- Testing Chat with System Prompt ---');
|
|
33
33
|
const request = {
|
|
34
|
-
|
|
34
|
+
gateId: 'test-gate',
|
|
35
35
|
type: 'chat',
|
|
36
36
|
model: 'mistral-small-latest',
|
|
37
37
|
data: {
|
|
@@ -54,7 +54,7 @@ async function testChatWithSystemPrompt() {
|
|
|
54
54
|
async function testChatWithTools() {
|
|
55
55
|
console.log('--- Testing Chat with Tools ---');
|
|
56
56
|
const request = {
|
|
57
|
-
|
|
57
|
+
gateId: 'test-gate',
|
|
58
58
|
type: 'chat',
|
|
59
59
|
model: 'mistral-small-latest',
|
|
60
60
|
data: {
|
|
@@ -102,7 +102,7 @@ async function testToolResponse() {
|
|
|
102
102
|
console.log('--- Testing Tool Response Flow ---');
|
|
103
103
|
// First, get the tool call
|
|
104
104
|
const initialRequest = {
|
|
105
|
-
|
|
105
|
+
gateId: 'test-gate',
|
|
106
106
|
type: 'chat',
|
|
107
107
|
model: 'mistral-small-latest',
|
|
108
108
|
data: {
|
|
@@ -143,7 +143,7 @@ async function testToolResponse() {
|
|
|
143
143
|
const toolCall = initialResponse.toolCalls[0];
|
|
144
144
|
await delay(2000);
|
|
145
145
|
const followUpRequest = {
|
|
146
|
-
|
|
146
|
+
gateId: 'test-gate',
|
|
147
147
|
type: 'chat',
|
|
148
148
|
model: 'mistral-small-latest',
|
|
149
149
|
data: {
|
|
@@ -175,7 +175,7 @@ async function testToolResponse() {
|
|
|
175
175
|
async function testEmbeddings() {
|
|
176
176
|
console.log('--- Testing Embeddings ---');
|
|
177
177
|
const request = {
|
|
178
|
-
|
|
178
|
+
gateId: 'test-gate',
|
|
179
179
|
type: 'embeddings',
|
|
180
180
|
model: 'mistral-embed',
|
|
181
181
|
data: {
|
|
@@ -193,7 +193,7 @@ async function testVisionCapability() {
|
|
|
193
193
|
console.log('--- Testing Vision Capability (Pixtral) ---');
|
|
194
194
|
// Use a public image URL for testing
|
|
195
195
|
const request = {
|
|
196
|
-
|
|
196
|
+
gateId: 'test-gate',
|
|
197
197
|
type: 'chat',
|
|
198
198
|
model: 'pixtral-large-2411',
|
|
199
199
|
data: {
|
|
@@ -224,7 +224,7 @@ async function testVisionCapability() {
|
|
|
224
224
|
async function testResponseFormat() {
|
|
225
225
|
console.log('--- Testing JSON Response Format ---');
|
|
226
226
|
const request = {
|
|
227
|
-
|
|
227
|
+
gateId: 'test-gate',
|
|
228
228
|
type: 'chat',
|
|
229
229
|
model: 'mistral-small-latest',
|
|
230
230
|
data: {
|
|
@@ -245,7 +245,7 @@ async function testResponseFormat() {
|
|
|
245
245
|
async function testMultiTurn() {
|
|
246
246
|
console.log('--- Testing Multi-turn Conversation ---');
|
|
247
247
|
const request = {
|
|
248
|
-
|
|
248
|
+
gateId: 'test-gate',
|
|
249
249
|
type: 'chat',
|
|
250
250
|
model: 'mistral-small-latest',
|
|
251
251
|
data: {
|
|
@@ -273,7 +273,7 @@ async function testMultiTurn() {
|
|
|
273
273
|
async function testOCR() {
|
|
274
274
|
console.log('--- Testing OCR Capability ---');
|
|
275
275
|
const request = {
|
|
276
|
-
|
|
276
|
+
gateId: 'test-gate',
|
|
277
277
|
type: 'ocr',
|
|
278
278
|
model: 'mistral-ocr-latest',
|
|
279
279
|
data: {
|
|
@@ -295,7 +295,7 @@ async function testOCR() {
|
|
|
295
295
|
async function testUnsupportedModality() {
|
|
296
296
|
console.log('--- Testing Unsupported Modality (Image Generation) ---');
|
|
297
297
|
const request = {
|
|
298
|
-
|
|
298
|
+
gateId: 'test-gate',
|
|
299
299
|
type: 'image',
|
|
300
300
|
model: 'mistral-large-latest',
|
|
301
301
|
data: {
|
|
@@ -3,7 +3,7 @@ const adapter = new OpenAIAdapter();
|
|
|
3
3
|
async function testChatCompletion() {
|
|
4
4
|
console.log('Testing chat completion...');
|
|
5
5
|
const request = {
|
|
6
|
-
|
|
6
|
+
gateId: 'test-gate',
|
|
7
7
|
model: 'gpt-4o-mini',
|
|
8
8
|
type: 'chat',
|
|
9
9
|
data: {
|
|
@@ -25,7 +25,7 @@ async function testChatCompletion() {
|
|
|
25
25
|
async function testChatWithVision() {
|
|
26
26
|
console.log('Testing chat with vision...');
|
|
27
27
|
const request = {
|
|
28
|
-
|
|
28
|
+
gateId: 'test-gate',
|
|
29
29
|
model: 'gpt-4o-mini',
|
|
30
30
|
type: 'chat',
|
|
31
31
|
data: {
|
|
@@ -50,7 +50,7 @@ async function testChatWithVision() {
|
|
|
50
50
|
async function testImageGeneration() {
|
|
51
51
|
console.log('Testing image generation...');
|
|
52
52
|
const request = {
|
|
53
|
-
|
|
53
|
+
gateId: 'test-gate',
|
|
54
54
|
model: 'dall-e-3',
|
|
55
55
|
type: 'image',
|
|
56
56
|
data: {
|
|
@@ -69,7 +69,7 @@ async function testImageGeneration() {
|
|
|
69
69
|
async function testEmbeddings() {
|
|
70
70
|
console.log('Testing embeddings...');
|
|
71
71
|
const request = {
|
|
72
|
-
|
|
72
|
+
gateId: 'test-gate',
|
|
73
73
|
model: 'text-embedding-3-small',
|
|
74
74
|
type: 'embeddings',
|
|
75
75
|
data: {
|
|
@@ -85,7 +85,7 @@ async function testEmbeddings() {
|
|
|
85
85
|
async function testTextToSpeech() {
|
|
86
86
|
console.log('Testing text-to-speech...');
|
|
87
87
|
const request = {
|
|
88
|
-
|
|
88
|
+
gateId: 'test-gate',
|
|
89
89
|
model: 'tts-1',
|
|
90
90
|
type: 'tts',
|
|
91
91
|
data: {
|
|
@@ -104,7 +104,7 @@ async function testToolCalling() {
|
|
|
104
104
|
console.log('Testing tool calling...');
|
|
105
105
|
// Step 1: Initial request with tool available
|
|
106
106
|
const request = {
|
|
107
|
-
|
|
107
|
+
gateId: 'test-gate',
|
|
108
108
|
model: 'gpt-4o-mini',
|
|
109
109
|
type: 'chat',
|
|
110
110
|
data: {
|
|
@@ -145,7 +145,7 @@ async function testToolCalling() {
|
|
|
145
145
|
console.log('Function arguments:', toolCall.function.arguments);
|
|
146
146
|
// Step 2: Send tool response back
|
|
147
147
|
const toolResponseRequest = {
|
|
148
|
-
|
|
148
|
+
gateId: 'test-gate',
|
|
149
149
|
model: 'gpt-4o-mini',
|
|
150
150
|
type: 'chat',
|
|
151
151
|
data: {
|
|
@@ -173,7 +173,7 @@ async function testContentAndToolCalls() {
|
|
|
173
173
|
console.log('Testing content + tool calls in same message...');
|
|
174
174
|
// This tests the fix we made - assistant messages can have BOTH content and toolCalls
|
|
175
175
|
const request = {
|
|
176
|
-
|
|
176
|
+
gateId: 'test-gate',
|
|
177
177
|
model: 'gpt-4o-mini',
|
|
178
178
|
type: 'chat',
|
|
179
179
|
data: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layer-ai/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
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": "^
|
|
39
|
+
"@layer-ai/sdk": "^2.0.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/bcryptjs": "^2.4.6",
|