@jambonz/llm 0.2.7 → 0.3.1

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.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as ServiceAccountJson, A as AuthSpec, P as PromptRequest, a as AdapterFactory, b as AdapterManifest, C as CreateLlmArgs, L as LlmAdapter } from './types-bq1XMi_T.cjs';
2
- export { c as ApiKeyAuth, d as AuthKind, e as AuthKindSchema, B as BedrockApiKeyAuth, f as BedrockIamAuth, g as ClientOptions, h as ContentBlock, F as FinishReason, i as FormField, j as FormFieldType, G as GoogleApiKeyAuth, k as GoogleServiceAccountAuth, J as JsonSchema, l as LlmEvent, M as Message, m as ModelCapabilities, n as ModelInfo, R as Role, T as Tool, o as ToolCallEvent, U as Usage, V as VertexServiceAccountAuth } from './types-bq1XMi_T.cjs';
1
+ import { S as ServiceAccountJson, A as AuthSpec, P as PromptRequest, a as AdapterFactory, b as AdapterManifest, C as CreateLlmArgs, L as LlmAdapter } from './types-4d2QrlAe.cjs';
2
+ export { c as ApiKeyAuth, d as AuthKind, e as AuthKindSchema, B as BedrockApiKeyAuth, f as BedrockIamAuth, g as ClientOptions, h as ContentBlock, F as FinishReason, i as FormField, j as FormFieldType, G as GoogleApiKeyAuth, k as GoogleServiceAccountAuth, J as JsonSchema, l as LlmEvent, M as Message, m as ModelCapabilities, n as ModelInfo, R as Role, T as Tool, o as ToolCallEvent, U as Usage, V as VertexServiceAccountAuth } from './types-4d2QrlAe.cjs';
3
3
 
4
4
  /**
5
5
  * The loose "DB-shape" input accepted by `normalizeAuth`.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as ServiceAccountJson, A as AuthSpec, P as PromptRequest, a as AdapterFactory, b as AdapterManifest, C as CreateLlmArgs, L as LlmAdapter } from './types-bq1XMi_T.js';
2
- export { c as ApiKeyAuth, d as AuthKind, e as AuthKindSchema, B as BedrockApiKeyAuth, f as BedrockIamAuth, g as ClientOptions, h as ContentBlock, F as FinishReason, i as FormField, j as FormFieldType, G as GoogleApiKeyAuth, k as GoogleServiceAccountAuth, J as JsonSchema, l as LlmEvent, M as Message, m as ModelCapabilities, n as ModelInfo, R as Role, T as Tool, o as ToolCallEvent, U as Usage, V as VertexServiceAccountAuth } from './types-bq1XMi_T.js';
1
+ import { S as ServiceAccountJson, A as AuthSpec, P as PromptRequest, a as AdapterFactory, b as AdapterManifest, C as CreateLlmArgs, L as LlmAdapter } from './types-4d2QrlAe.js';
2
+ export { c as ApiKeyAuth, d as AuthKind, e as AuthKindSchema, B as BedrockApiKeyAuth, f as BedrockIamAuth, g as ClientOptions, h as ContentBlock, F as FinishReason, i as FormField, j as FormFieldType, G as GoogleApiKeyAuth, k as GoogleServiceAccountAuth, J as JsonSchema, l as LlmEvent, M as Message, m as ModelCapabilities, n as ModelInfo, R as Role, T as Tool, o as ToolCallEvent, U as Usage, V as VertexServiceAccountAuth } from './types-4d2QrlAe.js';
3
3
 
4
4
  /**
5
5
  * The loose "DB-shape" input accepted by `normalizeAuth`.
package/dist/index.js CHANGED
@@ -433,6 +433,9 @@ var OpenAIAdapter = class {
433
433
  async listAvailableModels() {
434
434
  return listOpenAICompatibleModels(this.ensureClient(), openAIManifest.knownModels);
435
435
  }
436
+ async testCredential() {
437
+ await this.ensureClient().models.list();
438
+ }
436
439
  async warmup() {
437
440
  const client = this.ensureClient();
438
441
  await client.models.list().catch(() => void 0);
@@ -859,6 +862,9 @@ var AnthropicAdapter = class {
859
862
  }
860
863
  return models;
861
864
  }
865
+ async testCredential() {
866
+ await this.ensureClient().models.list();
867
+ }
862
868
  async warmup() {
863
869
  const client = this.ensureClient();
864
870
  await client.models.list().catch(() => void 0);
@@ -1285,6 +1291,9 @@ var GoogleAdapter = class {
1285
1291
  async listAvailableModels() {
1286
1292
  return listGeminiModels(this.ensureClient(), googleManifest.knownModels);
1287
1293
  }
1294
+ async testCredential() {
1295
+ await listGeminiModels(this.ensureClient(), googleManifest.knownModels);
1296
+ }
1288
1297
  async warmup() {
1289
1298
  }
1290
1299
  ensureClient() {
@@ -1455,6 +1464,9 @@ var VertexGeminiAdapter = class {
1455
1464
  async listAvailableModels() {
1456
1465
  return listGeminiModels(this.ensureClient(), vertexGeminiManifest.knownModels);
1457
1466
  }
1467
+ async testCredential() {
1468
+ await listGeminiModels(this.ensureClient(), vertexGeminiManifest.knownModels);
1469
+ }
1458
1470
  async warmup() {
1459
1471
  }
1460
1472
  ensureClient() {
@@ -1553,11 +1565,22 @@ var vertexOpenAIManifest = {
1553
1565
  type: "select",
1554
1566
  required: true,
1555
1567
  default: "us-central1",
1568
+ // Same region set as vertex-gemini plus us-east5 (where Google
1569
+ // hosts Llama partner models). Partner-model availability varies
1570
+ // per region; Google's docs for each model are the source of truth.
1556
1571
  options: [
1557
1572
  { value: "us-central1", label: "us-central1" },
1573
+ { value: "us-east1", label: "us-east1" },
1558
1574
  { value: "us-east4", label: "us-east4" },
1575
+ { value: "us-east5", label: "us-east5" },
1576
+ { value: "us-west1", label: "us-west1" },
1577
+ { value: "us-west4", label: "us-west4" },
1559
1578
  { value: "europe-west1", label: "europe-west1" },
1579
+ { value: "europe-west2", label: "europe-west2" },
1580
+ { value: "europe-west3", label: "europe-west3" },
1560
1581
  { value: "europe-west4", label: "europe-west4" },
1582
+ { value: "asia-east1", label: "asia-east1" },
1583
+ { value: "asia-northeast1", label: "asia-northeast1" },
1561
1584
  { value: "asia-southeast1", label: "asia-southeast1" }
1562
1585
  ]
1563
1586
  }
@@ -1575,6 +1598,7 @@ var VertexOpenAIAdapter = class {
1575
1598
  vendor = vertexOpenAIManifest.vendor;
1576
1599
  acceptedAuth = ["vertexServiceAccount"];
1577
1600
  client;
1601
+ googleAuth;
1578
1602
  init(auth, client) {
1579
1603
  if (auth.kind !== "vertexServiceAccount") {
1580
1604
  throw new Error(
@@ -1591,12 +1615,12 @@ var VertexOpenAIAdapter = class {
1591
1615
  throw new Error("VertexOpenAIAdapter: location is required");
1592
1616
  }
1593
1617
  const baseURL = `https://${auth.location}-aiplatform.googleapis.com/v1beta1/projects/${auth.projectId}/locations/${auth.location}/endpoints/openapi`;
1594
- const googleAuth = new GoogleAuth({
1618
+ this.googleAuth = new GoogleAuth({
1595
1619
  credentials: auth.credentials,
1596
1620
  scopes: ["https://www.googleapis.com/auth/cloud-platform"]
1597
1621
  });
1598
1622
  const authedFetch = async (input, init) => {
1599
- const googleClient = await googleAuth.getClient();
1623
+ const googleClient = await this.googleAuth.getClient();
1600
1624
  const token = await googleClient.getAccessToken();
1601
1625
  const headers = new Headers(init?.headers);
1602
1626
  headers.set("Authorization", `Bearer ${token.token ?? ""}`);
@@ -1625,6 +1649,16 @@ var VertexOpenAIAdapter = class {
1625
1649
  async listAvailableModels() {
1626
1650
  return [...vertexOpenAIManifest.knownModels];
1627
1651
  }
1652
+ async testCredential() {
1653
+ if (!this.googleAuth) {
1654
+ throw new Error("VertexOpenAIAdapter: init() must be called before testCredential()");
1655
+ }
1656
+ const googleClient = await this.googleAuth.getClient();
1657
+ const token = await googleClient.getAccessToken();
1658
+ if (!token.token) {
1659
+ throw new Error("VertexOpenAIAdapter: service account did not mint an access token");
1660
+ }
1661
+ }
1628
1662
  async warmup() {
1629
1663
  }
1630
1664
  ensureClient() {
@@ -1649,6 +1683,10 @@ import {
1649
1683
  BedrockRuntimeClient,
1650
1684
  ConverseStreamCommand
1651
1685
  } from "@aws-sdk/client-bedrock-runtime";
1686
+ import {
1687
+ BedrockClient,
1688
+ ListFoundationModelsCommand
1689
+ } from "@aws-sdk/client-bedrock";
1652
1690
 
1653
1691
  // src/adapters/bedrock/manifest.ts
1654
1692
  var BEDROCK_KNOWN_MODELS = [
@@ -1863,6 +1901,7 @@ var BedrockAdapter = class {
1863
1901
  vendor = bedrockManifest.vendor;
1864
1902
  acceptedAuth = ["bedrockApiKey", "bedrockIam"];
1865
1903
  client;
1904
+ controlClientConfig;
1866
1905
  init(auth, client) {
1867
1906
  if (!auth.region) {
1868
1907
  throw new Error("BedrockAdapter: region is required");
@@ -1893,6 +1932,7 @@ var BedrockAdapter = class {
1893
1932
  );
1894
1933
  }
1895
1934
  this.client = new BedrockRuntimeClient(config);
1935
+ this.controlClientConfig = config;
1896
1936
  }
1897
1937
  async *stream(req) {
1898
1938
  assertValidRequest(req);
@@ -2071,6 +2111,17 @@ var BedrockAdapter = class {
2071
2111
  async listAvailableModels() {
2072
2112
  return [...bedrockManifest.knownModels];
2073
2113
  }
2114
+ async testCredential() {
2115
+ if (!this.controlClientConfig) {
2116
+ throw new Error("BedrockAdapter: init() must be called before testCredential()");
2117
+ }
2118
+ const control = new BedrockClient(this.controlClientConfig);
2119
+ try {
2120
+ await control.send(new ListFoundationModelsCommand({}));
2121
+ } finally {
2122
+ control.destroy();
2123
+ }
2124
+ }
2074
2125
  async warmup() {
2075
2126
  }
2076
2127
  ensureClient() {