@ai-sdk/xai 4.0.0-beta.13 → 4.0.0-beta.15

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.mjs CHANGED
@@ -18,6 +18,8 @@ import {
18
18
  createEventSourceResponseHandler,
19
19
  createJsonResponseHandler,
20
20
  extractResponseHeaders,
21
+ isCustomReasoning,
22
+ mapReasoningToProviderEffort,
21
23
  parseProviderOptions,
22
24
  postJsonToApi,
23
25
  safeParseJSON
@@ -376,12 +378,13 @@ var XaiChatLanguageModel = class {
376
378
  presencePenalty,
377
379
  stopSequences,
378
380
  seed,
381
+ reasoning,
379
382
  responseFormat,
380
383
  providerOptions,
381
384
  tools,
382
385
  toolChoice
383
386
  }) {
384
- var _a, _b, _c;
387
+ var _a, _b, _c, _d;
385
388
  const warnings = [];
386
389
  const options = (_a = await parseProviderOptions({
387
390
  provider: "xai",
@@ -421,14 +424,24 @@ var XaiChatLanguageModel = class {
421
424
  temperature,
422
425
  top_p: topP,
423
426
  seed,
424
- reasoning_effort: options.reasoningEffort,
427
+ reasoning_effort: (_b = options.reasoningEffort) != null ? _b : isCustomReasoning(reasoning) ? reasoning === "none" ? void 0 : mapReasoningToProviderEffort({
428
+ reasoning,
429
+ effortMap: {
430
+ minimal: "low",
431
+ low: "low",
432
+ medium: "low",
433
+ high: "high",
434
+ xhigh: "high"
435
+ },
436
+ warnings
437
+ }) : void 0,
425
438
  // parallel function calling
426
439
  parallel_function_calling: options.parallel_function_calling,
427
440
  // response format
428
441
  response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? responseFormat.schema != null ? {
429
442
  type: "json_schema",
430
443
  json_schema: {
431
- name: (_b = responseFormat.name) != null ? _b : "response",
444
+ name: (_c = responseFormat.name) != null ? _c : "response",
432
445
  schema: responseFormat.schema,
433
446
  strict: true
434
447
  }
@@ -440,7 +453,7 @@ var XaiChatLanguageModel = class {
440
453
  from_date: options.searchParameters.fromDate,
441
454
  to_date: options.searchParameters.toDate,
442
455
  max_search_results: options.searchParameters.maxSearchResults,
443
- sources: (_c = options.searchParameters.sources) == null ? void 0 : _c.map((source) => {
456
+ sources: (_d = options.searchParameters.sources) == null ? void 0 : _d.map((source) => {
444
457
  var _a2;
445
458
  return {
446
459
  type: source.type,
@@ -1043,6 +1056,8 @@ import {
1043
1056
  combineHeaders as combineHeaders3,
1044
1057
  createEventSourceResponseHandler as createEventSourceResponseHandler2,
1045
1058
  createJsonResponseHandler as createJsonResponseHandler3,
1059
+ isCustomReasoning as isCustomReasoning2,
1060
+ mapReasoningToProviderEffort as mapReasoningToProviderEffort2,
1046
1061
  parseProviderOptions as parseProviderOptions3,
1047
1062
  postJsonToApi as postJsonToApi3
1048
1063
  } from "@ai-sdk/provider-utils";
@@ -2005,9 +2020,10 @@ var XaiResponsesLanguageModel = class {
2005
2020
  responseFormat,
2006
2021
  providerOptions,
2007
2022
  tools,
2008
- toolChoice
2023
+ toolChoice,
2024
+ reasoning
2009
2025
  }) {
2010
- var _a, _b, _c, _d, _e, _f, _g;
2026
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2011
2027
  const warnings = [];
2012
2028
  const options = (_a = await parseProviderOptions3({
2013
2029
  provider: "xai",
@@ -2054,6 +2070,17 @@ var XaiResponsesLanguageModel = class {
2054
2070
  include = [...include, "reasoning.encrypted_content"];
2055
2071
  }
2056
2072
  }
2073
+ const resolvedReasoningEffort = (_g = options.reasoningEffort) != null ? _g : isCustomReasoning2(reasoning) ? reasoning === "none" ? void 0 : mapReasoningToProviderEffort2({
2074
+ reasoning,
2075
+ effortMap: {
2076
+ minimal: "low",
2077
+ low: "low",
2078
+ medium: "medium",
2079
+ high: "high",
2080
+ xhigh: "high"
2081
+ },
2082
+ warnings
2083
+ }) : void 0;
2057
2084
  const baseArgs = {
2058
2085
  model: this.modelId,
2059
2086
  input,
@@ -2068,16 +2095,16 @@ var XaiResponsesLanguageModel = class {
2068
2095
  format: responseFormat.schema != null ? {
2069
2096
  type: "json_schema",
2070
2097
  strict: true,
2071
- name: (_g = responseFormat.name) != null ? _g : "response",
2098
+ name: (_h = responseFormat.name) != null ? _h : "response",
2072
2099
  description: responseFormat.description,
2073
2100
  schema: responseFormat.schema
2074
2101
  } : { type: "json_object" }
2075
2102
  }
2076
2103
  },
2077
- ...(options.reasoningEffort != null || options.reasoningSummary != null) && {
2104
+ ...(resolvedReasoningEffort != null || options.reasoningSummary != null) && {
2078
2105
  reasoning: {
2079
- ...options.reasoningEffort != null && {
2080
- effort: options.reasoningEffort
2106
+ ...resolvedReasoningEffort != null && {
2107
+ effort: resolvedReasoningEffort
2081
2108
  },
2082
2109
  ...options.reasoningSummary != null && {
2083
2110
  summary: options.reasoningSummary
@@ -2747,7 +2774,7 @@ var xaiTools = {
2747
2774
  };
2748
2775
 
2749
2776
  // src/version.ts
2750
- var VERSION = true ? "4.0.0-beta.13" : "0.0.0-test";
2777
+ var VERSION = true ? "4.0.0-beta.15" : "0.0.0-test";
2751
2778
 
2752
2779
  // src/xai-video-model.ts
2753
2780
  import {