@ai-sdk/google 4.0.50 → 4.0.53
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 +30 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1154 -577
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +147 -6
- package/dist/internal/index.js +86 -42
- package/dist/internal/index.js.map +1 -1
- package/docs/15-google.mdx +71 -0
- package/package.json +6 -6
- package/src/convert-json-schema-to-openapi-schema.ts +13 -1
- package/src/google-batch.ts +670 -0
- package/src/google-files.ts +27 -2
- package/src/google-language-model.ts +58 -35
- package/src/google-prepare-tools.ts +45 -21
- package/src/google-provider.ts +7 -6
- package/src/interactions/build-google-interactions-stream-transform.ts +13 -5
package/dist/internal/index.d.ts
CHANGED
|
@@ -1,12 +1,75 @@
|
|
|
1
1
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
2
2
|
import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE, Resolvable, FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
|
|
3
3
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
4
|
-
import { LanguageModelV4, JSONObject, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult, SpeechModelV4 } from '@ai-sdk/provider';
|
|
4
|
+
import { LanguageModelV4, JSONObject, LanguageModelV4CallOptions, SharedV4Warning, LanguageModelV4GenerateResult, LanguageModelV4StreamResult, SpeechModelV4 } from '@ai-sdk/provider';
|
|
5
5
|
import { z } from 'zod/v4';
|
|
6
6
|
|
|
7
|
+
type GoogleSystemInstruction = {
|
|
8
|
+
parts: Array<{
|
|
9
|
+
text: string;
|
|
10
|
+
}>;
|
|
11
|
+
};
|
|
12
|
+
type GoogleContent = {
|
|
13
|
+
role: 'user' | 'model';
|
|
14
|
+
parts: Array<GoogleContentPart>;
|
|
15
|
+
};
|
|
16
|
+
type GoogleContentPart = {
|
|
17
|
+
text: string;
|
|
18
|
+
thought?: boolean;
|
|
19
|
+
thoughtSignature?: string;
|
|
20
|
+
} | {
|
|
21
|
+
inlineData: {
|
|
22
|
+
mimeType: string;
|
|
23
|
+
data: string;
|
|
24
|
+
};
|
|
25
|
+
thought?: boolean;
|
|
26
|
+
thoughtSignature?: string;
|
|
27
|
+
} | {
|
|
28
|
+
functionCall: {
|
|
29
|
+
id?: string;
|
|
30
|
+
name: string;
|
|
31
|
+
args: unknown;
|
|
32
|
+
};
|
|
33
|
+
thoughtSignature?: string;
|
|
34
|
+
} | {
|
|
35
|
+
functionResponse: {
|
|
36
|
+
id?: string;
|
|
37
|
+
name: string;
|
|
38
|
+
response: unknown;
|
|
39
|
+
parts?: Array<GoogleFunctionResponsePart>;
|
|
40
|
+
};
|
|
41
|
+
} | {
|
|
42
|
+
fileData: {
|
|
43
|
+
mimeType: string;
|
|
44
|
+
fileUri: string;
|
|
45
|
+
};
|
|
46
|
+
thought?: boolean;
|
|
47
|
+
thoughtSignature?: string;
|
|
48
|
+
} | {
|
|
49
|
+
toolCall: {
|
|
50
|
+
toolType: string;
|
|
51
|
+
args?: unknown;
|
|
52
|
+
id: string;
|
|
53
|
+
};
|
|
54
|
+
thoughtSignature?: string;
|
|
55
|
+
} | {
|
|
56
|
+
toolResponse: {
|
|
57
|
+
toolType: string;
|
|
58
|
+
response?: unknown;
|
|
59
|
+
id: string;
|
|
60
|
+
};
|
|
61
|
+
thoughtSignature?: string;
|
|
62
|
+
};
|
|
63
|
+
type GoogleFunctionResponsePart = {
|
|
64
|
+
inlineData: {
|
|
65
|
+
mimeType: string;
|
|
66
|
+
data: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
|
|
7
70
|
type GoogleModelId = 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash-lite-001' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-preview-tts' | 'gemini-2.5-pro-preview-tts' | 'gemini-2.5-flash-native-audio-latest' | 'gemini-2.5-flash-native-audio-preview-09-2025' | 'gemini-2.5-flash-native-audio-preview-12-2025' | 'gemini-2.5-computer-use-preview-10-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-pro-preview-customtools' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-3.1-flash-tts-preview' | 'gemini-3.5-flash' | 'gemini-3.5-flash-lite' | 'gemini-3.6-flash' | 'gemini-3.7-flash' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'deep-research-pro-preview-12-2025' | 'deep-research-max-preview-04-2026' | 'deep-research-preview-04-2026' | 'nano-banana-pro-preview' | 'aqa' | 'gemini-robotics-er-1.5-preview' | 'gemma-3-1b-it' | 'gemma-3-4b-it' | 'gemma-3n-e4b-it' | 'gemma-3n-e2b-it' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
|
|
8
71
|
|
|
9
|
-
type
|
|
72
|
+
type GoogleLanguageModelConfig = {
|
|
10
73
|
provider: string;
|
|
11
74
|
baseURL: string;
|
|
12
75
|
headers?: Resolvable<Record<string, string | undefined>>;
|
|
@@ -28,12 +91,90 @@ declare class GoogleLanguageModel implements LanguageModelV4 {
|
|
|
28
91
|
};
|
|
29
92
|
static [WORKFLOW_DESERIALIZE](options: {
|
|
30
93
|
modelId: string;
|
|
31
|
-
config:
|
|
94
|
+
config: GoogleLanguageModelConfig;
|
|
32
95
|
}): GoogleLanguageModel;
|
|
33
|
-
constructor(modelId: GoogleModelId, config:
|
|
96
|
+
constructor(modelId: GoogleModelId, config: GoogleLanguageModelConfig);
|
|
34
97
|
get provider(): string;
|
|
35
98
|
get supportedUrls(): Record<string, RegExp[]> | PromiseLike<Record<string, RegExp[]>>;
|
|
36
|
-
|
|
99
|
+
protected getArgs({ prompt, maxOutputTokens, temperature, topP, topK, frequencyPenalty, presencePenalty, stopSequences, responseFormat, seed, tools, toolChoice, reasoning, providerOptions, }: LanguageModelV4CallOptions, { isStreaming }?: {
|
|
100
|
+
isStreaming?: boolean;
|
|
101
|
+
}): Promise<{
|
|
102
|
+
args: {
|
|
103
|
+
generationConfig: {
|
|
104
|
+
imageConfig?: {
|
|
105
|
+
aspectRatio?: "1:1" | "2:3" | "3:2" | "3:4" | "4:3" | "4:5" | "5:4" | "9:16" | "16:9" | "21:9" | "1:8" | "8:1" | "1:4" | "4:1" | undefined;
|
|
106
|
+
imageSize?: "1K" | "2K" | "4K" | "512" | undefined;
|
|
107
|
+
personGeneration?: "PERSON_GENERATION_UNSPECIFIED" | "ALLOW_ALL" | "ALLOW_ADULT" | "ALLOW_NONE" | undefined;
|
|
108
|
+
prominentPeople?: "PROMINENT_PEOPLE_UNSPECIFIED" | "ALLOW_PROMINENT_PEOPLE" | "BLOCK_PROMINENT_PEOPLE" | undefined;
|
|
109
|
+
imageOutputOptions?: {
|
|
110
|
+
mimeType?: "image/jpeg" | "image/png" | undefined;
|
|
111
|
+
compressionQuality?: number | undefined;
|
|
112
|
+
} | undefined;
|
|
113
|
+
} | undefined;
|
|
114
|
+
mediaResolution?: "MEDIA_RESOLUTION_UNSPECIFIED" | "MEDIA_RESOLUTION_LOW" | "MEDIA_RESOLUTION_MEDIUM" | "MEDIA_RESOLUTION_HIGH" | undefined;
|
|
115
|
+
responseModalities: ("TEXT" | "IMAGE")[] | undefined;
|
|
116
|
+
thinkingConfig: {
|
|
117
|
+
thinkingBudget?: number | undefined;
|
|
118
|
+
includeThoughts?: boolean | undefined;
|
|
119
|
+
thinkingLevel?: "minimal" | "low" | "medium" | "high" | undefined;
|
|
120
|
+
} | undefined;
|
|
121
|
+
audioTimestamp?: true | undefined;
|
|
122
|
+
maxOutputTokens: number | undefined;
|
|
123
|
+
temperature: number | undefined;
|
|
124
|
+
topK: number | undefined;
|
|
125
|
+
topP: number | undefined;
|
|
126
|
+
frequencyPenalty: number | undefined;
|
|
127
|
+
presencePenalty: number | undefined;
|
|
128
|
+
stopSequences: string[] | undefined;
|
|
129
|
+
seed: number | undefined;
|
|
130
|
+
responseMimeType: string | undefined;
|
|
131
|
+
responseSchema: unknown;
|
|
132
|
+
};
|
|
133
|
+
contents: GoogleContent[];
|
|
134
|
+
systemInstruction: GoogleSystemInstruction | undefined;
|
|
135
|
+
safetySettings: {
|
|
136
|
+
category: "HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_CIVIC_INTEGRITY";
|
|
137
|
+
threshold: "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE" | "OFF";
|
|
138
|
+
}[] | undefined;
|
|
139
|
+
tools: ({
|
|
140
|
+
functionDeclarations: {
|
|
141
|
+
name: string;
|
|
142
|
+
description: string;
|
|
143
|
+
parameters?: unknown;
|
|
144
|
+
parametersJsonSchema?: unknown;
|
|
145
|
+
}[];
|
|
146
|
+
} | Record<string, any>)[] | undefined;
|
|
147
|
+
toolConfig: {
|
|
148
|
+
retrievalConfig?: {
|
|
149
|
+
latLng?: {
|
|
150
|
+
latitude: number;
|
|
151
|
+
longitude: number;
|
|
152
|
+
} | undefined;
|
|
153
|
+
} | undefined;
|
|
154
|
+
functionCallingConfig?: {
|
|
155
|
+
mode: "AUTO" | "NONE" | "ANY" | "VALIDATED";
|
|
156
|
+
allowedFunctionNames?: string[];
|
|
157
|
+
streamFunctionCallArguments?: boolean;
|
|
158
|
+
} | {
|
|
159
|
+
streamFunctionCallArguments: true;
|
|
160
|
+
mode?: "AUTO" | "NONE" | "ANY" | "VALIDATED" | undefined;
|
|
161
|
+
allowedFunctionNames?: string[];
|
|
162
|
+
} | undefined;
|
|
163
|
+
includeServerSideToolInvocations?: boolean;
|
|
164
|
+
} | undefined;
|
|
165
|
+
cachedContent: string | undefined;
|
|
166
|
+
labels: Record<string, string> | undefined;
|
|
167
|
+
serviceTier: "standard" | "flex" | "priority" | undefined;
|
|
168
|
+
};
|
|
169
|
+
warnings: SharedV4Warning[];
|
|
170
|
+
providerOptionsNames: readonly string[];
|
|
171
|
+
extraHeaders: Record<string, string> | undefined;
|
|
172
|
+
}>;
|
|
173
|
+
protected convertGenerateContentResponse({ response, warnings, providerOptionsNames, }: {
|
|
174
|
+
response: InferSchema<typeof responseSchema>;
|
|
175
|
+
warnings: SharedV4Warning[];
|
|
176
|
+
providerOptionsNames: readonly string[];
|
|
177
|
+
}): LanguageModelV4GenerateResult;
|
|
37
178
|
doGenerate(options: LanguageModelV4CallOptions): Promise<LanguageModelV4GenerateResult>;
|
|
38
179
|
doStream(options: LanguageModelV4CallOptions): Promise<LanguageModelV4StreamResult>;
|
|
39
180
|
}
|
|
@@ -419,4 +560,4 @@ declare class GoogleInteractionsLanguageModel implements LanguageModelV4 {
|
|
|
419
560
|
*/
|
|
420
561
|
type GoogleInteractionsAgentName = 'deep-research-pro-preview-12-2025' | 'deep-research-preview-04-2026' | 'deep-research-max-preview-04-2026' | 'antigravity-preview-05-2026';
|
|
421
562
|
|
|
422
|
-
export { type GoogleInteractionsAgentName, GoogleInteractionsLanguageModel, type GoogleInteractionsModelId, type GoogleInteractionsModelInput, GoogleLanguageModel, type GoogleModelId, GoogleSpeechModel, type GroundingMetadataSchema, type PromptFeedbackSchema, type SafetyRatingSchema, type UrlContextMetadataSchema, type UsageMetadataSchema, getGroundingMetadataSchema, getUrlContextMetadataSchema, googleTools };
|
|
563
|
+
export { type GoogleInteractionsAgentName, GoogleInteractionsLanguageModel, type GoogleInteractionsModelId, type GoogleInteractionsModelInput, GoogleLanguageModel, type GoogleLanguageModelConfig, type GoogleModelId, GoogleSpeechModel, type GroundingMetadataSchema, type PromptFeedbackSchema, type SafetyRatingSchema, type UrlContextMetadataSchema, type UsageMetadataSchema, getGroundingMetadataSchema, getUrlContextMetadataSchema, googleTools, responseSchema };
|
package/dist/internal/index.js
CHANGED
|
@@ -49,6 +49,10 @@ function convertGoogleUsage(usage) {
|
|
|
49
49
|
import {
|
|
50
50
|
UnsupportedFunctionalityError
|
|
51
51
|
} from "@ai-sdk/provider";
|
|
52
|
+
var recursiveReferenceFunctionalityPrefix = "recursive JSON Schema reference:";
|
|
53
|
+
function isRecursiveJSONSchemaReferenceError(error) {
|
|
54
|
+
return UnsupportedFunctionalityError.isInstance(error) && error.functionality.startsWith(recursiveReferenceFunctionalityPrefix);
|
|
55
|
+
}
|
|
52
56
|
function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
|
|
53
57
|
const rootSchema = typeof jsonSchema === "object" ? jsonSchema : void 0;
|
|
54
58
|
return convertJSONSchemaDefinition(jsonSchema, isRoot, {
|
|
@@ -189,7 +193,7 @@ function convertJSONSchemaReference({
|
|
|
189
193
|
);
|
|
190
194
|
if (referenceContext.resolvingReferences.has(referenceKey)) {
|
|
191
195
|
throw new UnsupportedFunctionalityError({
|
|
192
|
-
functionality:
|
|
196
|
+
functionality: `${recursiveReferenceFunctionalityPrefix} ${reference}`,
|
|
193
197
|
message: "Google schema conversion does not support recursive JSON Schema references."
|
|
194
198
|
});
|
|
195
199
|
}
|
|
@@ -1025,7 +1029,6 @@ function prepareTools({
|
|
|
1025
1029
|
modelId,
|
|
1026
1030
|
isVertexProvider = false
|
|
1027
1031
|
}) {
|
|
1028
|
-
var _a, _b;
|
|
1029
1032
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
1030
1033
|
const toolWarnings = [];
|
|
1031
1034
|
const { supportsGemini2Tools, supportsFileSearch, usesGemini3Features } = getGoogleModelCapabilities(modelId);
|
|
@@ -1143,11 +1146,7 @@ function prepareTools({
|
|
|
1143
1146
|
const functionDeclarations2 = [];
|
|
1144
1147
|
for (const tool of tools) {
|
|
1145
1148
|
if (tool.type === "function") {
|
|
1146
|
-
functionDeclarations2.push(
|
|
1147
|
-
name: tool.name,
|
|
1148
|
-
description: (_a = tool.description) != null ? _a : "",
|
|
1149
|
-
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
1150
|
-
});
|
|
1149
|
+
functionDeclarations2.push(prepareFunctionDeclaration(tool));
|
|
1151
1150
|
}
|
|
1152
1151
|
}
|
|
1153
1152
|
const combinedToolConfig = {
|
|
@@ -1191,11 +1190,7 @@ function prepareTools({
|
|
|
1191
1190
|
for (const tool of tools) {
|
|
1192
1191
|
switch (tool.type) {
|
|
1193
1192
|
case "function":
|
|
1194
|
-
functionDeclarations.push(
|
|
1195
|
-
name: tool.name,
|
|
1196
|
-
description: (_b = tool.description) != null ? _b : "",
|
|
1197
|
-
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
1198
|
-
});
|
|
1193
|
+
functionDeclarations.push(prepareFunctionDeclaration(tool));
|
|
1199
1194
|
if (tool.strict === true) {
|
|
1200
1195
|
hasStrictTools = true;
|
|
1201
1196
|
}
|
|
@@ -1262,6 +1257,27 @@ function prepareTools({
|
|
|
1262
1257
|
}
|
|
1263
1258
|
}
|
|
1264
1259
|
}
|
|
1260
|
+
function prepareFunctionDeclaration(tool) {
|
|
1261
|
+
var _a;
|
|
1262
|
+
const declaration = {
|
|
1263
|
+
name: tool.name,
|
|
1264
|
+
description: (_a = tool.description) != null ? _a : ""
|
|
1265
|
+
};
|
|
1266
|
+
try {
|
|
1267
|
+
return {
|
|
1268
|
+
...declaration,
|
|
1269
|
+
parameters: convertJSONSchemaToOpenAPISchema(tool.inputSchema)
|
|
1270
|
+
};
|
|
1271
|
+
} catch (error) {
|
|
1272
|
+
if (!isRecursiveJSONSchemaReferenceError(error)) {
|
|
1273
|
+
throw error;
|
|
1274
|
+
}
|
|
1275
|
+
return {
|
|
1276
|
+
...declaration,
|
|
1277
|
+
parametersJsonSchema: tool.inputSchema
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1265
1281
|
|
|
1266
1282
|
// src/google-json-accumulator.ts
|
|
1267
1283
|
var GoogleJSONAccumulator = class {
|
|
@@ -1740,32 +1756,15 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1740
1756
|
extraHeaders: vertexPaygoHeaders
|
|
1741
1757
|
};
|
|
1742
1758
|
}
|
|
1743
|
-
|
|
1759
|
+
convertGenerateContentResponse({
|
|
1760
|
+
response,
|
|
1761
|
+
warnings,
|
|
1762
|
+
providerOptionsNames
|
|
1763
|
+
}) {
|
|
1744
1764
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
1745
|
-
const { args, warnings, providerOptionsNames, extraHeaders } = await this.getArgs(options);
|
|
1746
1765
|
const wrapProviderMetadata = (payload) => Object.fromEntries(
|
|
1747
1766
|
providerOptionsNames.map((name) => [name, payload])
|
|
1748
1767
|
);
|
|
1749
|
-
const mergedHeaders = combineHeaders(
|
|
1750
|
-
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
1751
|
-
options.headers,
|
|
1752
|
-
extraHeaders
|
|
1753
|
-
);
|
|
1754
|
-
const {
|
|
1755
|
-
responseHeaders,
|
|
1756
|
-
value: response,
|
|
1757
|
-
rawValue: rawResponse
|
|
1758
|
-
} = await postJsonToApi({
|
|
1759
|
-
url: `${this.config.baseURL}/${getModelPath(
|
|
1760
|
-
this.modelId
|
|
1761
|
-
)}:generateContent`,
|
|
1762
|
-
headers: mergedHeaders,
|
|
1763
|
-
body: args,
|
|
1764
|
-
failedResponseHandler: googleFailedResponseHandler,
|
|
1765
|
-
successfulResponseHandler: createJsonResponseHandler(responseSchema),
|
|
1766
|
-
abortSignal: options.abortSignal,
|
|
1767
|
-
fetch: this.config.fetch
|
|
1768
|
-
});
|
|
1769
1768
|
const candidate = response.candidates[0];
|
|
1770
1769
|
const content = [];
|
|
1771
1770
|
const parts = (_b = (_a = candidate.content) == null ? void 0 : _a.parts) != null ? _b : [];
|
|
@@ -1899,10 +1898,44 @@ var GoogleLanguageModel = class _GoogleLanguageModel {
|
|
|
1899
1898
|
finishMessage: (_n = candidate.finishMessage) != null ? _n : null,
|
|
1900
1899
|
serviceTier: (_o = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _o : null
|
|
1901
1900
|
}),
|
|
1902
|
-
request: { body: args },
|
|
1903
1901
|
response: {
|
|
1904
1902
|
// TODO timestamp, model id
|
|
1905
|
-
id: (_p = response.responseId) != null ? _p : void 0
|
|
1903
|
+
id: (_p = response.responseId) != null ? _p : void 0
|
|
1904
|
+
}
|
|
1905
|
+
};
|
|
1906
|
+
}
|
|
1907
|
+
async doGenerate(options) {
|
|
1908
|
+
const { args, warnings, providerOptionsNames, extraHeaders } = await this.getArgs(options);
|
|
1909
|
+
const mergedHeaders = combineHeaders(
|
|
1910
|
+
this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
1911
|
+
options.headers,
|
|
1912
|
+
extraHeaders
|
|
1913
|
+
);
|
|
1914
|
+
const {
|
|
1915
|
+
responseHeaders,
|
|
1916
|
+
value: response,
|
|
1917
|
+
rawValue: rawResponse
|
|
1918
|
+
} = await postJsonToApi({
|
|
1919
|
+
url: `${this.config.baseURL}/${getModelPath(
|
|
1920
|
+
this.modelId
|
|
1921
|
+
)}:generateContent`,
|
|
1922
|
+
headers: mergedHeaders,
|
|
1923
|
+
body: args,
|
|
1924
|
+
failedResponseHandler: googleFailedResponseHandler,
|
|
1925
|
+
successfulResponseHandler: createJsonResponseHandler(responseSchema),
|
|
1926
|
+
abortSignal: options.abortSignal,
|
|
1927
|
+
fetch: this.config.fetch
|
|
1928
|
+
});
|
|
1929
|
+
const result = this.convertGenerateContentResponse({
|
|
1930
|
+
response,
|
|
1931
|
+
warnings,
|
|
1932
|
+
providerOptionsNames
|
|
1933
|
+
});
|
|
1934
|
+
return {
|
|
1935
|
+
...result,
|
|
1936
|
+
request: { body: args },
|
|
1937
|
+
response: {
|
|
1938
|
+
...result.response,
|
|
1906
1939
|
headers: responseHeaders,
|
|
1907
1940
|
body: rawResponse
|
|
1908
1941
|
}
|
|
@@ -3162,6 +3195,11 @@ import {
|
|
|
3162
3195
|
WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE3
|
|
3163
3196
|
} from "@ai-sdk/provider-utils";
|
|
3164
3197
|
|
|
3198
|
+
// src/interactions/build-google-interactions-stream-transform.ts
|
|
3199
|
+
import {
|
|
3200
|
+
createProviderStreamError
|
|
3201
|
+
} from "@ai-sdk/provider-utils";
|
|
3202
|
+
|
|
3165
3203
|
// src/interactions/convert-google-interactions-usage.ts
|
|
3166
3204
|
import { createNullLanguageModelUsage as createNullLanguageModelUsage2 } from "@ai-sdk/provider-utils";
|
|
3167
3205
|
function convertGoogleInteractionsUsage(usage) {
|
|
@@ -3456,7 +3494,7 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3456
3494
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3457
3495
|
},
|
|
3458
3496
|
transform(chunk, controller) {
|
|
3459
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
3497
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
3460
3498
|
if (includeRawChunks) {
|
|
3461
3499
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3462
3500
|
}
|
|
@@ -3867,10 +3905,15 @@ function buildGoogleInteractionsStreamTransform({
|
|
|
3867
3905
|
case "error": {
|
|
3868
3906
|
const event = value;
|
|
3869
3907
|
finishStatus = "failed";
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3908
|
+
controller.enqueue({
|
|
3909
|
+
type: "error",
|
|
3910
|
+
error: createProviderStreamError({
|
|
3911
|
+
message: (_r = (_q = event.error) == null ? void 0 : _q.message) != null ? _r : "Unknown interaction error",
|
|
3912
|
+
type: event.event_type,
|
|
3913
|
+
code: (_t = (_s = event.error) == null ? void 0 : _s.code) != null ? _t : void 0,
|
|
3914
|
+
data: event
|
|
3915
|
+
})
|
|
3916
|
+
});
|
|
3874
3917
|
break;
|
|
3875
3918
|
}
|
|
3876
3919
|
default:
|
|
@@ -6075,6 +6118,7 @@ export {
|
|
|
6075
6118
|
GoogleSpeechModel,
|
|
6076
6119
|
getGroundingMetadataSchema,
|
|
6077
6120
|
getUrlContextMetadataSchema,
|
|
6078
|
-
googleTools
|
|
6121
|
+
googleTools,
|
|
6122
|
+
responseSchema
|
|
6079
6123
|
};
|
|
6080
6124
|
//# sourceMappingURL=index.js.map
|