@cortexkit/pi-magic-context 0.41.0 → 0.41.1
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/historian-calibration-extension.js +20 -14
- package/dist/{index-ts6nabp0.js → index-0jgz8yja.js} +553 -278
- package/dist/{index-3k71e196.js → index-q2vgz0j1.js} +87 -2
- package/dist/index.js +292 -59
- package/dist/{safe-notification-target-g8fx80va.js → safe-notification-target-hjcb423r.js} +1 -1
- package/dist/subagent-entry.js +2 -2
- package/dist/transformers-web.js +24570 -0
- package/dist/transformers.node-b1wa0hgx.js +28808 -0
- package/package.json +8 -3
- /package/dist/{index-wnrygn5h.js → index-y63nbvkk.js} +0 -0
|
@@ -12,13 +12,15 @@ function finiteNumber(value) {
|
|
|
12
12
|
function calibrateHistorianProviderPayload(payload, temperature, maxOutputTokens) {
|
|
13
13
|
if (typeof payload !== "object" || payload === null || Array.isArray(payload))
|
|
14
14
|
return payload;
|
|
15
|
+
if (temperature === undefined && maxOutputTokens === undefined)
|
|
16
|
+
return payload;
|
|
15
17
|
const calibrated = { ...payload };
|
|
16
18
|
const generationConfig = calibrated.generationConfig;
|
|
17
19
|
if (typeof generationConfig === "object" && generationConfig !== null && !Array.isArray(generationConfig)) {
|
|
18
20
|
calibrated.generationConfig = {
|
|
19
21
|
...generationConfig,
|
|
20
|
-
temperature,
|
|
21
|
-
maxOutputTokens
|
|
22
|
+
...temperature !== undefined ? { temperature } : {},
|
|
23
|
+
...maxOutputTokens !== undefined ? { maxOutputTokens } : {}
|
|
22
24
|
};
|
|
23
25
|
return calibrated;
|
|
24
26
|
}
|
|
@@ -26,27 +28,31 @@ function calibrateHistorianProviderPayload(payload, temperature, maxOutputTokens
|
|
|
26
28
|
if (typeof inferenceConfig === "object" && inferenceConfig !== null && !Array.isArray(inferenceConfig)) {
|
|
27
29
|
calibrated.inferenceConfig = {
|
|
28
30
|
...inferenceConfig,
|
|
29
|
-
temperature,
|
|
30
|
-
maxTokens: maxOutputTokens
|
|
31
|
+
...temperature !== undefined ? { temperature } : {},
|
|
32
|
+
...maxOutputTokens !== undefined ? { maxTokens: maxOutputTokens } : {}
|
|
31
33
|
};
|
|
32
34
|
return calibrated;
|
|
33
35
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
calibrated
|
|
39
|
-
|
|
40
|
-
calibrated
|
|
41
|
-
|
|
42
|
-
calibrated
|
|
36
|
+
if (temperature !== undefined) {
|
|
37
|
+
calibrated.temperature = temperature;
|
|
38
|
+
}
|
|
39
|
+
if (maxOutputTokens !== undefined) {
|
|
40
|
+
if ("max_output_tokens" in calibrated) {
|
|
41
|
+
calibrated.max_output_tokens = maxOutputTokens;
|
|
42
|
+
} else if ("max_completion_tokens" in calibrated) {
|
|
43
|
+
calibrated.max_completion_tokens = maxOutputTokens;
|
|
44
|
+
} else if ("max_tokens" in calibrated) {
|
|
45
|
+
calibrated.max_tokens = maxOutputTokens;
|
|
46
|
+
} else if ("maxTokens" in calibrated) {
|
|
47
|
+
calibrated.maxTokens = maxOutputTokens;
|
|
48
|
+
}
|
|
43
49
|
}
|
|
44
50
|
return calibrated;
|
|
45
51
|
}
|
|
46
52
|
function historianCalibrationExtension(pi) {
|
|
47
53
|
const temperature = finiteNumber(process.env[HISTORIAN_TEMPERATURE_ENV]);
|
|
48
54
|
const maxOutputTokens = finiteNumber(process.env[HISTORIAN_MAX_OUTPUT_TOKENS_ENV]);
|
|
49
|
-
if (temperature === undefined
|
|
55
|
+
if (temperature === undefined && maxOutputTokens === undefined)
|
|
50
56
|
return;
|
|
51
57
|
pi.on("before_provider_request", (event) => calibrateHistorianProviderPayload(event.payload, temperature, maxOutputTokens));
|
|
52
58
|
}
|