@midscene/shared 1.6.4 → 1.7.1-beta-20260408073050.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.
|
@@ -43,6 +43,16 @@ const getModelDescription = (modelFamily, uiTarsModelVersion)=>{
|
|
|
43
43
|
if (modelFamily) return `${modelFamily} mode`;
|
|
44
44
|
return '';
|
|
45
45
|
};
|
|
46
|
+
const normalizeOpenaiExtraConfig = (config)=>{
|
|
47
|
+
if (!config || 'object' != typeof config || Array.isArray(config)) return;
|
|
48
|
+
const { defaultHeaders, extra_headers, extraHeaders, ...rest } = config;
|
|
49
|
+
const headers = defaultHeaders ?? extra_headers ?? extraHeaders;
|
|
50
|
+
if (void 0 !== headers) return {
|
|
51
|
+
...rest,
|
|
52
|
+
defaultHeaders: headers
|
|
53
|
+
};
|
|
54
|
+
return rest;
|
|
55
|
+
};
|
|
46
56
|
const parseOpenaiSdkConfig = ({ keys, provider, useLegacyLogic = false })=>{
|
|
47
57
|
initDebugConfig();
|
|
48
58
|
const debugLog = getDebug('ai:config');
|
|
@@ -73,7 +83,7 @@ const parseOpenaiSdkConfig = ({ keys, provider, useLegacyLogic = false })=>{
|
|
|
73
83
|
httpProxy,
|
|
74
84
|
openaiBaseURL,
|
|
75
85
|
openaiApiKey,
|
|
76
|
-
openaiExtraConfig,
|
|
86
|
+
openaiExtraConfig: normalizeOpenaiExtraConfig(openaiExtraConfig),
|
|
77
87
|
extraBody,
|
|
78
88
|
modelFamily,
|
|
79
89
|
uiTarsModelVersion,
|
|
@@ -75,6 +75,16 @@ const getModelDescription = (modelFamily, uiTarsModelVersion)=>{
|
|
|
75
75
|
if (modelFamily) return `${modelFamily} mode`;
|
|
76
76
|
return '';
|
|
77
77
|
};
|
|
78
|
+
const normalizeOpenaiExtraConfig = (config)=>{
|
|
79
|
+
if (!config || 'object' != typeof config || Array.isArray(config)) return;
|
|
80
|
+
const { defaultHeaders, extra_headers, extraHeaders, ...rest } = config;
|
|
81
|
+
const headers = defaultHeaders ?? extra_headers ?? extraHeaders;
|
|
82
|
+
if (void 0 !== headers) return {
|
|
83
|
+
...rest,
|
|
84
|
+
defaultHeaders: headers
|
|
85
|
+
};
|
|
86
|
+
return rest;
|
|
87
|
+
};
|
|
78
88
|
const parseOpenaiSdkConfig = ({ keys, provider, useLegacyLogic = false })=>{
|
|
79
89
|
(0, external_init_debug_js_namespaceObject.initDebugConfig)();
|
|
80
90
|
const debugLog = (0, external_logger_js_namespaceObject.getDebug)('ai:config');
|
|
@@ -105,7 +115,7 @@ const parseOpenaiSdkConfig = ({ keys, provider, useLegacyLogic = false })=>{
|
|
|
105
115
|
httpProxy,
|
|
106
116
|
openaiBaseURL,
|
|
107
117
|
openaiApiKey,
|
|
108
|
-
openaiExtraConfig,
|
|
118
|
+
openaiExtraConfig: normalizeOpenaiExtraConfig(openaiExtraConfig),
|
|
109
119
|
extraBody,
|
|
110
120
|
modelFamily,
|
|
111
121
|
uiTarsModelVersion,
|
package/package.json
CHANGED
|
@@ -136,6 +136,26 @@ const getModelDescription = (
|
|
|
136
136
|
return '';
|
|
137
137
|
};
|
|
138
138
|
|
|
139
|
+
const normalizeOpenaiExtraConfig = (
|
|
140
|
+
config: unknown,
|
|
141
|
+
): Record<string, unknown> | undefined => {
|
|
142
|
+
if (!config || typeof config !== 'object' || Array.isArray(config)) {
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const { defaultHeaders, extra_headers, extraHeaders, ...rest } =
|
|
147
|
+
config as Record<string, unknown>;
|
|
148
|
+
|
|
149
|
+
// Priority: defaultHeaders > extra_headers > extraHeaders
|
|
150
|
+
const headers = defaultHeaders ?? extra_headers ?? extraHeaders;
|
|
151
|
+
|
|
152
|
+
if (headers !== undefined) {
|
|
153
|
+
return { ...rest, defaultHeaders: headers };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return rest;
|
|
157
|
+
};
|
|
158
|
+
|
|
139
159
|
/**
|
|
140
160
|
* Parse OpenAI SDK config
|
|
141
161
|
*/
|
|
@@ -201,7 +221,7 @@ export const parseOpenaiSdkConfig = ({
|
|
|
201
221
|
httpProxy,
|
|
202
222
|
openaiBaseURL,
|
|
203
223
|
openaiApiKey,
|
|
204
|
-
openaiExtraConfig,
|
|
224
|
+
openaiExtraConfig: normalizeOpenaiExtraConfig(openaiExtraConfig),
|
|
205
225
|
extraBody,
|
|
206
226
|
modelFamily,
|
|
207
227
|
uiTarsModelVersion,
|