@nomad-e/bluma-cli 0.1.76 → 0.1.78
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/main.js +37 -25
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -14967,6 +14967,41 @@ function buildFactorHeaders(ctx) {
|
|
|
14967
14967
|
"X-Company-Name": encodeHeader(ctx.companyName)
|
|
14968
14968
|
};
|
|
14969
14969
|
}
|
|
14970
|
+
var THINKING_TOKEN_BUDGET_BY_EFFORT = {
|
|
14971
|
+
low: 256,
|
|
14972
|
+
medium: 1024,
|
|
14973
|
+
high: 2048
|
|
14974
|
+
};
|
|
14975
|
+
function getThinkingTokenBudgetForEffort(effort) {
|
|
14976
|
+
if (!effort) return void 0;
|
|
14977
|
+
return THINKING_TOKEN_BUDGET_BY_EFFORT[effort];
|
|
14978
|
+
}
|
|
14979
|
+
function buildVllmReasoningPayload(effort) {
|
|
14980
|
+
if (!effort) return void 0;
|
|
14981
|
+
return {
|
|
14982
|
+
reasoning: { effort },
|
|
14983
|
+
extra_body: {
|
|
14984
|
+
thinking_token_budget: getThinkingTokenBudgetForEffort(effort)
|
|
14985
|
+
}
|
|
14986
|
+
};
|
|
14987
|
+
}
|
|
14988
|
+
function buildChatCompletionRequestBody(params, runtimeConfig = getRuntimeConfig(), stream = false) {
|
|
14989
|
+
const tools = params.tools;
|
|
14990
|
+
const hasTools = Array.isArray(tools) && tools.length > 0;
|
|
14991
|
+
const effort = params.reasoning?.effort ?? runtimeConfig.reasoningEffort;
|
|
14992
|
+
const reasoningPayload = buildVllmReasoningPayload(effort);
|
|
14993
|
+
return {
|
|
14994
|
+
model: params.model || runtimeConfig.model || "auto",
|
|
14995
|
+
messages: params.messages,
|
|
14996
|
+
tools: hasTools ? tools : void 0,
|
|
14997
|
+
tool_choice: hasTools ? "auto" : void 0,
|
|
14998
|
+
parallel_tool_calls: params.parallel_tool_calls ?? false,
|
|
14999
|
+
temperature: params.temperature ?? 0,
|
|
15000
|
+
...reasoningPayload ?? {},
|
|
15001
|
+
max_tokens: params.max_tokens,
|
|
15002
|
+
...stream ? { stream: true } : {}
|
|
15003
|
+
};
|
|
15004
|
+
}
|
|
14970
15005
|
function applyDeltaToolCallsToAccumulator(toolCallsAccumulator, deltaToolCalls) {
|
|
14971
15006
|
if (!deltaToolCalls?.length) {
|
|
14972
15007
|
return false;
|
|
@@ -15044,20 +15079,9 @@ var LLMService = class {
|
|
|
15044
15079
|
if (!params.userContext) {
|
|
15045
15080
|
throw new Error("LLMService.chatCompletion: userContext \xE9 obrigat\xF3rio");
|
|
15046
15081
|
}
|
|
15047
|
-
const tools = params.tools;
|
|
15048
|
-
const hasTools = Array.isArray(tools) && tools.length > 0;
|
|
15049
15082
|
const runtimeConfig = getRuntimeConfig();
|
|
15050
15083
|
const resp = await this.client.chat.completions.create(
|
|
15051
|
-
|
|
15052
|
-
model: params.model || runtimeConfig.model || "auto",
|
|
15053
|
-
messages: params.messages,
|
|
15054
|
-
tools: hasTools ? tools : void 0,
|
|
15055
|
-
tool_choice: hasTools ? "auto" : void 0,
|
|
15056
|
-
parallel_tool_calls: params.parallel_tool_calls ?? false,
|
|
15057
|
-
temperature: params.temperature ?? 0,
|
|
15058
|
-
reasoning: params.reasoning ?? (runtimeConfig.reasoningEffort ? { effort: runtimeConfig.reasoningEffort } : void 0),
|
|
15059
|
-
max_tokens: params.max_tokens
|
|
15060
|
-
},
|
|
15084
|
+
buildChatCompletionRequestBody(params, runtimeConfig, false),
|
|
15061
15085
|
{ headers: this.requestHeaders(params.userContext) }
|
|
15062
15086
|
);
|
|
15063
15087
|
return resp;
|
|
@@ -15069,21 +15093,9 @@ var LLMService = class {
|
|
|
15069
15093
|
if (!params.userContext) {
|
|
15070
15094
|
throw new Error("LLMService.chatCompletionStream: userContext \xE9 obrigat\xF3rio");
|
|
15071
15095
|
}
|
|
15072
|
-
const tools = params.tools;
|
|
15073
|
-
const hasTools = Array.isArray(tools) && tools.length > 0;
|
|
15074
15096
|
const runtimeConfig = getRuntimeConfig();
|
|
15075
15097
|
const stream = await this.client.chat.completions.create(
|
|
15076
|
-
|
|
15077
|
-
model: params.model || runtimeConfig.model || "auto",
|
|
15078
|
-
messages: params.messages,
|
|
15079
|
-
tools: hasTools ? tools : void 0,
|
|
15080
|
-
tool_choice: hasTools ? "auto" : void 0,
|
|
15081
|
-
parallel_tool_calls: params.parallel_tool_calls ?? false,
|
|
15082
|
-
temperature: params.temperature ?? 0,
|
|
15083
|
-
reasoning: params.reasoning ?? (runtimeConfig.reasoningEffort ? { effort: runtimeConfig.reasoningEffort } : void 0),
|
|
15084
|
-
max_tokens: params.max_tokens,
|
|
15085
|
-
stream: true
|
|
15086
|
-
},
|
|
15098
|
+
buildChatCompletionRequestBody(params, runtimeConfig, true),
|
|
15087
15099
|
{ headers: this.requestHeaders(params.userContext) }
|
|
15088
15100
|
);
|
|
15089
15101
|
const toolCallsAccumulator = /* @__PURE__ */ new Map();
|