@veryfront/ext-llm-google 0.1.1271-rc.23355 → 0.1.1271
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-provider.d.ts","sourceRoot":"","sources":["../src/google-provider.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,2BAA2B,EAC5B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,kBAAkB,EAMlB,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EAKpB,+BAA+B,EAC/B,qBAAqB,EACtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAEL,KAAK,+BAA+B,EACrC,MAAM,6BAA6B,CAAC;AAyBrC,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,+BAA+B,EAC/B,qBAAqB,GACtB,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC;AAydD,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,MAAM,GACd,YAAY,CAAC,+BAA+B,EAAE,2BAA2B,CAAC,
|
|
1
|
+
{"version":3,"file":"google-provider.d.ts","sourceRoot":"","sources":["../src/google-provider.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK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AAG,gBAAgB;CAW9E"}
|
package/esm/google-provider.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-request-builder.d.ts","sourceRoot":"","sources":["../src/google-request-builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"google-request-builder.d.ts","sourceRoot":"","sources":["../src/google-request-builder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,uBAAuB,EAEvB,0BAA0B,EAE3B,MAAM,2BAA2B,CAAC;AAmBnC,MAAM,WAAW,+BAAgC,SAAQ,uBAAuB;IAC9E,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,oBAAoB,CAAC,EAAE,aAAa,CAAC;QACnC,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC,CAAC;CACJ;AAED,gGAAgG;AAChG,MAAM,MAAM,qBAAqB,GAAG,0BAA0B,CAAC;AAE/D,KAAK,gBAAgB,GAAG;IACtB,IAAI,CAAC,OAAO,EAAE;QACZ,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC;QACtC,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,IAAI,CAAC;IACT,KAAK,IAAI,KAAK,CAAC;QACb,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC;QACtC,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC,CAAC;CACJ,CAAC;AAEF,KAAK,uBAAuB,GAAG;IAC7B,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,KAAK,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;CAC3C,CAAC;AAEF,KAAK,uBAAuB,GAAG;IAC7B,QAAQ,EAAE,uBAAuB,EAAE,CAAC;IACpC,iBAAiB,CAAC,EAAE;QAClB,KAAK,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAChC,CAAC;IACF,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACvC,UAAU,CAAC,EAAE;QACX,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAChD,CAAC;IACF,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AA25BF,wBAAgB,iCAAiC,CAC/C,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,+BAA+B,EACxC,QAAQ,EAAE,gBAAgB,GACzB,uBAAuB,CAyDzB"}
|
|
@@ -1,6 +1,76 @@
|
|
|
1
|
-
import { jsonValuesEqual,
|
|
1
|
+
import { jsonValuesEqual, readRecord, unwrapToolInputSchema } from "veryfront/provider/shared";
|
|
2
2
|
import { createGoogleToolCallCorrelationRegistry, GOOGLE_CODE_EXECUTION_TOOL_NAME, googleCodeExecutionInput, googleCodeExecutionOutput, readGoogleCodeExecutionResult, readGoogleExecutableCode, readGooglePartDataField, } from "./google-content-parts.js";
|
|
3
3
|
import { readGoogleRawAssistantReplay } from "./google-thought-signatures.js";
|
|
4
|
+
const arrayIsArray = Array.isArray;
|
|
5
|
+
const numberIsSafeInteger = Number.isSafeInteger;
|
|
6
|
+
const objectDefineProperty = Object.defineProperty;
|
|
7
|
+
const objectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
8
|
+
const objectHasOwn = Object.hasOwn;
|
|
9
|
+
const objectKeys = Object.keys;
|
|
10
|
+
function defineGoogleProviderOption(target, key, value) {
|
|
11
|
+
objectDefineProperty(target, key, {
|
|
12
|
+
value,
|
|
13
|
+
writable: true,
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function mergeGoogleProviderOptions(target, providerOptions) {
|
|
19
|
+
const optionNames = objectKeys(providerOptions);
|
|
20
|
+
for (let index = 0; index < optionNames.length; index++) {
|
|
21
|
+
const optionName = optionNames[index];
|
|
22
|
+
const descriptor = objectGetOwnPropertyDescriptor(providerOptions, optionName);
|
|
23
|
+
if (!descriptor || !descriptor.enumerable || !objectHasOwn(descriptor, "value"))
|
|
24
|
+
continue;
|
|
25
|
+
defineGoogleProviderOption(target, optionName, descriptor.value);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function readGoogleProviderOptions(providerOptions, ...providerNames) {
|
|
29
|
+
const output = {};
|
|
30
|
+
if (!providerOptions)
|
|
31
|
+
return output;
|
|
32
|
+
for (let providerIndex = 0; providerIndex < providerNames.length; providerIndex++) {
|
|
33
|
+
const providerName = providerNames[providerIndex];
|
|
34
|
+
let bucketDescriptor;
|
|
35
|
+
try {
|
|
36
|
+
bucketDescriptor = objectGetOwnPropertyDescriptor(providerOptions, providerName);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
throw new TypeError(`Provider options for "${providerName}" could not be read`);
|
|
40
|
+
}
|
|
41
|
+
if (!bucketDescriptor)
|
|
42
|
+
continue;
|
|
43
|
+
if (!objectHasOwn(bucketDescriptor, "value")) {
|
|
44
|
+
throw new TypeError(`Provider options for "${providerName}" must be a data property`);
|
|
45
|
+
}
|
|
46
|
+
const bucket = bucketDescriptor.value;
|
|
47
|
+
if (!bucket || typeof bucket !== "object" || arrayIsArray(bucket))
|
|
48
|
+
continue;
|
|
49
|
+
let keys;
|
|
50
|
+
try {
|
|
51
|
+
keys = objectKeys(bucket);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
throw new TypeError(`Provider options for "${providerName}" could not be enumerated`);
|
|
55
|
+
}
|
|
56
|
+
for (let keyIndex = 0; keyIndex < keys.length; keyIndex++) {
|
|
57
|
+
const optionName = keys[keyIndex];
|
|
58
|
+
let optionDescriptor;
|
|
59
|
+
try {
|
|
60
|
+
optionDescriptor = objectGetOwnPropertyDescriptor(bucket, optionName);
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
throw new TypeError(`Provider options for "${providerName}" could not be enumerated`);
|
|
64
|
+
}
|
|
65
|
+
if (!optionDescriptor || !optionDescriptor.enumerable ||
|
|
66
|
+
!objectHasOwn(optionDescriptor, "value")) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
defineGoogleProviderOption(output, optionName, optionDescriptor.value);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return output;
|
|
73
|
+
}
|
|
4
74
|
function invalidGoogleProviderHistory() {
|
|
5
75
|
return new TypeError("Google raw assistant metadata did not match canonical provider tool history");
|
|
6
76
|
}
|
|
@@ -331,13 +401,13 @@ const GOOGLE_SEARCH_TYPE_KEYS = new Set(["webSearch", "imageSearch"]);
|
|
|
331
401
|
const GOOGLE_TIME_RANGE_KEYS = new Set(["startTime", "endTime"]);
|
|
332
402
|
const RFC_3339_TIMESTAMP = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d{1,9})?(?:Z|[+-](\d{2}):(\d{2}))$/;
|
|
333
403
|
function rejectUnknownKeys(record, allowedKeys, subject) {
|
|
334
|
-
if (
|
|
404
|
+
if (objectKeys(record).some((key) => !allowedKeys.has(key))) {
|
|
335
405
|
throw new TypeError(`${subject} contained an unsupported field`);
|
|
336
406
|
}
|
|
337
407
|
}
|
|
338
408
|
function readEmptyGoogleToolObject(value, subject) {
|
|
339
409
|
const record = readRecord(value);
|
|
340
|
-
if (!record ||
|
|
410
|
+
if (!record || objectKeys(record).length > 0) {
|
|
341
411
|
throw new TypeError(`${subject} must be an empty object`);
|
|
342
412
|
}
|
|
343
413
|
return {};
|
|
@@ -549,7 +619,7 @@ function normalizeGoogleToolChoice(toolChoice) {
|
|
|
549
619
|
}
|
|
550
620
|
function resolveGoogleThinkingConfig(option) {
|
|
551
621
|
if (option?.budgetTokens !== undefined &&
|
|
552
|
-
(!
|
|
622
|
+
(!numberIsSafeInteger(option.budgetTokens) || option.budgetTokens < 0)) {
|
|
553
623
|
throw new TypeError("Google reasoning budgetTokens must be a non-negative safe integer");
|
|
554
624
|
}
|
|
555
625
|
if (!option || option.enabled !== true) {
|
|
@@ -608,7 +678,7 @@ function buildGoogleGenerationConfig(options) {
|
|
|
608
678
|
...(thinkingConfig ? { thinkingConfig } : {}),
|
|
609
679
|
...buildGoogleStructuredOutputConfig(options.responseFormat),
|
|
610
680
|
};
|
|
611
|
-
return
|
|
681
|
+
return objectKeys(config).length > 0 ? config : undefined;
|
|
612
682
|
}
|
|
613
683
|
export function buildGoogleGenerateContentRequest(providerName, options, warnings) {
|
|
614
684
|
if (options.presencePenalty !== undefined) {
|
|
@@ -631,7 +701,7 @@ export function buildGoogleGenerateContentRequest(providerName, options, warning
|
|
|
631
701
|
const generationConfig = buildGoogleGenerationConfig(options);
|
|
632
702
|
const tools = toGoogleTools(options.tools);
|
|
633
703
|
const toolConfig = normalizeGoogleToolChoice(options.toolChoice);
|
|
634
|
-
const labels = options.requestLabels &&
|
|
704
|
+
const labels = options.requestLabels && objectKeys(options.requestLabels).length > 0
|
|
635
705
|
? options.requestLabels
|
|
636
706
|
: typeof options.userId === "string" && options.userId.length > 0
|
|
637
707
|
? { user_id: options.userId }
|
|
@@ -650,11 +720,11 @@ export function buildGoogleGenerateContentRequest(providerName, options, warning
|
|
|
650
720
|
? { safetySettings: options.googleSafetySettings }
|
|
651
721
|
: {}),
|
|
652
722
|
};
|
|
653
|
-
|
|
723
|
+
mergeGoogleProviderOptions(body, readGoogleProviderOptions(options.providerOptions, "google", providerName));
|
|
654
724
|
// Provider options replace `generationConfig` wholesale, so re-pin the
|
|
655
725
|
// runtime-owned structured-output keys the caller asked for.
|
|
656
726
|
const structuredOutput = buildGoogleStructuredOutputConfig(options.responseFormat);
|
|
657
|
-
if (
|
|
727
|
+
if (objectKeys(structuredOutput).length > 0) {
|
|
658
728
|
const generationConfig = { ...(readRecord(body.generationConfig) ?? {}) };
|
|
659
729
|
if ("responseJsonSchema" in structuredOutput) {
|
|
660
730
|
delete generationConfig.responseSchema;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veryfront/ext-llm-google",
|
|
3
|
-
"version": "0.1.1271
|
|
3
|
+
"version": "0.1.1271",
|
|
4
4
|
"description": "Veryfront first-party extension package for ext-llm-google",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"veryfront",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@deno/shim-crypto": "~0.3.1"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"veryfront": "^0.1.1271
|
|
52
|
+
"veryfront": "^0.1.1271"
|
|
53
53
|
},
|
|
54
54
|
"type": "module",
|
|
55
55
|
"types": "./esm/index.d.ts",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"NOTICE",
|
|
60
60
|
"README.md"
|
|
61
61
|
],
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "48e040987859350ca028ed696b8774ca092d1846"
|
|
63
63
|
}
|