@layer-ai/core 2.0.11 → 2.0.12
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/v3/chat.js +7 -8
- package/package.json +2 -2
package/dist/routes/v3/chat.js
CHANGED
|
@@ -51,10 +51,8 @@ function resolveFinalRequest(gateConfig, request) {
|
|
|
51
51
|
if (modelProvider === PROVIDER.OPENAI) {
|
|
52
52
|
// OpenAI: Use native response_format support
|
|
53
53
|
if (gateConfig.responseFormatType === 'json_schema' && gateConfig.responseFormatSchema) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
json_schema: gateConfig.responseFormatSchema,
|
|
57
|
-
};
|
|
54
|
+
// Schema is already in the correct format from DB
|
|
55
|
+
chatData.responseFormat = gateConfig.responseFormatSchema;
|
|
58
56
|
}
|
|
59
57
|
else {
|
|
60
58
|
chatData.responseFormat = gateConfig.responseFormatType; // 'text' or 'json_object'
|
|
@@ -65,12 +63,13 @@ function resolveFinalRequest(gateConfig, request) {
|
|
|
65
63
|
if (gateConfig.responseFormatType !== 'text') {
|
|
66
64
|
let schemaInstructions = '';
|
|
67
65
|
if (gateConfig.responseFormatType === 'json_schema' && gateConfig.responseFormatSchema) {
|
|
68
|
-
//
|
|
69
|
-
|
|
66
|
+
// Extract just the schema portion if it's the full OpenAI format
|
|
67
|
+
const schemaObj = gateConfig.responseFormatSchema;
|
|
68
|
+
const actualSchema = schemaObj.json_schema?.schema || schemaObj;
|
|
69
|
+
schemaInstructions = `\n\nYou MUST respond with ONLY a valid JSON object matching this schema. Do not include ANY text before or after the JSON. Do not wrap it in markdown code blocks. Do not add explanations. ONLY output the raw JSON object.\n\nRequired JSON Schema:\n${JSON.stringify(actualSchema, null, 2)}`;
|
|
70
70
|
}
|
|
71
71
|
else if (gateConfig.responseFormatType === 'json_object') {
|
|
72
|
-
|
|
73
|
-
schemaInstructions = `\n\n[STRUCTURED OUTPUT - BETA] You MUST respond with valid JSON only. Do not include any explanatory text, markdown formatting, or code blocks. Output should be a raw JSON object.`;
|
|
72
|
+
schemaInstructions = `\n\nYou MUST respond with ONLY a valid JSON object. Do not include ANY text before or after the JSON. Do not wrap it in markdown code blocks. Do not add explanations. ONLY output the raw JSON object.`;
|
|
74
73
|
}
|
|
75
74
|
// Append to existing system prompt or create new one
|
|
76
75
|
chatData.systemPrompt = (chatData.systemPrompt || '') + schemaInstructions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layer-ai/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.12",
|
|
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": "^2.5.
|
|
39
|
+
"@layer-ai/sdk": "^2.5.4"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/bcryptjs": "^2.4.6",
|