@garrix82/reactgenie-lib 1.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/.env.example +22 -0
- package/.github/workflows/publish.yml +20 -0
- package/LICENSE.txt +201 -0
- package/README.md +621 -0
- package/babel.config.js +29 -0
- package/dist/adapters/__tests__/expo-router-adapter.test.d.ts +1 -0
- package/dist/adapters/expo-router-adapter.d.ts +16 -0
- package/dist/adapters/expo-router-adapter.js +521 -0
- package/dist/adapters/navigation-adapter.d.ts +20 -0
- package/dist/adapters/navigation-adapter.js +137 -0
- package/dist/audio-visualizer.d.ts +14 -0
- package/dist/audio-visualizer.js +123 -0
- package/dist/current-selection.d.ts +27 -0
- package/dist/current-selection.js +94 -0
- package/dist/errors.d.ts +19 -0
- package/dist/errors.js +37 -0
- package/dist/genie/DateTime.d.ts +66 -0
- package/dist/genie/DateTime.js +399 -0
- package/dist/genie/TimeDelta.d.ts +35 -0
- package/dist/genie/TimeDelta.js +169 -0
- package/dist/genie-view-wrapper.d.ts +1 -0
- package/dist/genie-view-wrapper.js +377 -0
- package/dist/hooks/__tests__/useSpeechRecognition.test.d.ts +1 -0
- package/dist/hooks/useSpeechRecognition.d.ts +28 -0
- package/dist/hooks/useSpeechRecognition.js +118 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +469 -0
- package/dist/logger.d.ts +23 -0
- package/dist/logger.js +597 -0
- package/dist/logger.remote.test.d.ts +0 -0
- package/dist/modality-provider-v2.d.ts +28 -0
- package/dist/modality-provider-v2.js +1321 -0
- package/dist/modality-provider.d.ts +22 -0
- package/dist/modality-provider.js +373 -0
- package/dist/native-visibility.d.ts +28 -0
- package/dist/native-visibility.js +50 -0
- package/dist/platform/VoiceRecognitionBar.d.ts +17 -0
- package/dist/platform/VoiceRecognitionBar.js +332 -0
- package/dist/platform/components.d.ts +32 -0
- package/dist/platform/components.js +351 -0
- package/dist/platform/events.d.ts +31 -0
- package/dist/platform/events.js +274 -0
- package/dist/platform/index.d.ts +3 -0
- package/dist/platform/index.js +39 -0
- package/dist/platform/types.d.ts +79 -0
- package/dist/platform/types.js +97 -0
- package/dist/react-decorators.d.ts +87 -0
- package/dist/react-decorators.js +368 -0
- package/dist/shared-store.d.ts +74 -0
- package/dist/shared-store.js +589 -0
- package/dist/speech-recognition/__tests__/speech-recognition-groq-transport.test.d.ts +1 -0
- package/dist/speech-recognition/__tests__/speech-recognition-native.test.d.ts +1 -0
- package/dist/speech-recognition/__tests__/speech-recognition-openai-native.test.d.ts +1 -0
- package/dist/speech-recognition/__tests__/speech-recognition-openai.test.d.ts +1 -0
- package/dist/speech-recognition/__tests__/speech-recognition-unified-import.test.d.ts +0 -0
- package/dist/speech-recognition/__tests__/speech-recognition-unified.test.d.ts +1 -0
- package/dist/speech-recognition/speech-recognition-groq.d.ts +21 -0
- package/dist/speech-recognition/speech-recognition-groq.js +409 -0
- package/dist/speech-recognition/speech-recognition-mlx.d.ts +15 -0
- package/dist/speech-recognition/speech-recognition-mlx.js +393 -0
- package/dist/speech-recognition/speech-recognition-native.d.ts +24 -0
- package/dist/speech-recognition/speech-recognition-native.js +632 -0
- package/dist/speech-recognition/speech-recognition-openai-native.d.ts +40 -0
- package/dist/speech-recognition/speech-recognition-openai-native.js +653 -0
- package/dist/speech-recognition/speech-recognition-openai.d.ts +39 -0
- package/dist/speech-recognition/speech-recognition-openai.js +718 -0
- package/dist/speech-recognition/speech-recognition-unified.d.ts +93 -0
- package/dist/speech-recognition/speech-recognition-unified.js +589 -0
- package/dist/speech-recognition/utils/groq-transcription.d.ts +41 -0
- package/dist/speech-recognition/utils/groq-transcription.js +382 -0
- package/dist/speech-recognition.d.ts +7 -0
- package/dist/speech-recognition.js +61 -0
- package/dist/voice-pipeline-telemetry.d.ts +26 -0
- package/dist/voice-pipeline-telemetry.js +15 -0
- package/garrix82-reactgenie-lib-1.3.0.tgz +0 -0
- package/metro/index.js +3 -0
- package/metro/with-genie-registry.js +47 -0
- package/package.json +111 -0
- package/scripts/dry-run.js +23 -0
- package/scripts/generate-genie-registry.js +278 -0
- package/scripts/log-file-test.js +51 -0
- package/scripts/parse.js +26 -0
- package/scripts/prompt.js +19 -0
- package/scripts/set-script.js +200 -0
- package/tsconfig.json +36 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const folderName = "./__test__";
|
|
5
|
+
|
|
6
|
+
if (!fs.existsSync(folderName)) {
|
|
7
|
+
fs.mkdirSync(folderName);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
console.log("Test folder created");
|
|
11
|
+
|
|
12
|
+
const dry_run_test = `
|
|
13
|
+
import {DslInterpreter, DescriptorPromptGen} from "@garrix82/reactgenie-dsl";
|
|
14
|
+
import {initReactGenie, AllGenieObjects} from "@garrix82/reactgenie-lib";
|
|
15
|
+
import * as fs from 'fs';
|
|
16
|
+
import { get } from "http";
|
|
17
|
+
|
|
18
|
+
test("test", async () => {
|
|
19
|
+
// list all files in "../genie" folder
|
|
20
|
+
const files = fs.readdirSync("./genie");
|
|
21
|
+
// get only ts files
|
|
22
|
+
const tsFiles = files.filter((file) => file.endsWith(".ts"));
|
|
23
|
+
// require all ts files
|
|
24
|
+
tsFiles.forEach((file) => {
|
|
25
|
+
require("../genie/" + file);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
//set descriptor
|
|
29
|
+
const reactGenieStore = initReactGenie();
|
|
30
|
+
let descriptors = []
|
|
31
|
+
for (const key in AllGenieObjects) {
|
|
32
|
+
descriptors.push(AllGenieObjects[key].ClassDescriptor)
|
|
33
|
+
// console.log(key)
|
|
34
|
+
}
|
|
35
|
+
const interpreter = new DslInterpreter(descriptors, true);
|
|
36
|
+
|
|
37
|
+
//get all commands
|
|
38
|
+
const cmd = fs.readFileSync('./__test__/dry-run-input.txt', 'utf8');
|
|
39
|
+
// split by new line
|
|
40
|
+
const cmdList = cmd.split("\\n");
|
|
41
|
+
console.log(cmdList);
|
|
42
|
+
|
|
43
|
+
let output = "";
|
|
44
|
+
for (let i = 0; i < cmdList.length; i++) {
|
|
45
|
+
const cmd = cmdList[i];
|
|
46
|
+
try {
|
|
47
|
+
let funcCallResult = await interpreter.interpret(cmd);
|
|
48
|
+
console.log(funcCallResult);
|
|
49
|
+
output += JSON.stringify({status: 'success', result: funcCallResult}) + "\\n";
|
|
50
|
+
// print ok or success
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
output += JSON.stringify({status: 'error', result: e}) + "\\n";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
fs.writeFileSync('./__test__/dry-run-output.txt', output);
|
|
58
|
+
});
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
fs.writeFile("./__test__/dry-run.test.ts", dry_run_test, function (err) {
|
|
62
|
+
if (err) throw err;
|
|
63
|
+
console.log("Created dry-run test!");
|
|
64
|
+
});
|
|
65
|
+
fs.writeFile("./__test__/dry-run-input.txt", "", function (err) {
|
|
66
|
+
if (err) throw err;
|
|
67
|
+
console.log("Created dry-run input!");
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
fs.writeFile("./__test__/dry-run-output.txt", "", function (err) {
|
|
71
|
+
if (err) throw err;
|
|
72
|
+
console.log("Created dry-run output!");
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// fs.writeFile("./__test__/dry-run-error.txt", "", function (err) {
|
|
76
|
+
// if (err) throw err;
|
|
77
|
+
// console.log("Created dry-run error!");
|
|
78
|
+
// });
|
|
79
|
+
|
|
80
|
+
const prompt_test = `
|
|
81
|
+
import {DslInterpreter, GenieObject} from "@garrix82/reactgenie-dsl";
|
|
82
|
+
import {ClassDescriptor, DateTime, TimeDelta} from "@garrix82/reactgenie-lib";
|
|
83
|
+
import {initReactGenie} from "@garrix82/reactgenie-lib";
|
|
84
|
+
import {AllGenieObjects} from "@garrix82/reactgenie-dsl";
|
|
85
|
+
import {DescriptorPromptGen, sharedState} from "@garrix82/reactgenie-dsl";
|
|
86
|
+
import fs from "fs";
|
|
87
|
+
|
|
88
|
+
test("test", () => {
|
|
89
|
+
const files = fs.readdirSync("./genie");
|
|
90
|
+
// get only ts files
|
|
91
|
+
const tsFiles = files.filter((file) => file.endsWith(".ts"));
|
|
92
|
+
// require all ts files
|
|
93
|
+
tsFiles.forEach((file) => {
|
|
94
|
+
require("../genie/" + file);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const reactGenieStore = initReactGenie();
|
|
98
|
+
|
|
99
|
+
let descriptors:ClassDescriptor<GenieObject>[] = []
|
|
100
|
+
for (const key in AllGenieObjects) {
|
|
101
|
+
descriptors.push(AllGenieObjects[key].ClassDescriptor)
|
|
102
|
+
// console.log(key)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
// @ts-ignore
|
|
107
|
+
const nl_interpreter = new DescriptorPromptGen(descriptors,sharedState["__EXAMPLES__"])
|
|
108
|
+
const prompt_basic = nl_interpreter.prompt_basic()
|
|
109
|
+
fs.writeFileSync('./__test__/prompt.txt', prompt_basic);
|
|
110
|
+
|
|
111
|
+
});
|
|
112
|
+
`;
|
|
113
|
+
|
|
114
|
+
fs.writeFile("./__test__/prompt.test.ts", prompt_test, function (err) {
|
|
115
|
+
if (err) throw err;
|
|
116
|
+
console.log("Created prompt test!");
|
|
117
|
+
});
|
|
118
|
+
fs.writeFile("./__test__/prompt.txt", "", function (err) {
|
|
119
|
+
if (err) throw err;
|
|
120
|
+
console.log("Created prompt output!");
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const parse_test = `
|
|
124
|
+
import {NlParser, DescriptorPromptGen, ClassDescriptor, GenieObject, sharedState} from "@garrix82/reactgenie-dsl";
|
|
125
|
+
import {initReactGenie, AllGenieObjects} from "@garrix82/reactgenie-lib";
|
|
126
|
+
import * as fs from 'fs';
|
|
127
|
+
let API_KEY = ""
|
|
128
|
+
|
|
129
|
+
test("test", async () => {
|
|
130
|
+
const files = fs.readdirSync("./genie");
|
|
131
|
+
const tsFiles = files.filter((file) => file.endsWith(".ts"));
|
|
132
|
+
tsFiles.forEach((file) => {
|
|
133
|
+
require("../genie/" + file);
|
|
134
|
+
});
|
|
135
|
+
const reactGenieStore = initReactGenie();
|
|
136
|
+
|
|
137
|
+
let descriptors:ClassDescriptor<GenieObject>[] = []
|
|
138
|
+
for (const key in AllGenieObjects) {
|
|
139
|
+
descriptors.push(AllGenieObjects[key].ClassDescriptor)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
const testPath = process.argv;
|
|
144
|
+
const nl_interpreter = new DescriptorPromptGen(descriptors,sharedState["__EXAMPLES__"])
|
|
145
|
+
|
|
146
|
+
let NLP = new NlParser(
|
|
147
|
+
nl_interpreter,
|
|
148
|
+
API_KEY,
|
|
149
|
+
"http://104.40.11.234:5000/v1",
|
|
150
|
+
process.env.SEMANTIC_MODEL
|
|
151
|
+
);
|
|
152
|
+
// console.log(testPath);
|
|
153
|
+
let res = await NLP.parse(process.argv[3])
|
|
154
|
+
console.log(res)
|
|
155
|
+
|
|
156
|
+
// console.log(testPath[3]);
|
|
157
|
+
}, 100000);
|
|
158
|
+
|
|
159
|
+
`;
|
|
160
|
+
|
|
161
|
+
fs.writeFile("./__test__/parse.test.ts", parse_test, function (err) {
|
|
162
|
+
if (err) throw err;
|
|
163
|
+
console.log("Created parse test!");
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
const jest_config = `
|
|
169
|
+
module.exports = {
|
|
170
|
+
testEnvironment: "jsdom",
|
|
171
|
+
preset: "jest-expo",
|
|
172
|
+
"moduleNameMapper": {
|
|
173
|
+
"\\.(jpg|ico|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/mocks/fileMock.js",
|
|
174
|
+
"\\.(css|less)$": "<rootDir>/mocks/fileMock.js",
|
|
175
|
+
"^uuid$": require.resolve('uuid'),
|
|
176
|
+
},
|
|
177
|
+
testEnvironmentOptions: {
|
|
178
|
+
url: 'http://104.40.11.234:5000/v1',
|
|
179
|
+
verbose: true,
|
|
180
|
+
},
|
|
181
|
+
}
|
|
182
|
+
`;
|
|
183
|
+
|
|
184
|
+
fs.writeFile("./jest.config.js", jest_config, function (err) {
|
|
185
|
+
if (err) throw err;
|
|
186
|
+
console.log("Created jest config!");
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
const mocksName = "./mocks";
|
|
190
|
+
|
|
191
|
+
if (!fs.existsSync(mocksName)) {
|
|
192
|
+
fs.mkdirSync(mocksName);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const mock_config = "module.exports = '';";
|
|
196
|
+
|
|
197
|
+
fs.writeFile("./mocks/fileMock.js", mock_config, function (err) {
|
|
198
|
+
if (err) throw err;
|
|
199
|
+
console.log("Created mock config!");
|
|
200
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"esModuleInterop": true,
|
|
4
|
+
"jsx": "react",
|
|
5
|
+
"experimentalDecorators": true,
|
|
6
|
+
"target": "es2022",
|
|
7
|
+
"lib": ["es2022", "dom", "dom.iterable"],
|
|
8
|
+
"module": "commonjs",
|
|
9
|
+
"moduleResolution": "node",
|
|
10
|
+
"noImplicitAny": false,
|
|
11
|
+
"removeComments": true,
|
|
12
|
+
"preserveConstEnums": true,
|
|
13
|
+
"sourceMap": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"outDir": "dist",
|
|
16
|
+
"declaration": true,
|
|
17
|
+
"allowJs": true,
|
|
18
|
+
"resolveJsonModule": true,
|
|
19
|
+
"emitDecoratorMetadata": true,
|
|
20
|
+
"noEmit": false,
|
|
21
|
+
"skipLibCheck": true,
|
|
22
|
+
"paths": {
|
|
23
|
+
"@root/*": ["./src/*"]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"include": [
|
|
27
|
+
"./src",
|
|
28
|
+
"./src/__tests__/test-types.d.ts"
|
|
29
|
+
],
|
|
30
|
+
"exclude": [
|
|
31
|
+
"./example",
|
|
32
|
+
"./node_modules",
|
|
33
|
+
"./dist",
|
|
34
|
+
"./scripts"
|
|
35
|
+
]
|
|
36
|
+
}
|