@ai-sdk/google 3.0.123 → 3.0.124
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.js +25 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -22
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +24 -21
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +24 -21
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/google-generative-ai-language-model.ts +7 -2
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -235,7 +235,7 @@ var googleInteractionsTranscriptionResponseSchema = import_v43.z.object({
|
|
|
235
235
|
var import_provider_utils24 = require("@ai-sdk/provider-utils");
|
|
236
236
|
|
|
237
237
|
// src/version.ts
|
|
238
|
-
var VERSION = true ? "3.0.
|
|
238
|
+
var VERSION = true ? "3.0.124" : "0.0.0-test";
|
|
239
239
|
|
|
240
240
|
// src/google-generative-ai-embedding-model.ts
|
|
241
241
|
var import_provider2 = require("@ai-sdk/provider");
|
|
@@ -2056,7 +2056,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2056
2056
|
};
|
|
2057
2057
|
}
|
|
2058
2058
|
async doGenerate(options) {
|
|
2059
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u
|
|
2059
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
2060
2060
|
const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
|
|
2061
2061
|
const mergedHeaders = (0, import_provider_utils7.combineHeaders)(
|
|
2062
2062
|
await (0, import_provider_utils7.resolve)(this.config.headers),
|
|
@@ -2080,15 +2080,18 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2080
2080
|
});
|
|
2081
2081
|
const candidate = (_a = response.candidates) == null ? void 0 : _a[0];
|
|
2082
2082
|
const promptBlockReason = (_b = response.promptFeedback) == null ? void 0 : _b.blockReason;
|
|
2083
|
-
const
|
|
2084
|
-
|
|
2083
|
+
const confirmedPromptBlockReason = isConfirmedPromptBlockReason(
|
|
2084
|
+
promptBlockReason
|
|
2085
|
+
) ? promptBlockReason : void 0;
|
|
2086
|
+
const isPromptBlocked = (candidate == null ? void 0 : candidate.finishReason) == null && confirmedPromptBlockReason != null;
|
|
2087
|
+
const rawFinishReason = (_c = candidate == null ? void 0 : candidate.finishReason) != null ? _c : confirmedPromptBlockReason;
|
|
2085
2088
|
const content = [];
|
|
2086
|
-
const parts = (
|
|
2089
|
+
const parts = (_e = (_d = candidate == null ? void 0 : candidate.content) == null ? void 0 : _d.parts) != null ? _e : [];
|
|
2087
2090
|
const usageMetadata = response.usageMetadata;
|
|
2088
2091
|
let lastCodeExecutionToolCallId;
|
|
2089
2092
|
let lastServerToolCallId;
|
|
2090
2093
|
for (const part of parts) {
|
|
2091
|
-
if ("executableCode" in part && ((
|
|
2094
|
+
if ("executableCode" in part && ((_f = part.executableCode) == null ? void 0 : _f.code)) {
|
|
2092
2095
|
const toolCallId = this.config.generateId();
|
|
2093
2096
|
lastCodeExecutionToolCallId = toolCallId;
|
|
2094
2097
|
content.push({
|
|
@@ -2106,7 +2109,7 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2106
2109
|
toolName: "code_execution",
|
|
2107
2110
|
result: {
|
|
2108
2111
|
outcome: part.codeExecutionResult.outcome,
|
|
2109
|
-
output: (
|
|
2112
|
+
output: (_g = part.codeExecutionResult.output) != null ? _g : ""
|
|
2110
2113
|
}
|
|
2111
2114
|
});
|
|
2112
2115
|
} else if ("text" in part && part.text != null) {
|
|
@@ -2130,9 +2133,9 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2130
2133
|
} else if ("functionCall" in part && part.functionCall.name != null) {
|
|
2131
2134
|
content.push({
|
|
2132
2135
|
type: "tool-call",
|
|
2133
|
-
toolCallId: (
|
|
2136
|
+
toolCallId: (_h = part.functionCall.id) != null ? _h : this.config.generateId(),
|
|
2134
2137
|
toolName: part.functionCall.name,
|
|
2135
|
-
input: JSON.stringify((
|
|
2138
|
+
input: JSON.stringify((_i = part.functionCall.args) != null ? _i : {}),
|
|
2136
2139
|
providerMetadata: part.thoughtSignature ? {
|
|
2137
2140
|
[providerOptionsName]: {
|
|
2138
2141
|
thoughtSignature: part.thoughtSignature
|
|
@@ -2154,13 +2157,13 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2154
2157
|
} : void 0
|
|
2155
2158
|
});
|
|
2156
2159
|
} else if ("toolCall" in part && part.toolCall) {
|
|
2157
|
-
const toolCallId = (
|
|
2160
|
+
const toolCallId = (_j = part.toolCall.id) != null ? _j : this.config.generateId();
|
|
2158
2161
|
lastServerToolCallId = toolCallId;
|
|
2159
2162
|
content.push({
|
|
2160
2163
|
type: "tool-call",
|
|
2161
2164
|
toolCallId,
|
|
2162
2165
|
toolName: `server:${part.toolCall.toolType}`,
|
|
2163
|
-
input: JSON.stringify((
|
|
2166
|
+
input: JSON.stringify((_k = part.toolCall.args) != null ? _k : {}),
|
|
2164
2167
|
providerExecuted: true,
|
|
2165
2168
|
dynamic: true,
|
|
2166
2169
|
providerMetadata: part.thoughtSignature ? {
|
|
@@ -2177,12 +2180,12 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2177
2180
|
}
|
|
2178
2181
|
});
|
|
2179
2182
|
} else if ("toolResponse" in part && part.toolResponse) {
|
|
2180
|
-
const responseToolCallId = (
|
|
2183
|
+
const responseToolCallId = (_l = lastServerToolCallId != null ? lastServerToolCallId : part.toolResponse.id) != null ? _l : this.config.generateId();
|
|
2181
2184
|
content.push({
|
|
2182
2185
|
type: "tool-result",
|
|
2183
2186
|
toolCallId: responseToolCallId,
|
|
2184
2187
|
toolName: `server:${part.toolResponse.toolType}`,
|
|
2185
|
-
result: (
|
|
2188
|
+
result: (_m = part.toolResponse.response) != null ? _m : {},
|
|
2186
2189
|
providerMetadata: part.thoughtSignature ? {
|
|
2187
2190
|
[providerOptionsName]: {
|
|
2188
2191
|
thoughtSignature: part.thoughtSignature,
|
|
@@ -2199,10 +2202,10 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2199
2202
|
lastServerToolCallId = void 0;
|
|
2200
2203
|
}
|
|
2201
2204
|
}
|
|
2202
|
-
const sources = (
|
|
2205
|
+
const sources = (_n = extractSources({
|
|
2203
2206
|
groundingMetadata: candidate == null ? void 0 : candidate.groundingMetadata,
|
|
2204
2207
|
generateId: this.config.generateId
|
|
2205
|
-
})) != null ?
|
|
2208
|
+
})) != null ? _n : [];
|
|
2206
2209
|
for (const source of sources) {
|
|
2207
2210
|
content.push(source);
|
|
2208
2211
|
}
|
|
@@ -2222,19 +2225,19 @@ var GoogleGenerativeAILanguageModel = class {
|
|
|
2222
2225
|
warnings,
|
|
2223
2226
|
providerMetadata: {
|
|
2224
2227
|
[providerOptionsName]: {
|
|
2225
|
-
promptFeedback: (
|
|
2226
|
-
groundingMetadata: (
|
|
2227
|
-
urlContextMetadata: (
|
|
2228
|
-
safetyRatings: (
|
|
2228
|
+
promptFeedback: (_o = response.promptFeedback) != null ? _o : null,
|
|
2229
|
+
groundingMetadata: (_p = candidate == null ? void 0 : candidate.groundingMetadata) != null ? _p : null,
|
|
2230
|
+
urlContextMetadata: (_q = candidate == null ? void 0 : candidate.urlContextMetadata) != null ? _q : null,
|
|
2231
|
+
safetyRatings: (_r = candidate == null ? void 0 : candidate.safetyRatings) != null ? _r : null,
|
|
2229
2232
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
2230
|
-
finishMessage: (
|
|
2231
|
-
serviceTier: (
|
|
2233
|
+
finishMessage: (_s = candidate == null ? void 0 : candidate.finishMessage) != null ? _s : null,
|
|
2234
|
+
serviceTier: (_t = usageMetadata == null ? void 0 : usageMetadata.serviceTier) != null ? _t : null
|
|
2232
2235
|
}
|
|
2233
2236
|
},
|
|
2234
2237
|
request: { body: args },
|
|
2235
2238
|
response: {
|
|
2236
2239
|
// TODO timestamp, model id
|
|
2237
|
-
id: (
|
|
2240
|
+
id: (_u = response.responseId) != null ? _u : void 0,
|
|
2238
2241
|
headers: responseHeaders,
|
|
2239
2242
|
body: rawResponse
|
|
2240
2243
|
}
|