Skip to content

armgit / laya

Public Imported from GitHub
0

Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.

laya-go: document min_confidence on PredictBatch; raise the test floor to 1447

Adeshina Lasisi4087bb0f7aad
diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml
index d5d5bc3c..4e646c09 100644
--- a/.github/workflows/go.yml
+++ b/.github/workflows/go.yml
@@ -128,11 +128,11 @@ jobs:
LAYA_GO_FIXTURES: ${{ github.workspace }}/.go-goldens
LAYA_CHECKPOINTS: ${{ github.workspace }}/laya-java/.work/checkpoints
run: go test -race -count=1 -json ./... > "$RUNNER_TEMP/go-test.json"
- # Exactly the measured count (1412 tests and subtests, on both Go versions): dropping a
+ # Exactly the measured count (1447 tests and subtests, on both Go versions): dropping a
# case fails here, and adding one means raising this number.
- name: No test was skipped
if: ${{ !cancelled() }}
- run: python laya-go/scripts/check_test_json.py "$RUNNER_TEMP/go-test.json" --min-tests 1412
+ run: python laya-go/scripts/check_test_json.py "$RUNNER_TEMP/go-test.json" --min-tests 1447
# go.mod declares go 1.22, so that is what a consumer may build with.
- name: Run the tests on the oldest supported Go
@@ -144,7 +144,7 @@ jobs:
run: go test -count=1 -json ./... > "$RUNNER_TEMP/go-test-oldest.json"
- name: No test was skipped on the oldest Go either
if: ${{ !cancelled() }}
- run: python laya-go/scripts/check_test_json.py "$RUNNER_TEMP/go-test-oldest.json" --min-tests 1412
+ run: python laya-go/scripts/check_test_json.py "$RUNNER_TEMP/go-test-oldest.json" --min-tests 1447
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: ${{ failure() }}
diff --git a/laya-go/agent/agent.go b/laya-go/agent/agent.go
index 0d6d46b0..c737ebcf 100644
--- a/laya-go/agent/agent.go
+++ b/laya-go/agent/agent.go
@@ -216,7 +216,12 @@ func (a *Agent) Predict(ctx context.Context, state any, qs schema.Questions, opt
// list or dict. With no questions each state gets an empty answer and zero usage, with no model
// run.
//
+// WithMinConfidence or WithMinConfidenceMap gates every answer: it sets low_confidence,
+// abstention and abstention_threshold as laya does. An invalid threshold is refused first, as a
+// *MinConfidenceError, before any state is encoded or run.
+//
// Errors may be wrapped; match them with errors.Is and errors.As:
+// - *MinConfidenceError, for an invalid threshold, before anything else is checked;
// - ErrClosed, once Close has been called (a context already done is reported first);
// - ctx.Err(), checked on entry, before each state is encoded and between runs;
// - *StateError, naming the state, around sequence.ErrUnsupportedState (also for a nil