@jambonz/llm 0.3.1 → 0.3.2
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 +27 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -1
- package/dist/index.js.map +1 -1
- package/dist/test-kit/index.cjs +27 -1
- package/dist/test-kit/index.cjs.map +1 -1
- package/dist/test-kit/index.js +27 -1
- package/dist/test-kit/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1668,7 +1668,11 @@ var VertexOpenAIAdapter = class {
|
|
|
1668
1668
|
const token = await googleClient.getAccessToken();
|
|
1669
1669
|
const headers = new Headers(init?.headers);
|
|
1670
1670
|
headers.set("Authorization", `Bearer ${token.token ?? ""}`);
|
|
1671
|
-
|
|
1671
|
+
const response = await fetch(input, { ...init, headers });
|
|
1672
|
+
if (!response.ok) {
|
|
1673
|
+
return surfaceErrorBody(response, input);
|
|
1674
|
+
}
|
|
1675
|
+
return response;
|
|
1672
1676
|
};
|
|
1673
1677
|
this.client = new import_openai2.default({
|
|
1674
1678
|
apiKey: "vertex-ai",
|
|
@@ -1714,6 +1718,28 @@ var VertexOpenAIAdapter = class {
|
|
|
1714
1718
|
return this.client;
|
|
1715
1719
|
}
|
|
1716
1720
|
};
|
|
1721
|
+
async function surfaceErrorBody(response, input) {
|
|
1722
|
+
let body = "";
|
|
1723
|
+
try {
|
|
1724
|
+
body = await response.text();
|
|
1725
|
+
} catch {
|
|
1726
|
+
}
|
|
1727
|
+
const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
1728
|
+
const hint = response.status === 404 && !body ? " (no body returned \u2014 most commonly means the requested model is not hosted in this region; check Google's partner-model availability matrix)" : "";
|
|
1729
|
+
if (typeof console !== "undefined" && console.warn) {
|
|
1730
|
+
console.warn(
|
|
1731
|
+
`[vertex-openai] ${response.status} ${response.statusText} from ${url}: ${body || "(empty body)"}${hint}`
|
|
1732
|
+
);
|
|
1733
|
+
}
|
|
1734
|
+
const headers = new Headers(response.headers);
|
|
1735
|
+
headers.delete("content-encoding");
|
|
1736
|
+
headers.delete("content-length");
|
|
1737
|
+
return new Response(body + hint, {
|
|
1738
|
+
status: response.status,
|
|
1739
|
+
statusText: response.statusText,
|
|
1740
|
+
headers
|
|
1741
|
+
});
|
|
1742
|
+
}
|
|
1717
1743
|
|
|
1718
1744
|
// src/adapters/vertex-openai/factory.ts
|
|
1719
1745
|
var vertexOpenAIFactory = {
|