@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 CHANGED
@@ -23,7 +23,7 @@ const client = new OpenAI({
23
23
  });
24
24
 
25
25
  const response = await client.responses.create({
26
- model: 'deepseek-v4-pro',
26
+ model: 'deepseek-v4-flash',
27
27
  input: 'Hello!',
28
28
  });
29
29
  ```
package/README.zh-CN.md CHANGED
@@ -23,7 +23,7 @@ const client = new OpenAI({
23
23
  });
24
24
 
25
25
  const response = await client.responses.create({
26
- model: 'deepseek-v4-pro',
26
+ model: 'deepseek-v4-flash',
27
27
  input: 'Hello!',
28
28
  });
29
29
  ```
package/dist/index.cjs CHANGED
@@ -1795,6 +1795,15 @@ function inferFormatFromUrl(baseUrl) {
1795
1795
  }
1796
1796
  return null;
1797
1797
  }
1798
+ function inferFormatFromModel(model) {
1799
+ if (!model) {
1800
+ return null;
1801
+ }
1802
+ if (/^claude/i.test(model)) {
1803
+ return "anthropic";
1804
+ }
1805
+ return null;
1806
+ }
1798
1807
  function isResponsesEndpoint(url) {
1799
1808
  try {
1800
1809
  return /\/v1\/responses\/?$/.test(new URL(url, "http://_internal_").pathname);
@@ -1860,7 +1869,7 @@ async function handleResponses(request, format, options, baseFetch, incomingHead
1860
1869
  dropImages = false;
1861
1870
  const fb = options.fallbackUpstream;
1862
1871
  options = { ...options, ...fb, fallbackUpstream: void 0 };
1863
- format = fb.upstreamFormat ?? format;
1872
+ format = fb.upstreamFormat ?? inferFormatFromUrl(fb.baseUrl) ?? inferFormatFromModel(fb.model) ?? format;
1864
1873
  if (options.model) {
1865
1874
  request.model = options.model;
1866
1875
  }
@@ -1952,6 +1961,12 @@ function buildUpstreamBody(request, format, streaming, baseUrl, dropImages, reas
1952
1961
  ar.thinking = { type: "enabled", budget_tokens: 65536 };
1953
1962
  }
1954
1963
  }
1964
+ if (ar.thinking && typeof ar.thinking === "object" && "budget_tokens" in ar.thinking) {
1965
+ const budget = Number(ar.thinking.budget_tokens);
1966
+ if (budget > 0 && ar.max_tokens <= budget) {
1967
+ ar.max_tokens = budget + 1024;
1968
+ }
1969
+ }
1955
1970
  return {
1956
1971
  upstreamBody: ar,
1957
1972
  requestMetadata: buildRequestMetadata(request, ar.temperature, ar.top_p)