@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/README.md +4 -0
- package/dist/index.cjs +50 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +53 -2
- package/dist/index.js.map +1 -1
- package/dist/test-kit/index.cjs +58 -2
- package/dist/test-kit/index.cjs.map +1 -1
- package/dist/test-kit/index.d.cts +2 -1
- package/dist/test-kit/index.d.ts +2 -1
- package/dist/test-kit/index.js +61 -2
- package/dist/test-kit/index.js.map +1 -1
- package/dist/{types-bq1XMi_T.d.cts → types-4d2QrlAe.d.cts} +22 -0
- package/dist/{types-bq1XMi_T.d.ts → types-4d2QrlAe.d.ts} +22 -0
- package/package.json +2 -2
package/dist/test-kit/index.cjs
CHANGED
|
@@ -465,6 +465,9 @@ var OpenAIAdapter = class {
|
|
|
465
465
|
async listAvailableModels() {
|
|
466
466
|
return listOpenAICompatibleModels(this.ensureClient(), openAIManifest.knownModels);
|
|
467
467
|
}
|
|
468
|
+
async testCredential() {
|
|
469
|
+
await this.ensureClient().models.list();
|
|
470
|
+
}
|
|
468
471
|
async warmup() {
|
|
469
472
|
const client = this.ensureClient();
|
|
470
473
|
await client.models.list().catch(() => void 0);
|
|
@@ -891,6 +894,9 @@ var AnthropicAdapter = class {
|
|
|
891
894
|
}
|
|
892
895
|
return models;
|
|
893
896
|
}
|
|
897
|
+
async testCredential() {
|
|
898
|
+
await this.ensureClient().models.list();
|
|
899
|
+
}
|
|
894
900
|
async warmup() {
|
|
895
901
|
const client = this.ensureClient();
|
|
896
902
|
await client.models.list().catch(() => void 0);
|
|
@@ -1317,6 +1323,9 @@ var GoogleAdapter = class {
|
|
|
1317
1323
|
async listAvailableModels() {
|
|
1318
1324
|
return listGeminiModels(this.ensureClient(), googleManifest.knownModels);
|
|
1319
1325
|
}
|
|
1326
|
+
async testCredential() {
|
|
1327
|
+
await listGeminiModels(this.ensureClient(), googleManifest.knownModels);
|
|
1328
|
+
}
|
|
1320
1329
|
async warmup() {
|
|
1321
1330
|
}
|
|
1322
1331
|
ensureClient() {
|
|
@@ -1487,6 +1496,9 @@ var VertexGeminiAdapter = class {
|
|
|
1487
1496
|
async listAvailableModels() {
|
|
1488
1497
|
return listGeminiModels(this.ensureClient(), vertexGeminiManifest.knownModels);
|
|
1489
1498
|
}
|
|
1499
|
+
async testCredential() {
|
|
1500
|
+
await listGeminiModels(this.ensureClient(), vertexGeminiManifest.knownModels);
|
|
1501
|
+
}
|
|
1490
1502
|
async warmup() {
|
|
1491
1503
|
}
|
|
1492
1504
|
ensureClient() {
|
|
@@ -1585,11 +1597,22 @@ var vertexOpenAIManifest = {
|
|
|
1585
1597
|
type: "select",
|
|
1586
1598
|
required: true,
|
|
1587
1599
|
default: "us-central1",
|
|
1600
|
+
// Same region set as vertex-gemini plus us-east5 (where Google
|
|
1601
|
+
// hosts Llama partner models). Partner-model availability varies
|
|
1602
|
+
// per region; Google's docs for each model are the source of truth.
|
|
1588
1603
|
options: [
|
|
1589
1604
|
{ value: "us-central1", label: "us-central1" },
|
|
1605
|
+
{ value: "us-east1", label: "us-east1" },
|
|
1590
1606
|
{ value: "us-east4", label: "us-east4" },
|
|
1607
|
+
{ value: "us-east5", label: "us-east5" },
|
|
1608
|
+
{ value: "us-west1", label: "us-west1" },
|
|
1609
|
+
{ value: "us-west4", label: "us-west4" },
|
|
1591
1610
|
{ value: "europe-west1", label: "europe-west1" },
|
|
1611
|
+
{ value: "europe-west2", label: "europe-west2" },
|
|
1612
|
+
{ value: "europe-west3", label: "europe-west3" },
|
|
1592
1613
|
{ value: "europe-west4", label: "europe-west4" },
|
|
1614
|
+
{ value: "asia-east1", label: "asia-east1" },
|
|
1615
|
+
{ value: "asia-northeast1", label: "asia-northeast1" },
|
|
1593
1616
|
{ value: "asia-southeast1", label: "asia-southeast1" }
|
|
1594
1617
|
]
|
|
1595
1618
|
}
|
|
@@ -1607,6 +1630,7 @@ var VertexOpenAIAdapter = class {
|
|
|
1607
1630
|
vendor = vertexOpenAIManifest.vendor;
|
|
1608
1631
|
acceptedAuth = ["vertexServiceAccount"];
|
|
1609
1632
|
client;
|
|
1633
|
+
googleAuth;
|
|
1610
1634
|
init(auth, client) {
|
|
1611
1635
|
if (auth.kind !== "vertexServiceAccount") {
|
|
1612
1636
|
throw new Error(
|
|
@@ -1623,12 +1647,12 @@ var VertexOpenAIAdapter = class {
|
|
|
1623
1647
|
throw new Error("VertexOpenAIAdapter: location is required");
|
|
1624
1648
|
}
|
|
1625
1649
|
const baseURL = `https://${auth.location}-aiplatform.googleapis.com/v1beta1/projects/${auth.projectId}/locations/${auth.location}/endpoints/openapi`;
|
|
1626
|
-
|
|
1650
|
+
this.googleAuth = new import_google_auth_library.GoogleAuth({
|
|
1627
1651
|
credentials: auth.credentials,
|
|
1628
1652
|
scopes: ["https://www.googleapis.com/auth/cloud-platform"]
|
|
1629
1653
|
});
|
|
1630
1654
|
const authedFetch = async (input, init2) => {
|
|
1631
|
-
const googleClient = await googleAuth.getClient();
|
|
1655
|
+
const googleClient = await this.googleAuth.getClient();
|
|
1632
1656
|
const token = await googleClient.getAccessToken();
|
|
1633
1657
|
const headers = new Headers(init2?.headers);
|
|
1634
1658
|
headers.set("Authorization", `Bearer ${token.token ?? ""}`);
|
|
@@ -1657,6 +1681,16 @@ var VertexOpenAIAdapter = class {
|
|
|
1657
1681
|
async listAvailableModels() {
|
|
1658
1682
|
return [...vertexOpenAIManifest.knownModels];
|
|
1659
1683
|
}
|
|
1684
|
+
async testCredential() {
|
|
1685
|
+
if (!this.googleAuth) {
|
|
1686
|
+
throw new Error("VertexOpenAIAdapter: init() must be called before testCredential()");
|
|
1687
|
+
}
|
|
1688
|
+
const googleClient = await this.googleAuth.getClient();
|
|
1689
|
+
const token = await googleClient.getAccessToken();
|
|
1690
|
+
if (!token.token) {
|
|
1691
|
+
throw new Error("VertexOpenAIAdapter: service account did not mint an access token");
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1660
1694
|
async warmup() {
|
|
1661
1695
|
}
|
|
1662
1696
|
ensureClient() {
|
|
@@ -1678,6 +1712,7 @@ var vertexOpenAIFactory = {
|
|
|
1678
1712
|
|
|
1679
1713
|
// src/adapters/bedrock/adapter.ts
|
|
1680
1714
|
var import_client_bedrock_runtime = require("@aws-sdk/client-bedrock-runtime");
|
|
1715
|
+
var import_client_bedrock = require("@aws-sdk/client-bedrock");
|
|
1681
1716
|
|
|
1682
1717
|
// src/adapters/bedrock/manifest.ts
|
|
1683
1718
|
var BEDROCK_KNOWN_MODELS = [
|
|
@@ -1892,6 +1927,7 @@ var BedrockAdapter = class {
|
|
|
1892
1927
|
vendor = bedrockManifest.vendor;
|
|
1893
1928
|
acceptedAuth = ["bedrockApiKey", "bedrockIam"];
|
|
1894
1929
|
client;
|
|
1930
|
+
controlClientConfig;
|
|
1895
1931
|
init(auth, client) {
|
|
1896
1932
|
if (!auth.region) {
|
|
1897
1933
|
throw new Error("BedrockAdapter: region is required");
|
|
@@ -1922,6 +1958,7 @@ var BedrockAdapter = class {
|
|
|
1922
1958
|
);
|
|
1923
1959
|
}
|
|
1924
1960
|
this.client = new import_client_bedrock_runtime.BedrockRuntimeClient(config);
|
|
1961
|
+
this.controlClientConfig = config;
|
|
1925
1962
|
}
|
|
1926
1963
|
async *stream(req) {
|
|
1927
1964
|
assertValidRequest(req);
|
|
@@ -2100,6 +2137,17 @@ var BedrockAdapter = class {
|
|
|
2100
2137
|
async listAvailableModels() {
|
|
2101
2138
|
return [...bedrockManifest.knownModels];
|
|
2102
2139
|
}
|
|
2140
|
+
async testCredential() {
|
|
2141
|
+
if (!this.controlClientConfig) {
|
|
2142
|
+
throw new Error("BedrockAdapter: init() must be called before testCredential()");
|
|
2143
|
+
}
|
|
2144
|
+
const control = new import_client_bedrock.BedrockClient(this.controlClientConfig);
|
|
2145
|
+
try {
|
|
2146
|
+
await control.send(new import_client_bedrock.ListFoundationModelsCommand({}));
|
|
2147
|
+
} finally {
|
|
2148
|
+
control.destroy();
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2103
2151
|
async warmup() {
|
|
2104
2152
|
}
|
|
2105
2153
|
ensureClient() {
|
|
@@ -2432,6 +2480,11 @@ function runContractTests(harness) {
|
|
|
2432
2480
|
(0, import_vitest.expect)(typeof m.capabilities.tools).toBe("boolean");
|
|
2433
2481
|
}
|
|
2434
2482
|
});
|
|
2483
|
+
(0, import_vitest.it)("[15a] testCredential resolves on a valid auth probe", async () => {
|
|
2484
|
+
await harness.mockScenario("list-models");
|
|
2485
|
+
const adapter = await init(harness);
|
|
2486
|
+
await (0, import_vitest.expect)(adapter.testCredential()).resolves.not.toThrow();
|
|
2487
|
+
});
|
|
2435
2488
|
if (harness.nonToolCapableModel) {
|
|
2436
2489
|
(0, import_vitest.it)("[16] non-tool-capable model with tools declared either fails fast or runs without tool calls", async () => {
|
|
2437
2490
|
await harness.mockScenario("simple-stream");
|
|
@@ -2626,6 +2679,9 @@ var FakeAdapter = class {
|
|
|
2626
2679
|
this.ensureInitialized();
|
|
2627
2680
|
return fakeManifest.knownModels;
|
|
2628
2681
|
}
|
|
2682
|
+
async testCredential() {
|
|
2683
|
+
this.ensureInitialized();
|
|
2684
|
+
}
|
|
2629
2685
|
ensureInitialized() {
|
|
2630
2686
|
if (!this.initialized) {
|
|
2631
2687
|
throw new Error("FakeAdapter: init() must be called before stream()/listAvailableModels()");
|