@jambonz/llm 0.3.2 → 0.3.3
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.cjs +15 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/test-kit/index.cjs +15 -1
- package/dist/test-kit/index.cjs.map +1 -1
- package/dist/test-kit/index.js +15 -1
- package/dist/test-kit/index.js.map +1 -1
- package/package.json +1 -1
package/dist/test-kit/index.js
CHANGED
|
@@ -1680,15 +1680,29 @@ async function surfaceErrorBody(response, input) {
|
|
|
1680
1680
|
`[vertex-openai] ${response.status} ${response.statusText} from ${url}: ${body || "(empty body)"}${hint}`
|
|
1681
1681
|
);
|
|
1682
1682
|
}
|
|
1683
|
+
const normalizedBody = unwrapVertexErrorArray(body) + hint;
|
|
1683
1684
|
const headers = new Headers(response.headers);
|
|
1684
1685
|
headers.delete("content-encoding");
|
|
1685
1686
|
headers.delete("content-length");
|
|
1686
|
-
return new Response(
|
|
1687
|
+
return new Response(normalizedBody, {
|
|
1687
1688
|
status: response.status,
|
|
1688
1689
|
statusText: response.statusText,
|
|
1689
1690
|
headers
|
|
1690
1691
|
});
|
|
1691
1692
|
}
|
|
1693
|
+
function unwrapVertexErrorArray(body) {
|
|
1694
|
+
if (!body) return body;
|
|
1695
|
+
const trimmed = body.trim();
|
|
1696
|
+
if (!trimmed.startsWith("[")) return body;
|
|
1697
|
+
try {
|
|
1698
|
+
const parsed = JSON.parse(trimmed);
|
|
1699
|
+
if (Array.isArray(parsed) && parsed.length === 1 && parsed[0]?.error) {
|
|
1700
|
+
return JSON.stringify(parsed[0]);
|
|
1701
|
+
}
|
|
1702
|
+
} catch {
|
|
1703
|
+
}
|
|
1704
|
+
return body;
|
|
1705
|
+
}
|
|
1692
1706
|
|
|
1693
1707
|
// src/adapters/vertex-openai/factory.ts
|
|
1694
1708
|
var vertexOpenAIFactory = {
|