@flutchai/flutch-sdk 0.7.8 → 0.7.9

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
@@ -7609,6 +7609,22 @@ function buildEffortRequestFields(effort) {
7609
7609
  } : void 0;
7610
7610
  }
7611
7611
  __name(buildEffortRequestFields, "buildEffortRequestFields");
7612
+ function buildReasoningRequestFields(effort, thinking) {
7613
+ if (!effort && !thinking) return void 0;
7614
+ return {
7615
+ ...effort && {
7616
+ output_config: {
7617
+ effort
7618
+ }
7619
+ },
7620
+ ...thinking && {
7621
+ thinking: {
7622
+ type: thinking
7623
+ }
7624
+ }
7625
+ };
7626
+ }
7627
+ __name(buildReasoningRequestFields, "buildReasoningRequestFields");
7612
7628
  function resolveSamplingParams(modelIdentifiers, requested, supportsSamplingParams) {
7613
7629
  const accepted = supportsSamplingParams ?? modelIdentifiers.every((id) => modelAcceptsSamplingParams(id));
7614
7630
  if (accepted) {
@@ -7956,7 +7972,8 @@ var ModelInitializer = class _ModelInitializer {
7956
7972
  const withSampling = config.supportsSamplingParams === void 0 ? withMcp : `${withMcp}:sp:${config.supportsSamplingParams}`;
7957
7973
  const withCache = config.promptCache === void 0 && config.promptCacheTtl === void 0 ? withSampling : `${withSampling}:pc:${config.promptCache ?? "auto"}:${config.promptCacheTtl ?? "default"}`;
7958
7974
  const withEffort = config.effort === void 0 ? withCache : `${withCache}:eff:${config.effort}`;
7959
- return config.toolSearch?.enabled ? `${withEffort}:ts:${JSON.stringify(config.toolSearch)}` : withEffort;
7975
+ const withThinking = config.thinking === void 0 ? withEffort : `${withEffort}:th:${config.thinking}`;
7976
+ return config.toolSearch?.enabled ? `${withThinking}:ts:${JSON.stringify(config.toolSearch)}` : withThinking;
7960
7977
  }
7961
7978
  // Chat model creators
7962
7979
  chatModelCreators = {
@@ -7971,7 +7988,7 @@ var ModelInitializer = class _ModelInitializer {
7971
7988
  }
7972
7989
  return new openai.ChatOpenAI(config);
7973
7990
  },
7974
- [ModelProvider.ANTHROPIC]: ({ modelName, defaultTemperature, defaultMaxTokens, apiToken, baseURL }, promptCacheControl) => {
7991
+ [ModelProvider.ANTHROPIC]: ({ modelName, defaultTemperature, defaultMaxTokens, apiToken, baseURL, defaultThinking }, promptCacheControl) => {
7975
7992
  const routerURL = resolveRouterURL(baseURL);
7976
7993
  return new anthropic.ChatAnthropic({
7977
7994
  modelName,
@@ -7988,6 +8005,12 @@ var ModelInitializer = class _ModelInitializer {
7988
8005
  ...promptCacheControl && {
7989
8006
  cache_control: promptCacheControl
7990
8007
  },
8008
+ // The thinking mode as the API's own parameter; absent when unset.
8009
+ ...defaultThinking && {
8010
+ thinking: {
8011
+ type: defaultThinking
8012
+ }
8013
+ },
7991
8014
  anthropicApiKey: apiToken || this.resolveApiKey(ModelProvider.ANTHROPIC),
7992
8015
  ...routerURL && {
7993
8016
  anthropicApiUrl: routerURL
@@ -8194,7 +8217,8 @@ var ModelInitializer = class _ModelInitializer {
8194
8217
  defaultTemperature: sampling.temperature,
8195
8218
  defaultMaxTokens: toOptionalNumber(config.maxTokens) ?? toOptionalNumber(modelConfig.defaultMaxTokens),
8196
8219
  baseURL: config.baseURL ?? modelConfig.baseURL,
8197
- defaultEffort: config.effort ?? modelConfig.defaultEffort
8220
+ defaultEffort: config.effort ?? modelConfig.defaultEffort,
8221
+ defaultThinking: config.thinking ?? modelConfig.defaultThinking
8198
8222
  };
8199
8223
  const promptCacheControl = resolvePromptCacheControl([
8200
8224
  finalConfig.bedrockModelId,
@@ -8206,7 +8230,7 @@ var ModelInitializer = class _ModelInitializer {
8206
8230
  this.logger.debug(`Creating new chat model instance: ${cacheKey}`);
8207
8231
  let model;
8208
8232
  if (finalConfig.useBedrock && finalConfig.bedrockModelId) {
8209
- const effortFields = buildEffortRequestFields(config.effort ?? modelConfig.defaultEffort);
8233
+ const effortFields = buildReasoningRequestFields(config.effort ?? modelConfig.defaultEffort, config.thinking ?? modelConfig.defaultThinking);
8210
8234
  model = new FlutchChatBedrockConverse({
8211
8235
  model: finalConfig.bedrockModelId,
8212
8236
  region: this.resolveBedrockRegion(),
@@ -9211,6 +9235,7 @@ exports.bootstrap = bootstrap;
9211
9235
  exports.buildEffortRequestFields = buildEffortRequestFields;
9212
9236
  exports.buildOAuthAuthorizationUrl = buildOAuthAuthorizationUrl;
9213
9237
  exports.buildOpenAIModelConfig = buildOpenAIModelConfig;
9238
+ exports.buildReasoningRequestFields = buildReasoningRequestFields;
9214
9239
  exports.clearAttachmentDataStore = clearAttachmentDataStore;
9215
9240
  exports.createEndpointDescriptors = createEndpointDescriptors;
9216
9241
  exports.createGraphAttachment = createGraphAttachment;