blun-king-cli 9.1.354 → 9.1.355
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/bin/llm-config-log-dedup-policy.cjs +76 -0
- package/blun.mjs +8 -18
- package/package.json +1 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function createLlmConfigChangeDetector(options = {}) {
|
|
4
|
+
const serializeParameters = options.serializeParameters ?? JSON.stringify;
|
|
5
|
+
if (typeof serializeParameters !== 'function') {
|
|
6
|
+
throw new TypeError('serializeParameters must be a function');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
let previous;
|
|
10
|
+
|
|
11
|
+
return function shouldLogConfig(input) {
|
|
12
|
+
const tools = Array.isArray(input.tools) ? input.tools : [];
|
|
13
|
+
const sameScalars = previous !== undefined
|
|
14
|
+
&& previous.provider === input.provider
|
|
15
|
+
&& previous.model === input.model
|
|
16
|
+
&& previous.modelAlias === input.modelAlias
|
|
17
|
+
&& previous.thinkingEffort === input.thinkingEffort
|
|
18
|
+
&& previous.systemPrompt === input.systemPrompt;
|
|
19
|
+
|
|
20
|
+
if (sameScalars && previous.tools.length === tools.length) {
|
|
21
|
+
let exactToolMatch = true;
|
|
22
|
+
for (let index = 0; index < tools.length; index += 1) {
|
|
23
|
+
const tool = tools[index];
|
|
24
|
+
const prior = previous.tools[index];
|
|
25
|
+
if (
|
|
26
|
+
prior.tool !== tool
|
|
27
|
+
|| prior.name !== tool.name
|
|
28
|
+
|| prior.description !== tool.description
|
|
29
|
+
|| prior.parameters !== tool.parameters
|
|
30
|
+
) {
|
|
31
|
+
exactToolMatch = false;
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (exactToolMatch) return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let toolsChanged = previous === undefined || previous.tools.length !== tools.length;
|
|
39
|
+
const toolSnapshot = tools.map((tool, index) => {
|
|
40
|
+
const prior = previous?.tools[index];
|
|
41
|
+
const parametersJson = prior?.parameters === tool.parameters
|
|
42
|
+
? prior.parametersJson
|
|
43
|
+
: serializeParameters(tool.parameters);
|
|
44
|
+
if (
|
|
45
|
+
prior === undefined
|
|
46
|
+
|| prior.name !== tool.name
|
|
47
|
+
|| prior.description !== tool.description
|
|
48
|
+
|| prior.parametersJson !== parametersJson
|
|
49
|
+
) {
|
|
50
|
+
toolsChanged = true;
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
tool,
|
|
54
|
+
name: tool.name,
|
|
55
|
+
description: tool.description,
|
|
56
|
+
parameters: tool.parameters,
|
|
57
|
+
parametersJson,
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const changed = !sameScalars || toolsChanged;
|
|
62
|
+
previous = {
|
|
63
|
+
provider: input.provider,
|
|
64
|
+
model: input.model,
|
|
65
|
+
modelAlias: input.modelAlias,
|
|
66
|
+
thinkingEffort: input.thinkingEffort,
|
|
67
|
+
systemPrompt: input.systemPrompt,
|
|
68
|
+
tools: toolSnapshot,
|
|
69
|
+
};
|
|
70
|
+
return changed;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
module.exports = {
|
|
75
|
+
createLlmConfigChangeDetector,
|
|
76
|
+
};
|
package/blun.mjs
CHANGED
|
@@ -264953,23 +264953,15 @@ function splitGenerateOptions(options) {
|
|
|
264953
264953
|
generateOptions
|
|
264954
264954
|
};
|
|
264955
264955
|
}
|
|
264956
|
-
|
|
264957
|
-
return tools.map(({ name, description, parameters }) => ({
|
|
264958
|
-
name,
|
|
264959
|
-
description,
|
|
264960
|
-
parameters
|
|
264961
|
-
}));
|
|
264962
|
-
}
|
|
264963
|
-
function fingerprint(content) {
|
|
264964
|
-
return createHash("sha256").update(content).digest("hex");
|
|
264965
|
-
}
|
|
264966
|
-
var LlmRequestLogger;
|
|
264956
|
+
var createLlmConfigChangeDetector, LlmRequestLogger;
|
|
264967
264957
|
var init_llm_request_logger = __esmMin((() => {
|
|
264958
|
+
createLlmConfigChangeDetector = createRequire(import.meta.url)("./bin/llm-config-log-dedup-policy.cjs").createLlmConfigChangeDetector;
|
|
264968
264959
|
LlmRequestLogger = class {
|
|
264969
264960
|
log;
|
|
264970
|
-
|
|
264961
|
+
shouldLogConfig;
|
|
264971
264962
|
constructor(log) {
|
|
264972
264963
|
this.log = log;
|
|
264964
|
+
this.shouldLogConfig = createLlmConfigChangeDetector();
|
|
264973
264965
|
}
|
|
264974
264966
|
logRequest(input) {
|
|
264975
264967
|
const { provider, modelAlias, systemPrompt, tools, messages, fields } = input;
|
|
@@ -264982,13 +264974,11 @@ var init_llm_request_logger = __esmMin((() => {
|
|
|
264982
264974
|
systemPromptChars: systemPrompt.length,
|
|
264983
264975
|
toolCount: tools.length
|
|
264984
264976
|
};
|
|
264985
|
-
|
|
264977
|
+
if (this.shouldLogConfig({
|
|
264986
264978
|
...config,
|
|
264987
|
-
|
|
264988
|
-
|
|
264989
|
-
})
|
|
264990
|
-
if (signature !== this.lastConfigLogSignature) {
|
|
264991
|
-
this.lastConfigLogSignature = signature;
|
|
264979
|
+
systemPrompt,
|
|
264980
|
+
tools
|
|
264981
|
+
})) {
|
|
264992
264982
|
this.log.info("llm config", {
|
|
264993
264983
|
...requestLogFields,
|
|
264994
264984
|
...config
|