@ai-sdk/google 4.0.93 → 4.0.95
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 +17 -0
- package/dist/index.d.ts +20 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +183 -23
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +6 -3
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +182 -22
- package/dist/internal/index.js.map +1 -1
- package/docs/15-google.mdx +137 -0
- package/package.json +3 -3
- package/src/continue-google-stream.ts +75 -0
- package/src/convert-google-usage.ts +76 -0
- package/src/google-language-model-options.ts +12 -0
- package/src/google-language-model.ts +163 -31
- package/src/google-model-capabilities.ts +6 -6
- package/src/google-prompt.ts +18 -0
- package/src/interactions/google-interactions-language-model-options.ts +1 -0
- package/src/interactions/google-interactions-language-model.ts +6 -6
- package/src/map-google-finish-reason.ts +3 -0
|
@@ -4,16 +4,16 @@ type GoogleModelCapabilities = {
|
|
|
4
4
|
usesGemini3Features: boolean;
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
const gemini1ModelPattern = /(
|
|
8
|
-
const gemini2ModelPattern = /(
|
|
9
|
-
const gemini25ModelPattern = /(
|
|
10
|
-
const geminiModelPattern = /(
|
|
7
|
+
const gemini1ModelPattern = /(^|[/.])gemini-1(?:[.-]|$)/i;
|
|
8
|
+
const gemini2ModelPattern = /(^|[/.])gemini-2(?:[.-]|$)/i;
|
|
9
|
+
const gemini25ModelPattern = /(^|[/.])gemini-2\.5(?:[.-]|$)/i;
|
|
10
|
+
const geminiModelPattern = /(^|[/.])gemini-/i;
|
|
11
11
|
|
|
12
12
|
function isKnownPreGemini2Model(modelId: string): boolean {
|
|
13
13
|
return (
|
|
14
14
|
gemini1ModelPattern.test(modelId) ||
|
|
15
|
-
/(
|
|
16
|
-
/(
|
|
15
|
+
/(^|[/.])gemini-pro(?:-vision)?$/i.test(modelId) ||
|
|
16
|
+
/(^|[/.])gemini-robotics-er-1\.5(?:[.-]|$)/i.test(modelId)
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
19
|
|
package/src/google-prompt.ts
CHANGED
|
@@ -100,4 +100,22 @@ export interface GoogleProviderMetadata {
|
|
|
100
100
|
finishReason?: string | null;
|
|
101
101
|
finishMessage: string | null;
|
|
102
102
|
serviceTier: string | null;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Opaque token returned when a response stops with `MAX_TOKENS` because it
|
|
106
|
+
* used up its `maxOutputTokens` budget. Pass it back as
|
|
107
|
+
* `providerOptions.google.continuationToken` together with a higher
|
|
108
|
+
* `maxOutputTokens` and the original prompt to resume generation.
|
|
109
|
+
*/
|
|
110
|
+
continuationToken?: string | null;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Prompt token count of the first request of a long decode response that
|
|
114
|
+
* was continued automatically (Gemini 4). Usage is summed across requests
|
|
115
|
+
* to match billing, and each continued request re-sends the prompt plus all
|
|
116
|
+
* output so far as input. Use this value instead of the summed input tokens
|
|
117
|
+
* for context window checks and compaction. Only present when the response
|
|
118
|
+
* spanned more than one request.
|
|
119
|
+
*/
|
|
120
|
+
initialPromptTokenCount?: number | null;
|
|
103
121
|
}
|
|
@@ -482,7 +482,7 @@ export class GoogleInteractionsLanguageModel implements LanguageModelV4 {
|
|
|
482
482
|
async doGenerate(
|
|
483
483
|
options: LanguageModelV4CallOptions,
|
|
484
484
|
): Promise<LanguageModelV4GenerateResult> {
|
|
485
|
-
const { args, warnings, isAgent, pollingTimeoutMs } =
|
|
485
|
+
const { args, warnings, isAgent, isBackground, pollingTimeoutMs } =
|
|
486
486
|
await this.getArgs(options);
|
|
487
487
|
|
|
488
488
|
const url = `${this.config.baseURL}/interactions`;
|
|
@@ -511,12 +511,12 @@ export class GoogleInteractionsLanguageModel implements LanguageModelV4 {
|
|
|
511
511
|
} = postResult;
|
|
512
512
|
|
|
513
513
|
/*
|
|
514
|
-
* Agent calls
|
|
515
|
-
*
|
|
516
|
-
* `GET /interactions/{id}` until
|
|
517
|
-
* matches a synchronous call.
|
|
514
|
+
* Agent calls and `background: true` calls (e.g. Gemini 4 long decode,
|
|
515
|
+
* where the server runs every hop) may return a non-terminal status
|
|
516
|
+
* (`in_progress` / `requires_action`). Poll `GET /interactions/{id}` until
|
|
517
|
+
* terminal so the user-facing surface matches a synchronous call.
|
|
518
518
|
*/
|
|
519
|
-
if (isAgent && !isTerminalStatus(response.status)) {
|
|
519
|
+
if ((isAgent || isBackground) && !isTerminalStatus(response.status)) {
|
|
520
520
|
const polled = await pollGoogleInteractionUntilTerminal({
|
|
521
521
|
baseURL: this.config.baseURL,
|
|
522
522
|
interactionId: response.id,
|
|
@@ -11,6 +11,9 @@ export function mapGoogleFinishReason({
|
|
|
11
11
|
case 'STOP':
|
|
12
12
|
return hasToolCalls ? 'tool-calls' : 'stop';
|
|
13
13
|
case 'MAX_TOKENS':
|
|
14
|
+
// Gemini 4 long decode: the per-request cap was reached while budget
|
|
15
|
+
// remains. Continued automatically; only surfaced if continuing fails.
|
|
16
|
+
case 'CONTINUATION':
|
|
14
17
|
return 'length';
|
|
15
18
|
case 'IMAGE_SAFETY':
|
|
16
19
|
case 'RECITATION':
|