@jambonz/llm 0.6.0 → 0.6.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.cjs +153 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +153 -2
- package/dist/index.js.map +1 -1
- package/dist/test-kit/index.cjs +152 -2
- package/dist/test-kit/index.cjs.map +1 -1
- package/dist/test-kit/index.js +152 -2
- package/dist/test-kit/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -31,9 +31,10 @@ interface RawCredential {
|
|
|
31
31
|
/**
|
|
32
32
|
* Convert a vendor + raw credential into an `AuthSpec` discriminated union member.
|
|
33
33
|
*
|
|
34
|
-
* Supported vendors: openai, deepseek, baseten, moonshot, zai, xai,
|
|
35
|
-
* vertex (alias for vertex-gemini + vertex-openai — both accept
|
|
36
|
-
* vertex-gemini, vertex-openai, bedrock, azure-openai, groq,
|
|
34
|
+
* Supported vendors: openai, deepseek, baseten, moonshot, zai, xai, bedrock-mantle,
|
|
35
|
+
* anthropic, google, vertex (alias for vertex-gemini + vertex-openai — both accept
|
|
36
|
+
* the same auth shape), vertex-gemini, vertex-openai, bedrock, azure-openai, groq,
|
|
37
|
+
* huggingface.
|
|
37
38
|
*
|
|
38
39
|
* Throws with a clear message if the raw credential is missing required fields.
|
|
39
40
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -31,9 +31,10 @@ interface RawCredential {
|
|
|
31
31
|
/**
|
|
32
32
|
* Convert a vendor + raw credential into an `AuthSpec` discriminated union member.
|
|
33
33
|
*
|
|
34
|
-
* Supported vendors: openai, deepseek, baseten, moonshot, zai, xai,
|
|
35
|
-
* vertex (alias for vertex-gemini + vertex-openai — both accept
|
|
36
|
-
* vertex-gemini, vertex-openai, bedrock, azure-openai, groq,
|
|
34
|
+
* Supported vendors: openai, deepseek, baseten, moonshot, zai, xai, bedrock-mantle,
|
|
35
|
+
* anthropic, google, vertex (alias for vertex-gemini + vertex-openai — both accept
|
|
36
|
+
* the same auth shape), vertex-gemini, vertex-openai, bedrock, azure-openai, groq,
|
|
37
|
+
* huggingface.
|
|
37
38
|
*
|
|
38
39
|
* Throws with a clear message if the raw credential is missing required fields.
|
|
39
40
|
*/
|
package/dist/index.js
CHANGED
|
@@ -523,7 +523,8 @@ var OpenAIAdapter = class {
|
|
|
523
523
|
stream(req) {
|
|
524
524
|
return streamFromOpenAI(this.ensureClient(), req, {
|
|
525
525
|
knownModels: this.knownModels(),
|
|
526
|
-
vendorMetadataExtractor: OPENAI_METADATA_EXTRACTOR
|
|
526
|
+
vendorMetadataExtractor: OPENAI_METADATA_EXTRACTOR,
|
|
527
|
+
includeCacheKey: this.forwardCacheKey()
|
|
527
528
|
});
|
|
528
529
|
}
|
|
529
530
|
appendAssistantToolCall(history, toolCalls) {
|
|
@@ -544,6 +545,20 @@ var OpenAIAdapter = class {
|
|
|
544
545
|
knownModels() {
|
|
545
546
|
return openAIManifest.knownModels;
|
|
546
547
|
}
|
|
548
|
+
/**
|
|
549
|
+
* Whether to forward `req.cacheKey` as OpenAI's `prompt_cache_key` request
|
|
550
|
+
* param. Default true — verified accepted by OpenAI, Azure OpenAI,
|
|
551
|
+
* Vertex-OpenAI, and Baseten. OpenAI-compatible vendors whose param
|
|
552
|
+
* handling is strict or unverified (DeepSeek, Moonshot, Zai, xAI — and
|
|
553
|
+
* Groq via its own stream override) override to false: a strict backend
|
|
554
|
+
* rejects the whole request on an unknown body param, which is far worse
|
|
555
|
+
* than forgoing a cache-routing hint. Flip a vendor to true only after
|
|
556
|
+
* verifying its endpoint (including any proxy in front of it, e.g.
|
|
557
|
+
* Bedrock Mantle) tolerates the param.
|
|
558
|
+
*/
|
|
559
|
+
forwardCacheKey() {
|
|
560
|
+
return true;
|
|
561
|
+
}
|
|
547
562
|
async testCredential() {
|
|
548
563
|
await this.ensureClient().models.list();
|
|
549
564
|
}
|
|
@@ -656,6 +671,11 @@ var DeepSeekAdapter = class extends OpenAIAdapter {
|
|
|
656
671
|
knownModels() {
|
|
657
672
|
return deepseekManifest.knownModels;
|
|
658
673
|
}
|
|
674
|
+
// DeepSeek caches automatically server-side; prompt_cache_key is
|
|
675
|
+
// unverified against its param handling — do not forward.
|
|
676
|
+
forwardCacheKey() {
|
|
677
|
+
return false;
|
|
678
|
+
}
|
|
659
679
|
};
|
|
660
680
|
var deepseekFactory = {
|
|
661
681
|
vendor: deepseekManifest.vendor,
|
|
@@ -879,6 +899,12 @@ var MoonshotAdapter = class extends OpenAIAdapter {
|
|
|
879
899
|
knownModels() {
|
|
880
900
|
return moonshotManifest.knownModels;
|
|
881
901
|
}
|
|
902
|
+
// Moonshot's param handling is strict (e.g. it rejects unknown template
|
|
903
|
+
// kwargs) and prompt_cache_key is unverified against both the native
|
|
904
|
+
// endpoint and Bedrock Mantle deployments — do not forward.
|
|
905
|
+
forwardCacheKey() {
|
|
906
|
+
return false;
|
|
907
|
+
}
|
|
882
908
|
};
|
|
883
909
|
var moonshotFactory = {
|
|
884
910
|
vendor: moonshotManifest.vendor,
|
|
@@ -952,6 +978,11 @@ var ZaiAdapter = class extends OpenAIAdapter {
|
|
|
952
978
|
knownModels() {
|
|
953
979
|
return zaiManifest.knownModels;
|
|
954
980
|
}
|
|
981
|
+
// prompt_cache_key is unverified against Zai's OpenAI-compat endpoint —
|
|
982
|
+
// do not forward.
|
|
983
|
+
forwardCacheKey() {
|
|
984
|
+
return false;
|
|
985
|
+
}
|
|
955
986
|
};
|
|
956
987
|
var zaiFactory = {
|
|
957
988
|
vendor: zaiManifest.vendor,
|
|
@@ -1047,12 +1078,127 @@ var XaiAdapter = class extends OpenAIAdapter {
|
|
|
1047
1078
|
knownModels() {
|
|
1048
1079
|
return xaiManifest.knownModels;
|
|
1049
1080
|
}
|
|
1081
|
+
// xAI caches automatically server-side; prompt_cache_key is unverified
|
|
1082
|
+
// against its param handling — do not forward.
|
|
1083
|
+
forwardCacheKey() {
|
|
1084
|
+
return false;
|
|
1085
|
+
}
|
|
1050
1086
|
};
|
|
1051
1087
|
var xaiFactory = {
|
|
1052
1088
|
vendor: xaiManifest.vendor,
|
|
1053
1089
|
manifest: xaiManifest,
|
|
1054
1090
|
create: () => new XaiAdapter()
|
|
1055
1091
|
};
|
|
1092
|
+
var BEDROCK_MANTLE_DEFAULT_BASE_URL = "https://bedrock-mantle.us-east-1.api.aws/v1";
|
|
1093
|
+
var bedrockMantleManifest = {
|
|
1094
|
+
vendor: "bedrock-mantle",
|
|
1095
|
+
displayName: "AWS Bedrock (OpenAI-compatible)",
|
|
1096
|
+
authKinds: [
|
|
1097
|
+
{
|
|
1098
|
+
kind: "apiKey",
|
|
1099
|
+
displayName: "API Key",
|
|
1100
|
+
fields: [
|
|
1101
|
+
{
|
|
1102
|
+
name: "apiKey",
|
|
1103
|
+
label: "Bedrock API Key",
|
|
1104
|
+
type: "password",
|
|
1105
|
+
required: true,
|
|
1106
|
+
help: "Generate a long-term Bedrock API key in the AWS console (Amazon Bedrock \u2192 API keys)."
|
|
1107
|
+
},
|
|
1108
|
+
{
|
|
1109
|
+
name: "baseURL",
|
|
1110
|
+
label: "Base URL",
|
|
1111
|
+
type: "url",
|
|
1112
|
+
required: false,
|
|
1113
|
+
default: BEDROCK_MANTLE_DEFAULT_BASE_URL,
|
|
1114
|
+
help: "Change the region to match your key. xAI models are served only on the /openai/v1 path."
|
|
1115
|
+
}
|
|
1116
|
+
]
|
|
1117
|
+
}
|
|
1118
|
+
],
|
|
1119
|
+
/* A convenience seed, NOT the source of truth: the live `/v1/models`
|
|
1120
|
+
* endpoint is authoritative and grows continuously, which is why
|
|
1121
|
+
* `supportsModelListing` is true. Any model the endpoint lists can be used
|
|
1122
|
+
* by id without appearing here.
|
|
1123
|
+
*
|
|
1124
|
+
* AWS publishes no context-window metadata (neither `/v1/models` nor
|
|
1125
|
+
* `GetFoundationModel` returns it), so these limits are carried over from
|
|
1126
|
+
* the native-vendor manifests above for the same underlying models. Vision
|
|
1127
|
+
* follows Bedrock's `inputModalities`. */
|
|
1128
|
+
knownModels: [
|
|
1129
|
+
{
|
|
1130
|
+
id: "zai.glm-5",
|
|
1131
|
+
displayName: "GLM 5",
|
|
1132
|
+
capabilities: {
|
|
1133
|
+
streaming: true,
|
|
1134
|
+
tools: true,
|
|
1135
|
+
vision: false,
|
|
1136
|
+
systemPrompt: true,
|
|
1137
|
+
maxContextTokens: 202800
|
|
1138
|
+
}
|
|
1139
|
+
},
|
|
1140
|
+
{
|
|
1141
|
+
id: "zai.glm-4.7",
|
|
1142
|
+
displayName: "GLM 4.7",
|
|
1143
|
+
capabilities: {
|
|
1144
|
+
streaming: true,
|
|
1145
|
+
tools: true,
|
|
1146
|
+
vision: false,
|
|
1147
|
+
systemPrompt: true,
|
|
1148
|
+
maxContextTokens: 2e5
|
|
1149
|
+
}
|
|
1150
|
+
},
|
|
1151
|
+
{
|
|
1152
|
+
id: "moonshotai.kimi-k2.5",
|
|
1153
|
+
displayName: "Kimi K2.5",
|
|
1154
|
+
capabilities: {
|
|
1155
|
+
streaming: true,
|
|
1156
|
+
tools: true,
|
|
1157
|
+
vision: true,
|
|
1158
|
+
systemPrompt: true,
|
|
1159
|
+
maxContextTokens: 262144
|
|
1160
|
+
}
|
|
1161
|
+
},
|
|
1162
|
+
{
|
|
1163
|
+
id: "xai.grok-4.3",
|
|
1164
|
+
displayName: "Grok 4.3",
|
|
1165
|
+
capabilities: {
|
|
1166
|
+
streaming: true,
|
|
1167
|
+
tools: true,
|
|
1168
|
+
vision: true,
|
|
1169
|
+
systemPrompt: true,
|
|
1170
|
+
maxContextTokens: 1e6
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
],
|
|
1174
|
+
supportsModelListing: true,
|
|
1175
|
+
docsUrl: "https://docs.aws.amazon.com/bedrock/latest/userguide/inference-chat-completions.html"
|
|
1176
|
+
};
|
|
1177
|
+
var BedrockMantleAdapter = class extends OpenAIAdapter {
|
|
1178
|
+
vendor = bedrockMantleManifest.vendor;
|
|
1179
|
+
init(auth, client) {
|
|
1180
|
+
super.init(
|
|
1181
|
+
{
|
|
1182
|
+
...auth,
|
|
1183
|
+
baseURL: auth.baseURL ?? BEDROCK_MANTLE_DEFAULT_BASE_URL
|
|
1184
|
+
},
|
|
1185
|
+
client
|
|
1186
|
+
);
|
|
1187
|
+
}
|
|
1188
|
+
knownModels() {
|
|
1189
|
+
return bedrockMantleManifest.knownModels;
|
|
1190
|
+
}
|
|
1191
|
+
// Mantle fronts many third-party runtimes with differing param strictness,
|
|
1192
|
+
// and prompt_cache_key is unverified against all of them — do not forward.
|
|
1193
|
+
forwardCacheKey() {
|
|
1194
|
+
return false;
|
|
1195
|
+
}
|
|
1196
|
+
};
|
|
1197
|
+
var bedrockMantleFactory = {
|
|
1198
|
+
vendor: bedrockMantleManifest.vendor,
|
|
1199
|
+
manifest: bedrockMantleManifest,
|
|
1200
|
+
create: () => new BedrockMantleAdapter()
|
|
1201
|
+
};
|
|
1056
1202
|
|
|
1057
1203
|
// src/adapters/anthropic/adapter.ts
|
|
1058
1204
|
import Anthropic from "@anthropic-ai/sdk";
|
|
@@ -3357,7 +3503,10 @@ var HuggingfaceAdapter = class extends OpenAIAdapter {
|
|
|
3357
3503
|
stream(req) {
|
|
3358
3504
|
return streamFromOpenAI(this.ensureClient(), req, {
|
|
3359
3505
|
knownModels: huggingfaceManifest.knownModels,
|
|
3360
|
-
vendorMetadataExtractor: HUGGINGFACE_METADATA_EXTRACTOR
|
|
3506
|
+
vendorMetadataExtractor: HUGGINGFACE_METADATA_EXTRACTOR,
|
|
3507
|
+
// The HF router fronts many third-party inference providers;
|
|
3508
|
+
// prompt_cache_key is unverified against them — do not forward.
|
|
3509
|
+
includeCacheKey: false
|
|
3361
3510
|
});
|
|
3362
3511
|
}
|
|
3363
3512
|
};
|
|
@@ -3376,6 +3525,7 @@ registerAdapter(basetenFactory);
|
|
|
3376
3525
|
registerAdapter(moonshotFactory);
|
|
3377
3526
|
registerAdapter(zaiFactory);
|
|
3378
3527
|
registerAdapter(xaiFactory);
|
|
3528
|
+
registerAdapter(bedrockMantleFactory);
|
|
3379
3529
|
registerAdapter(anthropicFactory);
|
|
3380
3530
|
registerAdapter(googleFactory);
|
|
3381
3531
|
registerAdapter(vertexGeminiFactory);
|
|
@@ -3395,6 +3545,7 @@ function normalizeAuth(vendor, raw) {
|
|
|
3395
3545
|
case "moonshot":
|
|
3396
3546
|
case "zai":
|
|
3397
3547
|
case "xai":
|
|
3548
|
+
case "bedrock-mantle":
|
|
3398
3549
|
return requireApiKey(vendor, raw);
|
|
3399
3550
|
case "deepseek":
|
|
3400
3551
|
return {
|