@ai-sdk/google-vertex 5.0.132 → 5.0.134
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 +40 -0
- package/dist/anthropic/edge/index.js +1 -1
- package/dist/edge/index.d.ts.map +1 -1
- package/dist/edge/index.js +502 -13
- package/dist/edge/index.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +502 -13
- package/dist/index.js.map +1 -1
- package/dist/maas/edge/index.d.ts.map +1 -1
- package/dist/maas/edge/index.js +43 -14
- package/dist/maas/edge/index.js.map +1 -1
- package/dist/maas/index.d.ts.map +1 -1
- package/dist/maas/index.js +42 -13
- package/dist/maas/index.js.map +1 -1
- package/dist/xai/edge/index.js +1 -1
- package/docs/16-google-vertex.mdx +167 -32
- package/package.json +6 -6
- package/src/gemini-transcription/google-vertex-gemini-transcription-model.ts +2 -1
- package/src/google-vertex-embedding-model.ts +2 -1
- package/src/google-vertex-image-model.ts +5 -9
- package/src/google-vertex-model-catalog-config.ts +42 -0
- package/src/google-vertex-model-catalog.ts +586 -0
- package/src/google-vertex-provider-base.ts +4 -5
- package/src/maas/edge/google-vertex-maas-provider-edge.ts +14 -1
- package/src/maas/google-vertex-maas-provider-node.ts +14 -1
- package/src/maas/google-vertex-maas-provider.ts +24 -16
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getGoogleVertexRequestConfig } from '../google-vertex-model-catalog-config';
|
|
1
2
|
import { InvalidArgumentError } from '@ai-sdk/provider';
|
|
2
3
|
import {
|
|
3
4
|
createOpenAICompatible,
|
|
@@ -13,13 +14,9 @@ import {
|
|
|
13
14
|
} from '@ai-sdk/provider-utils';
|
|
14
15
|
import type { GoogleVertexMaasModelId } from './google-vertex-maas-options';
|
|
15
16
|
|
|
16
|
-
const maxOutputTokensByModel: Record<string, number | undefined> = {
|
|
17
|
-
'meta/llama-4-maverick-17b-128e-instruct-maas': 8192,
|
|
18
|
-
'meta/llama-4-scout-17b-16e-instruct-maas': 8192,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
17
|
function transformGoogleVertexMaasRequestBody(args: Record<string, any>) {
|
|
22
|
-
const maxOutputTokens =
|
|
18
|
+
const maxOutputTokens = getGoogleVertexRequestConfig(args.model).language
|
|
19
|
+
?.maxOutputTokens;
|
|
23
20
|
|
|
24
21
|
return maxOutputTokens != null && args.max_tokens === undefined
|
|
25
22
|
? { ...args, max_tokens: maxOutputTokens }
|
|
@@ -67,14 +64,16 @@ export interface GoogleVertexMaasProviderSettings {
|
|
|
67
64
|
}
|
|
68
65
|
|
|
69
66
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/maas/use-open-models
|
|
67
|
+
* Loads the base URL of the MaaS API from the settings or from the project and
|
|
68
|
+
* location. Settings are loaded on each call so environment variables are read
|
|
69
|
+
* at runtime.
|
|
74
70
|
*/
|
|
75
|
-
export function
|
|
76
|
-
options:
|
|
77
|
-
|
|
71
|
+
export function loadGoogleVertexMaasBaseURL(
|
|
72
|
+
options: Pick<
|
|
73
|
+
GoogleVertexMaasProviderSettings,
|
|
74
|
+
'baseURL' | 'project' | 'location'
|
|
75
|
+
>,
|
|
76
|
+
): string {
|
|
78
77
|
// Lazy-load settings to support loading from environment variables at runtime
|
|
79
78
|
const loadLocation = () => {
|
|
80
79
|
const location =
|
|
@@ -117,14 +116,23 @@ export function createGoogleVertexMaas(
|
|
|
117
116
|
return `https://${getHost(location)}/v1/projects/${projectId}/locations/${location}/endpoints/openapi`;
|
|
118
117
|
};
|
|
119
118
|
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
return withoutTrailingSlash(options.baseURL ?? '') || constructBaseURL();
|
|
120
|
+
}
|
|
122
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Create a Google Vertex AI MaaS (Model as a Service) provider instance.
|
|
124
|
+
* Uses the OpenAI-compatible Chat Completions API for partner and open models.
|
|
125
|
+
*
|
|
126
|
+
* @see https://cloud.google.com/vertex-ai/generative-ai/docs/maas/use-open-models
|
|
127
|
+
*/
|
|
128
|
+
export function createGoogleVertexMaas(
|
|
129
|
+
options: GoogleVertexMaasProviderSettings = {},
|
|
130
|
+
): GoogleVertexMaasProvider {
|
|
123
131
|
let cachedProvider: GoogleVertexMaasProvider | undefined;
|
|
124
132
|
const getProvider = () =>
|
|
125
133
|
(cachedProvider ??= createOpenAICompatible({
|
|
126
134
|
name: 'vertex.maas',
|
|
127
|
-
baseURL:
|
|
135
|
+
baseURL: loadGoogleVertexMaasBaseURL(options),
|
|
128
136
|
fetch: options.fetch,
|
|
129
137
|
transformRequestBody: transformGoogleVertexMaasRequestBody,
|
|
130
138
|
}));
|