@jambonz/llm 0.2.7 → 0.3.0
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 +39 -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 +42 -2
- package/dist/index.js.map +1 -1
- package/dist/test-kit/index.cjs +47 -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 +50 -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/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-
|
|
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-
|
|
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-
|
|
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-
|
|
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() {
|
|
@@ -1575,6 +1587,7 @@ var VertexOpenAIAdapter = class {
|
|
|
1575
1587
|
vendor = vertexOpenAIManifest.vendor;
|
|
1576
1588
|
acceptedAuth = ["vertexServiceAccount"];
|
|
1577
1589
|
client;
|
|
1590
|
+
googleAuth;
|
|
1578
1591
|
init(auth, client) {
|
|
1579
1592
|
if (auth.kind !== "vertexServiceAccount") {
|
|
1580
1593
|
throw new Error(
|
|
@@ -1591,12 +1604,12 @@ var VertexOpenAIAdapter = class {
|
|
|
1591
1604
|
throw new Error("VertexOpenAIAdapter: location is required");
|
|
1592
1605
|
}
|
|
1593
1606
|
const baseURL = `https://${auth.location}-aiplatform.googleapis.com/v1beta1/projects/${auth.projectId}/locations/${auth.location}/endpoints/openapi`;
|
|
1594
|
-
|
|
1607
|
+
this.googleAuth = new GoogleAuth({
|
|
1595
1608
|
credentials: auth.credentials,
|
|
1596
1609
|
scopes: ["https://www.googleapis.com/auth/cloud-platform"]
|
|
1597
1610
|
});
|
|
1598
1611
|
const authedFetch = async (input, init) => {
|
|
1599
|
-
const googleClient = await googleAuth.getClient();
|
|
1612
|
+
const googleClient = await this.googleAuth.getClient();
|
|
1600
1613
|
const token = await googleClient.getAccessToken();
|
|
1601
1614
|
const headers = new Headers(init?.headers);
|
|
1602
1615
|
headers.set("Authorization", `Bearer ${token.token ?? ""}`);
|
|
@@ -1625,6 +1638,16 @@ var VertexOpenAIAdapter = class {
|
|
|
1625
1638
|
async listAvailableModels() {
|
|
1626
1639
|
return [...vertexOpenAIManifest.knownModels];
|
|
1627
1640
|
}
|
|
1641
|
+
async testCredential() {
|
|
1642
|
+
if (!this.googleAuth) {
|
|
1643
|
+
throw new Error("VertexOpenAIAdapter: init() must be called before testCredential()");
|
|
1644
|
+
}
|
|
1645
|
+
const googleClient = await this.googleAuth.getClient();
|
|
1646
|
+
const token = await googleClient.getAccessToken();
|
|
1647
|
+
if (!token.token) {
|
|
1648
|
+
throw new Error("VertexOpenAIAdapter: service account did not mint an access token");
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1628
1651
|
async warmup() {
|
|
1629
1652
|
}
|
|
1630
1653
|
ensureClient() {
|
|
@@ -1649,6 +1672,10 @@ import {
|
|
|
1649
1672
|
BedrockRuntimeClient,
|
|
1650
1673
|
ConverseStreamCommand
|
|
1651
1674
|
} from "@aws-sdk/client-bedrock-runtime";
|
|
1675
|
+
import {
|
|
1676
|
+
BedrockClient,
|
|
1677
|
+
ListFoundationModelsCommand
|
|
1678
|
+
} from "@aws-sdk/client-bedrock";
|
|
1652
1679
|
|
|
1653
1680
|
// src/adapters/bedrock/manifest.ts
|
|
1654
1681
|
var BEDROCK_KNOWN_MODELS = [
|
|
@@ -1863,6 +1890,7 @@ var BedrockAdapter = class {
|
|
|
1863
1890
|
vendor = bedrockManifest.vendor;
|
|
1864
1891
|
acceptedAuth = ["bedrockApiKey", "bedrockIam"];
|
|
1865
1892
|
client;
|
|
1893
|
+
controlClientConfig;
|
|
1866
1894
|
init(auth, client) {
|
|
1867
1895
|
if (!auth.region) {
|
|
1868
1896
|
throw new Error("BedrockAdapter: region is required");
|
|
@@ -1893,6 +1921,7 @@ var BedrockAdapter = class {
|
|
|
1893
1921
|
);
|
|
1894
1922
|
}
|
|
1895
1923
|
this.client = new BedrockRuntimeClient(config);
|
|
1924
|
+
this.controlClientConfig = config;
|
|
1896
1925
|
}
|
|
1897
1926
|
async *stream(req) {
|
|
1898
1927
|
assertValidRequest(req);
|
|
@@ -2071,6 +2100,17 @@ var BedrockAdapter = class {
|
|
|
2071
2100
|
async listAvailableModels() {
|
|
2072
2101
|
return [...bedrockManifest.knownModels];
|
|
2073
2102
|
}
|
|
2103
|
+
async testCredential() {
|
|
2104
|
+
if (!this.controlClientConfig) {
|
|
2105
|
+
throw new Error("BedrockAdapter: init() must be called before testCredential()");
|
|
2106
|
+
}
|
|
2107
|
+
const control = new BedrockClient(this.controlClientConfig);
|
|
2108
|
+
try {
|
|
2109
|
+
await control.send(new ListFoundationModelsCommand({}));
|
|
2110
|
+
} finally {
|
|
2111
|
+
control.destroy();
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2074
2114
|
async warmup() {
|
|
2075
2115
|
}
|
|
2076
2116
|
ensureClient() {
|