@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/README.md +2 -3
- package/dist/index.cjs +39 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -7
- package/dist/index.d.ts +0 -7
- package/dist/index.js +39 -29
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -491,15 +491,14 @@ const { value } = await generateJson({
|
|
|
491
491
|
console.log(value.ok, value.message);
|
|
492
492
|
```
|
|
493
493
|
|
|
494
|
-
For
|
|
495
|
-
`thinkingLevel` for Gemini requests:
|
|
494
|
+
For calls that should use a smaller reasoning budget, pass the cross-model `thinkingLevel` option:
|
|
496
495
|
|
|
497
496
|
```ts
|
|
498
497
|
const { value } = await generateJson({
|
|
499
498
|
model: "gemini-flash-latest",
|
|
500
499
|
input: "Return a JSON object with ok=true and message='hello'.",
|
|
501
500
|
schema,
|
|
502
|
-
|
|
501
|
+
thinkingLevel: "low",
|
|
503
502
|
});
|
|
504
503
|
```
|
|
505
504
|
|
package/dist/index.cjs
CHANGED
|
@@ -7248,29 +7248,16 @@ function toGeminiThinkingLevel(thinkingLevel) {
|
|
|
7248
7248
|
return import_genai2.ThinkingLevel.HIGH;
|
|
7249
7249
|
}
|
|
7250
7250
|
}
|
|
7251
|
-
function
|
|
7252
|
-
switch (thinkingLevel) {
|
|
7253
|
-
case "low":
|
|
7254
|
-
return 256;
|
|
7255
|
-
case "medium":
|
|
7256
|
-
return 4096;
|
|
7257
|
-
case "high":
|
|
7258
|
-
return 32768;
|
|
7259
|
-
}
|
|
7260
|
-
}
|
|
7261
|
-
function resolveGeminiThinkingConfig(modelId, thinkingLevel, thinkingBudget) {
|
|
7251
|
+
function resolveGeminiThinkingConfig(modelId, thinkingLevel) {
|
|
7262
7252
|
if (isGeminiImageModelId(modelId) || modelId === "gemini-flash-lite-latest") {
|
|
7263
7253
|
return void 0;
|
|
7264
7254
|
}
|
|
7265
|
-
if (thinkingBudget !== void 0) {
|
|
7266
|
-
const normalizedBudget = Math.max(0, Math.floor(thinkingBudget));
|
|
7267
|
-
return normalizedBudget === 0 ? { thinkingBudget: 0 } : { includeThoughts: true, thinkingBudget: normalizedBudget };
|
|
7268
|
-
}
|
|
7269
7255
|
if (thinkingLevel) {
|
|
7270
|
-
|
|
7256
|
+
const thinkingBudget = resolveGeminiThinkingBudget(modelId, thinkingLevel);
|
|
7257
|
+
if (thinkingBudget !== void 0) {
|
|
7271
7258
|
return {
|
|
7272
7259
|
includeThoughts: true,
|
|
7273
|
-
thinkingBudget
|
|
7260
|
+
thinkingBudget
|
|
7274
7261
|
};
|
|
7275
7262
|
}
|
|
7276
7263
|
return {
|
|
@@ -7292,6 +7279,39 @@ function resolveGeminiThinkingConfig(modelId, thinkingLevel, thinkingBudget) {
|
|
|
7292
7279
|
return { includeThoughts: true };
|
|
7293
7280
|
}
|
|
7294
7281
|
}
|
|
7282
|
+
function resolveGeminiThinkingBudget(modelId, thinkingLevel) {
|
|
7283
|
+
if (modelId === "gemini-2.5-pro") {
|
|
7284
|
+
switch (thinkingLevel) {
|
|
7285
|
+
case "low":
|
|
7286
|
+
return 256;
|
|
7287
|
+
case "medium":
|
|
7288
|
+
return 4096;
|
|
7289
|
+
case "high":
|
|
7290
|
+
return 32768;
|
|
7291
|
+
}
|
|
7292
|
+
}
|
|
7293
|
+
if (modelId === "gemini-flash-latest") {
|
|
7294
|
+
switch (thinkingLevel) {
|
|
7295
|
+
case "low":
|
|
7296
|
+
return 256;
|
|
7297
|
+
case "medium":
|
|
7298
|
+
return 8192;
|
|
7299
|
+
case "high":
|
|
7300
|
+
return 24576;
|
|
7301
|
+
}
|
|
7302
|
+
}
|
|
7303
|
+
if (modelId === "gemini-3-flash-preview") {
|
|
7304
|
+
switch (thinkingLevel) {
|
|
7305
|
+
case "low":
|
|
7306
|
+
return 256;
|
|
7307
|
+
case "medium":
|
|
7308
|
+
return 8192;
|
|
7309
|
+
case "high":
|
|
7310
|
+
return 16384;
|
|
7311
|
+
}
|
|
7312
|
+
}
|
|
7313
|
+
return void 0;
|
|
7314
|
+
}
|
|
7295
7315
|
function decodeInlineDataBuffer(base64) {
|
|
7296
7316
|
try {
|
|
7297
7317
|
return import_node_buffer4.Buffer.from(base64, "base64");
|
|
@@ -7641,7 +7661,6 @@ function startLlmCallLoggerFromContents(options) {
|
|
|
7641
7661
|
...options.request.imageAspectRatio ? { imageAspectRatio: options.request.imageAspectRatio } : {},
|
|
7642
7662
|
...options.request.imageSize ? { imageSize: options.request.imageSize } : {},
|
|
7643
7663
|
...options.request.thinkingLevel ? { thinkingLevel: options.request.thinkingLevel } : {},
|
|
7644
|
-
...options.request.thinkingBudget !== void 0 ? { thinkingBudget: options.request.thinkingBudget } : {},
|
|
7645
7664
|
...options.request.mediaResolution ? { mediaResolution: options.request.mediaResolution } : {},
|
|
7646
7665
|
...options.request.openAiTextFormat ? { openAiTextFormat: sanitiseLogValue(options.request.openAiTextFormat) } : {},
|
|
7647
7666
|
...getCurrentToolCallContext() ? { toolContext: getCurrentToolCallContext() } : {}
|
|
@@ -7943,11 +7962,7 @@ async function runTextCall(params) {
|
|
|
7943
7962
|
})
|
|
7944
7963
|
)
|
|
7945
7964
|
);
|
|
7946
|
-
const thinkingConfig = resolveGeminiThinkingConfig(
|
|
7947
|
-
modelForProvider,
|
|
7948
|
-
request.thinkingLevel,
|
|
7949
|
-
request.thinkingBudget
|
|
7950
|
-
);
|
|
7965
|
+
const thinkingConfig = resolveGeminiThinkingConfig(modelForProvider, request.thinkingLevel);
|
|
7951
7966
|
const mediaResolution = toGeminiMediaResolution(request.mediaResolution);
|
|
7952
7967
|
const config = {
|
|
7953
7968
|
maxOutputTokens: 32e3,
|
|
@@ -8254,7 +8269,6 @@ function startJsonStream(request, operation) {
|
|
|
8254
8269
|
responseMimeType: request.responseMimeType ?? "application/json",
|
|
8255
8270
|
responseJsonSchema,
|
|
8256
8271
|
thinkingLevel: request.thinkingLevel,
|
|
8257
|
-
thinkingBudget: request.thinkingBudget,
|
|
8258
8272
|
...openAiTextFormatForAttempt ? { openAiTextFormat: openAiTextFormatForAttempt } : {},
|
|
8259
8273
|
telemetry: false,
|
|
8260
8274
|
signal
|
|
@@ -9659,11 +9673,7 @@ async function runToolLoop(request) {
|
|
|
9659
9673
|
firstModelEventAtMs = Date.now();
|
|
9660
9674
|
}
|
|
9661
9675
|
};
|
|
9662
|
-
const thinkingConfig = resolveGeminiThinkingConfig(
|
|
9663
|
-
request.model,
|
|
9664
|
-
request.thinkingLevel,
|
|
9665
|
-
request.thinkingBudget
|
|
9666
|
-
);
|
|
9676
|
+
const thinkingConfig = resolveGeminiThinkingConfig(request.model, request.thinkingLevel);
|
|
9667
9677
|
const mediaResolution = toGeminiMediaResolution(request.mediaResolution);
|
|
9668
9678
|
const config = {
|
|
9669
9679
|
maxOutputTokens: 32e3,
|