@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 +19 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -16
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -521,7 +521,7 @@ const responsesAgentResponseSchema = z.object({
|
|
|
521
521
|
}).nullish(),
|
|
522
522
|
model: z.string().optional(),
|
|
523
523
|
output: z.array(responsesAgentOutputItem),
|
|
524
|
-
incomplete_details: z.object({ reason: z.
|
|
524
|
+
incomplete_details: z.object({ reason: z.string().nullish().optional() }).nullish(),
|
|
525
525
|
usage: z.object({
|
|
526
526
|
input_tokens: z.number(),
|
|
527
527
|
output_tokens: z.number(),
|
|
@@ -591,7 +591,7 @@ const responsesCompletedSchema = z.object({
|
|
|
591
591
|
"queued",
|
|
592
592
|
"incomplete"
|
|
593
593
|
]).optional(),
|
|
594
|
-
incomplete_details: z.object({ reason: z.
|
|
594
|
+
incomplete_details: z.object({ reason: z.string().nullish().optional() }).nullish(),
|
|
595
595
|
usage: z.object({
|
|
596
596
|
input_tokens: z.number(),
|
|
597
597
|
output_tokens: z.number(),
|
|
@@ -1455,11 +1455,7 @@ const fmapiChunkSchema = z.object({
|
|
|
1455
1455
|
]).optional(),
|
|
1456
1456
|
tool_calls: z.array(toolCallDeltaSchema).optional()
|
|
1457
1457
|
}),
|
|
1458
|
-
finish_reason: z.union([
|
|
1459
|
-
z.literal("stop"),
|
|
1460
|
-
z.literal("tool_calls"),
|
|
1461
|
-
z.null()
|
|
1462
|
-
]).optional()
|
|
1458
|
+
finish_reason: z.union([z.string(), z.null()]).optional()
|
|
1463
1459
|
}))
|
|
1464
1460
|
});
|
|
1465
1461
|
const fmapiResponseSchema = z.object({
|
|
@@ -1485,11 +1481,7 @@ const fmapiResponseSchema = z.object({
|
|
|
1485
1481
|
]).optional(),
|
|
1486
1482
|
tool_calls: z.array(toolCallSchema).optional()
|
|
1487
1483
|
}),
|
|
1488
|
-
finish_reason: z.union([
|
|
1489
|
-
z.literal("stop"),
|
|
1490
|
-
z.literal("tool_calls"),
|
|
1491
|
-
z.null()
|
|
1492
|
-
]).optional()
|
|
1484
|
+
finish_reason: z.union([z.string(), z.null()]).optional()
|
|
1493
1485
|
}))
|
|
1494
1486
|
});
|
|
1495
1487
|
|
|
@@ -1737,6 +1729,19 @@ const getToolNameFromPart = async (part) => {
|
|
|
1737
1729
|
return providerOptions?.toolName ?? part.toolName;
|
|
1738
1730
|
};
|
|
1739
1731
|
|
|
1732
|
+
//#endregion
|
|
1733
|
+
//#region src/fmapi-language-model/fmapi-finish-reason.ts
|
|
1734
|
+
function mapFmapiFinishReason(finishReason) {
|
|
1735
|
+
switch (finishReason) {
|
|
1736
|
+
case "stop": return "stop";
|
|
1737
|
+
case "length": return "length";
|
|
1738
|
+
case "content_filter": return "content-filter";
|
|
1739
|
+
case "function_call":
|
|
1740
|
+
case "tool_calls": return "tool-calls";
|
|
1741
|
+
default: return "other";
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1740
1745
|
//#endregion
|
|
1741
1746
|
//#region src/fmapi-language-model/fmapi-language-model.ts
|
|
1742
1747
|
var DatabricksFmapiLanguageModel = class {
|
|
@@ -1768,8 +1773,7 @@ var DatabricksFmapiLanguageModel = class {
|
|
|
1768
1773
|
})
|
|
1769
1774
|
});
|
|
1770
1775
|
const choice = response.choices[0];
|
|
1771
|
-
|
|
1772
|
-
if (choice?.finish_reason === "tool_calls") finishReason = "tool-calls";
|
|
1776
|
+
const finishReason = mapFmapiFinishReason(choice?.finish_reason);
|
|
1773
1777
|
return {
|
|
1774
1778
|
content: convertFmapiResponseToMessagePart(response),
|
|
1775
1779
|
finishReason,
|
|
@@ -1829,8 +1833,7 @@ var DatabricksFmapiLanguageModel = class {
|
|
|
1829
1833
|
return;
|
|
1830
1834
|
}
|
|
1831
1835
|
const choice = chunk.value.choices[0];
|
|
1832
|
-
|
|
1833
|
-
else if (choice?.finish_reason === "tool_calls") finishReason = "tool-calls";
|
|
1836
|
+
finishReason = mapFmapiFinishReason(choice?.finish_reason);
|
|
1834
1837
|
if (chunk.value.usage) usage = {
|
|
1835
1838
|
inputTokens: chunk.value.usage.prompt_tokens ?? 0,
|
|
1836
1839
|
outputTokens: chunk.value.usage.completion_tokens ?? 0,
|