@midscene/shared 1.8.11 → 1.9.1-beta-20260605030300.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/es/env/model-config-manager.mjs +3 -0
- package/dist/es/env/parse-model-config.mjs +7 -2
- package/dist/es/img/transform.mjs +1 -11
- package/dist/lib/env/model-config-manager.js +3 -0
- package/dist/lib/env/parse-model-config.js +7 -2
- package/dist/lib/img/transform.js +1 -11
- package/dist/types/img/transform.d.ts +1 -1
- package/package.json +1 -1
- package/src/env/model-config-manager.ts +3 -0
- package/src/env/parse-model-config.ts +10 -3
- package/src/img/transform.ts +0 -13
|
@@ -25,16 +25,19 @@ class ModelConfigManager {
|
|
|
25
25
|
default: {
|
|
26
26
|
...defaultConfig,
|
|
27
27
|
intent: 'default',
|
|
28
|
+
slot: 'default',
|
|
28
29
|
createOpenAIClient: this.createOpenAIClientFn
|
|
29
30
|
},
|
|
30
31
|
insight: {
|
|
31
32
|
...insightConfig || defaultConfig,
|
|
32
33
|
intent: 'insight',
|
|
34
|
+
slot: insightConfig ? 'insight' : 'default',
|
|
33
35
|
createOpenAIClient: this.createOpenAIClientFn
|
|
34
36
|
},
|
|
35
37
|
planning: {
|
|
36
38
|
...planningConfig || defaultConfig,
|
|
37
39
|
intent: 'planning',
|
|
40
|
+
slot: planningConfig ? 'planning' : 'default',
|
|
38
41
|
createOpenAIClient: this.createOpenAIClientFn
|
|
39
42
|
}
|
|
40
43
|
};
|
|
@@ -5,7 +5,7 @@ import { assert } from "../utils.mjs";
|
|
|
5
5
|
import { maskConfig, parseJson } from "./helper.mjs";
|
|
6
6
|
import { initDebugConfig } from "./init-debug.mjs";
|
|
7
7
|
const MODEL_CONFIG_DOC_URL = 'https://midscenejs.com/model-common-config.html';
|
|
8
|
-
const getCurrentVersion = ()=>"1.
|
|
8
|
+
const getCurrentVersion = ()=>"1.9.1-beta-20260605030300.0";
|
|
9
9
|
const getInvalidModelFamilyMessage = (modelFamily)=>`Invalid MIDSCENE_MODEL_FAMILY value: ${modelFamily}. Current version v${getCurrentVersion()} accepts the following model families: ${MODEL_FAMILY_VALUES.join(', ')}. You can also visit ${MODEL_CONFIG_DOC_URL} for the latest configuration information.`;
|
|
10
10
|
const KEYS_MAP = {
|
|
11
11
|
insight: INSIGHT_MODEL_CONFIG_KEYS,
|
|
@@ -56,6 +56,11 @@ const normalizeOpenaiExtraConfig = (config)=>{
|
|
|
56
56
|
};
|
|
57
57
|
return rest;
|
|
58
58
|
};
|
|
59
|
+
const parseTemperature = (rawValue)=>{
|
|
60
|
+
if (void 0 === rawValue || '' === rawValue) return;
|
|
61
|
+
const temperature = Number(rawValue);
|
|
62
|
+
return Number.isFinite(temperature) ? temperature : void 0;
|
|
63
|
+
};
|
|
59
64
|
const parseOpenaiSdkConfig = ({ keys, provider, useLegacyLogic = false })=>{
|
|
60
65
|
initDebugConfig();
|
|
61
66
|
const debugLog = getDebug('ai:config');
|
|
@@ -76,7 +81,7 @@ const parseOpenaiSdkConfig = ({ keys, provider, useLegacyLogic = false })=>{
|
|
|
76
81
|
const openaiExtraConfig = parseJson(keys.openaiExtraConfig, openaiExtraConfigStr || legacyOpenaiExtraConfig);
|
|
77
82
|
const extraBodyStr = provider[keys.extraBody];
|
|
78
83
|
const extraBody = parseJson(keys.extraBody, extraBodyStr);
|
|
79
|
-
const temperature =
|
|
84
|
+
const temperature = parseTemperature(provider[keys.temperature]);
|
|
80
85
|
const modelFamily = modelFamilyRaw;
|
|
81
86
|
validateModelFamily(modelFamily);
|
|
82
87
|
const uiTarsModelVersion = getUITarsModelVersion(modelFamily);
|
|
@@ -147,23 +147,13 @@ async function paddingToMatchBlockByBase64(imageBase64, blockSize = 28) {
|
|
|
147
147
|
photonImage.free();
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
async function cropByRect(imageBase64, rect
|
|
150
|
+
async function cropByRect(imageBase64, rect) {
|
|
151
151
|
const { crop } = await get_photon();
|
|
152
152
|
const photonImage = await photonFromBase64(imageBase64);
|
|
153
153
|
const { left, top, width, height } = rect;
|
|
154
154
|
const cropped = crop(photonImage, left, top, left + width, top + height);
|
|
155
155
|
photonImage.free();
|
|
156
156
|
try {
|
|
157
|
-
if (paddingImage) {
|
|
158
|
-
const paddedResult = await paddingToMatchBlock(cropped);
|
|
159
|
-
const result = {
|
|
160
|
-
width: paddedResult.width,
|
|
161
|
-
height: paddedResult.height,
|
|
162
|
-
imageBase64: await photonToBase64(paddedResult.image)
|
|
163
|
-
};
|
|
164
|
-
if (paddedResult.image !== cropped) paddedResult.image.free();
|
|
165
|
-
return result;
|
|
166
|
-
}
|
|
167
157
|
return {
|
|
168
158
|
width: cropped.get_width(),
|
|
169
159
|
height: cropped.get_height(),
|
|
@@ -53,16 +53,19 @@ class ModelConfigManager {
|
|
|
53
53
|
default: {
|
|
54
54
|
...defaultConfig,
|
|
55
55
|
intent: 'default',
|
|
56
|
+
slot: 'default',
|
|
56
57
|
createOpenAIClient: this.createOpenAIClientFn
|
|
57
58
|
},
|
|
58
59
|
insight: {
|
|
59
60
|
...insightConfig || defaultConfig,
|
|
60
61
|
intent: 'insight',
|
|
62
|
+
slot: insightConfig ? 'insight' : 'default',
|
|
61
63
|
createOpenAIClient: this.createOpenAIClientFn
|
|
62
64
|
},
|
|
63
65
|
planning: {
|
|
64
66
|
...planningConfig || defaultConfig,
|
|
65
67
|
intent: 'planning',
|
|
68
|
+
slot: planningConfig ? 'planning' : 'default',
|
|
66
69
|
createOpenAIClient: this.createOpenAIClientFn
|
|
67
70
|
}
|
|
68
71
|
};
|
|
@@ -37,7 +37,7 @@ const external_utils_js_namespaceObject = require("../utils.js");
|
|
|
37
37
|
const external_helper_js_namespaceObject = require("./helper.js");
|
|
38
38
|
const external_init_debug_js_namespaceObject = require("./init-debug.js");
|
|
39
39
|
const MODEL_CONFIG_DOC_URL = 'https://midscenejs.com/model-common-config.html';
|
|
40
|
-
const getCurrentVersion = ()=>"1.
|
|
40
|
+
const getCurrentVersion = ()=>"1.9.1-beta-20260605030300.0";
|
|
41
41
|
const getInvalidModelFamilyMessage = (modelFamily)=>`Invalid MIDSCENE_MODEL_FAMILY value: ${modelFamily}. Current version v${getCurrentVersion()} accepts the following model families: ${external_types_js_namespaceObject.MODEL_FAMILY_VALUES.join(', ')}. You can also visit ${MODEL_CONFIG_DOC_URL} for the latest configuration information.`;
|
|
42
42
|
const KEYS_MAP = {
|
|
43
43
|
insight: external_constants_js_namespaceObject.INSIGHT_MODEL_CONFIG_KEYS,
|
|
@@ -88,6 +88,11 @@ const normalizeOpenaiExtraConfig = (config)=>{
|
|
|
88
88
|
};
|
|
89
89
|
return rest;
|
|
90
90
|
};
|
|
91
|
+
const parseTemperature = (rawValue)=>{
|
|
92
|
+
if (void 0 === rawValue || '' === rawValue) return;
|
|
93
|
+
const temperature = Number(rawValue);
|
|
94
|
+
return Number.isFinite(temperature) ? temperature : void 0;
|
|
95
|
+
};
|
|
91
96
|
const parseOpenaiSdkConfig = ({ keys, provider, useLegacyLogic = false })=>{
|
|
92
97
|
(0, external_init_debug_js_namespaceObject.initDebugConfig)();
|
|
93
98
|
const debugLog = (0, external_logger_js_namespaceObject.getDebug)('ai:config');
|
|
@@ -108,7 +113,7 @@ const parseOpenaiSdkConfig = ({ keys, provider, useLegacyLogic = false })=>{
|
|
|
108
113
|
const openaiExtraConfig = (0, external_helper_js_namespaceObject.parseJson)(keys.openaiExtraConfig, openaiExtraConfigStr || legacyOpenaiExtraConfig);
|
|
109
114
|
const extraBodyStr = provider[keys.extraBody];
|
|
110
115
|
const extraBody = (0, external_helper_js_namespaceObject.parseJson)(keys.extraBody, extraBodyStr);
|
|
111
|
-
const temperature =
|
|
116
|
+
const temperature = parseTemperature(provider[keys.temperature]);
|
|
112
117
|
const modelFamily = modelFamilyRaw;
|
|
113
118
|
validateModelFamily(modelFamily);
|
|
114
119
|
const uiTarsModelVersion = getUITarsModelVersion(modelFamily);
|
|
@@ -203,23 +203,13 @@ async function paddingToMatchBlockByBase64(imageBase64, blockSize = 28) {
|
|
|
203
203
|
photonImage.free();
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
|
-
async function cropByRect(imageBase64, rect
|
|
206
|
+
async function cropByRect(imageBase64, rect) {
|
|
207
207
|
const { crop } = await external_get_photon_js_default()();
|
|
208
208
|
const photonImage = await photonFromBase64(imageBase64);
|
|
209
209
|
const { left, top, width, height } = rect;
|
|
210
210
|
const cropped = crop(photonImage, left, top, left + width, top + height);
|
|
211
211
|
photonImage.free();
|
|
212
212
|
try {
|
|
213
|
-
if (paddingImage) {
|
|
214
|
-
const paddedResult = await paddingToMatchBlock(cropped);
|
|
215
|
-
const result = {
|
|
216
|
-
width: paddedResult.width,
|
|
217
|
-
height: paddedResult.height,
|
|
218
|
-
imageBase64: await photonToBase64(paddedResult.image)
|
|
219
|
-
};
|
|
220
|
-
if (paddedResult.image !== cropped) paddedResult.image.free();
|
|
221
|
-
return result;
|
|
222
|
-
}
|
|
223
213
|
return {
|
|
224
214
|
width: cropped.get_width(),
|
|
225
215
|
height: cropped.get_height(),
|
|
@@ -59,7 +59,7 @@ export declare function paddingToMatchBlockByBase64(imageBase64: string, blockSi
|
|
|
59
59
|
height: number;
|
|
60
60
|
imageBase64: string;
|
|
61
61
|
}>;
|
|
62
|
-
export declare function cropByRect(imageBase64: string, rect: Rect
|
|
62
|
+
export declare function cropByRect(imageBase64: string, rect: Rect): Promise<{
|
|
63
63
|
width: number;
|
|
64
64
|
height: number;
|
|
65
65
|
imageBase64: string;
|
package/package.json
CHANGED
|
@@ -69,16 +69,19 @@ export class ModelConfigManager {
|
|
|
69
69
|
default: {
|
|
70
70
|
...defaultConfig,
|
|
71
71
|
intent: 'default',
|
|
72
|
+
slot: 'default',
|
|
72
73
|
createOpenAIClient: this.createOpenAIClientFn,
|
|
73
74
|
},
|
|
74
75
|
insight: {
|
|
75
76
|
...(insightConfig || defaultConfig),
|
|
76
77
|
intent: 'insight',
|
|
78
|
+
slot: insightConfig ? 'insight' : 'default',
|
|
77
79
|
createOpenAIClient: this.createOpenAIClientFn,
|
|
78
80
|
},
|
|
79
81
|
planning: {
|
|
80
82
|
...(planningConfig || defaultConfig),
|
|
81
83
|
intent: 'planning',
|
|
84
|
+
slot: planningConfig ? 'planning' : 'default',
|
|
82
85
|
createOpenAIClient: this.createOpenAIClientFn,
|
|
83
86
|
},
|
|
84
87
|
};
|
|
@@ -172,6 +172,15 @@ const normalizeOpenaiExtraConfig = (
|
|
|
172
172
|
return rest;
|
|
173
173
|
};
|
|
174
174
|
|
|
175
|
+
const parseTemperature = (rawValue: string | undefined): number | undefined => {
|
|
176
|
+
if (rawValue === undefined || rawValue === '') {
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const temperature = Number(rawValue);
|
|
181
|
+
return Number.isFinite(temperature) ? temperature : undefined;
|
|
182
|
+
};
|
|
183
|
+
|
|
175
184
|
/**
|
|
176
185
|
* Parse OpenAI SDK config
|
|
177
186
|
*/
|
|
@@ -222,9 +231,7 @@ export const parseOpenaiSdkConfig = ({
|
|
|
222
231
|
);
|
|
223
232
|
const extraBodyStr: string | undefined = provider[keys.extraBody];
|
|
224
233
|
const extraBody = parseJson(keys.extraBody, extraBodyStr);
|
|
225
|
-
const temperature = provider[keys.temperature]
|
|
226
|
-
? Number(provider[keys.temperature])
|
|
227
|
-
: 0;
|
|
234
|
+
const temperature = parseTemperature(provider[keys.temperature]);
|
|
228
235
|
|
|
229
236
|
const modelFamily = modelFamilyRaw as unknown as TModelFamily;
|
|
230
237
|
validateModelFamily(modelFamily);
|
package/src/img/transform.ts
CHANGED
|
@@ -299,7 +299,6 @@ export async function paddingToMatchBlockByBase64(
|
|
|
299
299
|
export async function cropByRect(
|
|
300
300
|
imageBase64: string,
|
|
301
301
|
rect: Rect,
|
|
302
|
-
paddingImage: boolean,
|
|
303
302
|
): Promise<{
|
|
304
303
|
width: number;
|
|
305
304
|
height: number;
|
|
@@ -314,18 +313,6 @@ export async function cropByRect(
|
|
|
314
313
|
photonImage.free();
|
|
315
314
|
|
|
316
315
|
try {
|
|
317
|
-
if (paddingImage) {
|
|
318
|
-
const paddedResult = await paddingToMatchBlock(cropped);
|
|
319
|
-
const result = {
|
|
320
|
-
width: paddedResult.width,
|
|
321
|
-
height: paddedResult.height,
|
|
322
|
-
imageBase64: await photonToBase64(paddedResult.image),
|
|
323
|
-
};
|
|
324
|
-
if (paddedResult.image !== cropped) {
|
|
325
|
-
paddedResult.image.free();
|
|
326
|
-
}
|
|
327
|
-
return result;
|
|
328
|
-
}
|
|
329
316
|
return {
|
|
330
317
|
width: cropped.get_width(),
|
|
331
318
|
height: cropped.get_height(),
|