@kortexya/reasoninglayer 4.2.0 → 4.2.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/index.cjs +57 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +136 -89
- package/dist/index.d.ts +136 -89
- package/dist/index.js +57 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@ var __export = (target, all) => {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
// src/config.ts
|
|
10
|
-
var SDK_VERSION = "4.2.
|
|
10
|
+
var SDK_VERSION = "4.2.1";
|
|
11
11
|
function resolveConfig(config) {
|
|
12
12
|
if (!config.baseUrl) {
|
|
13
13
|
throw new Error("ClientConfig.baseUrl is required");
|
|
@@ -12428,7 +12428,7 @@ var Conformal = class {
|
|
|
12428
12428
|
this.http = http;
|
|
12429
12429
|
}
|
|
12430
12430
|
/**
|
|
12431
|
-
* @description Compute a split-conformal non-conformity threshold from a labeled calibration set.
|
|
12431
|
+
* @description Compute a split-conformal non-conformity threshold from a labeled calibration set. Returns `τ` and an in-sample coverage check. The returned `threshold` should be passed verbatim to `POST /api/v1/conformal/predict`.
|
|
12432
12432
|
*
|
|
12433
12433
|
* @tags conformal
|
|
12434
12434
|
* @name CalibrateConformal
|
|
@@ -12444,7 +12444,7 @@ var Conformal = class {
|
|
|
12444
12444
|
...params
|
|
12445
12445
|
});
|
|
12446
12446
|
/**
|
|
12447
|
-
* @description Apply a pre-computed conformal threshold to unlabeled test inputs and return prediction sets with
|
|
12447
|
+
* @description Apply a pre-computed conformal threshold to unlabeled test inputs and return prediction sets with explicitly unverified supplied parameters. A class `y` is included in an input's prediction set iff `1 − class_scores[y] ≤ threshold`, evaluated in that score space. When no class meets this criterion the prediction set is empty and `abstains = true` is set on that input's result.
|
|
12448
12448
|
*
|
|
12449
12449
|
* @tags conformal
|
|
12450
12450
|
* @name Predict
|
|
@@ -17603,6 +17603,7 @@ var RESPONSE_COMPONENTS = {
|
|
|
17603
17603
|
algorithm: [1, 0],
|
|
17604
17604
|
alpha: [1, 0],
|
|
17605
17605
|
empirical_coverage: [1, 0],
|
|
17606
|
+
informative: [1, 0],
|
|
17606
17607
|
meets_target_coverage: [1, 0],
|
|
17607
17608
|
n_samples: [1, 0],
|
|
17608
17609
|
quantile_rank: [1, 0],
|
|
@@ -17611,7 +17612,7 @@ var RESPONSE_COMPONENTS = {
|
|
|
17611
17612
|
},
|
|
17612
17613
|
ConformalPredictResponse: {
|
|
17613
17614
|
object: {
|
|
17614
|
-
|
|
17615
|
+
calibration_parameters: [1, "SuppliedCalibrationParameters"],
|
|
17615
17616
|
predictions: [1, { array: "ConformalPrediction" }]
|
|
17616
17617
|
}
|
|
17617
17618
|
},
|
|
@@ -17848,15 +17849,6 @@ var RESPONSE_COMPONENTS = {
|
|
|
17848
17849
|
}
|
|
17849
17850
|
},
|
|
17850
17851
|
CounterfactualTraceDto: { object: { abduction: [1, 0], action: [1, 0], prediction: [1, 0] } },
|
|
17851
|
-
CoverageCertificate: {
|
|
17852
|
-
object: {
|
|
17853
|
-
algorithm: [1, 0],
|
|
17854
|
-
alpha: [1, 0],
|
|
17855
|
-
n_calibration_samples: [1, 0],
|
|
17856
|
-
nominal_coverage: [1, 0],
|
|
17857
|
-
threshold: [1, 0]
|
|
17858
|
-
}
|
|
17859
|
-
},
|
|
17860
17852
|
CoverageDetailDto: {
|
|
17861
17853
|
object: {
|
|
17862
17854
|
class_coverage: [1, 0],
|
|
@@ -22753,6 +22745,17 @@ var RESPONSE_COMPONENTS = {
|
|
|
22753
22745
|
supervisor_active: [1, 0]
|
|
22754
22746
|
}
|
|
22755
22747
|
},
|
|
22748
|
+
SuppliedCalibrationParameters: {
|
|
22749
|
+
object: {
|
|
22750
|
+
algorithm: [1, 0],
|
|
22751
|
+
alpha: [1, 0],
|
|
22752
|
+
informative: [1, 0],
|
|
22753
|
+
n_calibration_samples: [1, 0],
|
|
22754
|
+
requested_coverage: [1, 0],
|
|
22755
|
+
threshold: [1, 0],
|
|
22756
|
+
verification: [1, 0]
|
|
22757
|
+
}
|
|
22758
|
+
},
|
|
22756
22759
|
SuspendedQueryDto: {
|
|
22757
22760
|
object: {
|
|
22758
22761
|
confidence: [1, 0],
|
|
@@ -61501,6 +61504,7 @@ function ConformalCalibrateResponseFromApiToFront(dto) {
|
|
|
61501
61504
|
algorithm: dto.algorithm,
|
|
61502
61505
|
alpha: dto.alpha,
|
|
61503
61506
|
empiricalCoverage: dto.empirical_coverage,
|
|
61507
|
+
informative: dto.informative,
|
|
61504
61508
|
meetsTargetCoverage: dto.meets_target_coverage,
|
|
61505
61509
|
nSamples: dto.n_samples,
|
|
61506
61510
|
quantileRank: dto.quantile_rank,
|
|
@@ -61515,13 +61519,15 @@ function ConformalPredictRequestFromFrontToApi(model) {
|
|
|
61515
61519
|
threshold: model.threshold
|
|
61516
61520
|
};
|
|
61517
61521
|
}
|
|
61518
|
-
function
|
|
61522
|
+
function SuppliedCalibrationParametersFromApiToFront(dto) {
|
|
61519
61523
|
return {
|
|
61520
61524
|
algorithm: dto.algorithm,
|
|
61521
61525
|
alpha: dto.alpha,
|
|
61526
|
+
informative: dto.informative,
|
|
61522
61527
|
nCalibrationSamples: dto.n_calibration_samples,
|
|
61523
|
-
|
|
61524
|
-
threshold: dto.threshold
|
|
61528
|
+
requestedCoverage: dto.requested_coverage,
|
|
61529
|
+
threshold: dto.threshold,
|
|
61530
|
+
verification: dto.verification
|
|
61525
61531
|
};
|
|
61526
61532
|
}
|
|
61527
61533
|
function ConformalPredictionFromApiToFront(dto) {
|
|
@@ -61535,7 +61541,7 @@ function ConformalPredictionFromApiToFront(dto) {
|
|
|
61535
61541
|
}
|
|
61536
61542
|
function ConformalPredictResponseFromApiToFront(dto) {
|
|
61537
61543
|
return {
|
|
61538
|
-
|
|
61544
|
+
calibrationParameters: SuppliedCalibrationParametersFromApiToFront(dto.calibration_parameters),
|
|
61539
61545
|
predictions: dto.predictions.map(ConformalPredictionFromApiToFront)
|
|
61540
61546
|
};
|
|
61541
61547
|
}
|
|
@@ -61554,11 +61560,22 @@ var ConformalClient = class {
|
|
|
61554
61560
|
*
|
|
61555
61561
|
* @param request - The calibration set (samples + target miscoverage
|
|
61556
61562
|
* `α`).
|
|
61557
|
-
* @
|
|
61558
|
-
*
|
|
61563
|
+
* @param requestOptions - Per-request transport options.
|
|
61564
|
+
* @returns The computed threshold `τ`, whether it is informative, and
|
|
61565
|
+
* in-sample coverage statistics.
|
|
61559
61566
|
*
|
|
61560
61567
|
* @throws {ApiError} `400` if `alpha` is outside `(0, 1)` or the
|
|
61561
|
-
* calibration set is empty.
|
|
61568
|
+
* calibration set is empty or contains invalid scores.
|
|
61569
|
+
* @remarks The request maps schema keys to snake_case and preserves class labels.
|
|
61570
|
+
* An unobserved rank returns threshold 1 and `informative: false`.
|
|
61571
|
+
* @example
|
|
61572
|
+
* ```ts
|
|
61573
|
+
* const calibration = await client.conformal.calibrate({
|
|
61574
|
+
* alpha: 0.05,
|
|
61575
|
+
* samples: labeledSamples,
|
|
61576
|
+
* });
|
|
61577
|
+
* console.log(calibration.informative, calibration.quantileRank);
|
|
61578
|
+
* ```
|
|
61562
61579
|
*/
|
|
61563
61580
|
async calibrate(request, requestOptions) {
|
|
61564
61581
|
const response = await this.api.calibrateConformal(
|
|
@@ -61569,15 +61586,30 @@ var ConformalClient = class {
|
|
|
61569
61586
|
}
|
|
61570
61587
|
/**
|
|
61571
61588
|
* Apply a pre-computed conformal threshold to unlabeled test inputs
|
|
61572
|
-
* and return prediction sets with
|
|
61589
|
+
* and return prediction sets with unverified calibration parameters.
|
|
61573
61590
|
*
|
|
61574
61591
|
* @param request - The threshold `τ`, calibration `α` and sample count
|
|
61575
61592
|
* (from a prior `calibrate` call), and the test inputs to predict
|
|
61576
61593
|
* for.
|
|
61577
|
-
* @
|
|
61578
|
-
*
|
|
61579
|
-
*
|
|
61580
|
-
*
|
|
61594
|
+
* @param requestOptions - Per-request transport options.
|
|
61595
|
+
* @returns Per-input prediction results in request order and the applied
|
|
61596
|
+
* parameters with `verification: 'unverified'`.
|
|
61597
|
+
*
|
|
61598
|
+
* @throws {ApiError} `400` for invalid scores, parameters, rank consistency,
|
|
61599
|
+
* or an empty or oversized test-input batch.
|
|
61600
|
+
* @remarks The request maps schema keys to snake_case and preserves class labels.
|
|
61601
|
+
* A nonempty prediction set can still be uninformative. Parameter consistency
|
|
61602
|
+
* does not establish calibration provenance or prediction correctness.
|
|
61603
|
+
* @example
|
|
61604
|
+
* ```ts
|
|
61605
|
+
* const result = await client.conformal.predict({
|
|
61606
|
+
* threshold: calibration.threshold,
|
|
61607
|
+
* alpha: calibration.alpha,
|
|
61608
|
+
* nCalibrationSamples: calibration.nSamples,
|
|
61609
|
+
* testInputs,
|
|
61610
|
+
* });
|
|
61611
|
+
* console.log(result.calibrationParameters.verification);
|
|
61612
|
+
* ```
|
|
61581
61613
|
*/
|
|
61582
61614
|
async predict(request, requestOptions) {
|
|
61583
61615
|
const response = await this.api.predict(
|