@ai-sdk/xai 2.0.35 → 2.0.36
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.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +90 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +90 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -133,12 +133,14 @@ function convertToXaiChatMessages(prompt) {
|
|
|
133
133
|
function getResponseMetadata({
|
|
134
134
|
id,
|
|
135
135
|
model,
|
|
136
|
-
created
|
|
136
|
+
created,
|
|
137
|
+
created_at
|
|
137
138
|
}) {
|
|
139
|
+
const unixTime = created != null ? created : created_at;
|
|
138
140
|
return {
|
|
139
141
|
id: id != null ? id : void 0,
|
|
140
142
|
modelId: model != null ? model : void 0,
|
|
141
|
-
timestamp:
|
|
143
|
+
timestamp: unixTime != null ? new Date(unixTime * 1e3) : void 0
|
|
142
144
|
};
|
|
143
145
|
}
|
|
144
146
|
|
|
@@ -784,6 +786,10 @@ var messageContentPartSchema = z4.object({
|
|
|
784
786
|
logprobs: z4.array(z4.any()).optional(),
|
|
785
787
|
annotations: z4.array(annotationSchema).optional()
|
|
786
788
|
});
|
|
789
|
+
var reasoningSummaryPartSchema = z4.object({
|
|
790
|
+
type: z4.string(),
|
|
791
|
+
text: z4.string()
|
|
792
|
+
});
|
|
787
793
|
var toolCallSchema = z4.object({
|
|
788
794
|
name: z4.string(),
|
|
789
795
|
arguments: z4.string(),
|
|
@@ -829,6 +835,12 @@ var outputItemSchema = z4.discriminatedUnion("type", [
|
|
|
829
835
|
arguments: z4.string(),
|
|
830
836
|
call_id: z4.string(),
|
|
831
837
|
id: z4.string()
|
|
838
|
+
}),
|
|
839
|
+
z4.object({
|
|
840
|
+
type: z4.literal("reasoning"),
|
|
841
|
+
id: z4.string(),
|
|
842
|
+
summary: z4.array(reasoningSummaryPartSchema),
|
|
843
|
+
status: z4.string()
|
|
832
844
|
})
|
|
833
845
|
]);
|
|
834
846
|
var xaiResponsesUsageSchema = z4.object({
|
|
@@ -911,6 +923,34 @@ var xaiResponsesChunkSchema = z4.union([
|
|
|
911
923
|
annotation_index: z4.number(),
|
|
912
924
|
annotation: annotationSchema
|
|
913
925
|
}),
|
|
926
|
+
z4.object({
|
|
927
|
+
type: z4.literal("response.reasoning_summary_part.added"),
|
|
928
|
+
item_id: z4.string(),
|
|
929
|
+
output_index: z4.number(),
|
|
930
|
+
summary_index: z4.number(),
|
|
931
|
+
part: reasoningSummaryPartSchema
|
|
932
|
+
}),
|
|
933
|
+
z4.object({
|
|
934
|
+
type: z4.literal("response.reasoning_summary_part.done"),
|
|
935
|
+
item_id: z4.string(),
|
|
936
|
+
output_index: z4.number(),
|
|
937
|
+
summary_index: z4.number(),
|
|
938
|
+
part: reasoningSummaryPartSchema
|
|
939
|
+
}),
|
|
940
|
+
z4.object({
|
|
941
|
+
type: z4.literal("response.reasoning_summary_text.delta"),
|
|
942
|
+
item_id: z4.string(),
|
|
943
|
+
output_index: z4.number(),
|
|
944
|
+
summary_index: z4.number(),
|
|
945
|
+
delta: z4.string()
|
|
946
|
+
}),
|
|
947
|
+
z4.object({
|
|
948
|
+
type: z4.literal("response.reasoning_summary_text.done"),
|
|
949
|
+
item_id: z4.string(),
|
|
950
|
+
output_index: z4.number(),
|
|
951
|
+
summary_index: z4.number(),
|
|
952
|
+
text: z4.string()
|
|
953
|
+
}),
|
|
914
954
|
z4.object({
|
|
915
955
|
type: z4.literal("response.done"),
|
|
916
956
|
response: xaiResponsesResponseSchema
|
|
@@ -942,7 +982,20 @@ function mapXaiResponsesFinishReason(finishReason) {
|
|
|
942
982
|
// src/responses/xai-responses-options.ts
|
|
943
983
|
import { z as z5 } from "zod/v4";
|
|
944
984
|
var xaiResponsesProviderOptions = z5.object({
|
|
945
|
-
|
|
985
|
+
/**
|
|
986
|
+
* Constrains how hard a reasoning model thinks before responding.
|
|
987
|
+
* Possible values are `low` (uses fewer reasoning tokens), `medium` and `high` (uses more reasoning tokens).
|
|
988
|
+
*/
|
|
989
|
+
reasoningEffort: z5.enum(["low", "medium", "high"]).optional(),
|
|
990
|
+
/**
|
|
991
|
+
* Whether to store the input message(s) and model response for later retrieval.
|
|
992
|
+
* @default true
|
|
993
|
+
*/
|
|
994
|
+
store: z5.boolean().optional(),
|
|
995
|
+
/**
|
|
996
|
+
* The ID of the previous response from the model.
|
|
997
|
+
*/
|
|
998
|
+
previousResponseId: z5.string().optional()
|
|
946
999
|
});
|
|
947
1000
|
|
|
948
1001
|
// src/responses/convert-to-xai-responses-input.ts
|
|
@@ -1413,7 +1466,16 @@ var XaiResponsesLanguageModel = class {
|
|
|
1413
1466
|
temperature,
|
|
1414
1467
|
top_p: topP,
|
|
1415
1468
|
seed,
|
|
1416
|
-
|
|
1469
|
+
...options.reasoningEffort != null && {
|
|
1470
|
+
reasoning: { effort: options.reasoningEffort }
|
|
1471
|
+
},
|
|
1472
|
+
...options.store === false && {
|
|
1473
|
+
store: options.store,
|
|
1474
|
+
include: ["reasoning.encrypted_content"]
|
|
1475
|
+
},
|
|
1476
|
+
...options.previousResponseId != null && {
|
|
1477
|
+
previous_response_id: options.previousResponseId
|
|
1478
|
+
}
|
|
1417
1479
|
};
|
|
1418
1480
|
if (xaiTools2 && xaiTools2.length > 0) {
|
|
1419
1481
|
baseArgs.tools = xaiTools2;
|
|
@@ -1601,6 +1663,29 @@ var XaiResponsesLanguageModel = class {
|
|
|
1601
1663
|
}
|
|
1602
1664
|
return;
|
|
1603
1665
|
}
|
|
1666
|
+
if (event.type === "response.reasoning_summary_part.added") {
|
|
1667
|
+
const blockId = `reasoning-${event.item_id}`;
|
|
1668
|
+
controller.enqueue({
|
|
1669
|
+
type: "reasoning-start",
|
|
1670
|
+
id: blockId
|
|
1671
|
+
});
|
|
1672
|
+
}
|
|
1673
|
+
if (event.type === "response.reasoning_summary_text.delta") {
|
|
1674
|
+
const blockId = `reasoning-${event.item_id}`;
|
|
1675
|
+
controller.enqueue({
|
|
1676
|
+
type: "reasoning-delta",
|
|
1677
|
+
id: blockId,
|
|
1678
|
+
delta: event.delta
|
|
1679
|
+
});
|
|
1680
|
+
return;
|
|
1681
|
+
}
|
|
1682
|
+
if (event.type === "response.reasoning_summary_text.done") {
|
|
1683
|
+
const blockId = `reasoning-${event.item_id}`;
|
|
1684
|
+
controller.enqueue({
|
|
1685
|
+
type: "reasoning-end",
|
|
1686
|
+
id: blockId
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1604
1689
|
if (event.type === "response.output_text.delta") {
|
|
1605
1690
|
const blockId = `text-${event.item_id}`;
|
|
1606
1691
|
if (contentBlocks[blockId] == null) {
|
|
@@ -1840,7 +1925,7 @@ var xaiTools = {
|
|
|
1840
1925
|
};
|
|
1841
1926
|
|
|
1842
1927
|
// src/version.ts
|
|
1843
|
-
var VERSION = true ? "2.0.
|
|
1928
|
+
var VERSION = true ? "2.0.36" : "0.0.0-test";
|
|
1844
1929
|
|
|
1845
1930
|
// src/xai-provider.ts
|
|
1846
1931
|
var xaiErrorStructure = {
|