pi-freeflow 1.0.8 → 1.1.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/extensions/index.ts +21 -14
- package/package.json +1 -1
package/extensions/index.ts
CHANGED
|
@@ -948,15 +948,20 @@ function normalizeRequestBody(
|
|
|
948
948
|
}
|
|
949
949
|
|
|
950
950
|
// 3. Max & Min tokens clamping (OpenCode Zen requires min 16; Vercel relay caps at 64k)
|
|
951
|
-
const
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
951
|
+
const clampTokens = (val: number): number => {
|
|
952
|
+
if (val < 16) return 16;
|
|
953
|
+
if (isRelay && val > RELAY_MAX_TOKENS) return RELAY_MAX_TOKENS;
|
|
954
|
+
return val;
|
|
955
|
+
};
|
|
956
|
+
|
|
957
|
+
if (typeof body.max_tokens === "number") {
|
|
958
|
+
body.max_tokens = clampTokens(body.max_tokens);
|
|
959
|
+
}
|
|
960
|
+
if (typeof body.maxTokens === "number") {
|
|
961
|
+
body.maxTokens = clampTokens(body.maxTokens);
|
|
962
|
+
}
|
|
963
|
+
if (typeof body.max_output_tokens === "number") {
|
|
964
|
+
body.max_output_tokens = clampTokens(body.max_output_tokens);
|
|
960
965
|
}
|
|
961
966
|
|
|
962
967
|
return body;
|
|
@@ -1659,10 +1664,12 @@ export default async function (pi: ExtensionAPI) {
|
|
|
1659
1664
|
);
|
|
1660
1665
|
});
|
|
1661
1666
|
|
|
1662
|
-
pi.on("session_shutdown", () => {
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
+
pi.on?.("session_shutdown", () => {
|
|
1668
|
+
if (server) {
|
|
1669
|
+
log("info", "shutting down proxy...");
|
|
1670
|
+
server.close();
|
|
1671
|
+
rateLimitMap.clear();
|
|
1672
|
+
log("info", "shutdown complete");
|
|
1673
|
+
}
|
|
1667
1674
|
});
|
|
1668
1675
|
}
|