theprogrammablemind 7.12.2 → 7.12.3-beta.1
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/client.js +27 -21
- package/package.json +1 -1
- package/src/config.js +90 -66
package/client.js
CHANGED
@@ -89,12 +89,12 @@ const sameJSON = (json1, json2) => {
|
|
89
89
|
return JSON.stringify(sjson1) == JSON.stringify(sjson2)
|
90
90
|
}
|
91
91
|
|
92
|
-
const vimdiff = (actualJSON, expectedJSON) => {
|
92
|
+
const vimdiff = (actualJSON, expectedJSON, title) => {
|
93
93
|
const path = '.'
|
94
94
|
const actual = sortJson(actualJSON, { depth: 25 })
|
95
|
-
runtime.fs.writeFileSync(`${path}/actual.json`, JSON.stringify(actual, 0, 2))
|
95
|
+
runtime.fs.writeFileSync(`${path}/actual.json`, JSON.stringify({ title, actual}, 0, 2))
|
96
96
|
const expected = sortJson(expectedJSON, { depth: 25 })
|
97
|
-
runtime.fs.writeFileSync(`${path}/expected.json`, JSON.stringify(expected, 0, 2))
|
97
|
+
runtime.fs.writeFileSync(`${path}/expected.json`, JSON.stringify({ title, expected}, 0, 2))
|
98
98
|
// console.log(`vimdiff ${path}/actual.json ${path}/expected.json`)
|
99
99
|
{
|
100
100
|
const editor = runtime.process.env.EDITOR || 'vimdiff'
|
@@ -196,7 +196,7 @@ const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => {
|
|
196
196
|
|
197
197
|
args.addAssumedScoped = (args, assumed) => {
|
198
198
|
const addAssumed = (args, ...moreAssumed) => {
|
199
|
-
return { ...args, assumed: Object.assign({}, (args.assumed || {}), ...moreAssumed) }
|
199
|
+
return { ...args, assumed: Object.assign({}, assumed, (args.assumed || {}), ...moreAssumed) }
|
200
200
|
}
|
201
201
|
|
202
202
|
args.s = (c) => config.getSemantics(logs).apply(args, c)
|
@@ -638,7 +638,9 @@ const loadInstance = (config, instance) => {
|
|
638
638
|
// config.addInternal(results, useOldVersion = true, skipObjects = false, includeNamespaces = true, allowNameToBeNull = false)
|
639
639
|
// config.addInternal(config.template.queries[i], { handleCalculatedProps: true } )
|
640
640
|
const uuid = config.nameToUUID(instance.name)
|
641
|
-
|
641
|
+
// used to do a CLONE
|
642
|
+
// config.addInternal(_.cloneDeep(instance.template.queries[i]), { uuid, addFirst: true, handleCalculatedProps: true })
|
643
|
+
config.addInternal(instance.template.queries[i], { uuid, addFirst: true, handleCalculatedProps: true })
|
642
644
|
} else if (results.apply) {
|
643
645
|
const objects = config.get('objects')
|
644
646
|
const args = { objects, getObjects: getObjects(objects) }
|
@@ -1843,34 +1845,33 @@ const knowledgeModuleImpl = async ({
|
|
1843
1845
|
if (results.length > 0) {
|
1844
1846
|
let headerShown = false
|
1845
1847
|
|
1846
|
-
let
|
1848
|
+
let hasError = false
|
1847
1849
|
for (const result of results) {
|
1848
|
-
let hasError = false
|
1849
1850
|
if (JSON.stringify(result.expected.paraphrases) !== JSON.stringify(result.actual.paraphrases)) {
|
1850
|
-
hasError = true
|
1851
|
+
result.hasError = true
|
1851
1852
|
}
|
1852
1853
|
if (!args.testNoParenthesized) {
|
1853
1854
|
if (JSON.stringify(result.expected.paraphrasesParenthesized) !== JSON.stringify(result.actual.paraphrasesParenthesized)) {
|
1854
|
-
hasError = true
|
1855
|
+
result.hasError = true
|
1855
1856
|
}
|
1856
1857
|
if (JSON.stringify(result.expected.generatedParenthesized) !== JSON.stringify(result.actual.generatedParenthesized)) {
|
1857
|
-
hasError = true
|
1858
|
+
result.hasError = true
|
1858
1859
|
}
|
1859
1860
|
}
|
1860
1861
|
if (JSON.stringify(result.expected.responses) !== JSON.stringify(result.actual.responses)) {
|
1861
|
-
hasError = true
|
1862
|
+
result.hasError = true
|
1862
1863
|
}
|
1863
1864
|
if (JSON.stringify(result.expected.checked) !== JSON.stringify(result.actual.checked)) {
|
1864
|
-
hasError = true
|
1865
|
+
result.hasError = true
|
1865
1866
|
}
|
1866
1867
|
if (!sameJSON(result.expected.checkedContexts, result.actual.checkedContexts)) {
|
1867
|
-
hasError = true
|
1868
|
+
result.hasError = true
|
1868
1869
|
}
|
1869
|
-
if (hasError) {
|
1870
|
-
|
1870
|
+
if (result.hasError) {
|
1871
|
+
hasError = true
|
1871
1872
|
}
|
1872
1873
|
}
|
1873
|
-
|
1874
|
+
|
1874
1875
|
if (hasError) {
|
1875
1876
|
console.log('**************************** ERRORS ************************')
|
1876
1877
|
for (const result of results) {
|
@@ -1885,21 +1886,20 @@ const knowledgeModuleImpl = async ({
|
|
1885
1886
|
newError = true
|
1886
1887
|
headerShown = true
|
1887
1888
|
if (args.vimdiff) {
|
1888
|
-
vimdiff(
|
1889
|
+
vimdiff(actual, expected, `"${result.utterance}" - ${label}`)
|
1889
1890
|
}
|
1890
|
-
|
1891
|
+
result.hasError = true
|
1891
1892
|
}
|
1892
1893
|
}
|
1893
1894
|
show('paraphrases', result.expected.paraphrases, result.actual.paraphrases)
|
1894
1895
|
if (!args.testNoParenthesized) {
|
1895
1896
|
show('paraphrases parenthesized', result.expected.paraphrasesParenthesized, result.actual.paraphrasesParenthesized)
|
1896
1897
|
}
|
1897
|
-
/*
|
1898
|
-
}
|
1899
1898
|
show('responses', result.expected.responses, result.actual.responses)
|
1900
1899
|
if (!args.testNoParenthesized) {
|
1901
1900
|
show('responses parenthesized', result.expected.generatedParenthesized, result.actual.generatedParenthesized)
|
1902
1901
|
}
|
1902
|
+
/*
|
1903
1903
|
if (JSON.stringify(result.expected.paraphrases) !== JSON.stringify(result.actual.paraphrases)) {
|
1904
1904
|
if (!headerShown) {
|
1905
1905
|
console.log(' Failure')
|
@@ -1972,7 +1972,13 @@ const knowledgeModuleImpl = async ({
|
|
1972
1972
|
if (!(useTestConfig.check && useTestConfig.check.length > 0)) {
|
1973
1973
|
console.log('use -v arg to write files expected.json and actual.json in the current directory for detailed comparison. Or do -s and then git diff the changes.')
|
1974
1974
|
// console.log(JSON.stringify(contexts))
|
1975
|
-
|
1975
|
+
let errorCount = 0
|
1976
|
+
for (const result of results) {
|
1977
|
+
if (result.hasError) {
|
1978
|
+
errorCount += 1
|
1979
|
+
}
|
1980
|
+
}
|
1981
|
+
console.log(`**************************** THERE WERE ${errorCount} TEST FAILURES ************************`)
|
1976
1982
|
}
|
1977
1983
|
}
|
1978
1984
|
}
|
package/package.json
CHANGED
package/src/config.js
CHANGED
@@ -259,14 +259,16 @@ const handleBridgeProps = (config, bridge, addFirst) => {
|
|
259
259
|
}
|
260
260
|
}
|
261
261
|
*/
|
262
|
+
|
263
|
+
const addUUID = (obj) => { return { ...obj, uuid: config.uuid } }
|
262
264
|
if (bridge.generators) {
|
263
265
|
const generators = [...bridge.generators]
|
264
266
|
generators.reverse()
|
265
267
|
for (const generator of generators) {
|
266
268
|
if (addFirst) {
|
267
|
-
config.config.generators.unshift(generator)
|
269
|
+
config.config.generators.unshift(addUUID(generator))
|
268
270
|
} else {
|
269
|
-
config.config.generators.push(generator)
|
271
|
+
config.config.generators.push(addUUID(generator))
|
270
272
|
}
|
271
273
|
}
|
272
274
|
}
|
@@ -287,9 +289,9 @@ const handleBridgeProps = (config, bridge, addFirst) => {
|
|
287
289
|
property: 'generatorp'
|
288
290
|
}
|
289
291
|
if (addFirst) {
|
290
|
-
config.config.generators.unshift(generator)
|
292
|
+
config.config.generators.unshift(addUUID(generator))
|
291
293
|
} else {
|
292
|
-
config.config.generators.push(generator)
|
294
|
+
config.config.generators.push(addUUID(generator))
|
293
295
|
}
|
294
296
|
}
|
295
297
|
if (bridge.generatorr) {
|
@@ -304,9 +306,9 @@ const handleBridgeProps = (config, bridge, addFirst) => {
|
|
304
306
|
property: 'generatorr'
|
305
307
|
}
|
306
308
|
if (addFirst) {
|
307
|
-
config.config.generators.unshift(generator)
|
309
|
+
config.config.generators.unshift(addUUID(generator))
|
308
310
|
} else {
|
309
|
-
config.config.generators.push(generator)
|
311
|
+
config.config.generators.push(addUUID(generator))
|
310
312
|
}
|
311
313
|
}
|
312
314
|
if (bridge.evaluator) {
|
@@ -318,9 +320,9 @@ const handleBridgeProps = (config, bridge, addFirst) => {
|
|
318
320
|
property: 'evaluator'
|
319
321
|
}
|
320
322
|
if (addFirst) {
|
321
|
-
config.config.semantics.unshift(semantic)
|
323
|
+
config.config.semantics.unshift(addUUID(semantic))
|
322
324
|
} else {
|
323
|
-
config.config.semantics.push(semantic)
|
325
|
+
config.config.semantics.push(addUUID(semantic))
|
324
326
|
}
|
325
327
|
}
|
326
328
|
if (bridge.semantic) {
|
@@ -332,9 +334,9 @@ const handleBridgeProps = (config, bridge, addFirst) => {
|
|
332
334
|
property: 'semantic'
|
333
335
|
}
|
334
336
|
if (addFirst) {
|
335
|
-
config.config.semantics.unshift(semantic)
|
337
|
+
config.config.semantics.unshift(addUUID(semantic))
|
336
338
|
} else {
|
337
|
-
config.config.semantics.push(semantic)
|
339
|
+
config.config.semantics.push(addUUID(semantic))
|
338
340
|
}
|
339
341
|
}
|
340
342
|
}
|
@@ -511,6 +513,12 @@ function applyUUID (config, uuid) {
|
|
511
513
|
if (config.bridges) {
|
512
514
|
config.bridges = config.bridges.map((o) => Object.assign(o, { uuid }))
|
513
515
|
}
|
516
|
+
if (config.generators) {
|
517
|
+
config.generators = config.generators.map((o) => Object.assign(o, { uuid }))
|
518
|
+
}
|
519
|
+
if (config.semantics) {
|
520
|
+
config.semantics = config.semantics.map((o) => Object.assign(o, { uuid }))
|
521
|
+
}
|
514
522
|
if (config.words) {
|
515
523
|
setWordsUUIDs(config.words, uuid)
|
516
524
|
}
|
@@ -1097,6 +1105,7 @@ class Config {
|
|
1097
1105
|
if (!helpers.safeEquals(templateQueries[iq], instanceQueries[iq])) {
|
1098
1106
|
sameQueries = false
|
1099
1107
|
startOfChanges = iq
|
1108
|
+
break;
|
1100
1109
|
}
|
1101
1110
|
}
|
1102
1111
|
|
@@ -1114,10 +1123,6 @@ class Config {
|
|
1114
1123
|
|
1115
1124
|
if (debug) {
|
1116
1125
|
if (!(instance && sameQueries && sameFragments)) {
|
1117
|
-
if (!sameQueries) {
|
1118
|
-
debugger
|
1119
|
-
debugger
|
1120
|
-
}
|
1121
1126
|
// console.log("instance", instance)
|
1122
1127
|
console.log('sameQueries', sameQueries)
|
1123
1128
|
console.log('sameFragments', sameFragments)
|
@@ -1737,6 +1742,15 @@ class Config {
|
|
1737
1742
|
this.addedArgss.push(moreArgs)
|
1738
1743
|
}
|
1739
1744
|
|
1745
|
+
stop_auto_rebuild() {
|
1746
|
+
this._stop_auto_rebuild = true
|
1747
|
+
}
|
1748
|
+
|
1749
|
+
restart_auto_rebuild() {
|
1750
|
+
this._stop_auto_rebuild = false
|
1751
|
+
this.rebuild()
|
1752
|
+
}
|
1753
|
+
|
1740
1754
|
getAddedArgs (args) {
|
1741
1755
|
for (let addedArgs of this.addedArgss) {
|
1742
1756
|
addedArgs = addedArgs(args)
|
@@ -2245,6 +2259,9 @@ class Config {
|
|
2245
2259
|
|
2246
2260
|
// rebuild ({ isModule: mainIsModule = false } = {}) {
|
2247
2261
|
rebuild ({ isModule: mainIsModule } = {}) {
|
2262
|
+
if (this._stop_auto_rebuild) {
|
2263
|
+
return
|
2264
|
+
}
|
2248
2265
|
this.resetDelta()
|
2249
2266
|
const debug = this.config.debug
|
2250
2267
|
this.config = _.cloneDeep(this.initConfig)
|
@@ -2741,63 +2758,70 @@ class Config {
|
|
2741
2758
|
}
|
2742
2759
|
}
|
2743
2760
|
|
2744
|
-
add (
|
2745
|
-
|
2746
|
-
|
2747
|
-
|
2748
|
-
|
2749
|
-
|
2750
|
-
}
|
2761
|
+
add (...mores) {
|
2762
|
+
mores.forEach((km) => {
|
2763
|
+
if (km === this) {
|
2764
|
+
throw new Error('Cannot add an object to itself.')
|
2765
|
+
}
|
2766
|
+
})
|
2751
2767
|
|
2752
|
-
|
2753
|
-
|
2754
|
-
|
2755
|
-
|
2756
|
-
more.server(this._server, this._key, this._queryParams)
|
2757
|
-
|
2758
|
-
this.loadOrder.addList(more.configs.map((km) => km.name || km.uuid))
|
2759
|
-
|
2760
|
-
// get the new ones
|
2761
|
-
// remove the dups
|
2762
|
-
// run the initialize one all new ones
|
2763
|
-
// this.configs = this.configs.concat(new KM({config: more}));
|
2764
|
-
// only set for the first one the rest have it set
|
2765
|
-
const namespace = this._namespace.concat(more._namespace)
|
2766
|
-
const moreKMs1 = [new KM({ config: more, getCounter: (name) => this.getCounter(name), uuid: more.uuid, namespace })]
|
2767
|
-
const moreKMs2 = more.configs.slice(1).map((km) => {
|
2768
|
+
mores.map((km) => {
|
2769
|
+
if (!(km instanceof Config)) {
|
2770
|
+
km = new Config(km)
|
2771
|
+
}
|
2768
2772
|
return km
|
2769
|
-
// const cp = km.copy()
|
2770
|
-
// cp.namespace = namespace
|
2771
|
-
// return cp;
|
2772
2773
|
})
|
2773
|
-
|
2774
|
-
|
2775
|
-
|
2776
|
-
|
2777
|
-
|
2778
|
-
|
2779
|
-
|
2780
|
-
|
2781
|
-
|
2782
|
-
|
2774
|
+
|
2775
|
+
mores.forEach((more) => {
|
2776
|
+
this.valid()
|
2777
|
+
more.valid()
|
2778
|
+
// copy so i don't have to copy later
|
2779
|
+
more = more.copy()
|
2780
|
+
more.server(this._server, this._key, this._queryParams)
|
2781
|
+
|
2782
|
+
this.loadOrder.addList(more.configs.map((km) => km.name || km.uuid))
|
2783
|
+
|
2784
|
+
// get the new ones
|
2785
|
+
// remove the dups
|
2786
|
+
// run the initialize one all new ones
|
2787
|
+
// this.configs = this.configs.concat(new KM({config: more}));
|
2788
|
+
// only set for the first one the rest have it set
|
2789
|
+
const namespace = this._namespace.concat(more._namespace)
|
2790
|
+
const moreKMs1 = [new KM({ config: more, getCounter: (name) => this.getCounter(name), uuid: more.uuid, namespace })]
|
2791
|
+
const moreKMs2 = more.configs.slice(1).map((km) => {
|
2792
|
+
return km
|
2793
|
+
// const cp = km.copy()
|
2794
|
+
// cp.namespace = namespace
|
2795
|
+
// return cp;
|
2796
|
+
})
|
2797
|
+
const moreKMs = moreKMs1.concat(moreKMs2)
|
2798
|
+
const eqClass = moreKMs.map((km) => km.uuid)
|
2799
|
+
this._eqClasses.push(eqClass)
|
2800
|
+
// look for dups and combine them with the eqclasses
|
2801
|
+
for (const moreKM of moreKMs) {
|
2802
|
+
const existingKM = this.configs.find((km) => moreKM._name && km.name === moreKM.name)
|
2803
|
+
if (existingKM) {
|
2804
|
+
this.addEqClass(existingKM, moreKM)
|
2805
|
+
} else {
|
2806
|
+
this.configs.push(moreKM)
|
2807
|
+
}
|
2783
2808
|
}
|
2784
|
-
|
2785
|
-
|
2786
|
-
|
2787
|
-
|
2788
|
-
|
2789
|
-
|
2790
|
-
|
2791
|
-
|
2792
|
-
|
2793
|
-
|
2794
|
-
|
2795
|
-
|
2796
|
-
|
2809
|
+
more.resetToOne()
|
2810
|
+
this.config.eqClasses = this._eqClasses
|
2811
|
+
// greg
|
2812
|
+
// setup instances
|
2813
|
+
this.instances = []
|
2814
|
+
this.configs.forEach((km) => {
|
2815
|
+
this.instances = (km._config.instances || this.initInstances.slice()).concat(this.instances)
|
2816
|
+
})
|
2817
|
+
const noDups = []
|
2818
|
+
for (const instance of this.instances) {
|
2819
|
+
if (!noDups.find((existing) => existing.name == instance.name)) {
|
2820
|
+
noDups.push(instance)
|
2821
|
+
}
|
2797
2822
|
}
|
2798
|
-
|
2799
|
-
|
2800
|
-
|
2823
|
+
this.instances = noDups
|
2824
|
+
})
|
2801
2825
|
this.rebuild()
|
2802
2826
|
this.valid()
|
2803
2827
|
return this
|