@mnmal-ai/substrate-nl 1.0.0-alpha.8 → 1.0.0-alpha.9
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/ask/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/ask/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/ask/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,KAAK,KAAK,EAAqC,MAAM,mBAAmB,CAAC;AAElF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAa,MAAM,aAAa,CAAC;AAElE,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAClB;AAkID,wBAAuB,MAAM,CAC3B,GAAG,EAAE,UAAU,EACf,IAAI,EAAE,gBAAgB,EACtB,IAAI,EAAE,OAAO,GACZ,cAAc,CAAC,OAAO,CAAC,CAqHzB"}
|
|
@@ -1011,17 +1011,53 @@ async function rows(c, source, http, deps, handoff) {
|
|
|
1011
1011
|
const frame = executable(c, deps.pack);
|
|
1012
1012
|
const key = Object.keys(frame)[0];
|
|
1013
1013
|
const env = await deps.engine.query(frame, http);
|
|
1014
|
-
const
|
|
1014
|
+
const data = env.data !== void 0 && key in env.data ? env.data?.[key] : void 0;
|
|
1015
|
+
const errors = [...env.errors ?? []];
|
|
1016
|
+
let count;
|
|
1017
|
+
if (c.answer === "count" && Array.isArray(data)) {
|
|
1018
|
+
const counted = await countRest(frame, key, data.length, env, http, deps);
|
|
1019
|
+
if (typeof counted === "number") count = counted;
|
|
1020
|
+
else errors.push(counted);
|
|
1021
|
+
}
|
|
1015
1022
|
return {
|
|
1016
1023
|
kind: "rows",
|
|
1017
1024
|
frame,
|
|
1018
1025
|
answer: c.answer,
|
|
1019
|
-
data
|
|
1020
|
-
...
|
|
1026
|
+
data,
|
|
1027
|
+
...count !== void 0 ? { count } : {},
|
|
1028
|
+
...errors.length > 0 ? { errors } : {},
|
|
1021
1029
|
source,
|
|
1022
1030
|
...handoff !== void 0 ? { handoff } : {}
|
|
1023
1031
|
};
|
|
1024
1032
|
}
|
|
1033
|
+
const MAX_COUNT_PAGES = 1e3;
|
|
1034
|
+
/** The population a count candidate matches: `seen` rows from page one, then id-only pages after its cursor. */
|
|
1035
|
+
async function countRest(frame, key, seen, first, http, deps) {
|
|
1036
|
+
const params = frame[key]?.params ?? {};
|
|
1037
|
+
let count = seen;
|
|
1038
|
+
let page = first._pagination?.[key];
|
|
1039
|
+
for (let pages = 1; page?.hasMore === true; pages++) {
|
|
1040
|
+
if (pages >= MAX_COUNT_PAGES || page.nextCursor === void 0 || isAborted(http)) return {
|
|
1041
|
+
code: "count_incomplete",
|
|
1042
|
+
message: `counted ${count} rows and stopped before the end; the true count is higher`
|
|
1043
|
+
};
|
|
1044
|
+
const env = await deps.engine.query({ [key]: {
|
|
1045
|
+
params: {
|
|
1046
|
+
...params,
|
|
1047
|
+
cursor: page.nextCursor
|
|
1048
|
+
},
|
|
1049
|
+
fields: { id: true }
|
|
1050
|
+
} }, http);
|
|
1051
|
+
const rows = env.data?.[key];
|
|
1052
|
+
if (!Array.isArray(rows)) return {
|
|
1053
|
+
code: "count_incomplete",
|
|
1054
|
+
message: `counted ${count} rows, then a page failed: ${JSON.stringify(env.errors ?? [])}`
|
|
1055
|
+
};
|
|
1056
|
+
count += rows.length;
|
|
1057
|
+
page = env._pagination?.[key];
|
|
1058
|
+
}
|
|
1059
|
+
return count;
|
|
1060
|
+
}
|
|
1025
1061
|
async function recall(query, ns, type, http, deps) {
|
|
1026
1062
|
const frame = { "recall/Hit": {
|
|
1027
1063
|
params: {
|
package/dist/bootstrap.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as askHandler, c as profileNamespace, d as mergeRulings, f as readRulings, g as parseQuestion, h as parseWithJudge, i as createNlPlugin, l as buildNamespacePack, m as runAsk, n as bootstrap, o as packHandler, p as OllamaJudge, r as CONTRACT_VERSION, s as PackService, t as NlBootstrapConfigSchema, u as NamespaceRulingsSchema } from "./bootstrap-
|
|
1
|
+
import { a as askHandler, c as profileNamespace, d as mergeRulings, f as readRulings, g as parseQuestion, h as parseWithJudge, i as createNlPlugin, l as buildNamespacePack, m as runAsk, n as bootstrap, o as packHandler, p as OllamaJudge, r as CONTRACT_VERSION, s as PackService, t as NlBootstrapConfigSchema, u as NamespaceRulingsSchema } from "./bootstrap-Ck2fkpjP.js";
|
|
2
2
|
import { complete } from "./complete.js";
|
|
3
3
|
|
|
4
4
|
export { CONTRACT_VERSION, NamespaceRulingsSchema, NlBootstrapConfigSchema, OllamaJudge, PackService, askHandler, bootstrap, buildNamespacePack, complete, createNlPlugin, mergeRulings, packHandler, parseQuestion, parseWithJudge, profileNamespace, readRulings, runAsk };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mnmal-ai/substrate-nl",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.9",
|
|
4
4
|
"description": "Natural-language questions for Substrate — a deterministic parser with an optional constrained judge, served at POST /substrate/v1/nl and GET /substrate/v1/nl/pack/:ns, plus browser-safe completion.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@biomejs/biome": "2.6.2",
|
|
40
|
-
"@mnmal-ai/substrate": "1.0.0-alpha.
|
|
41
|
-
"@mnmal-ai/substrate-config": "1.0.0-alpha.
|
|
40
|
+
"@mnmal-ai/substrate": "1.0.0-alpha.9",
|
|
41
|
+
"@mnmal-ai/substrate-config": "1.0.0-alpha.9",
|
|
42
42
|
"@types/node": "^26.6.4",
|
|
43
43
|
"tsdown": "^0.23.0",
|
|
44
44
|
"typescript": "^7.0.2",
|