@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/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -225,6 +225,17 @@ interface GoogleGenerativeAIImageSettings {
|
|
|
225
225
|
declare const googleImageModelOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
226
226
|
personGeneration?: "dont_allow" | "allow_adult" | "allow_all" | null | undefined;
|
|
227
227
|
aspectRatio?: "1:1" | "3:4" | "4:3" | "9:16" | "16:9" | null | undefined;
|
|
228
|
+
googleSearch?: {
|
|
229
|
+
[x: string]: unknown;
|
|
230
|
+
searchTypes?: {
|
|
231
|
+
webSearch?: Record<string, never> | undefined;
|
|
232
|
+
imageSearch?: Record<string, never> | undefined;
|
|
233
|
+
} | undefined;
|
|
234
|
+
timeRangeFilter?: {
|
|
235
|
+
startTime: string;
|
|
236
|
+
endTime: string;
|
|
237
|
+
} | undefined;
|
|
238
|
+
} | undefined;
|
|
228
239
|
}>;
|
|
229
240
|
type GoogleImageModelOptions = InferSchema<typeof googleImageModelOptionsSchema>;
|
|
230
241
|
|
package/dist/index.d.ts
CHANGED
|
@@ -225,6 +225,17 @@ interface GoogleGenerativeAIImageSettings {
|
|
|
225
225
|
declare const googleImageModelOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
226
226
|
personGeneration?: "dont_allow" | "allow_adult" | "allow_all" | null | undefined;
|
|
227
227
|
aspectRatio?: "1:1" | "3:4" | "4:3" | "9:16" | "16:9" | null | undefined;
|
|
228
|
+
googleSearch?: {
|
|
229
|
+
[x: string]: unknown;
|
|
230
|
+
searchTypes?: {
|
|
231
|
+
webSearch?: Record<string, never> | undefined;
|
|
232
|
+
imageSearch?: Record<string, never> | undefined;
|
|
233
|
+
} | undefined;
|
|
234
|
+
timeRangeFilter?: {
|
|
235
|
+
startTime: string;
|
|
236
|
+
endTime: string;
|
|
237
|
+
} | undefined;
|
|
238
|
+
} | undefined;
|
|
228
239
|
}>;
|
|
229
240
|
type GoogleImageModelOptions = InferSchema<typeof googleImageModelOptionsSchema>;
|
|
230
241
|
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
30
30
|
var import_provider_utils23 = require("@ai-sdk/provider-utils");
|
|
31
31
|
|
|
32
32
|
// src/version.ts
|
|
33
|
-
var VERSION = true ? "3.0.
|
|
33
|
+
var VERSION = true ? "3.0.79" : "0.0.0-test";
|
|
34
34
|
|
|
35
35
|
// src/google-generative-ai-embedding-model.ts
|
|
36
36
|
var import_provider = require("@ai-sdk/provider");
|
|
@@ -2667,7 +2667,15 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
2667
2667
|
parameters.aspectRatio = aspectRatio;
|
|
2668
2668
|
}
|
|
2669
2669
|
if (googleOptions) {
|
|
2670
|
-
|
|
2670
|
+
const { googleSearch: imagenGoogleSearch, ...imagenOptions } = googleOptions;
|
|
2671
|
+
if (imagenGoogleSearch != null) {
|
|
2672
|
+
warnings.push({
|
|
2673
|
+
type: "unsupported",
|
|
2674
|
+
feature: "googleSearch",
|
|
2675
|
+
details: "Google Search grounding is only supported on Gemini image models."
|
|
2676
|
+
});
|
|
2677
|
+
}
|
|
2678
|
+
Object.assign(parameters, imagenOptions);
|
|
2671
2679
|
}
|
|
2672
2680
|
const body = {
|
|
2673
2681
|
instances: [{ prompt }],
|
|
@@ -2704,7 +2712,7 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
2704
2712
|
};
|
|
2705
2713
|
}
|
|
2706
2714
|
async doGenerateGemini(options) {
|
|
2707
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2715
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2708
2716
|
const {
|
|
2709
2717
|
prompt,
|
|
2710
2718
|
n,
|
|
@@ -2759,12 +2767,18 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
2759
2767
|
const languageModelPrompt = [
|
|
2760
2768
|
{ role: "user", content: userContent }
|
|
2761
2769
|
];
|
|
2770
|
+
const googleImageOptions = await (0, import_provider_utils14.parseProviderOptions)({
|
|
2771
|
+
provider: "google",
|
|
2772
|
+
providerOptions,
|
|
2773
|
+
schema: googleImageModelOptionsSchema
|
|
2774
|
+
});
|
|
2775
|
+
const { googleSearch: _strippedGoogleSearch, ...passthroughGoogleOptions } = (_a = providerOptions == null ? void 0 : providerOptions.google) != null ? _a : {};
|
|
2762
2776
|
const languageModel = new GoogleGenerativeAILanguageModel(this.modelId, {
|
|
2763
2777
|
provider: this.config.provider,
|
|
2764
2778
|
baseURL: this.config.baseURL,
|
|
2765
|
-
headers: (
|
|
2779
|
+
headers: (_b = this.config.headers) != null ? _b : {},
|
|
2766
2780
|
fetch: this.config.fetch,
|
|
2767
|
-
generateId: (
|
|
2781
|
+
generateId: (_c = this.config.generateId) != null ? _c : import_provider_utils14.generateId
|
|
2768
2782
|
});
|
|
2769
2783
|
const result = await languageModel.doGenerate({
|
|
2770
2784
|
prompt: languageModelPrompt,
|
|
@@ -2775,9 +2789,17 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
2775
2789
|
imageConfig: aspectRatio ? {
|
|
2776
2790
|
aspectRatio
|
|
2777
2791
|
} : void 0,
|
|
2778
|
-
...
|
|
2792
|
+
...passthroughGoogleOptions
|
|
2779
2793
|
}
|
|
2780
2794
|
},
|
|
2795
|
+
tools: (googleImageOptions == null ? void 0 : googleImageOptions.googleSearch) != null ? [
|
|
2796
|
+
{
|
|
2797
|
+
type: "provider",
|
|
2798
|
+
id: "google.google_search",
|
|
2799
|
+
name: "google_search",
|
|
2800
|
+
args: googleImageOptions.googleSearch
|
|
2801
|
+
}
|
|
2802
|
+
] : void 0,
|
|
2781
2803
|
headers,
|
|
2782
2804
|
abortSignal
|
|
2783
2805
|
});
|
|
@@ -2788,23 +2810,25 @@ var GoogleGenerativeAIImageModel = class {
|
|
|
2788
2810
|
images.push((0, import_provider_utils14.convertToBase64)(part.data));
|
|
2789
2811
|
}
|
|
2790
2812
|
}
|
|
2813
|
+
const languageModelGoogleMetadata = (_h = (_g = result.providerMetadata) == null ? void 0 : _g.google) != null ? _h : {};
|
|
2791
2814
|
return {
|
|
2792
2815
|
images,
|
|
2793
2816
|
warnings,
|
|
2794
2817
|
providerMetadata: {
|
|
2795
2818
|
google: {
|
|
2819
|
+
...languageModelGoogleMetadata,
|
|
2796
2820
|
images: images.map(() => ({}))
|
|
2797
2821
|
}
|
|
2798
2822
|
},
|
|
2799
2823
|
response: {
|
|
2800
2824
|
timestamp: currentDate,
|
|
2801
2825
|
modelId: this.modelId,
|
|
2802
|
-
headers: (
|
|
2826
|
+
headers: (_i = result.response) == null ? void 0 : _i.headers
|
|
2803
2827
|
},
|
|
2804
2828
|
usage: result.usage ? {
|
|
2805
2829
|
inputTokens: result.usage.inputTokens.total,
|
|
2806
2830
|
outputTokens: result.usage.outputTokens.total,
|
|
2807
|
-
totalTokens: ((
|
|
2831
|
+
totalTokens: ((_j = result.usage.inputTokens.total) != null ? _j : 0) + ((_k = result.usage.outputTokens.total) != null ? _k : 0)
|
|
2808
2832
|
} : void 0
|
|
2809
2833
|
};
|
|
2810
2834
|
}
|
|
@@ -2823,7 +2847,17 @@ var googleImageModelOptionsSchema = (0, import_provider_utils14.lazySchema)(
|
|
|
2823
2847
|
() => (0, import_provider_utils14.zodSchema)(
|
|
2824
2848
|
import_v413.z.object({
|
|
2825
2849
|
personGeneration: import_v413.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
|
|
2826
|
-
aspectRatio: import_v413.z.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish()
|
|
2850
|
+
aspectRatio: import_v413.z.enum(["1:1", "3:4", "4:3", "9:16", "16:9"]).nullish(),
|
|
2851
|
+
/**
|
|
2852
|
+
* Enable Google Search grounding for Gemini image models. The value is
|
|
2853
|
+
* forwarded as the args of the `google.tools.googleSearch` provider
|
|
2854
|
+
* tool on the underlying language-model call. Pass `{}` for defaults.
|
|
2855
|
+
*
|
|
2856
|
+
* `generateImage` does not accept a `tools` parameter, so this is the
|
|
2857
|
+
* dedicated escape hatch for grounding image generation the same way
|
|
2858
|
+
* `generateText` does.
|
|
2859
|
+
*/
|
|
2860
|
+
googleSearch: googleSearchToolArgsBaseSchema.optional()
|
|
2827
2861
|
})
|
|
2828
2862
|
)
|
|
2829
2863
|
);
|