@codeproxy/core 0.1.3 → 0.1.5
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/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/index.cjs +16 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1793,6 +1793,15 @@ function inferFormatFromUrl(baseUrl) {
|
|
|
1793
1793
|
}
|
|
1794
1794
|
return null;
|
|
1795
1795
|
}
|
|
1796
|
+
function inferFormatFromModel(model) {
|
|
1797
|
+
if (!model) {
|
|
1798
|
+
return null;
|
|
1799
|
+
}
|
|
1800
|
+
if (/^claude/i.test(model)) {
|
|
1801
|
+
return "anthropic";
|
|
1802
|
+
}
|
|
1803
|
+
return null;
|
|
1804
|
+
}
|
|
1796
1805
|
function isResponsesEndpoint(url) {
|
|
1797
1806
|
try {
|
|
1798
1807
|
return /\/v1\/responses\/?$/.test(new URL(url, "http://_internal_").pathname);
|
|
@@ -1858,7 +1867,7 @@ async function handleResponses(request, format, options, baseFetch, incomingHead
|
|
|
1858
1867
|
dropImages = false;
|
|
1859
1868
|
const fb = options.fallbackUpstream;
|
|
1860
1869
|
options = { ...options, ...fb, fallbackUpstream: void 0 };
|
|
1861
|
-
format = fb.upstreamFormat ?? format;
|
|
1870
|
+
format = fb.upstreamFormat ?? inferFormatFromUrl(fb.baseUrl) ?? inferFormatFromModel(fb.model) ?? format;
|
|
1862
1871
|
if (options.model) {
|
|
1863
1872
|
request.model = options.model;
|
|
1864
1873
|
}
|
|
@@ -1950,6 +1959,12 @@ function buildUpstreamBody(request, format, streaming, baseUrl, dropImages, reas
|
|
|
1950
1959
|
ar.thinking = { type: "enabled", budget_tokens: 65536 };
|
|
1951
1960
|
}
|
|
1952
1961
|
}
|
|
1962
|
+
if (ar.thinking && typeof ar.thinking === "object" && "budget_tokens" in ar.thinking) {
|
|
1963
|
+
const budget = Number(ar.thinking.budget_tokens);
|
|
1964
|
+
if (budget > 0 && ar.max_tokens <= budget) {
|
|
1965
|
+
ar.max_tokens = budget + 1024;
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1953
1968
|
return {
|
|
1954
1969
|
upstreamBody: ar,
|
|
1955
1970
|
requestMetadata: buildRequestMetadata(request, ar.temperature, ar.top_p)
|