@jambonz/llm 0.3.2 → 0.3.4

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/index.js CHANGED
@@ -1687,15 +1687,29 @@ async function surfaceErrorBody(response, input) {
1687
1687
  `[vertex-openai] ${response.status} ${response.statusText} from ${url}: ${body || "(empty body)"}${hint}`
1688
1688
  );
1689
1689
  }
1690
+ const normalizedBody = unwrapVertexErrorArray(body) + hint;
1690
1691
  const headers = new Headers(response.headers);
1691
1692
  headers.delete("content-encoding");
1692
1693
  headers.delete("content-length");
1693
- return new Response(body + hint, {
1694
+ return new Response(normalizedBody, {
1694
1695
  status: response.status,
1695
1696
  statusText: response.statusText,
1696
1697
  headers
1697
1698
  });
1698
1699
  }
1700
+ function unwrapVertexErrorArray(body) {
1701
+ if (!body) return body;
1702
+ const trimmed = body.trim();
1703
+ if (!trimmed.startsWith("[")) return body;
1704
+ try {
1705
+ const parsed = JSON.parse(trimmed);
1706
+ if (Array.isArray(parsed) && parsed.length === 1 && parsed[0]?.error) {
1707
+ return JSON.stringify(parsed[0]);
1708
+ }
1709
+ } catch {
1710
+ }
1711
+ return body;
1712
+ }
1699
1713
 
1700
1714
  // src/adapters/vertex-openai/factory.ts
1701
1715
  var vertexOpenAIFactory = {
@@ -1839,7 +1853,8 @@ var BEDROCK_KNOWN_MODELS = [
1839
1853
  vision: false,
1840
1854
  systemPrompt: true,
1841
1855
  maxContextTokens: 128e3
1842
- }
1856
+ },
1857
+ deprecated: true
1843
1858
  }
1844
1859
  ];
1845
1860
  var BEDROCK_REGIONS = [