@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.cjs
CHANGED
|
@@ -1719,15 +1719,29 @@ async function surfaceErrorBody(response, input) {
|
|
|
1719
1719
|
`[vertex-openai] ${response.status} ${response.statusText} from ${url}: ${body || "(empty body)"}${hint}`
|
|
1720
1720
|
);
|
|
1721
1721
|
}
|
|
1722
|
+
const normalizedBody = unwrapVertexErrorArray(body) + hint;
|
|
1722
1723
|
const headers = new Headers(response.headers);
|
|
1723
1724
|
headers.delete("content-encoding");
|
|
1724
1725
|
headers.delete("content-length");
|
|
1725
|
-
return new Response(
|
|
1726
|
+
return new Response(normalizedBody, {
|
|
1726
1727
|
status: response.status,
|
|
1727
1728
|
statusText: response.statusText,
|
|
1728
1729
|
headers
|
|
1729
1730
|
});
|
|
1730
1731
|
}
|
|
1732
|
+
function unwrapVertexErrorArray(body) {
|
|
1733
|
+
if (!body) return body;
|
|
1734
|
+
const trimmed = body.trim();
|
|
1735
|
+
if (!trimmed.startsWith("[")) return body;
|
|
1736
|
+
try {
|
|
1737
|
+
const parsed = JSON.parse(trimmed);
|
|
1738
|
+
if (Array.isArray(parsed) && parsed.length === 1 && parsed[0]?.error) {
|
|
1739
|
+
return JSON.stringify(parsed[0]);
|
|
1740
|
+
}
|
|
1741
|
+
} catch {
|
|
1742
|
+
}
|
|
1743
|
+
return body;
|
|
1744
|
+
}
|
|
1731
1745
|
|
|
1732
1746
|
// src/adapters/vertex-openai/factory.ts
|
|
1733
1747
|
var vertexOpenAIFactory = {
|