@veryfront/ext-llm-google 0.1.1245 → 0.1.1246-rc.13463
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/README.md
CHANGED
|
@@ -18,10 +18,11 @@ export default defineConfig({
|
|
|
18
18
|
|
|
19
19
|
## Environment Variables
|
|
20
20
|
|
|
21
|
-
| Variable | Required | Description
|
|
22
|
-
| ------------------------------ | -------- |
|
|
23
|
-
| `GOOGLE_API_KEY` | Yes | Your Google AI API key (from [AI Studio](https://aistudio.google.com/apikey)).
|
|
24
|
-
| `
|
|
21
|
+
| Variable | Required | Description |
|
|
22
|
+
| ------------------------------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
23
|
+
| `GOOGLE_API_KEY` | Yes | Your Google AI API key (from [AI Studio](https://aistudio.google.com/apikey)). |
|
|
24
|
+
| `GOOGLE_GEMINI_BASE_URL` | No | Custom Gemini endpoint (proxy or regional). Include the API version segment, e.g. `https://example.com/v1beta`. Applies to chat and embeddings. |
|
|
25
|
+
| `GOOGLE_GENERATIVE_AI_API_KEY` | No | Alternative name for the API key (checked as fallback). |
|
|
25
26
|
|
|
26
27
|
## Usage
|
|
27
28
|
|
|
@@ -204,6 +205,24 @@ const response = await ai.chat("google/gemini-2.5-pro", {
|
|
|
204
205
|
|
|
205
206
|
See [Gemini safety settings](https://ai.google.dev/gemini-api/docs/safety-settings) for available categories and thresholds.
|
|
206
207
|
|
|
208
|
+
## Structured Outputs
|
|
209
|
+
|
|
210
|
+
A response format maps to Gemini generation config keys. `type: "json"` sets
|
|
211
|
+
`responseMimeType` alone; `type: "json_schema"` adds `responseJsonSchema`:
|
|
212
|
+
|
|
213
|
+
```json
|
|
214
|
+
{
|
|
215
|
+
"generationConfig": {
|
|
216
|
+
"responseMimeType": "application/json",
|
|
217
|
+
"responseJsonSchema": { "type": "object" }
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Gemini has no counterpart for the format name, description, or strict flag, so
|
|
223
|
+
those are not sent. Provider options replace `generationConfig` wholesale, and
|
|
224
|
+
these two keys are re-applied afterward so an override cannot drop the schema.
|
|
225
|
+
|
|
207
226
|
## Provider Options
|
|
208
227
|
|
|
209
228
|
Pass Gemini-specific options through `providerOptions`:
|
|
@@ -242,11 +261,10 @@ When `requestLabels` is set, it takes precedence. Otherwise, `userId` is sent as
|
|
|
242
261
|
|
|
243
262
|
The following settings emit `unsupported-setting` warnings and are silently dropped:
|
|
244
263
|
|
|
245
|
-
| Setting | Reason
|
|
246
|
-
| ------------------ |
|
|
247
|
-
| `presencePenalty` | Gemini `generateContent` does not accept presence penalty.
|
|
248
|
-
| `frequencyPenalty` | Gemini `generateContent` does not accept frequency penalty.
|
|
249
|
-
| `responseFormat` | Gemini uses `generationConfig.responseMimeType` + `responseSchema` instead (use `providerOptions`). |
|
|
264
|
+
| Setting | Reason |
|
|
265
|
+
| ------------------ | ----------------------------------------------------------- |
|
|
266
|
+
| `presencePenalty` | Gemini `generateContent` does not accept presence penalty. |
|
|
267
|
+
| `frequencyPenalty` | Gemini `generateContent` does not accept frequency penalty. |
|
|
250
268
|
|
|
251
269
|
## Error Handling
|
|
252
270
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-provider.d.ts","sourceRoot":"","sources":["../src/google-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,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;AAmdD,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":"AAAA;;;;;;;GAOG;AAEH,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;AAmdD,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,MAAM,GACd,YAAY,CAAC,+BAA+B,EAAE,2BAA2B,CAAC,CAuF5E;AAED,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,MAAM,GACd,gBAAgB,CAiFlB;AAED,qBAAa,cAAe,YAAW,WAAW;IAChD,QAAQ,CAAC,EAAE,YAAY;IAEvB,WAAW,CACT,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,iBAAiB,GACxB,YAAY,CAAC,+BAA+B,EAAE,2BAA2B,CAAC;IAY7E,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,gBAAgB;CAW9E"}
|
package/esm/google-provider.js
CHANGED
|
@@ -371,6 +371,7 @@ export function createGoogleModelRuntime(config, modelId) {
|
|
|
371
371
|
modelId,
|
|
372
372
|
specificationVersion: "v3",
|
|
373
373
|
supportedUrls: {},
|
|
374
|
+
runtimeCapabilities: { structuredOutput: true },
|
|
374
375
|
_reconcileProviderMetadata(input) {
|
|
375
376
|
return reconcileGoogleProviderMetadata(input.providerMetadata, input.suppressedToolCalls);
|
|
376
377
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-request-builder.d.ts","sourceRoot":"","sources":["../src/google-request-builder.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,uBAAuB,EAEvB,0BAA0B,EAE3B,MAAM,2BAA2B,CAAC;AAYnC,MAAM,WAAW,+BAAgC,SAAQ,uBAAuB;IAC9E,aAAa,CA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,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;AAu0BF,wBAAgB,iCAAiC,CAC/C,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,+BAA+B,EACxC,QAAQ,EAAE,gBAAgB,GACzB,uBAAuB,CAsDzB"}
|
|
@@ -575,6 +575,23 @@ function resolveGoogleThinkingConfig(option) {
|
|
|
575
575
|
}
|
|
576
576
|
return config;
|
|
577
577
|
}
|
|
578
|
+
/**
|
|
579
|
+
* Map a framework response format onto Gemini generation config keys.
|
|
580
|
+
*
|
|
581
|
+
* Gemini constrains generation with `responseMimeType` plus, for arbitrary
|
|
582
|
+
* JSON Schema documents, `responseJsonSchema`. It has no counterpart for the
|
|
583
|
+
* format name, description, or strict flag, which are therefore not sent.
|
|
584
|
+
*/
|
|
585
|
+
function buildGoogleStructuredOutputConfig(responseFormat) {
|
|
586
|
+
if (!responseFormat || responseFormat.type === "text")
|
|
587
|
+
return {};
|
|
588
|
+
return {
|
|
589
|
+
responseMimeType: "application/json",
|
|
590
|
+
...(responseFormat.type === "json_schema"
|
|
591
|
+
? { responseJsonSchema: unwrapToolInputSchema(responseFormat.schema) }
|
|
592
|
+
: {}),
|
|
593
|
+
};
|
|
594
|
+
}
|
|
578
595
|
function buildGoogleGenerationConfig(options) {
|
|
579
596
|
const thinkingConfig = resolveGoogleThinkingConfig(options.reasoning);
|
|
580
597
|
const config = {
|
|
@@ -587,6 +604,7 @@ function buildGoogleGenerationConfig(options) {
|
|
|
587
604
|
: {}),
|
|
588
605
|
...(options.seed !== undefined ? { seed: options.seed } : {}),
|
|
589
606
|
...(thinkingConfig ? { thinkingConfig } : {}),
|
|
607
|
+
...buildGoogleStructuredOutputConfig(options.responseFormat),
|
|
590
608
|
};
|
|
591
609
|
return Object.keys(config).length > 0 ? config : undefined;
|
|
592
610
|
}
|
|
@@ -607,14 +625,6 @@ export function buildGoogleGenerateContentRequest(providerName, options, warning
|
|
|
607
625
|
details: "Gemini generateContent does not accept frequencyPenalty; the value was dropped.",
|
|
608
626
|
});
|
|
609
627
|
}
|
|
610
|
-
if (options.responseFormat && options.responseFormat.type !== "text") {
|
|
611
|
-
warnings.push({
|
|
612
|
-
type: "unsupported-setting",
|
|
613
|
-
provider: "google",
|
|
614
|
-
setting: "responseFormat",
|
|
615
|
-
details: "Gemini uses generationConfig.responseMimeType + responseSchema for structured outputs, which is a separate surface and not yet wired through this option.",
|
|
616
|
-
});
|
|
617
|
-
}
|
|
618
628
|
const { systemInstruction, contents } = toGoogleContents(options.prompt);
|
|
619
629
|
const generationConfig = buildGoogleGenerationConfig(options);
|
|
620
630
|
const tools = toGoogleTools(options.tools);
|
|
@@ -639,5 +649,15 @@ export function buildGoogleGenerateContentRequest(providerName, options, warning
|
|
|
639
649
|
: {}),
|
|
640
650
|
};
|
|
641
651
|
Object.assign(body, readProviderOptions(options.providerOptions, "google", providerName));
|
|
652
|
+
// Provider options replace `generationConfig` wholesale, so re-pin the
|
|
653
|
+
// runtime-owned structured-output keys the caller asked for.
|
|
654
|
+
const structuredOutput = buildGoogleStructuredOutputConfig(options.responseFormat);
|
|
655
|
+
if (Object.keys(structuredOutput).length > 0) {
|
|
656
|
+
const generationConfig = { ...(readRecord(body.generationConfig) ?? {}) };
|
|
657
|
+
if ("responseJsonSchema" in structuredOutput) {
|
|
658
|
+
delete generationConfig.responseSchema;
|
|
659
|
+
}
|
|
660
|
+
body.generationConfig = { ...generationConfig, ...structuredOutput };
|
|
661
|
+
}
|
|
642
662
|
return body;
|
|
643
663
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veryfront/ext-llm-google",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1246-rc.13463",
|
|
4
4
|
"description": "Veryfront first-party extension package for ext-llm-google",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"veryfront",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"capabilities": []
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"veryfront": "^0.1.
|
|
48
|
+
"veryfront": "^0.1.1246-rc.13463"
|
|
49
49
|
},
|
|
50
50
|
"type": "module",
|
|
51
51
|
"types": "./esm/index.d.ts",
|