@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/test-kit/index.js
CHANGED
|
@@ -516,7 +516,8 @@ var OpenAIAdapter = class {
|
|
|
516
516
|
stream(req) {
|
|
517
517
|
return streamFromOpenAI(this.ensureClient(), req, {
|
|
518
518
|
knownModels: this.knownModels(),
|
|
519
|
-
vendorMetadataExtractor: OPENAI_METADATA_EXTRACTOR
|
|
519
|
+
vendorMetadataExtractor: OPENAI_METADATA_EXTRACTOR,
|
|
520
|
+
includeCacheKey: this.forwardCacheKey()
|
|
520
521
|
});
|
|
521
522
|
}
|
|
522
523
|
appendAssistantToolCall(history, toolCalls) {
|
|
@@ -537,6 +538,20 @@ var OpenAIAdapter = class {
|
|
|
537
538
|
knownModels() {
|
|
538
539
|
return openAIManifest.knownModels;
|
|
539
540
|
}
|
|
541
|
+
/**
|
|
542
|
+
* Whether to forward `req.cacheKey` as OpenAI's `prompt_cache_key` request
|
|
543
|
+
* param. Default true — verified accepted by OpenAI, Azure OpenAI,
|
|
544
|
+
* Vertex-OpenAI, and Baseten. OpenAI-compatible vendors whose param
|
|
545
|
+
* handling is strict or unverified (DeepSeek, Moonshot, Zai, xAI — and
|
|
546
|
+
* Groq via its own stream override) override to false: a strict backend
|
|
547
|
+
* rejects the whole request on an unknown body param, which is far worse
|
|
548
|
+
* than forgoing a cache-routing hint. Flip a vendor to true only after
|
|
549
|
+
* verifying its endpoint (including any proxy in front of it, e.g.
|
|
550
|
+
* Bedrock Mantle) tolerates the param.
|
|
551
|
+
*/
|
|
552
|
+
forwardCacheKey() {
|
|
553
|
+
return true;
|
|
554
|
+
}
|
|
540
555
|
async testCredential() {
|
|
541
556
|
await this.ensureClient().models.list();
|
|
542
557
|
}
|
|
@@ -649,6 +664,11 @@ var DeepSeekAdapter = class extends OpenAIAdapter {
|
|
|
649
664
|
knownModels() {
|
|
650
665
|
return deepseekManifest.knownModels;
|
|
651
666
|
}
|
|
667
|
+
// DeepSeek caches automatically server-side; prompt_cache_key is
|
|
668
|
+
// unverified against its param handling — do not forward.
|
|
669
|
+
forwardCacheKey() {
|
|
670
|
+
return false;
|
|
671
|
+
}
|
|
652
672
|
};
|
|
653
673
|
var deepseekFactory = {
|
|
654
674
|
vendor: deepseekManifest.vendor,
|
|
@@ -872,6 +892,12 @@ var MoonshotAdapter = class extends OpenAIAdapter {
|
|
|
872
892
|
knownModels() {
|
|
873
893
|
return moonshotManifest.knownModels;
|
|
874
894
|
}
|
|
895
|
+
// Moonshot's param handling is strict (e.g. it rejects unknown template
|
|
896
|
+
// kwargs) and prompt_cache_key is unverified against both the native
|
|
897
|
+
// endpoint and Bedrock Mantle deployments — do not forward.
|
|
898
|
+
forwardCacheKey() {
|
|
899
|
+
return false;
|
|
900
|
+
}
|
|
875
901
|
};
|
|
876
902
|
var moonshotFactory = {
|
|
877
903
|
vendor: moonshotManifest.vendor,
|
|
@@ -945,6 +971,11 @@ var ZaiAdapter = class extends OpenAIAdapter {
|
|
|
945
971
|
knownModels() {
|
|
946
972
|
return zaiManifest.knownModels;
|
|
947
973
|
}
|
|
974
|
+
// prompt_cache_key is unverified against Zai's OpenAI-compat endpoint —
|
|
975
|
+
// do not forward.
|
|
976
|
+
forwardCacheKey() {
|
|
977
|
+
return false;
|
|
978
|
+
}
|
|
948
979
|
};
|
|
949
980
|
var zaiFactory = {
|
|
950
981
|
vendor: zaiManifest.vendor,
|
|
@@ -1040,12 +1071,127 @@ var XaiAdapter = class extends OpenAIAdapter {
|
|
|
1040
1071
|
knownModels() {
|
|
1041
1072
|
return xaiManifest.knownModels;
|
|
1042
1073
|
}
|
|
1074
|
+
// xAI caches automatically server-side; prompt_cache_key is unverified
|
|
1075
|
+
// against its param handling — do not forward.
|
|
1076
|
+
forwardCacheKey() {
|
|
1077
|
+
return false;
|
|
1078
|
+
}
|
|
1043
1079
|
};
|
|
1044
1080
|
var xaiFactory = {
|
|
1045
1081
|
vendor: xaiManifest.vendor,
|
|
1046
1082
|
manifest: xaiManifest,
|
|
1047
1083
|
create: () => new XaiAdapter()
|
|
1048
1084
|
};
|
|
1085
|
+
var BEDROCK_MANTLE_DEFAULT_BASE_URL = "https://bedrock-mantle.us-east-1.api.aws/v1";
|
|
1086
|
+
var bedrockMantleManifest = {
|
|
1087
|
+
vendor: "bedrock-mantle",
|
|
1088
|
+
displayName: "AWS Bedrock (OpenAI-compatible)",
|
|
1089
|
+
authKinds: [
|
|
1090
|
+
{
|
|
1091
|
+
kind: "apiKey",
|
|
1092
|
+
displayName: "API Key",
|
|
1093
|
+
fields: [
|
|
1094
|
+
{
|
|
1095
|
+
name: "apiKey",
|
|
1096
|
+
label: "Bedrock API Key",
|
|
1097
|
+
type: "password",
|
|
1098
|
+
required: true,
|
|
1099
|
+
help: "Generate a long-term Bedrock API key in the AWS console (Amazon Bedrock \u2192 API keys)."
|
|
1100
|
+
},
|
|
1101
|
+
{
|
|
1102
|
+
name: "baseURL",
|
|
1103
|
+
label: "Base URL",
|
|
1104
|
+
type: "url",
|
|
1105
|
+
required: false,
|
|
1106
|
+
default: BEDROCK_MANTLE_DEFAULT_BASE_URL,
|
|
1107
|
+
help: "Change the region to match your key. xAI models are served only on the /openai/v1 path."
|
|
1108
|
+
}
|
|
1109
|
+
]
|
|
1110
|
+
}
|
|
1111
|
+
],
|
|
1112
|
+
/* A convenience seed, NOT the source of truth: the live `/v1/models`
|
|
1113
|
+
* endpoint is authoritative and grows continuously, which is why
|
|
1114
|
+
* `supportsModelListing` is true. Any model the endpoint lists can be used
|
|
1115
|
+
* by id without appearing here.
|
|
1116
|
+
*
|
|
1117
|
+
* AWS publishes no context-window metadata (neither `/v1/models` nor
|
|
1118
|
+
* `GetFoundationModel` returns it), so these limits are carried over from
|
|
1119
|
+
* the native-vendor manifests above for the same underlying models. Vision
|
|
1120
|
+
* follows Bedrock's `inputModalities`. */
|
|
1121
|
+
knownModels: [
|
|
1122
|
+
{
|
|
1123
|
+
id: "zai.glm-5",
|
|
1124
|
+
displayName: "GLM 5",
|
|
1125
|
+
capabilities: {
|
|
1126
|
+
streaming: true,
|
|
1127
|
+
tools: true,
|
|
1128
|
+
vision: false,
|
|
1129
|
+
systemPrompt: true,
|
|
1130
|
+
maxContextTokens: 202800
|
|
1131
|
+
}
|
|
1132
|
+
},
|
|
1133
|
+
{
|
|
1134
|
+
id: "zai.glm-4.7",
|
|
1135
|
+
displayName: "GLM 4.7",
|
|
1136
|
+
capabilities: {
|
|
1137
|
+
streaming: true,
|
|
1138
|
+
tools: true,
|
|
1139
|
+
vision: false,
|
|
1140
|
+
systemPrompt: true,
|
|
1141
|
+
maxContextTokens: 2e5
|
|
1142
|
+
}
|
|
1143
|
+
},
|
|
1144
|
+
{
|
|
1145
|
+
id: "moonshotai.kimi-k2.5",
|
|
1146
|
+
displayName: "Kimi K2.5",
|
|
1147
|
+
capabilities: {
|
|
1148
|
+
streaming: true,
|
|
1149
|
+
tools: true,
|
|
1150
|
+
vision: true,
|
|
1151
|
+
systemPrompt: true,
|
|
1152
|
+
maxContextTokens: 262144
|
|
1153
|
+
}
|
|
1154
|
+
},
|
|
1155
|
+
{
|
|
1156
|
+
id: "xai.grok-4.3",
|
|
1157
|
+
displayName: "Grok 4.3",
|
|
1158
|
+
capabilities: {
|
|
1159
|
+
streaming: true,
|
|
1160
|
+
tools: true,
|
|
1161
|
+
vision: true,
|
|
1162
|
+
systemPrompt: true,
|
|
1163
|
+
maxContextTokens: 1e6
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
],
|
|
1167
|
+
supportsModelListing: true,
|
|
1168
|
+
docsUrl: "https://docs.aws.amazon.com/bedrock/latest/userguide/inference-chat-completions.html"
|
|
1169
|
+
};
|
|
1170
|
+
var BedrockMantleAdapter = class extends OpenAIAdapter {
|
|
1171
|
+
vendor = bedrockMantleManifest.vendor;
|
|
1172
|
+
init(auth, client) {
|
|
1173
|
+
super.init(
|
|
1174
|
+
{
|
|
1175
|
+
...auth,
|
|
1176
|
+
baseURL: auth.baseURL ?? BEDROCK_MANTLE_DEFAULT_BASE_URL
|
|
1177
|
+
},
|
|
1178
|
+
client
|
|
1179
|
+
);
|
|
1180
|
+
}
|
|
1181
|
+
knownModels() {
|
|
1182
|
+
return bedrockMantleManifest.knownModels;
|
|
1183
|
+
}
|
|
1184
|
+
// Mantle fronts many third-party runtimes with differing param strictness,
|
|
1185
|
+
// and prompt_cache_key is unverified against all of them — do not forward.
|
|
1186
|
+
forwardCacheKey() {
|
|
1187
|
+
return false;
|
|
1188
|
+
}
|
|
1189
|
+
};
|
|
1190
|
+
var bedrockMantleFactory = {
|
|
1191
|
+
vendor: bedrockMantleManifest.vendor,
|
|
1192
|
+
manifest: bedrockMantleManifest,
|
|
1193
|
+
create: () => new BedrockMantleAdapter()
|
|
1194
|
+
};
|
|
1049
1195
|
|
|
1050
1196
|
// src/adapters/anthropic/adapter.ts
|
|
1051
1197
|
import Anthropic from "@anthropic-ai/sdk";
|
|
@@ -3350,7 +3496,10 @@ var HuggingfaceAdapter = class extends OpenAIAdapter {
|
|
|
3350
3496
|
stream(req) {
|
|
3351
3497
|
return streamFromOpenAI(this.ensureClient(), req, {
|
|
3352
3498
|
knownModels: huggingfaceManifest.knownModels,
|
|
3353
|
-
vendorMetadataExtractor: HUGGINGFACE_METADATA_EXTRACTOR
|
|
3499
|
+
vendorMetadataExtractor: HUGGINGFACE_METADATA_EXTRACTOR,
|
|
3500
|
+
// The HF router fronts many third-party inference providers;
|
|
3501
|
+
// prompt_cache_key is unverified against them — do not forward.
|
|
3502
|
+
includeCacheKey: false
|
|
3354
3503
|
});
|
|
3355
3504
|
}
|
|
3356
3505
|
};
|
|
@@ -3369,6 +3518,7 @@ registerAdapter(basetenFactory);
|
|
|
3369
3518
|
registerAdapter(moonshotFactory);
|
|
3370
3519
|
registerAdapter(zaiFactory);
|
|
3371
3520
|
registerAdapter(xaiFactory);
|
|
3521
|
+
registerAdapter(bedrockMantleFactory);
|
|
3372
3522
|
registerAdapter(anthropicFactory);
|
|
3373
3523
|
registerAdapter(googleFactory);
|
|
3374
3524
|
registerAdapter(vertexGeminiFactory);
|