@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.js CHANGED
@@ -1624,7 +1624,11 @@ var VertexOpenAIAdapter = class {
1624
1624
  const token = await googleClient.getAccessToken();
1625
1625
  const headers = new Headers(init?.headers);
1626
1626
  headers.set("Authorization", `Bearer ${token.token ?? ""}`);
1627
- return fetch(input, { ...init, headers });
1627
+ const response = await fetch(input, { ...init, headers });
1628
+ if (!response.ok) {
1629
+ return surfaceErrorBody(response, input);
1630
+ }
1631
+ return response;
1628
1632
  };
1629
1633
  this.client = new OpenAI2({
1630
1634
  apiKey: "vertex-ai",
@@ -1670,6 +1674,28 @@ var VertexOpenAIAdapter = class {
1670
1674
  return this.client;
1671
1675
  }
1672
1676
  };
1677
+ async function surfaceErrorBody(response, input) {
1678
+ let body = "";
1679
+ try {
1680
+ body = await response.text();
1681
+ } catch {
1682
+ }
1683
+ const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
1684
+ 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)" : "";
1685
+ if (typeof console !== "undefined" && console.warn) {
1686
+ console.warn(
1687
+ `[vertex-openai] ${response.status} ${response.statusText} from ${url}: ${body || "(empty body)"}${hint}`
1688
+ );
1689
+ }
1690
+ const headers = new Headers(response.headers);
1691
+ headers.delete("content-encoding");
1692
+ headers.delete("content-length");
1693
+ return new Response(body + hint, {
1694
+ status: response.status,
1695
+ statusText: response.statusText,
1696
+ headers
1697
+ });
1698
+ }
1673
1699
 
1674
1700
  // src/adapters/vertex-openai/factory.ts
1675
1701
  var vertexOpenAIFactory = {