@ai-sdk/google 3.0.10 → 3.0.12
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 +12 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/docs/15-google-generative-ai.mdx +1088 -0
- package/package.json +9 -4
- package/src/__snapshots__/google-generative-ai-embedding-model.test.ts.snap +33 -0
- package/src/convert-google-generative-ai-usage.ts +51 -0
- package/src/convert-json-schema-to-openapi-schema.test.ts +684 -0
- package/src/convert-json-schema-to-openapi-schema.ts +158 -0
- package/src/convert-to-google-generative-ai-messages.test.ts +495 -0
- package/src/convert-to-google-generative-ai-messages.ts +232 -0
- package/src/get-model-path.test.ts +16 -0
- package/src/get-model-path.ts +3 -0
- package/src/google-error.ts +26 -0
- package/src/google-generative-ai-embedding-model.test.ts +204 -0
- package/src/google-generative-ai-embedding-model.ts +159 -0
- package/src/google-generative-ai-embedding-options.ts +52 -0
- package/src/google-generative-ai-image-model.test.ts +411 -0
- package/src/google-generative-ai-image-model.ts +184 -0
- package/src/google-generative-ai-image-settings.ts +12 -0
- package/src/google-generative-ai-language-model.test.ts +4616 -0
- package/src/google-generative-ai-language-model.ts +1009 -0
- package/src/google-generative-ai-options.ts +193 -0
- package/src/google-generative-ai-prompt.ts +38 -0
- package/src/google-prepare-tools.test.ts +474 -0
- package/src/google-prepare-tools.ts +264 -0
- package/src/google-provider.test.ts +307 -0
- package/src/google-provider.ts +201 -0
- package/src/google-supported-file-url.test.ts +57 -0
- package/src/google-supported-file-url.ts +20 -0
- package/src/google-tools.ts +71 -0
- package/src/index.ts +11 -0
- package/src/internal/index.ts +3 -0
- package/src/map-google-generative-ai-finish-reason.ts +29 -0
- package/src/tool/code-execution.ts +35 -0
- package/src/tool/enterprise-web-search.ts +18 -0
- package/src/tool/file-search.ts +51 -0
- package/src/tool/google-maps.ts +14 -0
- package/src/tool/google-search.ts +40 -0
- package/src/tool/url-context.ts +16 -0
- package/src/tool/vertex-rag-store.ts +31 -0
- package/src/version.ts +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/google",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.12",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -8,10 +8,15 @@
|
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist/**/*",
|
|
11
|
+
"docs/**/*",
|
|
12
|
+
"src",
|
|
11
13
|
"CHANGELOG.md",
|
|
12
14
|
"README.md",
|
|
13
15
|
"internal.d.ts"
|
|
14
16
|
],
|
|
17
|
+
"directories": {
|
|
18
|
+
"doc": "./docs"
|
|
19
|
+
},
|
|
15
20
|
"exports": {
|
|
16
21
|
"./package.json": "./package.json",
|
|
17
22
|
".": {
|
|
@@ -35,8 +40,8 @@
|
|
|
35
40
|
"tsup": "^8",
|
|
36
41
|
"typescript": "5.8.3",
|
|
37
42
|
"zod": "3.25.76",
|
|
38
|
-
"@ai-
|
|
39
|
-
"@
|
|
43
|
+
"@vercel/ai-tsconfig": "0.0.0",
|
|
44
|
+
"@ai-sdk/test-server": "1.0.2"
|
|
40
45
|
},
|
|
41
46
|
"peerDependencies": {
|
|
42
47
|
"zod": "^3.25.76 || ^4.1.8"
|
|
@@ -61,7 +66,7 @@
|
|
|
61
66
|
"scripts": {
|
|
62
67
|
"build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
|
|
63
68
|
"build:watch": "pnpm clean && tsup --watch",
|
|
64
|
-
"clean": "del-cli dist *.tsbuildinfo",
|
|
69
|
+
"clean": "del-cli dist docs *.tsbuildinfo",
|
|
65
70
|
"lint": "eslint \"./**/*.ts*\"",
|
|
66
71
|
"type-check": "tsc --build",
|
|
67
72
|
"prettier-check": "prettier --check \"./**/*.ts*\"",
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`GoogleGenerativeAIEmbeddingModel > should expose the raw response 1`] = `
|
|
4
|
+
{
|
|
5
|
+
"body": {
|
|
6
|
+
"embeddings": [
|
|
7
|
+
{
|
|
8
|
+
"values": [
|
|
9
|
+
0.1,
|
|
10
|
+
0.2,
|
|
11
|
+
0.3,
|
|
12
|
+
0.4,
|
|
13
|
+
0.5,
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"values": [
|
|
18
|
+
0.6,
|
|
19
|
+
0.7,
|
|
20
|
+
0.8,
|
|
21
|
+
0.9,
|
|
22
|
+
1,
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
"headers": {
|
|
28
|
+
"content-length": "80",
|
|
29
|
+
"content-type": "application/json",
|
|
30
|
+
"test-header": "test-value",
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { LanguageModelV3Usage } from '@ai-sdk/provider';
|
|
2
|
+
|
|
3
|
+
export type GoogleGenerativeAIUsageMetadata = {
|
|
4
|
+
promptTokenCount?: number | null;
|
|
5
|
+
candidatesTokenCount?: number | null;
|
|
6
|
+
totalTokenCount?: number | null;
|
|
7
|
+
cachedContentTokenCount?: number | null;
|
|
8
|
+
thoughtsTokenCount?: number | null;
|
|
9
|
+
trafficType?: string | null;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export function convertGoogleGenerativeAIUsage(
|
|
13
|
+
usage: GoogleGenerativeAIUsageMetadata | undefined | null,
|
|
14
|
+
): LanguageModelV3Usage {
|
|
15
|
+
if (usage == null) {
|
|
16
|
+
return {
|
|
17
|
+
inputTokens: {
|
|
18
|
+
total: undefined,
|
|
19
|
+
noCache: undefined,
|
|
20
|
+
cacheRead: undefined,
|
|
21
|
+
cacheWrite: undefined,
|
|
22
|
+
},
|
|
23
|
+
outputTokens: {
|
|
24
|
+
total: undefined,
|
|
25
|
+
text: undefined,
|
|
26
|
+
reasoning: undefined,
|
|
27
|
+
},
|
|
28
|
+
raw: undefined,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const promptTokens = usage.promptTokenCount ?? 0;
|
|
33
|
+
const candidatesTokens = usage.candidatesTokenCount ?? 0;
|
|
34
|
+
const cachedContentTokens = usage.cachedContentTokenCount ?? 0;
|
|
35
|
+
const thoughtsTokens = usage.thoughtsTokenCount ?? 0;
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
inputTokens: {
|
|
39
|
+
total: promptTokens,
|
|
40
|
+
noCache: promptTokens - cachedContentTokens,
|
|
41
|
+
cacheRead: cachedContentTokens,
|
|
42
|
+
cacheWrite: undefined,
|
|
43
|
+
},
|
|
44
|
+
outputTokens: {
|
|
45
|
+
total: candidatesTokens + thoughtsTokens,
|
|
46
|
+
text: candidatesTokens,
|
|
47
|
+
reasoning: thoughtsTokens,
|
|
48
|
+
},
|
|
49
|
+
raw: usage,
|
|
50
|
+
};
|
|
51
|
+
}
|