@ai-sdk/xai 3.0.0-beta.40 → 3.0.0-beta.41
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 +2 -2
package/dist/index.mjs
CHANGED
|
@@ -137,12 +137,14 @@ function convertToXaiChatMessages(prompt) {
|
|
|
137
137
|
function getResponseMetadata({
|
|
138
138
|
id,
|
|
139
139
|
model,
|
|
140
|
-
created
|
|
140
|
+
created,
|
|
141
|
+
created_at
|
|
141
142
|
}) {
|
|
143
|
+
const unixTime = created != null ? created : created_at;
|
|
142
144
|
return {
|
|
143
145
|
id: id != null ? id : void 0,
|
|
144
146
|
modelId: model != null ? model : void 0,
|
|
145
|
-
timestamp:
|
|
147
|
+
timestamp: unixTime != null ? new Date(unixTime * 1e3) : void 0
|
|
146
148
|
};
|
|
147
149
|
}
|
|
148
150
|
|
|
@@ -788,6 +790,10 @@ var messageContentPartSchema = z4.object({
|
|
|
788
790
|
logprobs: z4.array(z4.any()).optional(),
|
|
789
791
|
annotations: z4.array(annotationSchema).optional()
|
|
790
792
|
});
|
|
793
|
+
var reasoningSummaryPartSchema = z4.object({
|
|
794
|
+
type: z4.string(),
|
|
795
|
+
text: z4.string()
|
|
796
|
+
});
|
|
791
797
|
var toolCallSchema = z4.object({
|
|
792
798
|
name: z4.string(),
|
|
793
799
|
arguments: z4.string(),
|
|
@@ -833,6 +839,12 @@ var outputItemSchema = z4.discriminatedUnion("type", [
|
|
|
833
839
|
arguments: z4.string(),
|
|
834
840
|
call_id: z4.string(),
|
|
835
841
|
id: z4.string()
|
|
842
|
+
}),
|
|
843
|
+
z4.object({
|
|
844
|
+
type: z4.literal("reasoning"),
|
|
845
|
+
id: z4.string(),
|
|
846
|
+
summary: z4.array(reasoningSummaryPartSchema),
|
|
847
|
+
status: z4.string()
|
|
836
848
|
})
|
|
837
849
|
]);
|
|
838
850
|
var xaiResponsesUsageSchema = z4.object({
|
|
@@ -915,6 +927,34 @@ var xaiResponsesChunkSchema = z4.union([
|
|
|
915
927
|
annotation_index: z4.number(),
|
|
916
928
|
annotation: annotationSchema
|
|
917
929
|
}),
|
|
930
|
+
z4.object({
|
|
931
|
+
type: z4.literal("response.reasoning_summary_part.added"),
|
|
932
|
+
item_id: z4.string(),
|
|
933
|
+
output_index: z4.number(),
|
|
934
|
+
summary_index: z4.number(),
|
|
935
|
+
part: reasoningSummaryPartSchema
|
|
936
|
+
}),
|
|
937
|
+
z4.object({
|
|
938
|
+
type: z4.literal("response.reasoning_summary_part.done"),
|
|
939
|
+
item_id: z4.string(),
|
|
940
|
+
output_index: z4.number(),
|
|
941
|
+
summary_index: z4.number(),
|
|
942
|
+
part: reasoningSummaryPartSchema
|
|
943
|
+
}),
|
|
944
|
+
z4.object({
|
|
945
|
+
type: z4.literal("response.reasoning_summary_text.delta"),
|
|
946
|
+
item_id: z4.string(),
|
|
947
|
+
output_index: z4.number(),
|
|
948
|
+
summary_index: z4.number(),
|
|
949
|
+
delta: z4.string()
|
|
950
|
+
}),
|
|
951
|
+
z4.object({
|
|
952
|
+
type: z4.literal("response.reasoning_summary_text.done"),
|
|
953
|
+
item_id: z4.string(),
|
|
954
|
+
output_index: z4.number(),
|
|
955
|
+
summary_index: z4.number(),
|
|
956
|
+
text: z4.string()
|
|
957
|
+
}),
|
|
918
958
|
z4.object({
|
|
919
959
|
type: z4.literal("response.done"),
|
|
920
960
|
response: xaiResponsesResponseSchema
|
|
@@ -946,7 +986,20 @@ function mapXaiResponsesFinishReason(finishReason) {
|
|
|
946
986
|
// src/responses/xai-responses-options.ts
|
|
947
987
|
import { z as z5 } from "zod/v4";
|
|
948
988
|
var xaiResponsesProviderOptions = z5.object({
|
|
949
|
-
|
|
989
|
+
/**
|
|
990
|
+
* Constrains how hard a reasoning model thinks before responding.
|
|
991
|
+
* Possible values are `low` (uses fewer reasoning tokens), `medium` and `high` (uses more reasoning tokens).
|
|
992
|
+
*/
|
|
993
|
+
reasoningEffort: z5.enum(["low", "medium", "high"]).optional(),
|
|
994
|
+
/**
|
|
995
|
+
* Whether to store the input message(s) and model response for later retrieval.
|
|
996
|
+
* @default true
|
|
997
|
+
*/
|
|
998
|
+
store: z5.boolean().optional(),
|
|
999
|
+
/**
|
|
1000
|
+
* The ID of the previous response from the model.
|
|
1001
|
+
*/
|
|
1002
|
+
previousResponseId: z5.string().optional()
|
|
950
1003
|
});
|
|
951
1004
|
|
|
952
1005
|
// src/responses/convert-to-xai-responses-input.ts
|
|
@@ -1420,7 +1473,16 @@ var XaiResponsesLanguageModel = class {
|
|
|
1420
1473
|
temperature,
|
|
1421
1474
|
top_p: topP,
|
|
1422
1475
|
seed,
|
|
1423
|
-
|
|
1476
|
+
...options.reasoningEffort != null && {
|
|
1477
|
+
reasoning: { effort: options.reasoningEffort }
|
|
1478
|
+
},
|
|
1479
|
+
...options.store === false && {
|
|
1480
|
+
store: options.store,
|
|
1481
|
+
include: ["reasoning.encrypted_content"]
|
|
1482
|
+
},
|
|
1483
|
+
...options.previousResponseId != null && {
|
|
1484
|
+
previous_response_id: options.previousResponseId
|
|
1485
|
+
}
|
|
1424
1486
|
};
|
|
1425
1487
|
if (xaiTools2 && xaiTools2.length > 0) {
|
|
1426
1488
|
baseArgs.tools = xaiTools2;
|
|
@@ -1608,6 +1670,29 @@ var XaiResponsesLanguageModel = class {
|
|
|
1608
1670
|
}
|
|
1609
1671
|
return;
|
|
1610
1672
|
}
|
|
1673
|
+
if (event.type === "response.reasoning_summary_part.added") {
|
|
1674
|
+
const blockId = `reasoning-${event.item_id}`;
|
|
1675
|
+
controller.enqueue({
|
|
1676
|
+
type: "reasoning-start",
|
|
1677
|
+
id: blockId
|
|
1678
|
+
});
|
|
1679
|
+
}
|
|
1680
|
+
if (event.type === "response.reasoning_summary_text.delta") {
|
|
1681
|
+
const blockId = `reasoning-${event.item_id}`;
|
|
1682
|
+
controller.enqueue({
|
|
1683
|
+
type: "reasoning-delta",
|
|
1684
|
+
id: blockId,
|
|
1685
|
+
delta: event.delta
|
|
1686
|
+
});
|
|
1687
|
+
return;
|
|
1688
|
+
}
|
|
1689
|
+
if (event.type === "response.reasoning_summary_text.done") {
|
|
1690
|
+
const blockId = `reasoning-${event.item_id}`;
|
|
1691
|
+
controller.enqueue({
|
|
1692
|
+
type: "reasoning-end",
|
|
1693
|
+
id: blockId
|
|
1694
|
+
});
|
|
1695
|
+
}
|
|
1611
1696
|
if (event.type === "response.output_text.delta") {
|
|
1612
1697
|
const blockId = `text-${event.item_id}`;
|
|
1613
1698
|
if (contentBlocks[blockId] == null) {
|
|
@@ -1847,7 +1932,7 @@ var xaiTools = {
|
|
|
1847
1932
|
};
|
|
1848
1933
|
|
|
1849
1934
|
// src/version.ts
|
|
1850
|
-
var VERSION = true ? "3.0.0-beta.
|
|
1935
|
+
var VERSION = true ? "3.0.0-beta.41" : "0.0.0-test";
|
|
1851
1936
|
|
|
1852
1937
|
// src/xai-provider.ts
|
|
1853
1938
|
var xaiErrorStructure = {
|