@ljoukov/llm 7.0.3 → 7.0.5

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.d.cts CHANGED
@@ -282,12 +282,6 @@ type LlmBaseRequest = {
282
282
  readonly imageAspectRatio?: string;
283
283
  readonly imageSize?: LlmImageSize;
284
284
  readonly thinkingLevel?: LlmThinkingLevel;
285
- /**
286
- * Gemini-only explicit thinking budget. When provided, this overrides
287
- * `thinkingLevel` and the model default for Gemini requests. Use `0` to
288
- * disable thinking where the selected Gemini model supports it.
289
- */
290
- readonly thinkingBudget?: number;
291
285
  readonly mediaResolution?: LlmMediaResolution;
292
286
  readonly openAiTextFormat?: ResponseTextConfig["format"];
293
287
  readonly telemetry?: TelemetrySelection;
@@ -435,7 +429,6 @@ type LlmToolLoopRequest = LlmInput & {
435
429
  readonly modelTools?: readonly LlmToolConfig[];
436
430
  readonly maxSteps?: number;
437
431
  readonly thinkingLevel?: LlmThinkingLevel;
438
- readonly thinkingBudget?: number;
439
432
  readonly mediaResolution?: LlmMediaResolution;
440
433
  readonly steering?: LlmToolLoopSteeringChannel;
441
434
  readonly onEvent?: (event: LlmStreamEvent) => void;
package/dist/index.d.ts CHANGED
@@ -282,12 +282,6 @@ type LlmBaseRequest = {
282
282
  readonly imageAspectRatio?: string;
283
283
  readonly imageSize?: LlmImageSize;
284
284
  readonly thinkingLevel?: LlmThinkingLevel;
285
- /**
286
- * Gemini-only explicit thinking budget. When provided, this overrides
287
- * `thinkingLevel` and the model default for Gemini requests. Use `0` to
288
- * disable thinking where the selected Gemini model supports it.
289
- */
290
- readonly thinkingBudget?: number;
291
285
  readonly mediaResolution?: LlmMediaResolution;
292
286
  readonly openAiTextFormat?: ResponseTextConfig["format"];
293
287
  readonly telemetry?: TelemetrySelection;
@@ -435,7 +429,6 @@ type LlmToolLoopRequest = LlmInput & {
435
429
  readonly modelTools?: readonly LlmToolConfig[];
436
430
  readonly maxSteps?: number;
437
431
  readonly thinkingLevel?: LlmThinkingLevel;
438
- readonly thinkingBudget?: number;
439
432
  readonly mediaResolution?: LlmMediaResolution;
440
433
  readonly steering?: LlmToolLoopSteeringChannel;
441
434
  readonly onEvent?: (event: LlmStreamEvent) => void;
package/dist/index.js CHANGED
@@ -7135,29 +7135,16 @@ function toGeminiThinkingLevel(thinkingLevel) {
7135
7135
  return ThinkingLevel.HIGH;
7136
7136
  }
7137
7137
  }
7138
- function toGemini25ProThinkingBudget(thinkingLevel) {
7139
- switch (thinkingLevel) {
7140
- case "low":
7141
- return 256;
7142
- case "medium":
7143
- return 4096;
7144
- case "high":
7145
- return 32768;
7146
- }
7147
- }
7148
- function resolveGeminiThinkingConfig(modelId, thinkingLevel, thinkingBudget) {
7138
+ function resolveGeminiThinkingConfig(modelId, thinkingLevel) {
7149
7139
  if (isGeminiImageModelId(modelId) || modelId === "gemini-flash-lite-latest") {
7150
7140
  return void 0;
7151
7141
  }
7152
- if (thinkingBudget !== void 0) {
7153
- const normalizedBudget = Math.max(0, Math.floor(thinkingBudget));
7154
- return normalizedBudget === 0 ? { thinkingBudget: 0 } : { includeThoughts: true, thinkingBudget: normalizedBudget };
7155
- }
7156
7142
  if (thinkingLevel) {
7157
- if (modelId === "gemini-2.5-pro") {
7143
+ const thinkingBudget = resolveGeminiThinkingBudget(modelId, thinkingLevel);
7144
+ if (thinkingBudget !== void 0) {
7158
7145
  return {
7159
7146
  includeThoughts: true,
7160
- thinkingBudget: toGemini25ProThinkingBudget(thinkingLevel)
7147
+ thinkingBudget
7161
7148
  };
7162
7149
  }
7163
7150
  return {
@@ -7179,6 +7166,39 @@ function resolveGeminiThinkingConfig(modelId, thinkingLevel, thinkingBudget) {
7179
7166
  return { includeThoughts: true };
7180
7167
  }
7181
7168
  }
7169
+ function resolveGeminiThinkingBudget(modelId, thinkingLevel) {
7170
+ if (modelId === "gemini-2.5-pro") {
7171
+ switch (thinkingLevel) {
7172
+ case "low":
7173
+ return 256;
7174
+ case "medium":
7175
+ return 4096;
7176
+ case "high":
7177
+ return 32768;
7178
+ }
7179
+ }
7180
+ if (modelId === "gemini-flash-latest") {
7181
+ switch (thinkingLevel) {
7182
+ case "low":
7183
+ return 256;
7184
+ case "medium":
7185
+ return 8192;
7186
+ case "high":
7187
+ return 24576;
7188
+ }
7189
+ }
7190
+ if (modelId === "gemini-3-flash-preview") {
7191
+ switch (thinkingLevel) {
7192
+ case "low":
7193
+ return 256;
7194
+ case "medium":
7195
+ return 8192;
7196
+ case "high":
7197
+ return 16384;
7198
+ }
7199
+ }
7200
+ return void 0;
7201
+ }
7182
7202
  function decodeInlineDataBuffer(base64) {
7183
7203
  try {
7184
7204
  return Buffer5.from(base64, "base64");
@@ -7528,7 +7548,6 @@ function startLlmCallLoggerFromContents(options) {
7528
7548
  ...options.request.imageAspectRatio ? { imageAspectRatio: options.request.imageAspectRatio } : {},
7529
7549
  ...options.request.imageSize ? { imageSize: options.request.imageSize } : {},
7530
7550
  ...options.request.thinkingLevel ? { thinkingLevel: options.request.thinkingLevel } : {},
7531
- ...options.request.thinkingBudget !== void 0 ? { thinkingBudget: options.request.thinkingBudget } : {},
7532
7551
  ...options.request.mediaResolution ? { mediaResolution: options.request.mediaResolution } : {},
7533
7552
  ...options.request.openAiTextFormat ? { openAiTextFormat: sanitiseLogValue(options.request.openAiTextFormat) } : {},
7534
7553
  ...getCurrentToolCallContext() ? { toolContext: getCurrentToolCallContext() } : {}
@@ -7830,11 +7849,7 @@ async function runTextCall(params) {
7830
7849
  })
7831
7850
  )
7832
7851
  );
7833
- const thinkingConfig = resolveGeminiThinkingConfig(
7834
- modelForProvider,
7835
- request.thinkingLevel,
7836
- request.thinkingBudget
7837
- );
7852
+ const thinkingConfig = resolveGeminiThinkingConfig(modelForProvider, request.thinkingLevel);
7838
7853
  const mediaResolution = toGeminiMediaResolution(request.mediaResolution);
7839
7854
  const config = {
7840
7855
  maxOutputTokens: 32e3,
@@ -8141,7 +8156,6 @@ function startJsonStream(request, operation) {
8141
8156
  responseMimeType: request.responseMimeType ?? "application/json",
8142
8157
  responseJsonSchema,
8143
8158
  thinkingLevel: request.thinkingLevel,
8144
- thinkingBudget: request.thinkingBudget,
8145
8159
  ...openAiTextFormatForAttempt ? { openAiTextFormat: openAiTextFormatForAttempt } : {},
8146
8160
  telemetry: false,
8147
8161
  signal
@@ -9546,11 +9560,7 @@ async function runToolLoop(request) {
9546
9560
  firstModelEventAtMs = Date.now();
9547
9561
  }
9548
9562
  };
9549
- const thinkingConfig = resolveGeminiThinkingConfig(
9550
- request.model,
9551
- request.thinkingLevel,
9552
- request.thinkingBudget
9553
- );
9563
+ const thinkingConfig = resolveGeminiThinkingConfig(request.model, request.thinkingLevel);
9554
9564
  const mediaResolution = toGeminiMediaResolution(request.mediaResolution);
9555
9565
  const config = {
9556
9566
  maxOutputTokens: 32e3,