@ai-sdk/google 3.0.50 → 3.0.51
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 +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -8
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +4 -1
- package/dist/internal/index.d.ts +4 -1
- package/dist/internal/index.js +9 -7
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +9 -7
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/google-generative-ai-language-model.ts +19 -11
- package/src/google-generative-ai-prompt.ts +9 -0
|
@@ -38,7 +38,10 @@ import {
|
|
|
38
38
|
GoogleGenerativeAIModelId,
|
|
39
39
|
googleLanguageModelOptions,
|
|
40
40
|
} from './google-generative-ai-options';
|
|
41
|
-
import {
|
|
41
|
+
import {
|
|
42
|
+
GoogleGenerativeAIContentPart,
|
|
43
|
+
GoogleGenerativeAIProviderMetadata,
|
|
44
|
+
} from './google-generative-ai-prompt';
|
|
42
45
|
import { prepareTools } from './google-prepare-tools';
|
|
43
46
|
import { mapGoogleGenerativeAIFinishReason } from './map-google-generative-ai-finish-reason';
|
|
44
47
|
|
|
@@ -355,7 +358,8 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
|
|
|
355
358
|
urlContextMetadata: candidate.urlContextMetadata ?? null,
|
|
356
359
|
safetyRatings: candidate.safetyRatings ?? null,
|
|
357
360
|
usageMetadata: usageMetadata ?? null,
|
|
358
|
-
|
|
361
|
+
finishMessage: candidate.finishMessage ?? null,
|
|
362
|
+
} satisfies GoogleGenerativeAIProviderMetadata,
|
|
359
363
|
},
|
|
360
364
|
request: { body: args },
|
|
361
365
|
response: {
|
|
@@ -674,16 +678,10 @@ export class GoogleGenerativeAILanguageModel implements LanguageModelV3 {
|
|
|
674
678
|
groundingMetadata: lastGroundingMetadata,
|
|
675
679
|
urlContextMetadata: lastUrlContextMetadata,
|
|
676
680
|
safetyRatings: candidate.safetyRatings ?? null,
|
|
677
|
-
|
|
681
|
+
usageMetadata: usageMetadata ?? null,
|
|
682
|
+
finishMessage: candidate.finishMessage ?? null,
|
|
683
|
+
} satisfies GoogleGenerativeAIProviderMetadata,
|
|
678
684
|
};
|
|
679
|
-
if (usageMetadata != null) {
|
|
680
|
-
(
|
|
681
|
-
providerMetadata[providerOptionsName] as Record<
|
|
682
|
-
string,
|
|
683
|
-
unknown
|
|
684
|
-
>
|
|
685
|
-
).usageMetadata = usageMetadata;
|
|
686
|
-
}
|
|
687
685
|
}
|
|
688
686
|
},
|
|
689
687
|
|
|
@@ -1012,6 +1010,7 @@ const responseSchema = lazySchema(() =>
|
|
|
1012
1010
|
z.object({
|
|
1013
1011
|
content: getContentSchema().nullish().or(z.object({}).strict()),
|
|
1014
1012
|
finishReason: z.string().nullish(),
|
|
1013
|
+
finishMessage: z.string().nullish(),
|
|
1015
1014
|
safetyRatings: z.array(getSafetyRatingSchema()).nullish(),
|
|
1016
1015
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
1017
1016
|
urlContextMetadata: getUrlContextMetadataSchema().nullish(),
|
|
@@ -1047,6 +1046,14 @@ export type SafetyRatingSchema = NonNullable<
|
|
|
1047
1046
|
InferSchema<typeof responseSchema>['candidates'][number]['safetyRatings']
|
|
1048
1047
|
>[number];
|
|
1049
1048
|
|
|
1049
|
+
export type PromptFeedbackSchema = NonNullable<
|
|
1050
|
+
InferSchema<typeof responseSchema>['promptFeedback']
|
|
1051
|
+
>;
|
|
1052
|
+
|
|
1053
|
+
export type UsageMetadataSchema = NonNullable<
|
|
1054
|
+
InferSchema<typeof responseSchema>['usageMetadata']
|
|
1055
|
+
>;
|
|
1056
|
+
|
|
1050
1057
|
// limited version of the schema, focussed on what is needed for the implementation
|
|
1051
1058
|
// this approach limits breakages when the API changes and increases efficiency
|
|
1052
1059
|
const chunkSchema = lazySchema(() =>
|
|
@@ -1057,6 +1064,7 @@ const chunkSchema = lazySchema(() =>
|
|
|
1057
1064
|
z.object({
|
|
1058
1065
|
content: getContentSchema().nullish(),
|
|
1059
1066
|
finishReason: z.string().nullish(),
|
|
1067
|
+
finishMessage: z.string().nullish(),
|
|
1060
1068
|
safetyRatings: z.array(getSafetyRatingSchema()).nullish(),
|
|
1061
1069
|
groundingMetadata: getGroundingMetadataSchema().nullish(),
|
|
1062
1070
|
urlContextMetadata: getUrlContextMetadataSchema().nullish(),
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
GroundingMetadataSchema,
|
|
3
|
+
PromptFeedbackSchema,
|
|
3
4
|
UrlContextMetadataSchema,
|
|
5
|
+
UsageMetadataSchema,
|
|
4
6
|
} from './google-generative-ai-language-model';
|
|
5
7
|
import { type SafetyRatingSchema } from './google-generative-ai-language-model';
|
|
6
8
|
|
|
@@ -31,8 +33,15 @@ export type GoogleGenerativeAIUrlContextMetadata = UrlContextMetadataSchema;
|
|
|
31
33
|
|
|
32
34
|
export type GoogleGenerativeAISafetyRating = SafetyRatingSchema;
|
|
33
35
|
|
|
36
|
+
export type GoogleGenerativeAIPromptFeedback = PromptFeedbackSchema;
|
|
37
|
+
|
|
38
|
+
export type GoogleGenerativeAIUsageMetadata = UsageMetadataSchema;
|
|
39
|
+
|
|
34
40
|
export interface GoogleGenerativeAIProviderMetadata {
|
|
41
|
+
promptFeedback: GoogleGenerativeAIPromptFeedback | null;
|
|
35
42
|
groundingMetadata: GoogleGenerativeAIGroundingMetadata | null;
|
|
36
43
|
urlContextMetadata: GoogleGenerativeAIUrlContextMetadata | null;
|
|
37
44
|
safetyRatings: GoogleGenerativeAISafetyRating[] | null;
|
|
45
|
+
usageMetadata: GoogleGenerativeAIUsageMetadata | null;
|
|
46
|
+
finishMessage: string | null;
|
|
38
47
|
}
|