@ljoukov/llm 7.0.2 → 7.0.3
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/README.md +12 -0
- package/dist/index.cjs +17 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +17 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -282,6 +282,12 @@ 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;
|
|
285
291
|
readonly mediaResolution?: LlmMediaResolution;
|
|
286
292
|
readonly openAiTextFormat?: ResponseTextConfig["format"];
|
|
287
293
|
readonly telemetry?: TelemetrySelection;
|
|
@@ -429,6 +435,7 @@ type LlmToolLoopRequest = LlmInput & {
|
|
|
429
435
|
readonly modelTools?: readonly LlmToolConfig[];
|
|
430
436
|
readonly maxSteps?: number;
|
|
431
437
|
readonly thinkingLevel?: LlmThinkingLevel;
|
|
438
|
+
readonly thinkingBudget?: number;
|
|
432
439
|
readonly mediaResolution?: LlmMediaResolution;
|
|
433
440
|
readonly steering?: LlmToolLoopSteeringChannel;
|
|
434
441
|
readonly onEvent?: (event: LlmStreamEvent) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -282,6 +282,12 @@ 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;
|
|
285
291
|
readonly mediaResolution?: LlmMediaResolution;
|
|
286
292
|
readonly openAiTextFormat?: ResponseTextConfig["format"];
|
|
287
293
|
readonly telemetry?: TelemetrySelection;
|
|
@@ -429,6 +435,7 @@ type LlmToolLoopRequest = LlmInput & {
|
|
|
429
435
|
readonly modelTools?: readonly LlmToolConfig[];
|
|
430
436
|
readonly maxSteps?: number;
|
|
431
437
|
readonly thinkingLevel?: LlmThinkingLevel;
|
|
438
|
+
readonly thinkingBudget?: number;
|
|
432
439
|
readonly mediaResolution?: LlmMediaResolution;
|
|
433
440
|
readonly steering?: LlmToolLoopSteeringChannel;
|
|
434
441
|
readonly onEvent?: (event: LlmStreamEvent) => void;
|
package/dist/index.js
CHANGED
|
@@ -7145,10 +7145,14 @@ function toGemini25ProThinkingBudget(thinkingLevel) {
|
|
|
7145
7145
|
return 32768;
|
|
7146
7146
|
}
|
|
7147
7147
|
}
|
|
7148
|
-
function resolveGeminiThinkingConfig(modelId, thinkingLevel) {
|
|
7148
|
+
function resolveGeminiThinkingConfig(modelId, thinkingLevel, thinkingBudget) {
|
|
7149
7149
|
if (isGeminiImageModelId(modelId) || modelId === "gemini-flash-lite-latest") {
|
|
7150
7150
|
return void 0;
|
|
7151
7151
|
}
|
|
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
|
+
}
|
|
7152
7156
|
if (thinkingLevel) {
|
|
7153
7157
|
if (modelId === "gemini-2.5-pro") {
|
|
7154
7158
|
return {
|
|
@@ -7524,6 +7528,7 @@ function startLlmCallLoggerFromContents(options) {
|
|
|
7524
7528
|
...options.request.imageAspectRatio ? { imageAspectRatio: options.request.imageAspectRatio } : {},
|
|
7525
7529
|
...options.request.imageSize ? { imageSize: options.request.imageSize } : {},
|
|
7526
7530
|
...options.request.thinkingLevel ? { thinkingLevel: options.request.thinkingLevel } : {},
|
|
7531
|
+
...options.request.thinkingBudget !== void 0 ? { thinkingBudget: options.request.thinkingBudget } : {},
|
|
7527
7532
|
...options.request.mediaResolution ? { mediaResolution: options.request.mediaResolution } : {},
|
|
7528
7533
|
...options.request.openAiTextFormat ? { openAiTextFormat: sanitiseLogValue(options.request.openAiTextFormat) } : {},
|
|
7529
7534
|
...getCurrentToolCallContext() ? { toolContext: getCurrentToolCallContext() } : {}
|
|
@@ -7825,7 +7830,11 @@ async function runTextCall(params) {
|
|
|
7825
7830
|
})
|
|
7826
7831
|
)
|
|
7827
7832
|
);
|
|
7828
|
-
const thinkingConfig = resolveGeminiThinkingConfig(
|
|
7833
|
+
const thinkingConfig = resolveGeminiThinkingConfig(
|
|
7834
|
+
modelForProvider,
|
|
7835
|
+
request.thinkingLevel,
|
|
7836
|
+
request.thinkingBudget
|
|
7837
|
+
);
|
|
7829
7838
|
const mediaResolution = toGeminiMediaResolution(request.mediaResolution);
|
|
7830
7839
|
const config = {
|
|
7831
7840
|
maxOutputTokens: 32e3,
|
|
@@ -8132,6 +8141,7 @@ function startJsonStream(request, operation) {
|
|
|
8132
8141
|
responseMimeType: request.responseMimeType ?? "application/json",
|
|
8133
8142
|
responseJsonSchema,
|
|
8134
8143
|
thinkingLevel: request.thinkingLevel,
|
|
8144
|
+
thinkingBudget: request.thinkingBudget,
|
|
8135
8145
|
...openAiTextFormatForAttempt ? { openAiTextFormat: openAiTextFormatForAttempt } : {},
|
|
8136
8146
|
telemetry: false,
|
|
8137
8147
|
signal
|
|
@@ -9536,7 +9546,11 @@ async function runToolLoop(request) {
|
|
|
9536
9546
|
firstModelEventAtMs = Date.now();
|
|
9537
9547
|
}
|
|
9538
9548
|
};
|
|
9539
|
-
const thinkingConfig = resolveGeminiThinkingConfig(
|
|
9549
|
+
const thinkingConfig = resolveGeminiThinkingConfig(
|
|
9550
|
+
request.model,
|
|
9551
|
+
request.thinkingLevel,
|
|
9552
|
+
request.thinkingBudget
|
|
9553
|
+
);
|
|
9540
9554
|
const mediaResolution = toGeminiMediaResolution(request.mediaResolution);
|
|
9541
9555
|
const config = {
|
|
9542
9556
|
maxOutputTokens: 32e3,
|