@infersec/conduit 1.16.0 → 1.17.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.
|
@@ -5,7 +5,7 @@ export interface APIClient {
|
|
|
5
5
|
reportMachineMetadata: (payload: InferenceAgentMachineReportPayload) => Promise<void>;
|
|
6
6
|
reportPromptMetrics: (payload: InferenceAgentLLMMetricsPayload) => Promise<void>;
|
|
7
7
|
}
|
|
8
|
-
export declare function createAPIClient({ apiURL, inferenceSourceID }: {
|
|
8
|
+
export declare function createAPIClient({ apiKey, apiURL, inferenceSourceID }: {
|
|
9
9
|
apiKey: string;
|
|
10
10
|
apiURL: string;
|
|
11
11
|
inferenceSourceID: ULID;
|
package/dist/cli.js
CHANGED
|
@@ -6,7 +6,7 @@ const __dirname = __pathDirname(__filename);
|
|
|
6
6
|
|
|
7
7
|
import { parseArgs } from 'node:util';
|
|
8
8
|
import 'node:crypto';
|
|
9
|
-
import { a as asError, s as startInferenceAgent } from './start-
|
|
9
|
+
import { a as asError, s as startInferenceAgent } from './start-CCmUbFoS.js';
|
|
10
10
|
import 'argon2';
|
|
11
11
|
import 'node:child_process';
|
|
12
12
|
import 'node:stream';
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ const __filename = __fileURLToPath(import.meta.url);
|
|
|
5
5
|
const __dirname = __pathDirname(__filename);
|
|
6
6
|
|
|
7
7
|
import 'node:crypto';
|
|
8
|
-
import { s as startInferenceAgent, a as asError } from './start-
|
|
8
|
+
import { s as startInferenceAgent, a as asError } from './start-CCmUbFoS.js';
|
|
9
9
|
import 'argon2';
|
|
10
10
|
import 'node:child_process';
|
|
11
11
|
import 'node:stream';
|
|
@@ -14791,6 +14791,11 @@ const LLMModelSchema = object({
|
|
|
14791
14791
|
})
|
|
14792
14792
|
])
|
|
14793
14793
|
});
|
|
14794
|
+
const QuantizationFileSchema = object({
|
|
14795
|
+
filePath: string$1().min(1),
|
|
14796
|
+
sizeBytes: number$1().int().nonnegative().nullable()
|
|
14797
|
+
});
|
|
14798
|
+
array(QuantizationFileSchema);
|
|
14794
14799
|
|
|
14795
14800
|
const InferenceAgentConfigurationSchema = object({
|
|
14796
14801
|
contextLength: number$1().int().positive().nullable(),
|
|
@@ -52620,6 +52625,19 @@ function requireUndici () {
|
|
|
52620
52625
|
|
|
52621
52626
|
var undiciExports = requireUndici();
|
|
52622
52627
|
|
|
52628
|
+
function createFetchWithHeaders({ fetchFn = undiciExports.fetch, headers }) {
|
|
52629
|
+
function fetchWithHeaders(url, options) {
|
|
52630
|
+
const mergedHeaders = new Headers(options.headers);
|
|
52631
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
52632
|
+
mergedHeaders.set(key, value);
|
|
52633
|
+
}
|
|
52634
|
+
return fetchFn(url, {
|
|
52635
|
+
...options,
|
|
52636
|
+
headers: mergedHeaders
|
|
52637
|
+
});
|
|
52638
|
+
}
|
|
52639
|
+
return fetchWithHeaders;
|
|
52640
|
+
}
|
|
52623
52641
|
async function fetchByReference(options) {
|
|
52624
52642
|
const { baseURL, body, fetch: fetchFn = undiciExports.fetch, parameters = {}, query = {}, reference, route, method } = options;
|
|
52625
52643
|
if (!reference[route]) {
|
|
@@ -97901,11 +97919,17 @@ function implementAPIReference({ api, logger, mount, reference }) {
|
|
|
97901
97919
|
}
|
|
97902
97920
|
}
|
|
97903
97921
|
|
|
97904
|
-
function createAPIClient({ apiURL, inferenceSourceID }) {
|
|
97922
|
+
function createAPIClient({ apiKey, apiURL, inferenceSourceID }) {
|
|
97923
|
+
const fetchWithAPIKey = createFetchWithHeaders({
|
|
97924
|
+
headers: {
|
|
97925
|
+
"x-api-key": apiKey
|
|
97926
|
+
}
|
|
97927
|
+
});
|
|
97905
97928
|
return {
|
|
97906
97929
|
getConduitConfiguration: async () => {
|
|
97907
97930
|
const result = await fetchByReference({
|
|
97908
97931
|
baseURL: apiURL,
|
|
97932
|
+
fetch: fetchWithAPIKey,
|
|
97909
97933
|
reference: API_SERVICE_CONDUIT_API_REFERENCE,
|
|
97910
97934
|
route: "/conduit/api/v1/source/:sourceID/configuration",
|
|
97911
97935
|
method: "GET",
|
|
@@ -97919,6 +97943,7 @@ function createAPIClient({ apiURL, inferenceSourceID }) {
|
|
|
97919
97943
|
await fetchByReference({
|
|
97920
97944
|
baseURL: apiURL,
|
|
97921
97945
|
body: payload,
|
|
97946
|
+
fetch: fetchWithAPIKey,
|
|
97922
97947
|
method: "POST",
|
|
97923
97948
|
parameters: {
|
|
97924
97949
|
sourceID: inferenceSourceID
|
|
@@ -97931,6 +97956,7 @@ function createAPIClient({ apiURL, inferenceSourceID }) {
|
|
|
97931
97956
|
await fetchByReference({
|
|
97932
97957
|
baseURL: apiURL,
|
|
97933
97958
|
body: state,
|
|
97959
|
+
fetch: fetchWithAPIKey,
|
|
97934
97960
|
method: "POST",
|
|
97935
97961
|
parameters: {
|
|
97936
97962
|
sourceID: inferenceSourceID
|
|
@@ -97943,6 +97969,7 @@ function createAPIClient({ apiURL, inferenceSourceID }) {
|
|
|
97943
97969
|
await fetchByReference({
|
|
97944
97970
|
baseURL: apiURL,
|
|
97945
97971
|
body: payload,
|
|
97972
|
+
fetch: fetchWithAPIKey,
|
|
97946
97973
|
method: "POST",
|
|
97947
97974
|
parameters: {
|
|
97948
97975
|
sourceID: inferenceSourceID
|
|
@@ -99576,6 +99603,24 @@ const ModelDownloadProgressSchema = object({
|
|
|
99576
99603
|
const DOWNLOAD_PROGRESS_TIMEOUT = 60000;
|
|
99577
99604
|
const DOWNLOAD_RETRY_ATTEMPTS_FULL = 3;
|
|
99578
99605
|
const DOWNLOAD_RETRY_ATTEMPTS_RANGE = 10;
|
|
99606
|
+
function matchesQuantizationVariant({ filePath, variant }) {
|
|
99607
|
+
if (!variant) {
|
|
99608
|
+
return false;
|
|
99609
|
+
}
|
|
99610
|
+
const escapedVariant = variant.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
99611
|
+
const trailingBoundary = variant.includes("_") ? "[\\-./_]" : "[\\-./]";
|
|
99612
|
+
const matcher = new RegExp(`(^|[\\-./_])${escapedVariant}(?=$|${trailingBoundary})`, "i");
|
|
99613
|
+
const normalizedPath = filePath.replace(/\\/g, "/");
|
|
99614
|
+
const segments = normalizedPath.split("/").filter(Boolean);
|
|
99615
|
+
if (segments.length === 0) {
|
|
99616
|
+
return false;
|
|
99617
|
+
}
|
|
99618
|
+
const filename = segments[segments.length - 1].replace(/\.gguf$/i, "");
|
|
99619
|
+
if (matcher.test(filename)) {
|
|
99620
|
+
return true;
|
|
99621
|
+
}
|
|
99622
|
+
return segments.slice(0, -1).some(segment => matcher.test(segment));
|
|
99623
|
+
}
|
|
99579
99624
|
async function downloadModelViaHuggingFace({ format, huggingFaceToken, modelSlug: rawModelSlug, onProgress, progressFilePath, targetDirectory }) {
|
|
99580
99625
|
// Sanitise model ID
|
|
99581
99626
|
const [modelSlugWithRevision, variant = null] = rawModelSlug.split(":");
|
|
@@ -99607,7 +99652,10 @@ async function downloadModelViaHuggingFace({ format, huggingFaceToken, modelSlug
|
|
|
99607
99652
|
}
|
|
99608
99653
|
if (variant &&
|
|
99609
99654
|
filePath.endsWith(".gguf") &&
|
|
99610
|
-
|
|
99655
|
+
!matchesQuantizationVariant({
|
|
99656
|
+
filePath: file.path,
|
|
99657
|
+
variant
|
|
99658
|
+
})) {
|
|
99611
99659
|
console.log("Skipping due variant not being needed:", file.path, file.size);
|
|
99612
99660
|
continue;
|
|
99613
99661
|
}
|
|
@@ -118177,6 +118225,7 @@ async function startInferenceAgent({ configurationOverrides }) {
|
|
|
118177
118225
|
agentEngineType: configuration.agentEngineType
|
|
118178
118226
|
});
|
|
118179
118227
|
const apiClient = createAPIClient({
|
|
118228
|
+
apiKey: configuration.apiKey,
|
|
118180
118229
|
apiURL: configuration.apiURL,
|
|
118181
118230
|
inferenceSourceID: configuration.inferenceSourceID
|
|
118182
118231
|
});
|