@ai-sdk/google 3.0.78 → 3.0.79
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/CHANGELOG.md +6 -0
- package/dist/index.d.mts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +43 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -9
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/google-generative-ai-image-model.ts +55 -4
- package/src/tool/google-search.ts +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@ai-sdk/provider-utils";
|
|
8
8
|
|
|
9
9
|
// src/version.ts
|
|
10
|
-
var VERSION = true ? "3.0.
|
|
10
|
+
var VERSION = true ? "3.0.79" : "0.0.0-test";
|
|
11
11
|
|
|
12
12
|
// src/google-generative-ai-embedding-model.ts
|
|
13
13
|
import {
|
|
@@ -2708,7 +2708,15 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
2708
2708
|
parameters.aspectRatio = aspectRatio;
|
|
2709
2709
|
}
|
|
2710
2710
|
if (googleOptions) {
|
|
2711
|
-
|
|
2711
|
+
const { googleSearch: imagenGoogleSearch, ...imagenOptions } = googleOptions;
|
|
2712
|
+
if (imagenGoogleSearch != null) {
|
|
2713
|
+
warnings.push({
|
|
2714
|
+
type: "unsupported",
|
|
2715
|
+
feature: "googleSearch",
|
|
2716
|
+
details: "Google Search grounding is only supported on Gemini image models."
|
|
2717
|
+
});
|
|
2718
|
+
}
|
|
2719
|
+
Object.assign(parameters, imagenOptions);
|
|
2712
2720
|
}
|
|
2713
2721
|
const body = {
|
|
2714
2722
|
instances: [{ prompt }],
|
|
@@ -2745,7 +2753,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
2745
2753
|
};
|
|
2746
2754
|
}
|
|
2747
2755
|
async doGenerateGemini(options) {
|
|
2748
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2756
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2749
2757
|
const {
|
|
2750
2758
|
prompt,
|
|
2751
2759
|
n,
|
|
@@ -2800,12 +2808,18 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
2800
2808
|
const languageModelPrompt = [
|
|
2801
2809
|
{ role: "user", content: userContent }
|
|
2802
2810
|
];
|
|
2811
|
+
const googleImageOptions = await parseProviderOptions3({
|
|
2812
|
+
provider: "google",
|
|
2813
|
+
providerOptions,
|
|
2814
|
+
schema: googleImageModelOptionsSchema
|
|
2815
|
+
});
|
|
2816
|
+
const { googleSearch: _strippedGoogleSearch, ...passthroughGoogleOptions } = (_a = providerOptions == null ? void 0 : providerOptions.google) != null ? _a : {};
|
|
2803
2817
|
const languageModel = new GoogleGenerativeAILanguageModel(this.modelId, {
|
|
2804
2818
|
provider: this.config.provider,
|
|
2805
2819
|
baseURL: this.config.baseURL,
|
|
2806
|
-
headers: (
|
|
2820
|
+
headers: (_b = this.config.headers) != null ? _b : {},
|
|
2807
2821
|
fetch: this.config.fetch,
|
|
2808
|
-
generateId: (
|
|
2822
|
+
generateId: (_c = this.config.generateId) != null ? _c : defaultGenerateId
|
|
2809
2823
|
});
|
|
2810
2824
|
const result = await languageModel.doGenerate({
|
|
2811
2825
|
prompt: languageModelPrompt,
|
|
@@ -2816,9 +2830,17 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
2816
2830
|
imageConfig: aspectRatio ? {
|
|
2817
2831
|
aspectRatio
|
|
2818
2832
|
} : void 0,
|
|
2819
|
-
...
|
|
2833
|
+
...passthroughGoogleOptions
|
|
2820
2834
|
}
|
|
2821
2835
|
},
|
|
2836
|
+
tools: (googleImageOptions == null ? void 0 : googleImageOptions.googleSearch) != null ? [
|
|
2837
|
+
{
|
|
2838
|
+
type: "provider",
|
|
2839
|
+
id: "google.google_search",
|
|
2840
|
+
name: "google_search",
|
|
2841
|
+
args: googleImageOptions.googleSearch
|
|
2842
|
+
}
|
|
2843
|
+
] : void 0,
|
|
2822
2844
|
headers,
|
|
2823
2845
|
abortSignal
|
|
2824
2846
|
});
|
|
@@ -2829,23 +2851,25 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
2829
2851
|
images.push(convertToBase642(part.data));
|
|
2830
2852
|
}
|
|
2831
2853
|
}
|
|
2854
|
+
const languageModelGoogleMetadata = (_h = (_g = result.providerMetadata) == null ? void 0 : _g.google) != null ? _h : {};
|
|
2832
2855
|
return {
|
|
2833
2856
|
images,
|
|
2834
2857
|
warnings,
|
|
2835
2858
|
providerMetadata: {
|
|
2836
2859
|
google: {
|
|
2860
|
+
...languageModelGoogleMetadata,
|
|
2837
2861
|
images: images.map(() => ({}))
|
|
2838
2862
|
}
|
|
2839
2863
|
},
|
|
2840
2864
|
response: {
|
|
2841
2865
|
timestamp: currentDate,
|
|
2842
2866
|
modelId: this.modelId,
|
|
2843
|
-
headers: (
|
|
2867
|
+
headers: (_i = result.response) == null ? void 0 : _i.headers
|
|
2844
2868
|
},
|
|
2845
2869
|
usage: result.usage ? {
|
|
2846
2870
|
inputTokens: result.usage.inputTokens.total,
|
|
2847
2871
|
outputTokens: result.usage.outputTokens.total,
|
|
2848
|
-
totalTokens: ((
|
|
2872
|
+
totalTokens: ((_j = result.usage.inputTokens.total) != null ? _j : 0) + ((_k = result.usage.outputTokens.total) != null ? _k : 0)
|
|
2849
2873
|
} : void 0
|
|
2850
2874
|
};
|
|
2851
2875
|
}
|
|
@@ -2864,7 +2888,17 @@ var googleImageModelOptionsSchema = lazySchema11(
|
|
|
2864
2888
|
() => zodSchema11(
|
|
2865
2889
|
z13.object({
|
|
2866
2890
|
personGeneration: z13.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
2867
|
-
aspectRatio: z13.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
|
|
2891
|
+
aspectRatio: z13.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish(),
|
|
2892
|
+
/**
|
|
2893
|
+
* Enable Google Search grounding for Gemini image models. The value is
|
|
2894
|
+
* forwarded as the args of the `google.tools.googleSearch` provider
|
|
2895
|
+
* tool on the underlying language-model call. Pass `{}` for defaults.
|
|
2896
|
+
*
|
|
2897
|
+
* `generateImage` does not accept a `tools` parameter, so this is the
|
|
2898
|
+
* dedicated escape hatch for grounding image generation the same way
|
|
2899
|
+
* `generateText` does.
|
|
2900
|
+
*/
|
|
2901
|
+
googleSearch: googleSearchToolArgsBaseSchema.optional()
|
|
2868
2902
|
})
|
|
2869
2903
|
)
|
|
2870
2904
|
);
|