@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as AdapterFactory, d as AuthKind, A as AuthSpec, L as LlmAdapter, c as ApiKeyAuth, g as ClientOptions, P as PromptRequest, l as LlmEvent, M as Message, o as ToolCallEvent, n as ModelInfo, b as AdapterManifest } from '../types-
|
|
1
|
+
import { a as AdapterFactory, d as AuthKind, A as AuthSpec, L as LlmAdapter, c as ApiKeyAuth, g as ClientOptions, P as PromptRequest, l as LlmEvent, M as Message, o as ToolCallEvent, n as ModelInfo, b as AdapterManifest } from '../types-4d2QrlAe.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Named scenarios the harness must be able to stage. Each scenario configures
|
|
@@ -132,6 +132,7 @@ declare class FakeAdapter implements LlmAdapter<ApiKeyAuth> {
|
|
|
132
132
|
appendAssistantToolCall(history: Message[], toolCalls: ReadonlyArray<ToolCallEvent>): Message[];
|
|
133
133
|
appendToolResult(history: Message[], toolCallId: string, result: unknown): Message[];
|
|
134
134
|
listAvailableModels(): Promise<ModelInfo[]>;
|
|
135
|
+
testCredential(): Promise<void>;
|
|
135
136
|
private ensureInitialized;
|
|
136
137
|
private capture;
|
|
137
138
|
}
|
package/dist/test-kit/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as AdapterFactory, d as AuthKind, A as AuthSpec, L as LlmAdapter, c as ApiKeyAuth, g as ClientOptions, P as PromptRequest, l as LlmEvent, M as Message, o as ToolCallEvent, n as ModelInfo, b as AdapterManifest } from '../types-
|
|
1
|
+
import { a as AdapterFactory, d as AuthKind, A as AuthSpec, L as LlmAdapter, c as ApiKeyAuth, g as ClientOptions, P as PromptRequest, l as LlmEvent, M as Message, o as ToolCallEvent, n as ModelInfo, b as AdapterManifest } from '../types-4d2QrlAe.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Named scenarios the harness must be able to stage. Each scenario configures
|
|
@@ -132,6 +132,7 @@ declare class FakeAdapter implements LlmAdapter<ApiKeyAuth> {
|
|
|
132
132
|
appendAssistantToolCall(history: Message[], toolCalls: ReadonlyArray<ToolCallEvent>): Message[];
|
|
133
133
|
appendToolResult(history: Message[], toolCallId: string, result: unknown): Message[];
|
|
134
134
|
listAvailableModels(): Promise<ModelInfo[]>;
|
|
135
|
+
testCredential(): Promise<void>;
|
|
135
136
|
private ensureInitialized;
|
|
136
137
|
private capture;
|
|
137
138
|
}
|
package/dist/test-kit/index.js
CHANGED
|
@@ -426,6 +426,9 @@ var OpenAIAdapter = class {
|
|
|
426
426
|
async listAvailableModels() {
|
|
427
427
|
return listOpenAICompatibleModels(this.ensureClient(), openAIManifest.knownModels);
|
|
428
428
|
}
|
|
429
|
+
async testCredential() {
|
|
430
|
+
await this.ensureClient().models.list();
|
|
431
|
+
}
|
|
429
432
|
async warmup() {
|
|
430
433
|
const client = this.ensureClient();
|
|
431
434
|
await client.models.list().catch(() => void 0);
|
|
@@ -852,6 +855,9 @@ var AnthropicAdapter = class {
|
|
|
852
855
|
}
|
|
853
856
|
return models;
|
|
854
857
|
}
|
|
858
|
+
async testCredential() {
|
|
859
|
+
await this.ensureClient().models.list();
|
|
860
|
+
}
|
|
855
861
|
async warmup() {
|
|
856
862
|
const client = this.ensureClient();
|
|
857
863
|
await client.models.list().catch(() => void 0);
|
|
@@ -1278,6 +1284,9 @@ var GoogleAdapter = class {
|
|
|
1278
1284
|
async listAvailableModels() {
|
|
1279
1285
|
return listGeminiModels(this.ensureClient(), googleManifest.knownModels);
|
|
1280
1286
|
}
|
|
1287
|
+
async testCredential() {
|
|
1288
|
+
await listGeminiModels(this.ensureClient(), googleManifest.knownModels);
|
|
1289
|
+
}
|
|
1281
1290
|
async warmup() {
|
|
1282
1291
|
}
|
|
1283
1292
|
ensureClient() {
|
|
@@ -1448,6 +1457,9 @@ var VertexGeminiAdapter = class {
|
|
|
1448
1457
|
async listAvailableModels() {
|
|
1449
1458
|
return listGeminiModels(this.ensureClient(), vertexGeminiManifest.knownModels);
|
|
1450
1459
|
}
|
|
1460
|
+
async testCredential() {
|
|
1461
|
+
await listGeminiModels(this.ensureClient(), vertexGeminiManifest.knownModels);
|
|
1462
|
+
}
|
|
1451
1463
|
async warmup() {
|
|
1452
1464
|
}
|
|
1453
1465
|
ensureClient() {
|
|
@@ -1546,11 +1558,22 @@ var vertexOpenAIManifest = {
|
|
|
1546
1558
|
type: "select",
|
|
1547
1559
|
required: true,
|
|
1548
1560
|
default: "us-central1",
|
|
1561
|
+
// Same region set as vertex-gemini plus us-east5 (where Google
|
|
1562
|
+
// hosts Llama partner models). Partner-model availability varies
|
|
1563
|
+
// per region; Google's docs for each model are the source of truth.
|
|
1549
1564
|
options: [
|
|
1550
1565
|
{ value: "us-central1", label: "us-central1" },
|
|
1566
|
+
{ value: "us-east1", label: "us-east1" },
|
|
1551
1567
|
{ value: "us-east4", label: "us-east4" },
|
|
1568
|
+
{ value: "us-east5", label: "us-east5" },
|
|
1569
|
+
{ value: "us-west1", label: "us-west1" },
|
|
1570
|
+
{ value: "us-west4", label: "us-west4" },
|
|
1552
1571
|
{ value: "europe-west1", label: "europe-west1" },
|
|
1572
|
+
{ value: "europe-west2", label: "europe-west2" },
|
|
1573
|
+
{ value: "europe-west3", label: "europe-west3" },
|
|
1553
1574
|
{ value: "europe-west4", label: "europe-west4" },
|
|
1575
|
+
{ value: "asia-east1", label: "asia-east1" },
|
|
1576
|
+
{ value: "asia-northeast1", label: "asia-northeast1" },
|
|
1554
1577
|
{ value: "asia-southeast1", label: "asia-southeast1" }
|
|
1555
1578
|
]
|
|
1556
1579
|
}
|
|
@@ -1568,6 +1591,7 @@ var VertexOpenAIAdapter = class {
|
|
|
1568
1591
|
vendor = vertexOpenAIManifest.vendor;
|
|
1569
1592
|
acceptedAuth = ["vertexServiceAccount"];
|
|
1570
1593
|
client;
|
|
1594
|
+
googleAuth;
|
|
1571
1595
|
init(auth, client) {
|
|
1572
1596
|
if (auth.kind !== "vertexServiceAccount") {
|
|
1573
1597
|
throw new Error(
|
|
@@ -1584,12 +1608,12 @@ var VertexOpenAIAdapter = class {
|
|
|
1584
1608
|
throw new Error("VertexOpenAIAdapter: location is required");
|
|
1585
1609
|
}
|
|
1586
1610
|
const baseURL = `https://${auth.location}-aiplatform.googleapis.com/v1beta1/projects/${auth.projectId}/locations/${auth.location}/endpoints/openapi`;
|
|
1587
|
-
|
|
1611
|
+
this.googleAuth = new GoogleAuth({
|
|
1588
1612
|
credentials: auth.credentials,
|
|
1589
1613
|
scopes: ["https://www.googleapis.com/auth/cloud-platform"]
|
|
1590
1614
|
});
|
|
1591
1615
|
const authedFetch = async (input, init2) => {
|
|
1592
|
-
const googleClient = await googleAuth.getClient();
|
|
1616
|
+
const googleClient = await this.googleAuth.getClient();
|
|
1593
1617
|
const token = await googleClient.getAccessToken();
|
|
1594
1618
|
const headers = new Headers(init2?.headers);
|
|
1595
1619
|
headers.set("Authorization", `Bearer ${token.token ?? ""}`);
|
|
@@ -1618,6 +1642,16 @@ var VertexOpenAIAdapter = class {
|
|
|
1618
1642
|
async listAvailableModels() {
|
|
1619
1643
|
return [...vertexOpenAIManifest.knownModels];
|
|
1620
1644
|
}
|
|
1645
|
+
async testCredential() {
|
|
1646
|
+
if (!this.googleAuth) {
|
|
1647
|
+
throw new Error("VertexOpenAIAdapter: init() must be called before testCredential()");
|
|
1648
|
+
}
|
|
1649
|
+
const googleClient = await this.googleAuth.getClient();
|
|
1650
|
+
const token = await googleClient.getAccessToken();
|
|
1651
|
+
if (!token.token) {
|
|
1652
|
+
throw new Error("VertexOpenAIAdapter: service account did not mint an access token");
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1621
1655
|
async warmup() {
|
|
1622
1656
|
}
|
|
1623
1657
|
ensureClient() {
|
|
@@ -1642,6 +1676,10 @@ import {
|
|
|
1642
1676
|
BedrockRuntimeClient,
|
|
1643
1677
|
ConverseStreamCommand
|
|
1644
1678
|
} from "@aws-sdk/client-bedrock-runtime";
|
|
1679
|
+
import {
|
|
1680
|
+
BedrockClient,
|
|
1681
|
+
ListFoundationModelsCommand
|
|
1682
|
+
} from "@aws-sdk/client-bedrock";
|
|
1645
1683
|
|
|
1646
1684
|
// src/adapters/bedrock/manifest.ts
|
|
1647
1685
|
var BEDROCK_KNOWN_MODELS = [
|
|
@@ -1856,6 +1894,7 @@ var BedrockAdapter = class {
|
|
|
1856
1894
|
vendor = bedrockManifest.vendor;
|
|
1857
1895
|
acceptedAuth = ["bedrockApiKey", "bedrockIam"];
|
|
1858
1896
|
client;
|
|
1897
|
+
controlClientConfig;
|
|
1859
1898
|
init(auth, client) {
|
|
1860
1899
|
if (!auth.region) {
|
|
1861
1900
|
throw new Error("BedrockAdapter: region is required");
|
|
@@ -1886,6 +1925,7 @@ var BedrockAdapter = class {
|
|
|
1886
1925
|
);
|
|
1887
1926
|
}
|
|
1888
1927
|
this.client = new BedrockRuntimeClient(config);
|
|
1928
|
+
this.controlClientConfig = config;
|
|
1889
1929
|
}
|
|
1890
1930
|
async *stream(req) {
|
|
1891
1931
|
assertValidRequest(req);
|
|
@@ -2064,6 +2104,17 @@ var BedrockAdapter = class {
|
|
|
2064
2104
|
async listAvailableModels() {
|
|
2065
2105
|
return [...bedrockManifest.knownModels];
|
|
2066
2106
|
}
|
|
2107
|
+
async testCredential() {
|
|
2108
|
+
if (!this.controlClientConfig) {
|
|
2109
|
+
throw new Error("BedrockAdapter: init() must be called before testCredential()");
|
|
2110
|
+
}
|
|
2111
|
+
const control = new BedrockClient(this.controlClientConfig);
|
|
2112
|
+
try {
|
|
2113
|
+
await control.send(new ListFoundationModelsCommand({}));
|
|
2114
|
+
} finally {
|
|
2115
|
+
control.destroy();
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2067
2118
|
async warmup() {
|
|
2068
2119
|
}
|
|
2069
2120
|
ensureClient() {
|
|
@@ -2396,6 +2447,11 @@ function runContractTests(harness) {
|
|
|
2396
2447
|
expect(typeof m.capabilities.tools).toBe("boolean");
|
|
2397
2448
|
}
|
|
2398
2449
|
});
|
|
2450
|
+
it("[15a] testCredential resolves on a valid auth probe", async () => {
|
|
2451
|
+
await harness.mockScenario("list-models");
|
|
2452
|
+
const adapter = await init(harness);
|
|
2453
|
+
await expect(adapter.testCredential()).resolves.not.toThrow();
|
|
2454
|
+
});
|
|
2399
2455
|
if (harness.nonToolCapableModel) {
|
|
2400
2456
|
it("[16] non-tool-capable model with tools declared either fails fast or runs without tool calls", async () => {
|
|
2401
2457
|
await harness.mockScenario("simple-stream");
|
|
@@ -2590,6 +2646,9 @@ var FakeAdapter = class {
|
|
|
2590
2646
|
this.ensureInitialized();
|
|
2591
2647
|
return fakeManifest.knownModels;
|
|
2592
2648
|
}
|
|
2649
|
+
async testCredential() {
|
|
2650
|
+
this.ensureInitialized();
|
|
2651
|
+
}
|
|
2593
2652
|
ensureInitialized() {
|
|
2594
2653
|
if (!this.initialized) {
|
|
2595
2654
|
throw new Error("FakeAdapter: init() must be called before stream()/listAvailableModels()");
|