react-native-nobodywho 0.2.1 → 0.3.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.
- package/android/CMakeLists.txt +4 -2
- package/android/build.gradle +22 -17
- package/android/src/main/java/com/nobodywho/NobodywhoModule.kt +1 -0
- package/generated/cpp/nobodywho.cpp +453 -447
- package/generated/cpp/nobodywho.hpp +50 -49
- package/generated/ts/nobodywho-ffi.ts +19 -19
- package/generated/ts/nobodywho.ts +496 -496
- package/package.json +6 -1
- package/src/cross_encoder.ts +1 -1
- package/src/encoder.ts +1 -1
- package/src/model.ts +3 -3
- package/src/tool.ts +31 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nobodywho",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Run LLMs locally with offline inference — React Native bindings",
|
|
5
5
|
"main": "src/wrapper.ts",
|
|
6
6
|
"types": "src/wrapper.ts",
|
|
@@ -47,5 +47,10 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"uniffi-bindgen-react-native": "0.30.0-1"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@types/jest": "^30.0.0",
|
|
53
|
+
"jest": "^30.3.0",
|
|
54
|
+
"ts-jest": "^29.4.9"
|
|
50
55
|
}
|
|
51
56
|
}
|
package/src/cross_encoder.ts
CHANGED
package/src/encoder.ts
CHANGED
package/src/model.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
loadModel,
|
|
3
|
-
type
|
|
3
|
+
type RustModelInterface,
|
|
4
4
|
} from "../generated/ts/nobodywho";
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -26,10 +26,10 @@ import {
|
|
|
26
26
|
*/
|
|
27
27
|
export class Model {
|
|
28
28
|
/** @internal */
|
|
29
|
-
readonly _inner:
|
|
29
|
+
readonly _inner: RustModelInterface;
|
|
30
30
|
|
|
31
31
|
/** @internal */
|
|
32
|
-
private constructor(inner:
|
|
32
|
+
private constructor(inner: RustModelInterface) {
|
|
33
33
|
this._inner = inner;
|
|
34
34
|
}
|
|
35
35
|
|
package/src/tool.ts
CHANGED
|
@@ -5,12 +5,20 @@ import {
|
|
|
5
5
|
} from "../generated/ts/nobodywho";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Recursively convert a value from JSON based on a JSON Schema type.
|
|
9
|
+
*
|
|
10
|
+
* Supports primitives (`string`, `number`, `integer`, `boolean`),
|
|
11
|
+
* arrays (`{ type: "array", items: ... }`), and nested objects
|
|
12
|
+
* (`{ type: "object", properties: { ... } }`).
|
|
9
13
|
*/
|
|
10
14
|
function convertValue(
|
|
11
15
|
value: unknown,
|
|
12
16
|
schema: Record<string, unknown>,
|
|
13
17
|
): unknown {
|
|
18
|
+
if (value === null || value === undefined) {
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
|
|
14
22
|
switch (schema.type) {
|
|
15
23
|
case "integer":
|
|
16
24
|
case "number":
|
|
@@ -19,6 +27,25 @@ function convertValue(
|
|
|
19
27
|
return typeof value === "string" ? value === "true" : Boolean(value);
|
|
20
28
|
case "string":
|
|
21
29
|
return String(value);
|
|
30
|
+
case "array": {
|
|
31
|
+
if (!Array.isArray(value)) return value;
|
|
32
|
+
const itemSchema = schema.items as Record<string, unknown> | undefined;
|
|
33
|
+
if (!itemSchema) return value;
|
|
34
|
+
return value.map((item) => convertValue(item, itemSchema));
|
|
35
|
+
}
|
|
36
|
+
case "object": {
|
|
37
|
+
if (typeof value !== "object" || Array.isArray(value)) return value;
|
|
38
|
+
const properties = schema.properties as
|
|
39
|
+
| Record<string, Record<string, unknown>>
|
|
40
|
+
| undefined;
|
|
41
|
+
if (!properties) return value;
|
|
42
|
+
const obj = value as Record<string, unknown>;
|
|
43
|
+
const result: Record<string, unknown> = {};
|
|
44
|
+
for (const [key, propSchema] of Object.entries(properties)) {
|
|
45
|
+
result[key] = key in obj ? convertValue(obj[key], propSchema) : undefined;
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
22
49
|
default:
|
|
23
50
|
return value;
|
|
24
51
|
}
|
|
@@ -78,3 +105,6 @@ export class Tool {
|
|
|
78
105
|
return this._inner.getSchemaJson();
|
|
79
106
|
}
|
|
80
107
|
}
|
|
108
|
+
|
|
109
|
+
/** @internal Exported for testing only. */
|
|
110
|
+
export { convertValue as _convertValue };
|