@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.
@@ -1656,7 +1656,11 @@ var VertexOpenAIAdapter = class {
1656
1656
  const token = await googleClient.getAccessToken();
1657
1657
  const headers = new Headers(init2?.headers);
1658
1658
  headers.set("Authorization", `Bearer ${token.token ?? ""}`);
1659
- return fetch(input, { ...init2, headers });
1659
+ const response = await fetch(input, { ...init2, headers });
1660
+ if (!response.ok) {
1661
+ return surfaceErrorBody(response, input);
1662
+ }
1663
+ return response;
1660
1664
  };
1661
1665
  this.client = new import_openai2.default({
1662
1666
  apiKey: "vertex-ai",
@@ -1702,6 +1706,28 @@ var VertexOpenAIAdapter = class {
1702
1706
  return this.client;
1703
1707
  }
1704
1708
  };
1709
+ async function surfaceErrorBody(response, input) {
1710
+ let body = "";
1711
+ try {
1712
+ body = await response.text();
1713
+ } catch {
1714
+ }
1715
+ const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
1716
+ 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)" : "";
1717
+ if (typeof console !== "undefined" && console.warn) {
1718
+ console.warn(
1719
+ `[vertex-openai] ${response.status} ${response.statusText} from ${url}: ${body || "(empty body)"}${hint}`
1720
+ );
1721
+ }
1722
+ const headers = new Headers(response.headers);
1723
+ headers.delete("content-encoding");
1724
+ headers.delete("content-length");
1725
+ return new Response(body + hint, {
1726
+ status: response.status,
1727
+ statusText: response.statusText,
1728
+ headers
1729
+ });
1730
+ }
1705
1731
 
1706
1732
  // src/adapters/vertex-openai/factory.ts
1707
1733
  var vertexOpenAIFactory = {