neuralos 3.10.0 → 3.10.2
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/README.md +16 -0
- package/engine.js +3 -1
- package/package.json +6 -6
- package/test.js +25 -0
- package/tools.js +10 -0
package/README.md
CHANGED
|
@@ -70,6 +70,8 @@ const invoice = extract('Invoice INV-1042 issued 12 May 2024, total 49.62 USD.',
|
|
|
70
70
|
invoice_no: Field({ type: 'string' }),
|
|
71
71
|
issue_date: Field({ type: 'string', format: 'date' }),
|
|
72
72
|
total: Field({ type: 'number', ge: 0 }),
|
|
73
|
+
// the Python idiom works too:
|
|
74
|
+
balance: Field({ ge: 0 }).apply({ type: 'number' }),
|
|
73
75
|
},
|
|
74
76
|
required: ['invoice_no', 'total'],
|
|
75
77
|
},
|
|
@@ -77,6 +79,20 @@ const invoice = extract('Invoice INV-1042 issued 12 May 2024, total 49.62 USD.',
|
|
|
77
79
|
// { invoice_no: 'INV-1042', issue_date: '2024-05-12', total: 49.62 }
|
|
78
80
|
```
|
|
79
81
|
|
|
82
|
+
`Field(...)` accepts the same constraints as Python's `needle.Field` (`ge`, `le`,
|
|
83
|
+
`gt`, `lt`, `multiple_of`, `min_length`, `max_length`, `pattern`, `format`,
|
|
84
|
+
`enum`, `const`, `min_items`, `max_items`, `unique_items`, `description`,
|
|
85
|
+
`default`) and returns a JSON-schema fragment. Both call styles are supported and
|
|
86
|
+
produce identical schemas:
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
Field({ type: 'number', ge: 0 }) // Node form (schema inline)
|
|
90
|
+
Field({ ge: 0 }).apply({ type: 'number' }) // Python form (merge onto a schema)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
> Node's `Field` is a permissive superset of Python's: it also accepts a full
|
|
94
|
+
> schema (`type` and friends) inline, which Python's `Field` does not.
|
|
95
|
+
|
|
80
96
|
With `strict: true` (the default) a value the input does not license raises
|
|
81
97
|
`ExtractionValidationError` instead of being returned silently — a date whose
|
|
82
98
|
year is not written in the text, an invented number, or a negated request:
|
package/engine.js
CHANGED
|
@@ -22,7 +22,9 @@ const PLATFORM_PACKAGES = {
|
|
|
22
22
|
'darwin-x64': { pkg: 'neuralos-darwin-x64', lib: 'libneedle3.dylib' },
|
|
23
23
|
'linux-x64-gnu': { pkg: 'neuralos-linux-x64-gnu', lib: 'libneedle3.so' },
|
|
24
24
|
'linux-arm64-gnu': { pkg: 'neuralos-linux-arm64-gnu', lib: 'libneedle3.so' },
|
|
25
|
-
|
|
25
|
+
// npm blocks "neuralos-win32-x64" as a look-alike name (403 spam
|
|
26
|
+
// detection), so the Windows payload ships as this package instead.
|
|
27
|
+
'win32-x64': { pkg: 'neuralos-engine-windows-x64', lib: 'libneedle3.dll' },
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
function platformKey() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neuralos",
|
|
3
|
-
"version": "3.10.
|
|
3
|
+
"version": "3.10.2",
|
|
4
4
|
"description": "neuralOS - automation foundation model for tiny devices: offline tool-calling, structured extraction and embeddings for Node.js, weights bundled",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"koffi": "^2.9.0"
|
|
42
42
|
},
|
|
43
43
|
"optionalDependencies": {
|
|
44
|
-
"neuralos-darwin-arm64": "3.10.
|
|
45
|
-
"neuralos-darwin-x64": "3.10.
|
|
46
|
-
"neuralos-linux-x64-gnu": "3.10.
|
|
47
|
-
"neuralos-linux-arm64-gnu": "3.10.
|
|
48
|
-
"neuralos-
|
|
44
|
+
"neuralos-darwin-arm64": "3.10.2",
|
|
45
|
+
"neuralos-darwin-x64": "3.10.2",
|
|
46
|
+
"neuralos-linux-x64-gnu": "3.10.2",
|
|
47
|
+
"neuralos-linux-arm64-gnu": "3.10.2",
|
|
48
|
+
"neuralos-engine-windows-x64": "3.10.2"
|
|
49
49
|
}
|
|
50
50
|
}
|
package/test.js
CHANGED
|
@@ -18,3 +18,28 @@ console.log(JSON.stringify(result.results));
|
|
|
18
18
|
|
|
19
19
|
const vector = agent.embed('hello world');
|
|
20
20
|
console.log('embed dim:', vector.length);
|
|
21
|
+
|
|
22
|
+
// --- Field: both call styles must produce the same schema -------------------
|
|
23
|
+
const { Field } = require('./index');
|
|
24
|
+
|
|
25
|
+
const inline = Field({ type: 'number', description: 'total', ge: 0, le: 1000 });
|
|
26
|
+
const applied = Field({ description: 'total', ge: 0, le: 1000 }).apply({ type: 'number' });
|
|
27
|
+
console.log('field inline :', JSON.stringify(inline));
|
|
28
|
+
console.log('field applied:', JSON.stringify(applied));
|
|
29
|
+
if (JSON.stringify(inline) !== JSON.stringify(applied)) {
|
|
30
|
+
throw new Error('Field: inline form and .apply() form disagree');
|
|
31
|
+
}
|
|
32
|
+
// the method must not leak into the serialised schema
|
|
33
|
+
if (JSON.stringify(inline) !== '{"type":"number","description":"total","minimum":0,"maximum":1000}') {
|
|
34
|
+
throw new Error('Field: unexpected serialisation');
|
|
35
|
+
}
|
|
36
|
+
if (Object.keys(inline).includes('apply')) {
|
|
37
|
+
throw new Error('Field: apply() must be non-enumerable');
|
|
38
|
+
}
|
|
39
|
+
// Python-style constraint names, including the snake_case ones
|
|
40
|
+
console.log('field python :', JSON.stringify(Field({ min_length: 2, max_length: 8, multiple_of: 5 })));
|
|
41
|
+
console.log('Field OK');
|
|
42
|
+
|
|
43
|
+
// --- extraction: module API present and callable ----------------------------
|
|
44
|
+
const { extract, ExtractionValidationError } = require('./index');
|
|
45
|
+
console.log('extract:', typeof extract, '| error class:', ExtractionValidationError.name);
|
package/tools.js
CHANGED
|
@@ -83,6 +83,16 @@ function Field({ default: defaultValue, description, enum: enum_, const: const_,
|
|
|
83
83
|
}
|
|
84
84
|
if (const_ !== undefined) schema.const = const_;
|
|
85
85
|
if (defaultValue !== undefined) schema.default = defaultValue;
|
|
86
|
+
|
|
87
|
+
// Python parity: `needle.Field(ge=0).apply({"type": "number"})`. The method is
|
|
88
|
+
// non-enumerable so JSON.stringify(schema) — i.e. the payload sent to the
|
|
89
|
+
// engine — is byte-identical to the plain constraints object.
|
|
90
|
+
Object.defineProperty(schema, 'apply', {
|
|
91
|
+
enumerable: false,
|
|
92
|
+
value(target) {
|
|
93
|
+
return { ...(target || {}), ...this };
|
|
94
|
+
},
|
|
95
|
+
});
|
|
86
96
|
return schema;
|
|
87
97
|
}
|
|
88
98
|
|