@ljoukov/llm 3.0.15 → 4.0.0
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 +52 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -5
- package/dist/index.d.ts +4 -5
- package/dist/index.js +54 -23
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
package/dist/index.cjs
CHANGED
|
@@ -3154,9 +3154,16 @@ function resolveProvider(model) {
|
|
|
3154
3154
|
function isOpenAiCodexModel(modelId) {
|
|
3155
3155
|
return modelId.includes("codex");
|
|
3156
3156
|
}
|
|
3157
|
-
function resolveOpenAiReasoningEffort(modelId,
|
|
3158
|
-
if (
|
|
3159
|
-
|
|
3157
|
+
function resolveOpenAiReasoningEffort(modelId, thinkingLevel) {
|
|
3158
|
+
if (thinkingLevel) {
|
|
3159
|
+
switch (thinkingLevel) {
|
|
3160
|
+
case "low":
|
|
3161
|
+
return "low";
|
|
3162
|
+
case "medium":
|
|
3163
|
+
return "medium";
|
|
3164
|
+
case "high":
|
|
3165
|
+
return "xhigh";
|
|
3166
|
+
}
|
|
3160
3167
|
}
|
|
3161
3168
|
if (isOpenAiCodexModel(modelId)) {
|
|
3162
3169
|
return "medium";
|
|
@@ -4441,10 +4448,42 @@ function extractFireworksToolCalls(message) {
|
|
|
4441
4448
|
}
|
|
4442
4449
|
return calls;
|
|
4443
4450
|
}
|
|
4444
|
-
function
|
|
4451
|
+
function toGeminiThinkingLevel(thinkingLevel) {
|
|
4452
|
+
switch (thinkingLevel) {
|
|
4453
|
+
case "low":
|
|
4454
|
+
return import_genai2.ThinkingLevel.LOW;
|
|
4455
|
+
case "medium":
|
|
4456
|
+
return import_genai2.ThinkingLevel.MEDIUM;
|
|
4457
|
+
case "high":
|
|
4458
|
+
return import_genai2.ThinkingLevel.HIGH;
|
|
4459
|
+
}
|
|
4460
|
+
}
|
|
4461
|
+
function toGemini25ProThinkingBudget(thinkingLevel) {
|
|
4462
|
+
switch (thinkingLevel) {
|
|
4463
|
+
case "low":
|
|
4464
|
+
return 256;
|
|
4465
|
+
case "medium":
|
|
4466
|
+
return 4096;
|
|
4467
|
+
case "high":
|
|
4468
|
+
return 32768;
|
|
4469
|
+
}
|
|
4470
|
+
}
|
|
4471
|
+
function resolveGeminiThinkingConfig(modelId, thinkingLevel) {
|
|
4445
4472
|
if (isGeminiImageModelId(modelId)) {
|
|
4446
4473
|
return void 0;
|
|
4447
4474
|
}
|
|
4475
|
+
if (thinkingLevel) {
|
|
4476
|
+
if (modelId === "gemini-2.5-pro") {
|
|
4477
|
+
return {
|
|
4478
|
+
includeThoughts: true,
|
|
4479
|
+
thinkingBudget: toGemini25ProThinkingBudget(thinkingLevel)
|
|
4480
|
+
};
|
|
4481
|
+
}
|
|
4482
|
+
return {
|
|
4483
|
+
includeThoughts: true,
|
|
4484
|
+
thinkingLevel: toGeminiThinkingLevel(thinkingLevel)
|
|
4485
|
+
};
|
|
4486
|
+
}
|
|
4448
4487
|
switch (modelId) {
|
|
4449
4488
|
case "gemini-3.1-pro-preview":
|
|
4450
4489
|
return { includeThoughts: true };
|
|
@@ -4531,10 +4570,7 @@ async function runTextCall(params) {
|
|
|
4531
4570
|
if (provider === "openai") {
|
|
4532
4571
|
const openAiInput = toOpenAiInput(contents);
|
|
4533
4572
|
const openAiTools = toOpenAiTools(request.tools);
|
|
4534
|
-
const reasoningEffort = resolveOpenAiReasoningEffort(
|
|
4535
|
-
modelForProvider,
|
|
4536
|
-
request.openAiReasoningEffort
|
|
4537
|
-
);
|
|
4573
|
+
const reasoningEffort = resolveOpenAiReasoningEffort(modelForProvider, request.thinkingLevel);
|
|
4538
4574
|
const openAiTextConfig = {
|
|
4539
4575
|
format: request.openAiTextFormat ?? { type: "text" },
|
|
4540
4576
|
verbosity: resolveOpenAiVerbosity(modelForProvider)
|
|
@@ -4604,10 +4640,7 @@ async function runTextCall(params) {
|
|
|
4604
4640
|
}, modelForProvider);
|
|
4605
4641
|
} else if (provider === "chatgpt") {
|
|
4606
4642
|
const chatGptInput = toChatGptInput(contents);
|
|
4607
|
-
const reasoningEffort = resolveOpenAiReasoningEffort(
|
|
4608
|
-
request.model,
|
|
4609
|
-
request.openAiReasoningEffort
|
|
4610
|
-
);
|
|
4643
|
+
const reasoningEffort = resolveOpenAiReasoningEffort(request.model, request.thinkingLevel);
|
|
4611
4644
|
const openAiTools = toOpenAiTools(request.tools);
|
|
4612
4645
|
const requestPayload = {
|
|
4613
4646
|
model: modelForProvider,
|
|
@@ -4699,7 +4732,7 @@ async function runTextCall(params) {
|
|
|
4699
4732
|
}, modelForProvider);
|
|
4700
4733
|
} else {
|
|
4701
4734
|
const geminiContents = contents.map(convertLlmContentToGeminiContent);
|
|
4702
|
-
const thinkingConfig = resolveGeminiThinkingConfig(modelForProvider);
|
|
4735
|
+
const thinkingConfig = resolveGeminiThinkingConfig(modelForProvider, request.thinkingLevel);
|
|
4703
4736
|
const config = {
|
|
4704
4737
|
maxOutputTokens: 32e3,
|
|
4705
4738
|
...thinkingConfig ? { thinkingConfig } : {},
|
|
@@ -4877,7 +4910,7 @@ function streamJson(request) {
|
|
|
4877
4910
|
tools: request.tools,
|
|
4878
4911
|
responseMimeType: request.responseMimeType ?? "application/json",
|
|
4879
4912
|
responseJsonSchema,
|
|
4880
|
-
|
|
4913
|
+
thinkingLevel: request.thinkingLevel,
|
|
4881
4914
|
...openAiTextFormatForAttempt ? { openAiTextFormat: openAiTextFormatForAttempt } : {},
|
|
4882
4915
|
signal
|
|
4883
4916
|
});
|
|
@@ -4954,7 +4987,7 @@ async function generateJson(request) {
|
|
|
4954
4987
|
tools: request.tools,
|
|
4955
4988
|
responseMimeType: request.responseMimeType ?? "application/json",
|
|
4956
4989
|
responseJsonSchema,
|
|
4957
|
-
|
|
4990
|
+
thinkingLevel: request.thinkingLevel,
|
|
4958
4991
|
...openAiTextFormatForAttempt ? { openAiTextFormat: openAiTextFormatForAttempt } : {},
|
|
4959
4992
|
signal: request.signal
|
|
4960
4993
|
});
|
|
@@ -5220,7 +5253,7 @@ async function runToolLoop(request) {
|
|
|
5220
5253
|
const openAiTools = openAiNativeTools ? [...openAiNativeTools, ...openAiAgentTools] : [...openAiAgentTools];
|
|
5221
5254
|
const reasoningEffort = resolveOpenAiReasoningEffort(
|
|
5222
5255
|
providerInfo.model,
|
|
5223
|
-
request.
|
|
5256
|
+
request.thinkingLevel
|
|
5224
5257
|
);
|
|
5225
5258
|
const textConfig = {
|
|
5226
5259
|
format: { type: "text" },
|
|
@@ -5488,10 +5521,7 @@ async function runToolLoop(request) {
|
|
|
5488
5521
|
const openAiAgentTools = buildOpenAiToolsFromToolSet(request.tools);
|
|
5489
5522
|
const openAiNativeTools = toOpenAiTools(request.modelTools);
|
|
5490
5523
|
const openAiTools = openAiNativeTools ? [...openAiNativeTools, ...openAiAgentTools] : [...openAiAgentTools];
|
|
5491
|
-
const reasoningEffort = resolveOpenAiReasoningEffort(
|
|
5492
|
-
request.model,
|
|
5493
|
-
request.openAiReasoningEffort
|
|
5494
|
-
);
|
|
5524
|
+
const reasoningEffort = resolveOpenAiReasoningEffort(request.model, request.thinkingLevel);
|
|
5495
5525
|
const toolLoopInput = toChatGptInput(contents);
|
|
5496
5526
|
const conversationId = `tool-loop-${(0, import_node_crypto.randomBytes)(8).toString("hex")}`;
|
|
5497
5527
|
const promptCacheKey = conversationId;
|
|
@@ -5930,7 +5960,7 @@ async function runToolLoop(request) {
|
|
|
5930
5960
|
firstModelEventAtMs = Date.now();
|
|
5931
5961
|
}
|
|
5932
5962
|
};
|
|
5933
|
-
const thinkingConfig = resolveGeminiThinkingConfig(request.model);
|
|
5963
|
+
const thinkingConfig = resolveGeminiThinkingConfig(request.model, request.thinkingLevel);
|
|
5934
5964
|
const config = {
|
|
5935
5965
|
maxOutputTokens: 32e3,
|
|
5936
5966
|
tools: geminiTools,
|
|
@@ -9306,7 +9336,7 @@ function createSubagentController(params) {
|
|
|
9306
9336
|
subagentTool: params.subagentSelection,
|
|
9307
9337
|
modelTools: params.toolLoopRequest.modelTools,
|
|
9308
9338
|
maxSteps: subagentRequest.maxSteps,
|
|
9309
|
-
|
|
9339
|
+
thinkingLevel: params.toolLoopRequest.thinkingLevel,
|
|
9310
9340
|
signal: subagentRequest.signal
|
|
9311
9341
|
},
|
|
9312
9342
|
{
|