@databricks/ai-sdk-provider 0.2.1 → 0.2.2

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/dist/index.cjs CHANGED
@@ -545,7 +545,7 @@ const responsesAgentResponseSchema = zod_v4.z.object({
545
545
  }).nullish(),
546
546
  model: zod_v4.z.string().optional(),
547
547
  output: zod_v4.z.array(responsesAgentOutputItem),
548
- incomplete_details: zod_v4.z.object({ reason: zod_v4.z.enum(["max_output_tokens", "content_filter"]).optional() }).nullish(),
548
+ incomplete_details: zod_v4.z.object({ reason: zod_v4.z.string().nullish().optional() }).nullish(),
549
549
  usage: zod_v4.z.object({
550
550
  input_tokens: zod_v4.z.number(),
551
551
  output_tokens: zod_v4.z.number(),
@@ -615,7 +615,7 @@ const responsesCompletedSchema = zod_v4.z.object({
615
615
  "queued",
616
616
  "incomplete"
617
617
  ]).optional(),
618
- incomplete_details: zod_v4.z.object({ reason: zod_v4.z.enum(["max_output_tokens", "content_filter"]).optional() }).nullish(),
618
+ incomplete_details: zod_v4.z.object({ reason: zod_v4.z.string().nullish().optional() }).nullish(),
619
619
  usage: zod_v4.z.object({
620
620
  input_tokens: zod_v4.z.number(),
621
621
  output_tokens: zod_v4.z.number(),
@@ -1479,11 +1479,7 @@ const fmapiChunkSchema = zod_v4.z.object({
1479
1479
  ]).optional(),
1480
1480
  tool_calls: zod_v4.z.array(toolCallDeltaSchema).optional()
1481
1481
  }),
1482
- finish_reason: zod_v4.z.union([
1483
- zod_v4.z.literal("stop"),
1484
- zod_v4.z.literal("tool_calls"),
1485
- zod_v4.z.null()
1486
- ]).optional()
1482
+ finish_reason: zod_v4.z.union([zod_v4.z.string(), zod_v4.z.null()]).optional()
1487
1483
  }))
1488
1484
  });
1489
1485
  const fmapiResponseSchema = zod_v4.z.object({
@@ -1509,11 +1505,7 @@ const fmapiResponseSchema = zod_v4.z.object({
1509
1505
  ]).optional(),
1510
1506
  tool_calls: zod_v4.z.array(toolCallSchema).optional()
1511
1507
  }),
1512
- finish_reason: zod_v4.z.union([
1513
- zod_v4.z.literal("stop"),
1514
- zod_v4.z.literal("tool_calls"),
1515
- zod_v4.z.null()
1516
- ]).optional()
1508
+ finish_reason: zod_v4.z.union([zod_v4.z.string(), zod_v4.z.null()]).optional()
1517
1509
  }))
1518
1510
  });
1519
1511
 
@@ -1761,6 +1753,19 @@ const getToolNameFromPart = async (part) => {
1761
1753
  return providerOptions?.toolName ?? part.toolName;
1762
1754
  };
1763
1755
 
1756
+ //#endregion
1757
+ //#region src/fmapi-language-model/fmapi-finish-reason.ts
1758
+ function mapFmapiFinishReason(finishReason) {
1759
+ switch (finishReason) {
1760
+ case "stop": return "stop";
1761
+ case "length": return "length";
1762
+ case "content_filter": return "content-filter";
1763
+ case "function_call":
1764
+ case "tool_calls": return "tool-calls";
1765
+ default: return "other";
1766
+ }
1767
+ }
1768
+
1764
1769
  //#endregion
1765
1770
  //#region src/fmapi-language-model/fmapi-language-model.ts
1766
1771
  var DatabricksFmapiLanguageModel = class {
@@ -1792,8 +1797,7 @@ var DatabricksFmapiLanguageModel = class {
1792
1797
  })
1793
1798
  });
1794
1799
  const choice = response.choices[0];
1795
- let finishReason = "stop";
1796
- if (choice?.finish_reason === "tool_calls") finishReason = "tool-calls";
1800
+ const finishReason = mapFmapiFinishReason(choice?.finish_reason);
1797
1801
  return {
1798
1802
  content: convertFmapiResponseToMessagePart(response),
1799
1803
  finishReason,
@@ -1853,8 +1857,7 @@ var DatabricksFmapiLanguageModel = class {
1853
1857
  return;
1854
1858
  }
1855
1859
  const choice = chunk.value.choices[0];
1856
- if (choice?.finish_reason === "stop") finishReason = "stop";
1857
- else if (choice?.finish_reason === "tool_calls") finishReason = "tool-calls";
1860
+ finishReason = mapFmapiFinishReason(choice?.finish_reason);
1858
1861
  if (chunk.value.usage) usage = {
1859
1862
  inputTokens: chunk.value.usage.prompt_tokens ?? 0,
1860
1863
  outputTokens: chunk.value.usage.completion_tokens ?? 0,