@ai-sdk/google 4.0.55 → 4.0.56
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 +7 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +23 -6
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +14 -0
- package/dist/internal/index.js +22 -5
- package/dist/internal/index.js.map +1 -1
- package/package.json +1 -1
- package/src/convert-google-usage.ts +3 -0
- package/src/google-language-model.ts +48 -19
package/dist/internal/index.d.ts
CHANGED
|
@@ -351,18 +351,32 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
351
351
|
} | null | undefined;
|
|
352
352
|
}[] | null | undefined;
|
|
353
353
|
usageMetadata?: {
|
|
354
|
+
[x: string]: unknown;
|
|
354
355
|
cachedContentTokenCount?: number | null | undefined;
|
|
355
356
|
thoughtsTokenCount?: number | null | undefined;
|
|
356
357
|
promptTokenCount?: number | null | undefined;
|
|
357
358
|
candidatesTokenCount?: number | null | undefined;
|
|
359
|
+
toolUsePromptTokenCount?: number | null | undefined;
|
|
358
360
|
totalTokenCount?: number | null | undefined;
|
|
359
361
|
trafficType?: string | null | undefined;
|
|
360
362
|
serviceTier?: string | null | undefined;
|
|
361
363
|
promptTokensDetails?: {
|
|
364
|
+
[x: string]: unknown;
|
|
365
|
+
modality: string;
|
|
366
|
+
tokenCount: number;
|
|
367
|
+
}[] | null | undefined;
|
|
368
|
+
cacheTokensDetails?: {
|
|
369
|
+
[x: string]: unknown;
|
|
362
370
|
modality: string;
|
|
363
371
|
tokenCount: number;
|
|
364
372
|
}[] | null | undefined;
|
|
365
373
|
candidatesTokensDetails?: {
|
|
374
|
+
[x: string]: unknown;
|
|
375
|
+
modality: string;
|
|
376
|
+
tokenCount: number;
|
|
377
|
+
}[] | null | undefined;
|
|
378
|
+
toolUsePromptTokensDetails?: {
|
|
379
|
+
[x: string]: unknown;
|
|
366
380
|
modality: string;
|
|
367
381
|
tokenCount: number;
|
|
368
382
|
}[] | null | undefined;
|
package/dist/internal/index.js
CHANGED
|
@@ -1553,6 +1553,7 @@ var configurableSafetySettingCategories = [
|
|
|
1553
1553
|
"HARM_CATEGORY_HARASSMENT",
|
|
1554
1554
|
"HARM_CATEGORY_SEXUALLY_EXPLICIT"
|
|
1555
1555
|
];
|
|
1556
|
+
var gemini25ModelPattern2 = /(^|\/)gemini-2\.5(?:[.-]|$)/i;
|
|
1556
1557
|
var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
1557
1558
|
constructor(modelId, config) {
|
|
1558
1559
|
this.specificationVersion = "v4";
|
|
@@ -1670,6 +1671,19 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1670
1671
|
}
|
|
1671
1672
|
}
|
|
1672
1673
|
const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
|
|
1674
|
+
const isGemini25DeveloperApiModel = !isVertexProvider && gemini25ModelPattern2.test(this.modelId);
|
|
1675
|
+
if (isGemini25DeveloperApiModel && frequencyPenalty != null) {
|
|
1676
|
+
warnings.push({
|
|
1677
|
+
type: "unsupported",
|
|
1678
|
+
feature: "frequencyPenalty"
|
|
1679
|
+
});
|
|
1680
|
+
}
|
|
1681
|
+
if (isGemini25DeveloperApiModel && presencePenalty != null) {
|
|
1682
|
+
warnings.push({
|
|
1683
|
+
type: "unsupported",
|
|
1684
|
+
feature: "presencePenalty"
|
|
1685
|
+
});
|
|
1686
|
+
}
|
|
1673
1687
|
const { usesGemini3Features } = getGoogleModelCapabilities(this.modelId);
|
|
1674
1688
|
const { contents, systemInstruction } = convertToGoogleMessages(prompt, {
|
|
1675
1689
|
isGemmaModel,
|
|
@@ -1721,8 +1735,8 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1721
1735
|
temperature,
|
|
1722
1736
|
topK,
|
|
1723
1737
|
topP,
|
|
1724
|
-
frequencyPenalty,
|
|
1725
|
-
presencePenalty,
|
|
1738
|
+
frequencyPenalty: isGemini25DeveloperApiModel ? void 0 : frequencyPenalty,
|
|
1739
|
+
presencePenalty: isGemini25DeveloperApiModel ? void 0 : presencePenalty,
|
|
1726
1740
|
stopSequences,
|
|
1727
1741
|
seed,
|
|
1728
1742
|
// response format:
|
|
@@ -2683,21 +2697,24 @@ var tokenDetailsSchema = z3.array(
|
|
|
2683
2697
|
z3.object({
|
|
2684
2698
|
modality: z3.string(),
|
|
2685
2699
|
tokenCount: z3.number()
|
|
2686
|
-
})
|
|
2700
|
+
}).loose()
|
|
2687
2701
|
).nullish();
|
|
2688
2702
|
var usageSchema = z3.object({
|
|
2689
2703
|
cachedContentTokenCount: z3.number().nullish(),
|
|
2690
2704
|
thoughtsTokenCount: z3.number().nullish(),
|
|
2691
2705
|
promptTokenCount: z3.number().nullish(),
|
|
2692
2706
|
candidatesTokenCount: z3.number().nullish(),
|
|
2707
|
+
toolUsePromptTokenCount: z3.number().nullish(),
|
|
2693
2708
|
totalTokenCount: z3.number().nullish(),
|
|
2694
2709
|
// https://cloud.google.com/vertex-ai/generative-ai/docs/reference/rest/v1/GenerateContentResponse#TrafficType
|
|
2695
2710
|
trafficType: z3.string().nullish(),
|
|
2696
2711
|
serviceTier: z3.string().nullish(),
|
|
2697
2712
|
// https://ai.google.dev/api/generate-content#Modality
|
|
2698
2713
|
promptTokensDetails: tokenDetailsSchema,
|
|
2699
|
-
|
|
2700
|
-
|
|
2714
|
+
cacheTokensDetails: tokenDetailsSchema,
|
|
2715
|
+
candidatesTokensDetails: tokenDetailsSchema,
|
|
2716
|
+
toolUsePromptTokensDetails: tokenDetailsSchema
|
|
2717
|
+
}).loose();
|
|
2701
2718
|
var getUrlContextMetadataSchema = () => z3.object({
|
|
2702
2719
|
urlMetadata: z3.array(
|
|
2703
2720
|
z3.object({
|