@ai-sdk/google 3.0.95 → 3.0.97

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 3.0.97
4
+
5
+ ### Patch Changes
6
+
7
+ - a6cb3c1: fix(provider/google): surface Gemini `responseId` as `response-metadata` (stream) and `response.id` (generate)
8
+
9
+ ## 3.0.96
10
+
11
+ ### Patch Changes
12
+
13
+ - 0d51472: fix(provider/google): associate multiple code execution results with their tool call
14
+
3
15
  ## 3.0.95
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -170,6 +170,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
170
170
  }[] | null | undefined;
171
171
  } | null | undefined;
172
172
  }[];
173
+ responseId?: string | null | undefined;
173
174
  usageMetadata?: {
174
175
  cachedContentTokenCount?: number | null | undefined;
175
176
  thoughtsTokenCount?: number | null | undefined;
package/dist/index.d.ts CHANGED
@@ -170,6 +170,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
170
170
  }[] | null | undefined;
171
171
  } | null | undefined;
172
172
  }[];
173
+ responseId?: string | null | undefined;
173
174
  usageMetadata?: {
174
175
  cachedContentTokenCount?: number | null | undefined;
175
176
  thoughtsTokenCount?: number | null | undefined;
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(index_exports);
30
30
  var import_provider_utils23 = require("@ai-sdk/provider-utils");
31
31
 
32
32
  // src/version.ts
33
- var VERSION = true ? "3.0.95" : "0.0.0-test";
33
+ var VERSION = true ? "3.0.97" : "0.0.0-test";
34
34
 
35
35
  // src/google-generative-ai-embedding-model.ts
36
36
  var import_provider = require("@ai-sdk/provider");
@@ -1661,7 +1661,7 @@ var GoogleGenerativeAILanguageModel = class {
1661
1661
  };
1662
1662
  }
1663
1663
  async doGenerate(options) {
1664
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
1664
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
1665
1665
  const { args, warnings, providerOptionsName, extraHeaders } = await this.getArgs(options);
1666
1666
  const mergedHeaders = (0, import_provider_utils6.combineHeaders)(
1667
1667
  await (0, import_provider_utils6.resolve)(this.config.headers),
@@ -1703,7 +1703,7 @@ var GoogleGenerativeAILanguageModel = class {
1703
1703
  } else if ("codeExecutionResult" in part && part.codeExecutionResult) {
1704
1704
  content.push({
1705
1705
  type: "tool-result",
1706
- // Assumes a result directly follows its corresponding call part.
1706
+ // Results correspond to the most recent executable code part.
1707
1707
  toolCallId: lastCodeExecutionToolCallId,
1708
1708
  toolName: "code_execution",
1709
1709
  result: {
@@ -1711,7 +1711,6 @@ var GoogleGenerativeAILanguageModel = class {
1711
1711
  output: (_d = part.codeExecutionResult.output) != null ? _d : ""
1712
1712
  }
1713
1713
  });
1714
- lastCodeExecutionToolCallId = void 0;
1715
1714
  } else if ("text" in part && part.text != null) {
1716
1715
  const thoughtSignatureMetadata = part.thoughtSignature ? {
1717
1716
  [providerOptionsName]: {
@@ -1836,7 +1835,8 @@ var GoogleGenerativeAILanguageModel = class {
1836
1835
  },
1837
1836
  request: { body: args },
1838
1837
  response: {
1839
- // TODO timestamp, model id, id
1838
+ // TODO timestamp, model id
1839
+ id: (_s = response.responseId) != null ? _s : void 0,
1840
1840
  headers: responseHeaders,
1841
1841
  body: rawResponse
1842
1842
  }
@@ -1870,6 +1870,7 @@ var GoogleGenerativeAILanguageModel = class {
1870
1870
  let lastUrlContextMetadata = null;
1871
1871
  const generateId3 = this.config.generateId;
1872
1872
  let hasToolCalls = false;
1873
+ let hasEmittedResponseMetadata = false;
1873
1874
  let currentTextBlockId = null;
1874
1875
  let currentReasoningBlockId = null;
1875
1876
  let blockCounter = 0;
@@ -1921,6 +1922,13 @@ var GoogleGenerativeAILanguageModel = class {
1921
1922
  return;
1922
1923
  }
1923
1924
  const value = chunk.value;
1925
+ if (!hasEmittedResponseMetadata && value.responseId != null) {
1926
+ hasEmittedResponseMetadata = true;
1927
+ controller.enqueue({
1928
+ type: "response-metadata",
1929
+ id: value.responseId
1930
+ });
1931
+ }
1924
1932
  const usageMetadata = value.usageMetadata;
1925
1933
  if (usageMetadata != null) {
1926
1934
  usage = usageMetadata;
@@ -1973,7 +1981,6 @@ var GoogleGenerativeAILanguageModel = class {
1973
1981
  output: (_d = part.codeExecutionResult.output) != null ? _d : ""
1974
1982
  }
1975
1983
  });
1976
- lastCodeExecutionToolCallId = void 0;
1977
1984
  }
1978
1985
  } else if ("text" in part && part.text != null) {
1979
1986
  const thoughtSignatureMetadata = part.thoughtSignature ? {
@@ -2507,6 +2514,7 @@ var getUrlContextMetadataSchema = () => import_v45.z.object({
2507
2514
  var responseSchema = (0, import_provider_utils6.lazySchema)(
2508
2515
  () => (0, import_provider_utils6.zodSchema)(
2509
2516
  import_v45.z.object({
2517
+ responseId: import_v45.z.string().nullish(),
2510
2518
  candidates: import_v45.z.array(
2511
2519
  import_v45.z.object({
2512
2520
  content: getContentSchema().nullish().or(import_v45.z.object({}).strict()),
@@ -2528,6 +2536,7 @@ var responseSchema = (0, import_provider_utils6.lazySchema)(
2528
2536
  var chunkSchema = (0, import_provider_utils6.lazySchema)(
2529
2537
  () => (0, import_provider_utils6.zodSchema)(
2530
2538
  import_v45.z.object({
2539
+ responseId: import_v45.z.string().nullish(),
2531
2540
  candidates: import_v45.z.array(
2532
2541
  import_v45.z.object({
2533
2542
  content: getContentSchema().nullish(),