koishi-plugin-chatluna-google-gemini-adapter 1.2.0-alpha.3 → 1.2.0-alpha.4
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/lib/index.cjs +18 -20
- package/lib/index.mjs +18 -20
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -286,29 +286,27 @@ function formatToolToGeminiAITool(tool) {
|
|
|
286
286
|
}
|
|
287
287
|
__name(formatToolToGeminiAITool, "formatToolToGeminiAITool");
|
|
288
288
|
function removeAdditionalProperties(schema) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
289
|
+
if (!schema || typeof schema !== "object") return schema;
|
|
290
|
+
const stack = [[schema, null]];
|
|
291
|
+
while (stack.length > 0) {
|
|
292
|
+
const [current] = stack.pop();
|
|
293
|
+
if (typeof current !== "object" || current === null) continue;
|
|
294
|
+
if (Object.hasOwn(current, "additionalProperties")) {
|
|
295
|
+
delete current["additionalProperties"];
|
|
296
|
+
}
|
|
297
|
+
if (Object.hasOwn(current, "$schema")) {
|
|
298
|
+
delete current["$schema"];
|
|
299
|
+
}
|
|
300
|
+
for (const key of Object.keys(current)) {
|
|
301
|
+
const value = current[key];
|
|
302
|
+
if (value && typeof value === "object") {
|
|
303
|
+
stack.push([value, key]);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
299
306
|
}
|
|
300
|
-
return
|
|
307
|
+
return schema;
|
|
301
308
|
}
|
|
302
309
|
__name(removeAdditionalProperties, "removeAdditionalProperties");
|
|
303
|
-
function removeProperties(properties, keys, index) {
|
|
304
|
-
if (index >= keys.length) {
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
const key = keys[index];
|
|
308
|
-
properties[key] = removeAdditionalProperties(properties[key]);
|
|
309
|
-
removeProperties(properties, keys, index + 1);
|
|
310
|
-
}
|
|
311
|
-
__name(removeProperties, "removeProperties");
|
|
312
310
|
function messageTypeToGeminiRole(type) {
|
|
313
311
|
switch (type) {
|
|
314
312
|
case "system":
|
package/lib/index.mjs
CHANGED
|
@@ -269,29 +269,27 @@ function formatToolToGeminiAITool(tool) {
|
|
|
269
269
|
}
|
|
270
270
|
__name(formatToolToGeminiAITool, "formatToolToGeminiAITool");
|
|
271
271
|
function removeAdditionalProperties(schema) {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
272
|
+
if (!schema || typeof schema !== "object") return schema;
|
|
273
|
+
const stack = [[schema, null]];
|
|
274
|
+
while (stack.length > 0) {
|
|
275
|
+
const [current] = stack.pop();
|
|
276
|
+
if (typeof current !== "object" || current === null) continue;
|
|
277
|
+
if (Object.hasOwn(current, "additionalProperties")) {
|
|
278
|
+
delete current["additionalProperties"];
|
|
279
|
+
}
|
|
280
|
+
if (Object.hasOwn(current, "$schema")) {
|
|
281
|
+
delete current["$schema"];
|
|
282
|
+
}
|
|
283
|
+
for (const key of Object.keys(current)) {
|
|
284
|
+
const value = current[key];
|
|
285
|
+
if (value && typeof value === "object") {
|
|
286
|
+
stack.push([value, key]);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
282
289
|
}
|
|
283
|
-
return
|
|
290
|
+
return schema;
|
|
284
291
|
}
|
|
285
292
|
__name(removeAdditionalProperties, "removeAdditionalProperties");
|
|
286
|
-
function removeProperties(properties, keys, index) {
|
|
287
|
-
if (index >= keys.length) {
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
const key = keys[index];
|
|
291
|
-
properties[key] = removeAdditionalProperties(properties[key]);
|
|
292
|
-
removeProperties(properties, keys, index + 1);
|
|
293
|
-
}
|
|
294
|
-
__name(removeProperties, "removeProperties");
|
|
295
293
|
function messageTypeToGeminiRole(type) {
|
|
296
294
|
switch (type) {
|
|
297
295
|
case "system":
|
package/package.json
CHANGED