@infersec/conduit 1.101.0 → 1.102.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/dist/cli.js CHANGED
@@ -4345,35 +4345,6 @@ function ulid$2(seedTime, prng) {
4345
4345
  return encodeTime(seed, TIME_LEN) + encodeRandom(RANDOM_LEN, currentPRNG);
4346
4346
  }
4347
4347
 
4348
- function getEffectiveContextLength({ contextLength, engineConfig, engineType }) {
4349
- if (contextLength === null || contextLength <= 0) {
4350
- return null;
4351
- }
4352
- if (!engineConfig) {
4353
- return contextLength;
4354
- }
4355
- switch (engineType) {
4356
- case "llama.cpp": {
4357
- const parallelism = engineConfig.parallelism;
4358
- if (typeof parallelism === "number" && parallelism > 0) {
4359
- return contextLength / parallelism;
4360
- }
4361
- return contextLength;
4362
- }
4363
- case "sglang":
4364
- case "tensorrt-llm":
4365
- case "vllm": {
4366
- const tensorParallelSize = engineConfig.tensorParallelSize;
4367
- if (typeof tensorParallelSize === "number" && tensorParallelSize > 0) {
4368
- return contextLength / tensorParallelSize;
4369
- }
4370
- return contextLength;
4371
- }
4372
- default:
4373
- return contextLength;
4374
- }
4375
- }
4376
-
4377
4348
  function asError(error) {
4378
4349
  if (error instanceof Error) {
4379
4350
  return error;
@@ -19914,58 +19885,10 @@ const LLMEngineSchema = _enum$1([
19914
19885
  "tensorrt-llm",
19915
19886
  "vllm"
19916
19887
  ]);
19917
- const LlamacppEngineConfigSchema = object$1({
19918
- batchSize: number$1().int().positive().nullable().optional(),
19919
- cacheTypeK: string$2().nullable().optional(),
19920
- cacheTypeV: string$2().nullable().optional(),
19921
- extraArgs: array(string$2()).optional(),
19922
- flashAttn: boolean$1().optional(),
19923
- gpuLayers: number$1().int().min(0).optional(),
19924
- mainGpu: number$1().int().min(0).nullable().optional(),
19925
- parallelism: number$1().int().positive().optional(),
19926
- tensorSplit: string$2().nullable().optional(),
19927
- ubatchSize: number$1().int().positive().nullable().optional()
19928
- });
19929
- const VLLMEngineConfigSchema = object$1({
19930
- device: string$2().optional(),
19931
- dtype: string$2().optional(),
19932
- extraArgs: array(string$2()).optional(),
19933
- tensorParallelSize: number$1().int().positive().optional()
19934
- });
19935
- const SGLangEngineConfigSchema = object$1({
19936
- device: string$2().optional(),
19937
- dtype: string$2().optional(),
19938
- extraArgs: array(string$2()).optional(),
19939
- tensorParallelSize: number$1().int().positive().optional()
19940
- });
19941
- const TensorRTLLMEngineConfigSchema = object$1({
19942
- backend: _enum$1(["_autodeploy", "pytorch", "tensorrt"]).optional(),
19943
- dtype: string$2().optional(),
19944
- extraArgs: array(string$2()).optional(),
19945
- tensorParallelSize: number$1().int().positive().optional()
19946
- });
19947
- const Exllamav3EngineConfigSchema = object$1({
19948
- cacheMode: _enum$1(["fp16", "q4", "q6", "q8"]).optional(),
19949
- extraArgs: array(string$2()).optional(),
19950
- gpuSplit: string$2().optional(),
19951
- maxSeqLen: number$1().int().positive().optional()
19952
- });
19953
- const MLXLMEngineConfigSchema = object$1({
19954
- extraArgs: array(string$2()).optional(),
19955
- maxKvSize: number$1().int().positive().optional(),
19956
- trustRemoteCode: boolean$1().optional()
19888
+ const EngineConfigSchema = object$1({
19889
+ extraArgs: array(string$2()),
19890
+ type: LLMEngineSchema
19957
19891
  });
19958
- const EngineConfigSchema = discriminatedUnion("type", [
19959
- object$1({ config: Exllamav3EngineConfigSchema, type: literal("exllamav3") }),
19960
- object$1({ config: LlamacppEngineConfigSchema, type: literal("llama.cpp") }),
19961
- object$1({ config: MLXLMEngineConfigSchema, type: literal("mlx-lm") }),
19962
- object$1({ config: SGLangEngineConfigSchema, type: literal("sglang") }),
19963
- object$1({
19964
- config: TensorRTLLMEngineConfigSchema,
19965
- type: literal("tensorrt-llm")
19966
- }),
19967
- object$1({ config: VLLMEngineConfigSchema, type: literal("vllm") })
19968
- ]);
19969
19892
  const LLMModelFormatSchema = _enum$1([
19970
19893
  // VLLM / SGLang / TensorRT-LLM
19971
19894
  "safetensors",
@@ -21161,105 +21084,21 @@ object$1({
21161
21084
  });
21162
21085
  const EngineOutputSchema = object$1({
21163
21086
  created: string$2(),
21164
- exllamav3CacheMode: string$2().nullable(),
21165
- exllamav3ExtraArgs: array(string$2()),
21166
- exllamav3GpuSplit: string$2().nullable(),
21167
- exllamav3MaxSeqLen: number$1().nullable(),
21087
+ extraArgs: array(string$2()),
21168
21088
  id: ULIDSchema,
21169
- llamacppBatchSize: number$1().nullable(),
21170
- llamacppCacheTypeK: string$2().nullable(),
21171
- llamacppCacheTypeV: string$2().nullable(),
21172
- llamacppExtraArgs: array(string$2()),
21173
- llamacppFlashAttn: boolean$1(),
21174
- llamacppGpuLayers: number$1(),
21175
- llamacppMainGpu: number$1().nullable(),
21176
- llamacppParallelism: number$1(),
21177
- llamacppTensorSplit: string$2().nullable(),
21178
- llamacppUbatchSize: number$1().nullable(),
21179
- mlxlmExtraArgs: array(string$2()),
21180
- mlxlmMaxKvSize: number$1().nullable(),
21181
- mlxlmTrustRemoteCode: boolean$1(),
21182
21089
  name: string$2(),
21183
- sglangDevice: string$2().nullable(),
21184
- sglangDtype: string$2().nullable(),
21185
- sglangExtraArgs: array(string$2()),
21186
- sglangTensorParallelSize: number$1(),
21187
- trtllmBackend: string$2().nullable(),
21188
- trtllmDtype: string$2().nullable(),
21189
- trtllmExtraArgs: array(string$2()),
21190
- trtllmTensorParallelSize: number$1(),
21191
21090
  type: LLMEngineSchema,
21192
- updated: string$2(),
21193
- vllmDevice: string$2().nullable(),
21194
- vllmDtype: string$2().nullable(),
21195
- vllmExtraArgs: array(string$2()),
21196
- vllmTensorParallelSize: number$1()
21091
+ updated: string$2()
21197
21092
  });
21198
21093
  object$1({
21199
- exllamav3CacheMode: string$2().nullable().optional(),
21200
- exllamav3ExtraArgs: array(string$2()).optional(),
21201
- exllamav3GpuSplit: string$2().nullable().optional(),
21202
- exllamav3MaxSeqLen: number$1().int().positive().nullable().optional(),
21203
- llamacppBatchSize: number$1().int().positive().nullable().optional(),
21204
- llamacppCacheTypeK: string$2().nullable().optional(),
21205
- llamacppCacheTypeV: string$2().nullable().optional(),
21206
- llamacppExtraArgs: array(string$2()).optional(),
21207
- llamacppFlashAttn: boolean$1().optional(),
21208
- llamacppGpuLayers: number$1().int().min(0).optional(),
21209
- llamacppMainGpu: number$1().int().min(0).nullable().optional(),
21210
- llamacppParallelism: number$1().int().positive().optional(),
21211
- llamacppTensorSplit: string$2().nullable().optional(),
21212
- llamacppUbatchSize: number$1().int().positive().nullable().optional(),
21213
- mlxlmExtraArgs: array(string$2()).optional(),
21214
- mlxlmMaxKvSize: number$1().int().positive().nullable().optional(),
21215
- mlxlmTrustRemoteCode: boolean$1().optional(),
21094
+ extraArgs: array(string$2()).optional(),
21216
21095
  name: ResourceNameSchema,
21217
- sglangDevice: string$2().nullable().optional(),
21218
- sglangDtype: string$2().nullable().optional(),
21219
- sglangExtraArgs: array(string$2()).optional(),
21220
- sglangTensorParallelSize: number$1().int().positive().optional(),
21221
- trtllmBackend: string$2().nullable().optional(),
21222
- trtllmDtype: string$2().nullable().optional(),
21223
- trtllmExtraArgs: array(string$2()).optional(),
21224
- trtllmTensorParallelSize: number$1().int().positive().optional(),
21225
- type: LLMEngineSchema,
21226
- vllmDevice: string$2().nullable().optional(),
21227
- vllmDtype: string$2().nullable().optional(),
21228
- vllmExtraArgs: array(string$2()).optional(),
21229
- vllmTensorParallelSize: number$1().int().positive().optional()
21096
+ type: LLMEngineSchema
21230
21097
  });
21231
21098
  object$1({
21232
- exllamav3CacheMode: string$2().nullable().optional(),
21233
- exllamav3ExtraArgs: array(string$2()).optional(),
21234
- exllamav3GpuSplit: string$2().nullable().optional(),
21235
- exllamav3MaxSeqLen: number$1().int().positive().nullable().optional(),
21236
- llamacppBatchSize: number$1().int().positive().nullable().optional(),
21237
- llamacppCacheTypeK: string$2().nullable().optional(),
21238
- llamacppCacheTypeV: string$2().nullable().optional(),
21239
- llamacppExtraArgs: array(string$2()).optional(),
21240
- llamacppFlashAttn: boolean$1().optional(),
21241
- llamacppGpuLayers: number$1().int().min(0).optional(),
21242
- llamacppMainGpu: number$1().int().min(0).nullable().optional(),
21243
- llamacppParallelism: number$1().int().positive().optional(),
21244
- llamacppTensorSplit: string$2().nullable().optional(),
21245
- llamacppUbatchSize: number$1().int().positive().nullable().optional(),
21246
- mlxlmExtraArgs: array(string$2()).optional(),
21247
- mlxlmMaxKvSize: number$1().int().positive().nullable().optional(),
21248
- mlxlmTrustRemoteCode: boolean$1().optional(),
21099
+ extraArgs: array(string$2()).optional(),
21249
21100
  name: ResourceNameSchema.optional(),
21250
- sglangDevice: string$2().nullable().optional(),
21251
- sglangDtype: string$2().nullable().optional(),
21252
- sglangExtraArgs: array(string$2()).optional(),
21253
- sglangTensorParallelSize: number$1().int().positive().optional(),
21254
- trtllmBackend: string$2().nullable().optional(),
21255
- trtllmDtype: string$2().nullable().optional(),
21256
- trtllmExtraArgs: array(string$2()).optional(),
21257
- trtllmTensorParallelSize: number$1().int().positive().optional(),
21258
- type: LLMEngineSchema.optional(),
21259
- vllmDevice: string$2().nullable().optional(),
21260
- vllmDtype: string$2().nullable().optional(),
21261
- vllmExtraArgs: array(string$2()).optional(),
21262
- vllmTensorParallelSize: number$1().int().positive().optional()
21101
+ type: LLMEngineSchema.optional()
21263
21102
  });
21264
21103
  object$1({
21265
21104
  results: array(EngineOutputSchema)
@@ -21336,6 +21175,12 @@ object$1({
21336
21175
  }
21337
21176
  });
21338
21177
 
21178
+ object$1({
21179
+ config: EngineConfigSchema,
21180
+ description: string$2().optional(),
21181
+ name: ResourceNameSchema
21182
+ });
21183
+
21339
21184
  const ENGINE_API_COMPATIBILITY = {
21340
21185
  exllamav3: {
21341
21186
  nativeAnthropicMessages: false,
@@ -21754,6 +21599,105 @@ discriminatedUnion("chargeName", [
21754
21599
  ToolServiceCallMetaSchema
21755
21600
  ]);
21756
21601
 
21602
+ function parseExtraArgs(extraArgs) {
21603
+ if (!Array.isArray(extraArgs) ||
21604
+ !extraArgs.every((value) => typeof value === "string")) {
21605
+ return [];
21606
+ }
21607
+ return extraArgs.flatMap(tokenizeShellLine);
21608
+ }
21609
+ function findArgValue(args, flag) {
21610
+ let found = null;
21611
+ for (let index = 0; index < args.length; index += 1) {
21612
+ const token = args[index];
21613
+ if (token === flag) {
21614
+ const value = args[index + 1];
21615
+ if (value !== undefined && !value.startsWith("--")) {
21616
+ found = value;
21617
+ }
21618
+ else {
21619
+ found = null;
21620
+ }
21621
+ }
21622
+ else if (token.startsWith(`${flag}=`)) {
21623
+ found = token.slice(flag.length + 1);
21624
+ }
21625
+ }
21626
+ return found;
21627
+ }
21628
+ function tokenizeShellLine(input) {
21629
+ const tokens = [];
21630
+ let buffer = "";
21631
+ let inQuote = null;
21632
+ let hasBuffer = false;
21633
+ for (let index = 0; index < input.length; index += 1) {
21634
+ const char = input[index];
21635
+ if (inQuote) {
21636
+ if (char === inQuote) {
21637
+ inQuote = null;
21638
+ }
21639
+ else {
21640
+ buffer += char;
21641
+ }
21642
+ hasBuffer = true;
21643
+ }
21644
+ else if (char === '"' || char === "'") {
21645
+ inQuote = char;
21646
+ hasBuffer = true;
21647
+ }
21648
+ else if (char === " " || char === "\t") {
21649
+ if (hasBuffer) {
21650
+ tokens.push(buffer);
21651
+ buffer = "";
21652
+ hasBuffer = false;
21653
+ }
21654
+ }
21655
+ else {
21656
+ buffer += char;
21657
+ hasBuffer = true;
21658
+ }
21659
+ }
21660
+ if (hasBuffer) {
21661
+ tokens.push(buffer);
21662
+ }
21663
+ return tokens;
21664
+ }
21665
+
21666
+ function getEffectiveContextLength({ contextLength, engineConfig, engineType }) {
21667
+ if (contextLength === null || contextLength <= 0) {
21668
+ return null;
21669
+ }
21670
+ if (!engineConfig) {
21671
+ return contextLength;
21672
+ }
21673
+ let divisorFlag = null;
21674
+ switch (engineType) {
21675
+ case "llama.cpp":
21676
+ divisorFlag = "--parallel";
21677
+ break;
21678
+ case "sglang":
21679
+ case "tensorrt-llm":
21680
+ divisorFlag = "--tp-size";
21681
+ break;
21682
+ case "vllm":
21683
+ divisorFlag = "--tensor-parallel-size";
21684
+ break;
21685
+ }
21686
+ if (!divisorFlag) {
21687
+ return contextLength;
21688
+ }
21689
+ const tokens = parseExtraArgs(engineConfig.extraArgs);
21690
+ const rawValue = findArgValue(tokens, divisorFlag);
21691
+ if (rawValue === null) {
21692
+ return contextLength;
21693
+ }
21694
+ const divisor = Number(rawValue);
21695
+ if (Number.isSafeInteger(divisor) && divisor > 0) {
21696
+ return contextLength / divisor;
21697
+ }
21698
+ return contextLength;
21699
+ }
21700
+
21757
21701
  const ENV_BOOL_TRUE = ["true", "1", "yes"];
21758
21702
  const ENV_BOOL_FALSE = ["false", "0", "no"];
21759
21703
  function readEnvBoolean(name) {
@@ -22237,41 +22181,6 @@ class ProcessManager extends EventEmitter {
22237
22181
  }
22238
22182
  }
22239
22183
 
22240
- function watchStreamProgress(emitIntervalBytes) {
22241
- let bytesProcessed = 0;
22242
- let lastEmittedAt = 0;
22243
- const emitter = new EventEmitter();
22244
- const stream = new Transform({
22245
- transform(chunk, _encoding, callback) {
22246
- bytesProcessed += chunk.length;
22247
- // Emit progress updates at intervals
22248
- if (bytesProcessed - lastEmittedAt >= emitIntervalBytes) {
22249
- emitter.emit("progress", bytesProcessed);
22250
- lastEmittedAt = bytesProcessed;
22251
- }
22252
- // Pass chunk through unchanged
22253
- callback(null, chunk);
22254
- },
22255
- flush(callback) {
22256
- emitter.emit("progress", bytesProcessed);
22257
- callback();
22258
- }
22259
- });
22260
- stream.progress = emitter;
22261
- return stream;
22262
- }
22263
-
22264
- function joinURL(...parts) {
22265
- return parts
22266
- .join("/")
22267
- .replace(/[\/]+/g, "/")
22268
- .replace(/^(.+):\//, "$1://")
22269
- .replace(/^file:/, "file:/")
22270
- .replace(/\/(\?|&|#[^!])/g, "$1")
22271
- .replace(/\?/g, "&")
22272
- .replace("&", "?");
22273
- }
22274
-
22275
22184
  function isTerminatedError(error) {
22276
22185
  return error instanceof Error && error.message === "terminated" && error.name === "TypeError";
22277
22186
  }
@@ -22355,6 +22264,41 @@ function parseSSEEvent(rawEvent) {
22355
22264
  };
22356
22265
  }
22357
22266
 
22267
+ function watchStreamProgress(emitIntervalBytes) {
22268
+ let bytesProcessed = 0;
22269
+ let lastEmittedAt = 0;
22270
+ const emitter = new EventEmitter();
22271
+ const stream = new Transform({
22272
+ transform(chunk, _encoding, callback) {
22273
+ bytesProcessed += chunk.length;
22274
+ // Emit progress updates at intervals
22275
+ if (bytesProcessed - lastEmittedAt >= emitIntervalBytes) {
22276
+ emitter.emit("progress", bytesProcessed);
22277
+ lastEmittedAt = bytesProcessed;
22278
+ }
22279
+ // Pass chunk through unchanged
22280
+ callback(null, chunk);
22281
+ },
22282
+ flush(callback) {
22283
+ emitter.emit("progress", bytesProcessed);
22284
+ callback();
22285
+ }
22286
+ });
22287
+ stream.progress = emitter;
22288
+ return stream;
22289
+ }
22290
+
22291
+ function joinURL(...parts) {
22292
+ return parts
22293
+ .join("/")
22294
+ .replace(/[\/]+/g, "/")
22295
+ .replace(/^(.+):\//, "$1://")
22296
+ .replace(/^file:/, "file:/")
22297
+ .replace(/\/(\?|&|#[^!])/g, "$1")
22298
+ .replace(/\?/g, "&")
22299
+ .replace("&", "?");
22300
+ }
22301
+
22358
22302
  function buildConfigurationOverrides(options) {
22359
22303
  const configurationOverrides = {};
22360
22304
  if (options.apiUrl) {
@@ -114221,51 +114165,6 @@ async function createEngineProcess({ args, bin, logger }) {
114221
114165
  return processManager;
114222
114166
  }
114223
114167
 
114224
- function parseExtraArgs(extraArgs) {
114225
- if (!Array.isArray(extraArgs) ||
114226
- !extraArgs.every((value) => typeof value === "string")) {
114227
- return [];
114228
- }
114229
- return extraArgs.flatMap(tokenizeShellLine);
114230
- }
114231
- function tokenizeShellLine(input) {
114232
- const tokens = [];
114233
- let buffer = "";
114234
- let inQuote = null;
114235
- let hasBuffer = false;
114236
- for (let index = 0; index < input.length; index += 1) {
114237
- const char = input[index];
114238
- if (inQuote) {
114239
- if (char === inQuote) {
114240
- inQuote = null;
114241
- }
114242
- else {
114243
- buffer += char;
114244
- }
114245
- hasBuffer = true;
114246
- }
114247
- else if (char === '"' || char === "'") {
114248
- inQuote = char;
114249
- hasBuffer = true;
114250
- }
114251
- else if (char === " " || char === "\t") {
114252
- if (hasBuffer) {
114253
- tokens.push(buffer);
114254
- buffer = "";
114255
- hasBuffer = false;
114256
- }
114257
- }
114258
- else {
114259
- buffer += char;
114260
- hasBuffer = true;
114261
- }
114262
- }
114263
- if (hasBuffer) {
114264
- tokens.push(buffer);
114265
- }
114266
- return tokens;
114267
- }
114268
-
114269
114168
  const balanced = (a, b, str) => {
114270
114169
  const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
114271
114170
  const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
@@ -122669,9 +122568,8 @@ async function startVLLM({ enginePort, targetDirectory }) {
122669
122568
  modelPath = await findQuantizedModelTarget({ model: this.model, path: targetDirectory });
122670
122569
  }
122671
122570
  const engineConfig = this.engineConfig;
122672
- const device = typeof engineConfig?.device === "string" ? engineConfig.device : process.env.VLLM_DEVICE;
122673
- const dtype = typeof engineConfig?.dtype === "string" ? engineConfig.dtype : process.env.VLLM_DTYPE;
122674
- const tensorParallelSize = typeof engineConfig?.tensorParallelSize === "number" ? engineConfig.tensorParallelSize : 1;
122571
+ const device = process.env.VLLM_DEVICE;
122572
+ const dtype = process.env.VLLM_DTYPE;
122675
122573
  const args = [
122676
122574
  ...VLLM_START_ARGS,
122677
122575
  "--port",
@@ -122681,9 +122579,7 @@ async function startVLLM({ enginePort, targetDirectory }) {
122681
122579
  "--served-model-name",
122682
122580
  SERVED_MODEL_NAME,
122683
122581
  "--max-model-len",
122684
- String(contextLength),
122685
- "--tensor-parallel-size",
122686
- String(tensorParallelSize)
122582
+ String(contextLength)
122687
122583
  ];
122688
122584
  if (this.model.taskType === "embeddings") {
122689
122585
  args.push("--task", "embed");
@@ -123253,9 +123149,6 @@ const DEFAULT_EXLLAMAV3_CONTEXT_LENGTH = 4096;
123253
123149
  async function startExllamav3({ enginePort, targetDirectory }) {
123254
123150
  const contextLength = Math.max(1, this.contextLength ?? DEFAULT_EXLLAMAV3_CONTEXT_LENGTH);
123255
123151
  const engineConfig = this.engineConfig;
123256
- const cacheMode = typeof engineConfig?.cacheMode === "string" ? engineConfig.cacheMode : "q4";
123257
- const gpuSplit = typeof engineConfig?.gpuSplit === "string" ? engineConfig.gpuSplit : null;
123258
- const maxSeqLen = typeof engineConfig?.maxSeqLen === "number" ? engineConfig.maxSeqLen : contextLength;
123259
123152
  const args = [
123260
123153
  SERVER_SCRIPT,
123261
123154
  "--model",
@@ -123264,20 +123157,15 @@ async function startExllamav3({ enginePort, targetDirectory }) {
123264
123157
  "127.0.0.1",
123265
123158
  "--port",
123266
123159
  String(enginePort),
123267
- "--cache-mode",
123268
- cacheMode,
123269
123160
  "--max-seq-len",
123270
- String(maxSeqLen)
123161
+ String(contextLength)
123271
123162
  ];
123272
- if (gpuSplit) {
123273
- args.push("--gpu-split", gpuSplit);
123274
- }
123275
123163
  args.push(...parseExtraArgs(engineConfig?.extraArgs));
123276
123164
  return createEngineProcess({ args, bin: EXLLAMAV3_EXECUTABLE, logger: this.logger });
123277
123165
  }
123278
123166
 
123279
123167
  const DEFAULT_LLAMACPP_GPU_LAYERS = 999;
123280
- const LLAMACPP_START_ARGS = ["--host", "0.0.0.0", "--jinja"];
123168
+ const LLAMACPP_START_ARGS = ["--host", "0.0.0.0", "--jinja", "--flash-attn", "on"];
123281
123169
  const LLAMACPP_EXECUTABLE = process.env.LLAMACPP_EXECUTABLE ?? "llama-server";
123282
123170
  const DEFAULT_LLAMACPP_CONTEXT_LENGTH = 131072;
123283
123171
  async function findMultimodalProjector({ path }) {
@@ -123299,7 +123187,6 @@ async function startLlamacpp({ enginePort, targetDirectory }) {
123299
123187
  const target = await findQuantizedModelTarget({ model: this.model, path: targetDirectory });
123300
123188
  const contextLength = Math.max(1, this.contextLength ?? DEFAULT_LLAMACPP_CONTEXT_LENGTH);
123301
123189
  const engineConfig = this.engineConfig;
123302
- const parallelism = typeof engineConfig?.parallelism === "number" ? engineConfig.parallelism : null;
123303
123190
  const args = [
123304
123191
  ...LLAMACPP_START_ARGS,
123305
123192
  "--port",
@@ -123317,43 +123204,10 @@ async function startLlamacpp({ enginePort, targetDirectory }) {
123317
123204
  if (this.model.taskType === "embeddings") {
123318
123205
  args.push("--embedding");
123319
123206
  }
123320
- const gpuLayers = typeof engineConfig?.gpuLayers === "number"
123321
- ? engineConfig.gpuLayers
123322
- : Number.parseInt(process.env.LLAMACPP_GPU_LAYERS ?? String(DEFAULT_LLAMACPP_GPU_LAYERS), 10);
123207
+ const gpuLayers = Number.parseInt(process.env.LLAMACPP_GPU_LAYERS ?? String(DEFAULT_LLAMACPP_GPU_LAYERS), 10);
123323
123208
  if (Number.isFinite(gpuLayers) && gpuLayers > 0) {
123324
123209
  args.push("--n-gpu-layers", String(gpuLayers));
123325
123210
  }
123326
- if (typeof parallelism === "number") {
123327
- args.push("--parallel", String(Math.max(1, parallelism)));
123328
- }
123329
- const flashAttn = engineConfig?.flashAttn;
123330
- if (flashAttn === true || flashAttn === undefined) {
123331
- args.push("--flash-attn", "on");
123332
- }
123333
- const cacheTypeK = typeof engineConfig?.cacheTypeK === "string" ? engineConfig.cacheTypeK : null;
123334
- if (cacheTypeK) {
123335
- args.push("--cache-type-k", cacheTypeK);
123336
- }
123337
- const cacheTypeV = typeof engineConfig?.cacheTypeV === "string" ? engineConfig.cacheTypeV : null;
123338
- if (cacheTypeV) {
123339
- args.push("--cache-type-v", cacheTypeV);
123340
- }
123341
- const batchSize = typeof engineConfig?.batchSize === "number" ? engineConfig.batchSize : null;
123342
- if (batchSize !== null) {
123343
- args.push("--batch-size", String(batchSize));
123344
- }
123345
- const ubatchSize = typeof engineConfig?.ubatchSize === "number" ? engineConfig.ubatchSize : null;
123346
- if (ubatchSize !== null) {
123347
- args.push("--ubatch-size", String(ubatchSize));
123348
- }
123349
- const tensorSplit = typeof engineConfig?.tensorSplit === "string" ? engineConfig.tensorSplit : null;
123350
- if (tensorSplit) {
123351
- args.push("--tensor-split", tensorSplit);
123352
- }
123353
- const mainGpu = typeof engineConfig?.mainGpu === "number" ? engineConfig.mainGpu : null;
123354
- if (mainGpu !== null) {
123355
- args.push("--main-gpu", String(mainGpu));
123356
- }
123357
123211
  args.push(...parseExtraArgs(engineConfig?.extraArgs));
123358
123212
  if (this.model.multimodalEnabled) {
123359
123213
  const projector = await findMultimodalProjector({ path: targetDirectory });
@@ -123392,12 +123246,7 @@ async function startMLXLM({ enginePort, targetDirectory }) {
123392
123246
  "--context-length",
123393
123247
  String(contextLength)
123394
123248
  ];
123395
- const maxKvSize = typeof engineConfig?.maxKvSize === "number" ? engineConfig.maxKvSize : null;
123396
- if (maxKvSize !== null) {
123397
- args.push("--max-kv-size", String(maxKvSize));
123398
- }
123399
- const trustRemoteCode = engineConfig?.trustRemoteCode === true;
123400
- if (trustRemoteCode || process.env.MLXLM_TRUST_REMOTE_CODE === "true") {
123249
+ if (process.env.MLXLM_TRUST_REMOTE_CODE === "true") {
123401
123250
  args.push("--trust-remote-code");
123402
123251
  }
123403
123252
  args.push(...parseExtraArgs(engineConfig?.extraArgs));
@@ -123434,9 +123283,6 @@ const DEFAULT_SGLANG_CONTEXT_LENGTH = 2048;
123434
123283
  async function startSGLang({ enginePort, targetDirectory }) {
123435
123284
  const contextLength = Math.max(1, this.contextLength ?? DEFAULT_SGLANG_CONTEXT_LENGTH);
123436
123285
  const engineConfig = this.engineConfig;
123437
- const device = typeof engineConfig?.device === "string" ? engineConfig.device : undefined;
123438
- const dtype = typeof engineConfig?.dtype === "string" ? engineConfig.dtype : undefined;
123439
- const tensorParallelSize = typeof engineConfig?.tensorParallelSize === "number" ? engineConfig.tensorParallelSize : 1;
123440
123286
  const args = [
123441
123287
  ...SGLANG_START_ARGS,
123442
123288
  "--port",
@@ -123446,9 +123292,7 @@ async function startSGLang({ enginePort, targetDirectory }) {
123446
123292
  "--served-model-name",
123447
123293
  SERVED_MODEL_NAME,
123448
123294
  "--context-length",
123449
- String(contextLength),
123450
- "--tp-size",
123451
- String(tensorParallelSize)
123295
+ String(contextLength)
123452
123296
  ];
123453
123297
  if (this.model.taskType === "embeddings") {
123454
123298
  args.push("--task", "embed");
@@ -123458,12 +123302,6 @@ async function startSGLang({ enginePort, targetDirectory }) {
123458
123302
  model: this.model,
123459
123303
  targetDirectory
123460
123304
  })));
123461
- if (device) {
123462
- args.push("--device", device);
123463
- }
123464
- if (dtype) {
123465
- args.push("--dtype", dtype);
123466
- }
123467
123305
  args.push(...parseExtraArgs(engineConfig?.extraArgs));
123468
123306
  if (this.model.multimodalEnabled) {
123469
123307
  args.push("--limit-mm-per-prompt", process.env.SGLANG_MM_LIMIT ?? '{"image":5}');
@@ -123479,9 +123317,6 @@ const DEFAULT_TRTLLM_CONTEXT_LENGTH = 2048;
123479
123317
  async function startTensorRTLLM({ enginePort, targetDirectory }) {
123480
123318
  const contextLength = Math.max(1, this.contextLength ?? DEFAULT_TRTLLM_CONTEXT_LENGTH);
123481
123319
  const engineConfig = this.engineConfig;
123482
- const backend = typeof engineConfig?.backend === "string" ? engineConfig.backend : "pytorch";
123483
- const dtype = typeof engineConfig?.dtype === "string" ? engineConfig.dtype : undefined;
123484
- const tensorParallelSize = typeof engineConfig?.tensorParallelSize === "number" ? engineConfig.tensorParallelSize : 1;
123485
123320
  const args = [
123486
123321
  "serve",
123487
123322
  targetDirectory,
@@ -123489,19 +123324,12 @@ async function startTensorRTLLM({ enginePort, targetDirectory }) {
123489
123324
  "127.0.0.1",
123490
123325
  "--port",
123491
123326
  String(enginePort),
123492
- "--backend",
123493
- backend,
123494
123327
  "--max-seq-len",
123495
- String(contextLength),
123496
- "--tp-size",
123497
- String(tensorParallelSize)
123328
+ String(contextLength)
123498
123329
  ];
123499
123330
  if (this.model.taskType === "embeddings") {
123500
123331
  args.push("--task", "embed");
123501
123332
  }
123502
- if (dtype) {
123503
- args.push("--dtype", dtype);
123504
- }
123505
123333
  args.push(...parseExtraArgs(engineConfig?.extraArgs));
123506
123334
  return createEngineProcess({ args, bin: TRTLLM_EXECUTABLE, logger: this.logger });
123507
123335
  }
@@ -124720,7 +124548,7 @@ async function proxyEmbeddingsRoute({ body, conduitConfiguration, endpointId, lo
124720
124548
  });
124721
124549
  }
124722
124550
  const engineType = conduitConfiguration.engineConfig?.type ?? null;
124723
- const engineConfig = conduitConfiguration.engineConfig?.config ?? null;
124551
+ const engineConfig = conduitConfiguration.engineConfig ?? null;
124724
124552
  const serializedBody = isPlainObject$3(body)
124725
124553
  ? JSON.stringify(body)
124726
124554
  : typeof body === "string"
@@ -124864,7 +124692,7 @@ async function proxyOpenAIStreamingRoute({ body, conduitConfiguration, endpointI
124864
124692
  });
124865
124693
  }
124866
124694
  const engineType = conduitConfiguration.engineConfig?.type ?? null;
124867
- const engineConfig = conduitConfiguration.engineConfig?.config ?? null;
124695
+ const engineConfig = conduitConfiguration.engineConfig ?? null;
124868
124696
  const effectiveBody = modelManager.model.multimodalEnabled ? body : stripImagesFromBody(body);
124869
124697
  const { bytes: requestBodyBytes, payload: serializedBody } = serializeRequestBody$1(effectiveBody, { model: modelManager.model, path });
124870
124698
  const requestStartedAt = Date.now();
@@ -125113,7 +124941,7 @@ function createConduitOpenAIAPIReferenceHandlers({ apiClient, conduitConfigurati
125113
124941
  const currentConfig = conduitConfiguration();
125114
124942
  const effectiveContextLength = getEffectiveContextLength({
125115
124943
  contextLength: modelManager.contextLength,
125116
- engineConfig: currentConfig.engineConfig?.config ?? null,
124944
+ engineConfig: currentConfig.engineConfig ?? null,
125117
124945
  engineType: currentConfig.engineConfig?.type ?? null
125118
124946
  });
125119
124947
  return {
@@ -136580,7 +136408,9 @@ function createModelManagerFromConfig(conduitConfiguration, configuration, logge
136580
136408
  const engineConfig = conduitConfiguration.engineConfig;
136581
136409
  return new ModelManager({
136582
136410
  contextLength: conduitConfiguration.contextLength ?? null,
136583
- engineConfig: engineConfig?.config ?? null,
136411
+ engineConfig: engineConfig
136412
+ ? { extraArgs: engineConfig.extraArgs, type: engineConfig.type }
136413
+ : null,
136584
136414
  enginePort: configuration.enginePort,
136585
136415
  engineType: engineConfig?.type ?? "llama.cpp",
136586
136416
  logger,
package/dist/cli.sea.cjs CHANGED
@@ -4360,35 +4360,6 @@ function ulid$2(seedTime, prng) {
4360
4360
  return encodeTime(seed, TIME_LEN) + encodeRandom(RANDOM_LEN, currentPRNG);
4361
4361
  }
4362
4362
 
4363
- function getEffectiveContextLength({ contextLength, engineConfig, engineType }) {
4364
- if (contextLength === null || contextLength <= 0) {
4365
- return null;
4366
- }
4367
- if (!engineConfig) {
4368
- return contextLength;
4369
- }
4370
- switch (engineType) {
4371
- case "llama.cpp": {
4372
- const parallelism = engineConfig.parallelism;
4373
- if (typeof parallelism === "number" && parallelism > 0) {
4374
- return contextLength / parallelism;
4375
- }
4376
- return contextLength;
4377
- }
4378
- case "sglang":
4379
- case "tensorrt-llm":
4380
- case "vllm": {
4381
- const tensorParallelSize = engineConfig.tensorParallelSize;
4382
- if (typeof tensorParallelSize === "number" && tensorParallelSize > 0) {
4383
- return contextLength / tensorParallelSize;
4384
- }
4385
- return contextLength;
4386
- }
4387
- default:
4388
- return contextLength;
4389
- }
4390
- }
4391
-
4392
4363
  function asError(error) {
4393
4364
  if (error instanceof Error) {
4394
4365
  return error;
@@ -19929,58 +19900,10 @@ const LLMEngineSchema = _enum$1([
19929
19900
  "tensorrt-llm",
19930
19901
  "vllm"
19931
19902
  ]);
19932
- const LlamacppEngineConfigSchema = object$1({
19933
- batchSize: number$1().int().positive().nullable().optional(),
19934
- cacheTypeK: string$2().nullable().optional(),
19935
- cacheTypeV: string$2().nullable().optional(),
19936
- extraArgs: array(string$2()).optional(),
19937
- flashAttn: boolean$1().optional(),
19938
- gpuLayers: number$1().int().min(0).optional(),
19939
- mainGpu: number$1().int().min(0).nullable().optional(),
19940
- parallelism: number$1().int().positive().optional(),
19941
- tensorSplit: string$2().nullable().optional(),
19942
- ubatchSize: number$1().int().positive().nullable().optional()
19943
- });
19944
- const VLLMEngineConfigSchema = object$1({
19945
- device: string$2().optional(),
19946
- dtype: string$2().optional(),
19947
- extraArgs: array(string$2()).optional(),
19948
- tensorParallelSize: number$1().int().positive().optional()
19949
- });
19950
- const SGLangEngineConfigSchema = object$1({
19951
- device: string$2().optional(),
19952
- dtype: string$2().optional(),
19953
- extraArgs: array(string$2()).optional(),
19954
- tensorParallelSize: number$1().int().positive().optional()
19955
- });
19956
- const TensorRTLLMEngineConfigSchema = object$1({
19957
- backend: _enum$1(["_autodeploy", "pytorch", "tensorrt"]).optional(),
19958
- dtype: string$2().optional(),
19959
- extraArgs: array(string$2()).optional(),
19960
- tensorParallelSize: number$1().int().positive().optional()
19961
- });
19962
- const Exllamav3EngineConfigSchema = object$1({
19963
- cacheMode: _enum$1(["fp16", "q4", "q6", "q8"]).optional(),
19964
- extraArgs: array(string$2()).optional(),
19965
- gpuSplit: string$2().optional(),
19966
- maxSeqLen: number$1().int().positive().optional()
19967
- });
19968
- const MLXLMEngineConfigSchema = object$1({
19969
- extraArgs: array(string$2()).optional(),
19970
- maxKvSize: number$1().int().positive().optional(),
19971
- trustRemoteCode: boolean$1().optional()
19903
+ const EngineConfigSchema = object$1({
19904
+ extraArgs: array(string$2()),
19905
+ type: LLMEngineSchema
19972
19906
  });
19973
- const EngineConfigSchema = discriminatedUnion("type", [
19974
- object$1({ config: Exllamav3EngineConfigSchema, type: literal("exllamav3") }),
19975
- object$1({ config: LlamacppEngineConfigSchema, type: literal("llama.cpp") }),
19976
- object$1({ config: MLXLMEngineConfigSchema, type: literal("mlx-lm") }),
19977
- object$1({ config: SGLangEngineConfigSchema, type: literal("sglang") }),
19978
- object$1({
19979
- config: TensorRTLLMEngineConfigSchema,
19980
- type: literal("tensorrt-llm")
19981
- }),
19982
- object$1({ config: VLLMEngineConfigSchema, type: literal("vllm") })
19983
- ]);
19984
19907
  const LLMModelFormatSchema = _enum$1([
19985
19908
  // VLLM / SGLang / TensorRT-LLM
19986
19909
  "safetensors",
@@ -21176,105 +21099,21 @@ object$1({
21176
21099
  });
21177
21100
  const EngineOutputSchema = object$1({
21178
21101
  created: string$2(),
21179
- exllamav3CacheMode: string$2().nullable(),
21180
- exllamav3ExtraArgs: array(string$2()),
21181
- exllamav3GpuSplit: string$2().nullable(),
21182
- exllamav3MaxSeqLen: number$1().nullable(),
21102
+ extraArgs: array(string$2()),
21183
21103
  id: ULIDSchema,
21184
- llamacppBatchSize: number$1().nullable(),
21185
- llamacppCacheTypeK: string$2().nullable(),
21186
- llamacppCacheTypeV: string$2().nullable(),
21187
- llamacppExtraArgs: array(string$2()),
21188
- llamacppFlashAttn: boolean$1(),
21189
- llamacppGpuLayers: number$1(),
21190
- llamacppMainGpu: number$1().nullable(),
21191
- llamacppParallelism: number$1(),
21192
- llamacppTensorSplit: string$2().nullable(),
21193
- llamacppUbatchSize: number$1().nullable(),
21194
- mlxlmExtraArgs: array(string$2()),
21195
- mlxlmMaxKvSize: number$1().nullable(),
21196
- mlxlmTrustRemoteCode: boolean$1(),
21197
21104
  name: string$2(),
21198
- sglangDevice: string$2().nullable(),
21199
- sglangDtype: string$2().nullable(),
21200
- sglangExtraArgs: array(string$2()),
21201
- sglangTensorParallelSize: number$1(),
21202
- trtllmBackend: string$2().nullable(),
21203
- trtllmDtype: string$2().nullable(),
21204
- trtllmExtraArgs: array(string$2()),
21205
- trtllmTensorParallelSize: number$1(),
21206
21105
  type: LLMEngineSchema,
21207
- updated: string$2(),
21208
- vllmDevice: string$2().nullable(),
21209
- vllmDtype: string$2().nullable(),
21210
- vllmExtraArgs: array(string$2()),
21211
- vllmTensorParallelSize: number$1()
21106
+ updated: string$2()
21212
21107
  });
21213
21108
  object$1({
21214
- exllamav3CacheMode: string$2().nullable().optional(),
21215
- exllamav3ExtraArgs: array(string$2()).optional(),
21216
- exllamav3GpuSplit: string$2().nullable().optional(),
21217
- exllamav3MaxSeqLen: number$1().int().positive().nullable().optional(),
21218
- llamacppBatchSize: number$1().int().positive().nullable().optional(),
21219
- llamacppCacheTypeK: string$2().nullable().optional(),
21220
- llamacppCacheTypeV: string$2().nullable().optional(),
21221
- llamacppExtraArgs: array(string$2()).optional(),
21222
- llamacppFlashAttn: boolean$1().optional(),
21223
- llamacppGpuLayers: number$1().int().min(0).optional(),
21224
- llamacppMainGpu: number$1().int().min(0).nullable().optional(),
21225
- llamacppParallelism: number$1().int().positive().optional(),
21226
- llamacppTensorSplit: string$2().nullable().optional(),
21227
- llamacppUbatchSize: number$1().int().positive().nullable().optional(),
21228
- mlxlmExtraArgs: array(string$2()).optional(),
21229
- mlxlmMaxKvSize: number$1().int().positive().nullable().optional(),
21230
- mlxlmTrustRemoteCode: boolean$1().optional(),
21109
+ extraArgs: array(string$2()).optional(),
21231
21110
  name: ResourceNameSchema,
21232
- sglangDevice: string$2().nullable().optional(),
21233
- sglangDtype: string$2().nullable().optional(),
21234
- sglangExtraArgs: array(string$2()).optional(),
21235
- sglangTensorParallelSize: number$1().int().positive().optional(),
21236
- trtllmBackend: string$2().nullable().optional(),
21237
- trtllmDtype: string$2().nullable().optional(),
21238
- trtllmExtraArgs: array(string$2()).optional(),
21239
- trtllmTensorParallelSize: number$1().int().positive().optional(),
21240
- type: LLMEngineSchema,
21241
- vllmDevice: string$2().nullable().optional(),
21242
- vllmDtype: string$2().nullable().optional(),
21243
- vllmExtraArgs: array(string$2()).optional(),
21244
- vllmTensorParallelSize: number$1().int().positive().optional()
21111
+ type: LLMEngineSchema
21245
21112
  });
21246
21113
  object$1({
21247
- exllamav3CacheMode: string$2().nullable().optional(),
21248
- exllamav3ExtraArgs: array(string$2()).optional(),
21249
- exllamav3GpuSplit: string$2().nullable().optional(),
21250
- exllamav3MaxSeqLen: number$1().int().positive().nullable().optional(),
21251
- llamacppBatchSize: number$1().int().positive().nullable().optional(),
21252
- llamacppCacheTypeK: string$2().nullable().optional(),
21253
- llamacppCacheTypeV: string$2().nullable().optional(),
21254
- llamacppExtraArgs: array(string$2()).optional(),
21255
- llamacppFlashAttn: boolean$1().optional(),
21256
- llamacppGpuLayers: number$1().int().min(0).optional(),
21257
- llamacppMainGpu: number$1().int().min(0).nullable().optional(),
21258
- llamacppParallelism: number$1().int().positive().optional(),
21259
- llamacppTensorSplit: string$2().nullable().optional(),
21260
- llamacppUbatchSize: number$1().int().positive().nullable().optional(),
21261
- mlxlmExtraArgs: array(string$2()).optional(),
21262
- mlxlmMaxKvSize: number$1().int().positive().nullable().optional(),
21263
- mlxlmTrustRemoteCode: boolean$1().optional(),
21114
+ extraArgs: array(string$2()).optional(),
21264
21115
  name: ResourceNameSchema.optional(),
21265
- sglangDevice: string$2().nullable().optional(),
21266
- sglangDtype: string$2().nullable().optional(),
21267
- sglangExtraArgs: array(string$2()).optional(),
21268
- sglangTensorParallelSize: number$1().int().positive().optional(),
21269
- trtllmBackend: string$2().nullable().optional(),
21270
- trtllmDtype: string$2().nullable().optional(),
21271
- trtllmExtraArgs: array(string$2()).optional(),
21272
- trtllmTensorParallelSize: number$1().int().positive().optional(),
21273
- type: LLMEngineSchema.optional(),
21274
- vllmDevice: string$2().nullable().optional(),
21275
- vllmDtype: string$2().nullable().optional(),
21276
- vllmExtraArgs: array(string$2()).optional(),
21277
- vllmTensorParallelSize: number$1().int().positive().optional()
21116
+ type: LLMEngineSchema.optional()
21278
21117
  });
21279
21118
  object$1({
21280
21119
  results: array(EngineOutputSchema)
@@ -21351,6 +21190,12 @@ object$1({
21351
21190
  }
21352
21191
  });
21353
21192
 
21193
+ object$1({
21194
+ config: EngineConfigSchema,
21195
+ description: string$2().optional(),
21196
+ name: ResourceNameSchema
21197
+ });
21198
+
21354
21199
  const ENGINE_API_COMPATIBILITY = {
21355
21200
  exllamav3: {
21356
21201
  nativeAnthropicMessages: false,
@@ -21769,6 +21614,105 @@ discriminatedUnion("chargeName", [
21769
21614
  ToolServiceCallMetaSchema
21770
21615
  ]);
21771
21616
 
21617
+ function parseExtraArgs(extraArgs) {
21618
+ if (!Array.isArray(extraArgs) ||
21619
+ !extraArgs.every((value) => typeof value === "string")) {
21620
+ return [];
21621
+ }
21622
+ return extraArgs.flatMap(tokenizeShellLine);
21623
+ }
21624
+ function findArgValue(args, flag) {
21625
+ let found = null;
21626
+ for (let index = 0; index < args.length; index += 1) {
21627
+ const token = args[index];
21628
+ if (token === flag) {
21629
+ const value = args[index + 1];
21630
+ if (value !== undefined && !value.startsWith("--")) {
21631
+ found = value;
21632
+ }
21633
+ else {
21634
+ found = null;
21635
+ }
21636
+ }
21637
+ else if (token.startsWith(`${flag}=`)) {
21638
+ found = token.slice(flag.length + 1);
21639
+ }
21640
+ }
21641
+ return found;
21642
+ }
21643
+ function tokenizeShellLine(input) {
21644
+ const tokens = [];
21645
+ let buffer = "";
21646
+ let inQuote = null;
21647
+ let hasBuffer = false;
21648
+ for (let index = 0; index < input.length; index += 1) {
21649
+ const char = input[index];
21650
+ if (inQuote) {
21651
+ if (char === inQuote) {
21652
+ inQuote = null;
21653
+ }
21654
+ else {
21655
+ buffer += char;
21656
+ }
21657
+ hasBuffer = true;
21658
+ }
21659
+ else if (char === '"' || char === "'") {
21660
+ inQuote = char;
21661
+ hasBuffer = true;
21662
+ }
21663
+ else if (char === " " || char === "\t") {
21664
+ if (hasBuffer) {
21665
+ tokens.push(buffer);
21666
+ buffer = "";
21667
+ hasBuffer = false;
21668
+ }
21669
+ }
21670
+ else {
21671
+ buffer += char;
21672
+ hasBuffer = true;
21673
+ }
21674
+ }
21675
+ if (hasBuffer) {
21676
+ tokens.push(buffer);
21677
+ }
21678
+ return tokens;
21679
+ }
21680
+
21681
+ function getEffectiveContextLength({ contextLength, engineConfig, engineType }) {
21682
+ if (contextLength === null || contextLength <= 0) {
21683
+ return null;
21684
+ }
21685
+ if (!engineConfig) {
21686
+ return contextLength;
21687
+ }
21688
+ let divisorFlag = null;
21689
+ switch (engineType) {
21690
+ case "llama.cpp":
21691
+ divisorFlag = "--parallel";
21692
+ break;
21693
+ case "sglang":
21694
+ case "tensorrt-llm":
21695
+ divisorFlag = "--tp-size";
21696
+ break;
21697
+ case "vllm":
21698
+ divisorFlag = "--tensor-parallel-size";
21699
+ break;
21700
+ }
21701
+ if (!divisorFlag) {
21702
+ return contextLength;
21703
+ }
21704
+ const tokens = parseExtraArgs(engineConfig.extraArgs);
21705
+ const rawValue = findArgValue(tokens, divisorFlag);
21706
+ if (rawValue === null) {
21707
+ return contextLength;
21708
+ }
21709
+ const divisor = Number(rawValue);
21710
+ if (Number.isSafeInteger(divisor) && divisor > 0) {
21711
+ return contextLength / divisor;
21712
+ }
21713
+ return contextLength;
21714
+ }
21715
+
21772
21716
  const ENV_BOOL_TRUE = ["true", "1", "yes"];
21773
21717
  const ENV_BOOL_FALSE = ["false", "0", "no"];
21774
21718
  function readEnvBoolean(name) {
@@ -22252,41 +22196,6 @@ class ProcessManager extends EventEmitter {
22252
22196
  }
22253
22197
  }
22254
22198
 
22255
- function watchStreamProgress(emitIntervalBytes) {
22256
- let bytesProcessed = 0;
22257
- let lastEmittedAt = 0;
22258
- const emitter = new EventEmitter();
22259
- const stream = new require$$0$8.Transform({
22260
- transform(chunk, _encoding, callback) {
22261
- bytesProcessed += chunk.length;
22262
- // Emit progress updates at intervals
22263
- if (bytesProcessed - lastEmittedAt >= emitIntervalBytes) {
22264
- emitter.emit("progress", bytesProcessed);
22265
- lastEmittedAt = bytesProcessed;
22266
- }
22267
- // Pass chunk through unchanged
22268
- callback(null, chunk);
22269
- },
22270
- flush(callback) {
22271
- emitter.emit("progress", bytesProcessed);
22272
- callback();
22273
- }
22274
- });
22275
- stream.progress = emitter;
22276
- return stream;
22277
- }
22278
-
22279
- function joinURL(...parts) {
22280
- return parts
22281
- .join("/")
22282
- .replace(/[\/]+/g, "/")
22283
- .replace(/^(.+):\//, "$1://")
22284
- .replace(/^file:/, "file:/")
22285
- .replace(/\/(\?|&|#[^!])/g, "$1")
22286
- .replace(/\?/g, "&")
22287
- .replace("&", "?");
22288
- }
22289
-
22290
22199
  function isTerminatedError(error) {
22291
22200
  return error instanceof Error && error.message === "terminated" && error.name === "TypeError";
22292
22201
  }
@@ -22370,6 +22279,41 @@ function parseSSEEvent(rawEvent) {
22370
22279
  };
22371
22280
  }
22372
22281
 
22282
+ function watchStreamProgress(emitIntervalBytes) {
22283
+ let bytesProcessed = 0;
22284
+ let lastEmittedAt = 0;
22285
+ const emitter = new EventEmitter();
22286
+ const stream = new require$$0$8.Transform({
22287
+ transform(chunk, _encoding, callback) {
22288
+ bytesProcessed += chunk.length;
22289
+ // Emit progress updates at intervals
22290
+ if (bytesProcessed - lastEmittedAt >= emitIntervalBytes) {
22291
+ emitter.emit("progress", bytesProcessed);
22292
+ lastEmittedAt = bytesProcessed;
22293
+ }
22294
+ // Pass chunk through unchanged
22295
+ callback(null, chunk);
22296
+ },
22297
+ flush(callback) {
22298
+ emitter.emit("progress", bytesProcessed);
22299
+ callback();
22300
+ }
22301
+ });
22302
+ stream.progress = emitter;
22303
+ return stream;
22304
+ }
22305
+
22306
+ function joinURL(...parts) {
22307
+ return parts
22308
+ .join("/")
22309
+ .replace(/[\/]+/g, "/")
22310
+ .replace(/^(.+):\//, "$1://")
22311
+ .replace(/^file:/, "file:/")
22312
+ .replace(/\/(\?|&|#[^!])/g, "$1")
22313
+ .replace(/\?/g, "&")
22314
+ .replace("&", "?");
22315
+ }
22316
+
22373
22317
  function buildConfigurationOverrides(options) {
22374
22318
  const configurationOverrides = {};
22375
22319
  if (options.apiUrl) {
@@ -114236,51 +114180,6 @@ async function createEngineProcess({ args, bin, logger }) {
114236
114180
  return processManager;
114237
114181
  }
114238
114182
 
114239
- function parseExtraArgs(extraArgs) {
114240
- if (!Array.isArray(extraArgs) ||
114241
- !extraArgs.every((value) => typeof value === "string")) {
114242
- return [];
114243
- }
114244
- return extraArgs.flatMap(tokenizeShellLine);
114245
- }
114246
- function tokenizeShellLine(input) {
114247
- const tokens = [];
114248
- let buffer = "";
114249
- let inQuote = null;
114250
- let hasBuffer = false;
114251
- for (let index = 0; index < input.length; index += 1) {
114252
- const char = input[index];
114253
- if (inQuote) {
114254
- if (char === inQuote) {
114255
- inQuote = null;
114256
- }
114257
- else {
114258
- buffer += char;
114259
- }
114260
- hasBuffer = true;
114261
- }
114262
- else if (char === '"' || char === "'") {
114263
- inQuote = char;
114264
- hasBuffer = true;
114265
- }
114266
- else if (char === " " || char === "\t") {
114267
- if (hasBuffer) {
114268
- tokens.push(buffer);
114269
- buffer = "";
114270
- hasBuffer = false;
114271
- }
114272
- }
114273
- else {
114274
- buffer += char;
114275
- hasBuffer = true;
114276
- }
114277
- }
114278
- if (hasBuffer) {
114279
- tokens.push(buffer);
114280
- }
114281
- return tokens;
114282
- }
114283
-
114284
114183
  const balanced = (a, b, str) => {
114285
114184
  const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
114286
114185
  const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
@@ -122684,9 +122583,8 @@ async function startVLLM({ enginePort, targetDirectory }) {
122684
122583
  modelPath = await findQuantizedModelTarget({ model: this.model, path: targetDirectory });
122685
122584
  }
122686
122585
  const engineConfig = this.engineConfig;
122687
- const device = typeof engineConfig?.device === "string" ? engineConfig.device : process.env.VLLM_DEVICE;
122688
- const dtype = typeof engineConfig?.dtype === "string" ? engineConfig.dtype : process.env.VLLM_DTYPE;
122689
- const tensorParallelSize = typeof engineConfig?.tensorParallelSize === "number" ? engineConfig.tensorParallelSize : 1;
122586
+ const device = process.env.VLLM_DEVICE;
122587
+ const dtype = process.env.VLLM_DTYPE;
122690
122588
  const args = [
122691
122589
  ...VLLM_START_ARGS,
122692
122590
  "--port",
@@ -122696,9 +122594,7 @@ async function startVLLM({ enginePort, targetDirectory }) {
122696
122594
  "--served-model-name",
122697
122595
  SERVED_MODEL_NAME,
122698
122596
  "--max-model-len",
122699
- String(contextLength),
122700
- "--tensor-parallel-size",
122701
- String(tensorParallelSize)
122597
+ String(contextLength)
122702
122598
  ];
122703
122599
  if (this.model.taskType === "embeddings") {
122704
122600
  args.push("--task", "embed");
@@ -123268,9 +123164,6 @@ const DEFAULT_EXLLAMAV3_CONTEXT_LENGTH = 4096;
123268
123164
  async function startExllamav3({ enginePort, targetDirectory }) {
123269
123165
  const contextLength = Math.max(1, this.contextLength ?? DEFAULT_EXLLAMAV3_CONTEXT_LENGTH);
123270
123166
  const engineConfig = this.engineConfig;
123271
- const cacheMode = typeof engineConfig?.cacheMode === "string" ? engineConfig.cacheMode : "q4";
123272
- const gpuSplit = typeof engineConfig?.gpuSplit === "string" ? engineConfig.gpuSplit : null;
123273
- const maxSeqLen = typeof engineConfig?.maxSeqLen === "number" ? engineConfig.maxSeqLen : contextLength;
123274
123167
  const args = [
123275
123168
  SERVER_SCRIPT,
123276
123169
  "--model",
@@ -123279,20 +123172,15 @@ async function startExllamav3({ enginePort, targetDirectory }) {
123279
123172
  "127.0.0.1",
123280
123173
  "--port",
123281
123174
  String(enginePort),
123282
- "--cache-mode",
123283
- cacheMode,
123284
123175
  "--max-seq-len",
123285
- String(maxSeqLen)
123176
+ String(contextLength)
123286
123177
  ];
123287
- if (gpuSplit) {
123288
- args.push("--gpu-split", gpuSplit);
123289
- }
123290
123178
  args.push(...parseExtraArgs(engineConfig?.extraArgs));
123291
123179
  return createEngineProcess({ args, bin: EXLLAMAV3_EXECUTABLE, logger: this.logger });
123292
123180
  }
123293
123181
 
123294
123182
  const DEFAULT_LLAMACPP_GPU_LAYERS = 999;
123295
- const LLAMACPP_START_ARGS = ["--host", "0.0.0.0", "--jinja"];
123183
+ const LLAMACPP_START_ARGS = ["--host", "0.0.0.0", "--jinja", "--flash-attn", "on"];
123296
123184
  const LLAMACPP_EXECUTABLE = process.env.LLAMACPP_EXECUTABLE ?? "llama-server";
123297
123185
  const DEFAULT_LLAMACPP_CONTEXT_LENGTH = 131072;
123298
123186
  async function findMultimodalProjector({ path }) {
@@ -123314,7 +123202,6 @@ async function startLlamacpp({ enginePort, targetDirectory }) {
123314
123202
  const target = await findQuantizedModelTarget({ model: this.model, path: targetDirectory });
123315
123203
  const contextLength = Math.max(1, this.contextLength ?? DEFAULT_LLAMACPP_CONTEXT_LENGTH);
123316
123204
  const engineConfig = this.engineConfig;
123317
- const parallelism = typeof engineConfig?.parallelism === "number" ? engineConfig.parallelism : null;
123318
123205
  const args = [
123319
123206
  ...LLAMACPP_START_ARGS,
123320
123207
  "--port",
@@ -123332,43 +123219,10 @@ async function startLlamacpp({ enginePort, targetDirectory }) {
123332
123219
  if (this.model.taskType === "embeddings") {
123333
123220
  args.push("--embedding");
123334
123221
  }
123335
- const gpuLayers = typeof engineConfig?.gpuLayers === "number"
123336
- ? engineConfig.gpuLayers
123337
- : Number.parseInt(process.env.LLAMACPP_GPU_LAYERS ?? String(DEFAULT_LLAMACPP_GPU_LAYERS), 10);
123222
+ const gpuLayers = Number.parseInt(process.env.LLAMACPP_GPU_LAYERS ?? String(DEFAULT_LLAMACPP_GPU_LAYERS), 10);
123338
123223
  if (Number.isFinite(gpuLayers) && gpuLayers > 0) {
123339
123224
  args.push("--n-gpu-layers", String(gpuLayers));
123340
123225
  }
123341
- if (typeof parallelism === "number") {
123342
- args.push("--parallel", String(Math.max(1, parallelism)));
123343
- }
123344
- const flashAttn = engineConfig?.flashAttn;
123345
- if (flashAttn === true || flashAttn === undefined) {
123346
- args.push("--flash-attn", "on");
123347
- }
123348
- const cacheTypeK = typeof engineConfig?.cacheTypeK === "string" ? engineConfig.cacheTypeK : null;
123349
- if (cacheTypeK) {
123350
- args.push("--cache-type-k", cacheTypeK);
123351
- }
123352
- const cacheTypeV = typeof engineConfig?.cacheTypeV === "string" ? engineConfig.cacheTypeV : null;
123353
- if (cacheTypeV) {
123354
- args.push("--cache-type-v", cacheTypeV);
123355
- }
123356
- const batchSize = typeof engineConfig?.batchSize === "number" ? engineConfig.batchSize : null;
123357
- if (batchSize !== null) {
123358
- args.push("--batch-size", String(batchSize));
123359
- }
123360
- const ubatchSize = typeof engineConfig?.ubatchSize === "number" ? engineConfig.ubatchSize : null;
123361
- if (ubatchSize !== null) {
123362
- args.push("--ubatch-size", String(ubatchSize));
123363
- }
123364
- const tensorSplit = typeof engineConfig?.tensorSplit === "string" ? engineConfig.tensorSplit : null;
123365
- if (tensorSplit) {
123366
- args.push("--tensor-split", tensorSplit);
123367
- }
123368
- const mainGpu = typeof engineConfig?.mainGpu === "number" ? engineConfig.mainGpu : null;
123369
- if (mainGpu !== null) {
123370
- args.push("--main-gpu", String(mainGpu));
123371
- }
123372
123226
  args.push(...parseExtraArgs(engineConfig?.extraArgs));
123373
123227
  if (this.model.multimodalEnabled) {
123374
123228
  const projector = await findMultimodalProjector({ path: targetDirectory });
@@ -123407,12 +123261,7 @@ async function startMLXLM({ enginePort, targetDirectory }) {
123407
123261
  "--context-length",
123408
123262
  String(contextLength)
123409
123263
  ];
123410
- const maxKvSize = typeof engineConfig?.maxKvSize === "number" ? engineConfig.maxKvSize : null;
123411
- if (maxKvSize !== null) {
123412
- args.push("--max-kv-size", String(maxKvSize));
123413
- }
123414
- const trustRemoteCode = engineConfig?.trustRemoteCode === true;
123415
- if (trustRemoteCode || process.env.MLXLM_TRUST_REMOTE_CODE === "true") {
123264
+ if (process.env.MLXLM_TRUST_REMOTE_CODE === "true") {
123416
123265
  args.push("--trust-remote-code");
123417
123266
  }
123418
123267
  args.push(...parseExtraArgs(engineConfig?.extraArgs));
@@ -123449,9 +123298,6 @@ const DEFAULT_SGLANG_CONTEXT_LENGTH = 2048;
123449
123298
  async function startSGLang({ enginePort, targetDirectory }) {
123450
123299
  const contextLength = Math.max(1, this.contextLength ?? DEFAULT_SGLANG_CONTEXT_LENGTH);
123451
123300
  const engineConfig = this.engineConfig;
123452
- const device = typeof engineConfig?.device === "string" ? engineConfig.device : undefined;
123453
- const dtype = typeof engineConfig?.dtype === "string" ? engineConfig.dtype : undefined;
123454
- const tensorParallelSize = typeof engineConfig?.tensorParallelSize === "number" ? engineConfig.tensorParallelSize : 1;
123455
123301
  const args = [
123456
123302
  ...SGLANG_START_ARGS,
123457
123303
  "--port",
@@ -123461,9 +123307,7 @@ async function startSGLang({ enginePort, targetDirectory }) {
123461
123307
  "--served-model-name",
123462
123308
  SERVED_MODEL_NAME,
123463
123309
  "--context-length",
123464
- String(contextLength),
123465
- "--tp-size",
123466
- String(tensorParallelSize)
123310
+ String(contextLength)
123467
123311
  ];
123468
123312
  if (this.model.taskType === "embeddings") {
123469
123313
  args.push("--task", "embed");
@@ -123473,12 +123317,6 @@ async function startSGLang({ enginePort, targetDirectory }) {
123473
123317
  model: this.model,
123474
123318
  targetDirectory
123475
123319
  })));
123476
- if (device) {
123477
- args.push("--device", device);
123478
- }
123479
- if (dtype) {
123480
- args.push("--dtype", dtype);
123481
- }
123482
123320
  args.push(...parseExtraArgs(engineConfig?.extraArgs));
123483
123321
  if (this.model.multimodalEnabled) {
123484
123322
  args.push("--limit-mm-per-prompt", process.env.SGLANG_MM_LIMIT ?? '{"image":5}');
@@ -123494,9 +123332,6 @@ const DEFAULT_TRTLLM_CONTEXT_LENGTH = 2048;
123494
123332
  async function startTensorRTLLM({ enginePort, targetDirectory }) {
123495
123333
  const contextLength = Math.max(1, this.contextLength ?? DEFAULT_TRTLLM_CONTEXT_LENGTH);
123496
123334
  const engineConfig = this.engineConfig;
123497
- const backend = typeof engineConfig?.backend === "string" ? engineConfig.backend : "pytorch";
123498
- const dtype = typeof engineConfig?.dtype === "string" ? engineConfig.dtype : undefined;
123499
- const tensorParallelSize = typeof engineConfig?.tensorParallelSize === "number" ? engineConfig.tensorParallelSize : 1;
123500
123335
  const args = [
123501
123336
  "serve",
123502
123337
  targetDirectory,
@@ -123504,19 +123339,12 @@ async function startTensorRTLLM({ enginePort, targetDirectory }) {
123504
123339
  "127.0.0.1",
123505
123340
  "--port",
123506
123341
  String(enginePort),
123507
- "--backend",
123508
- backend,
123509
123342
  "--max-seq-len",
123510
- String(contextLength),
123511
- "--tp-size",
123512
- String(tensorParallelSize)
123343
+ String(contextLength)
123513
123344
  ];
123514
123345
  if (this.model.taskType === "embeddings") {
123515
123346
  args.push("--task", "embed");
123516
123347
  }
123517
- if (dtype) {
123518
- args.push("--dtype", dtype);
123519
- }
123520
123348
  args.push(...parseExtraArgs(engineConfig?.extraArgs));
123521
123349
  return createEngineProcess({ args, bin: TRTLLM_EXECUTABLE, logger: this.logger });
123522
123350
  }
@@ -124735,7 +124563,7 @@ async function proxyEmbeddingsRoute({ body, conduitConfiguration, endpointId, lo
124735
124563
  });
124736
124564
  }
124737
124565
  const engineType = conduitConfiguration.engineConfig?.type ?? null;
124738
- const engineConfig = conduitConfiguration.engineConfig?.config ?? null;
124566
+ const engineConfig = conduitConfiguration.engineConfig ?? null;
124739
124567
  const serializedBody = isPlainObject$3(body)
124740
124568
  ? JSON.stringify(body)
124741
124569
  : typeof body === "string"
@@ -124879,7 +124707,7 @@ async function proxyOpenAIStreamingRoute({ body, conduitConfiguration, endpointI
124879
124707
  });
124880
124708
  }
124881
124709
  const engineType = conduitConfiguration.engineConfig?.type ?? null;
124882
- const engineConfig = conduitConfiguration.engineConfig?.config ?? null;
124710
+ const engineConfig = conduitConfiguration.engineConfig ?? null;
124883
124711
  const effectiveBody = modelManager.model.multimodalEnabled ? body : stripImagesFromBody(body);
124884
124712
  const { bytes: requestBodyBytes, payload: serializedBody } = serializeRequestBody$1(effectiveBody, { model: modelManager.model, path });
124885
124713
  const requestStartedAt = Date.now();
@@ -125128,7 +124956,7 @@ function createConduitOpenAIAPIReferenceHandlers({ apiClient, conduitConfigurati
125128
124956
  const currentConfig = conduitConfiguration();
125129
124957
  const effectiveContextLength = getEffectiveContextLength({
125130
124958
  contextLength: modelManager.contextLength,
125131
- engineConfig: currentConfig.engineConfig?.config ?? null,
124959
+ engineConfig: currentConfig.engineConfig ?? null,
125132
124960
  engineType: currentConfig.engineConfig?.type ?? null
125133
124961
  });
125134
124962
  return {
@@ -156810,7 +156638,9 @@ function createModelManagerFromConfig(conduitConfiguration, configuration, logge
156810
156638
  const engineConfig = conduitConfiguration.engineConfig;
156811
156639
  return new ModelManager({
156812
156640
  contextLength: conduitConfiguration.contextLength ?? null,
156813
- engineConfig: engineConfig?.config ?? null,
156641
+ engineConfig: engineConfig
156642
+ ? { extraArgs: engineConfig.extraArgs, type: engineConfig.type }
156643
+ : null,
156814
156644
  enginePort: configuration.enginePort,
156815
156645
  engineType: engineConfig?.type ?? "llama.cpp",
156816
156646
  logger,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@infersec/conduit",
3
3
  "description": "End user conduit agent for connecting local LLMs to the cloud.",
4
- "version": "1.101.0",
4
+ "version": "1.102.1",
5
5
  "bin": {
6
6
  "infersec-conduit": "./dist/cli.js"
7
7
  },
@@ -1 +0,0 @@
1
- export declare function parseExtraArgs(extraArgs: unknown): Array<string>;