theprogrammablemind 7.5.8-beta.15 → 7.5.8-beta.17
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 +14 -8
- package/package.json +1 -1
- package/src/config.js +25 -12
package/client.js
CHANGED
@@ -9,7 +9,6 @@ const _ = require('lodash')
|
|
9
9
|
const stringify = require('json-stable-stringify')
|
10
10
|
const Lines = require('./lines')
|
11
11
|
const flattens = require('./src/flatten')
|
12
|
-
const { config_toServer } = require('./src/config.js')
|
13
12
|
const { appendNoDups, InitCalls, updateQueries } = require('./src/helpers')
|
14
13
|
const runtime = require('./runtime')
|
15
14
|
const sortJson = runtime.sortJson
|
@@ -299,7 +298,6 @@ const writeTest = (fn, query, objects, generated, paraphrases, responses, contex
|
|
299
298
|
}
|
300
299
|
associations.sort()
|
301
300
|
// tests[query] = sortJson({ paraphrases, responses, contexts, objects: convertToStable(objects), associations, metadata, config, developerTest: saveDeveloper }, { depth: 25 })
|
302
|
-
debugger
|
303
301
|
results = sortJson({
|
304
302
|
query,
|
305
303
|
paraphrases,
|
@@ -419,6 +417,7 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
|
|
419
417
|
if (json.has_errors) {
|
420
418
|
throw new Error('There are errors in the logs. Run with the -d flag and grep for Error')
|
421
419
|
}
|
420
|
+
const generateParenthesized = isTest || (commandLineArgs && commandLineArgs.save)
|
422
421
|
if (!config.get('skipSemantics')) {
|
423
422
|
if (!config.doMotivations(args, context)) {
|
424
423
|
const semantics = config.getSemantics(json.logs)
|
@@ -440,7 +439,7 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
|
|
440
439
|
let assumed = { isResponse: true };
|
441
440
|
const generated = contextPrime.isResponse ? config.getGenerators(json.logs).apply(args, contextPrime, assumed)[0] : ''
|
442
441
|
let generatedParenthesized = []
|
443
|
-
if (
|
442
|
+
if (generateParenthesized) {
|
444
443
|
config.parenthesized = true
|
445
444
|
generatedParenthesized = contextPrime.isResponse ? config.getGenerators(json.logs).apply(args, contextPrime, assumed)[0] : ''
|
446
445
|
config.parenthesized = false
|
@@ -453,12 +452,12 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
|
|
453
452
|
args.gs = gs(args.g)
|
454
453
|
args.gsp = gs(args.gsp)
|
455
454
|
args.gsr = gs(args.gr)
|
456
|
-
if (
|
455
|
+
if (generateParenthesized) {
|
457
456
|
config.parenthesized = false
|
458
457
|
}
|
459
458
|
const paraphrases = config.getGenerators(json.logs).apply(args, contextPrime, assumed)[0]
|
460
459
|
let paraphrasesParenthesized = []
|
461
|
-
if (
|
460
|
+
if (generateParenthesized) {
|
462
461
|
config.parenthesized = true
|
463
462
|
paraphrasesParenthesized = config.getGenerators(json.logs).apply(args, contextPrime, assumed)[0]
|
464
463
|
config.parenthesized = false
|
@@ -472,7 +471,7 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
|
|
472
471
|
contextsPrime.push(contextPrime)
|
473
472
|
generatedPrime.push(generated)
|
474
473
|
paraphrasesPrime.push(paraphrases)
|
475
|
-
if (
|
474
|
+
if (generateParenthesized) {
|
476
475
|
paraphrasesParenthesizedPrime.push(paraphrasesParenthesized)
|
477
476
|
generatedParenthesizedPrime.push(generatedParenthesized)
|
478
477
|
}
|
@@ -553,7 +552,7 @@ const setupProcessB = ({ config, initializer, allowDelta=false } = {}) => {
|
|
553
552
|
Object.assign(data, config.config)
|
554
553
|
}
|
555
554
|
|
556
|
-
|
555
|
+
config.toServer(data)
|
557
556
|
|
558
557
|
if (data.namespaces) {
|
559
558
|
for (const uuid of Object.keys(data.namespaces)) {
|
@@ -1353,9 +1352,15 @@ const knowledgeModule = async ({
|
|
1353
1352
|
beforeTests = () => {},
|
1354
1353
|
afterTests = () => {},
|
1355
1354
|
beforeTest = () => {},
|
1356
|
-
afterTest = () => {}
|
1355
|
+
afterTest = () => {},
|
1356
|
+
...rest
|
1357
1357
|
} = {}) => {
|
1358
1358
|
|
1359
|
+
const unknownArgs = Object.keys(rest)
|
1360
|
+
if (unknownArgs.length > 0) {
|
1361
|
+
throw new Error(`Unknown arguments to knowledgeModule: ${unknownArgs.join()}`)
|
1362
|
+
}
|
1363
|
+
|
1359
1364
|
config.beforeQuery = beforeQuery
|
1360
1365
|
config.beforeTests = beforeTests
|
1361
1366
|
config.afterTests = afterTests
|
@@ -1941,3 +1946,4 @@ module.exports = {
|
|
1941
1946
|
flattens,
|
1942
1947
|
writeTest
|
1943
1948
|
}
|
1949
|
+
|
package/package.json
CHANGED
package/src/config.js
CHANGED
@@ -79,7 +79,6 @@ const elist = (list, check, prefix) => {
|
|
79
79
|
}
|
80
80
|
}
|
81
81
|
const contextual_priorities_valid = (cps) => {
|
82
|
-
debugger
|
83
82
|
elist(cps, (cp) => contextual_priority_valid(cp), (index, e) => `contextual_priorities has an invalid contextual priority at position ${index}. ${e}`)
|
84
83
|
}
|
85
84
|
|
@@ -91,12 +90,20 @@ const contextual_priority_valid = (cp) => {
|
|
91
90
|
throw new Error(`The contextual priority ${JSON.stringify(cp)} has an invalid "context" value. That is a list of the operator keys that are to be prioritized differently.`)
|
92
91
|
}
|
93
92
|
elist(cp.context, (element) => operatorKey_valid(element), (index, e) => `The contextual priority ${JSON.stringify(cp)} has an invalid operator key at position ${index}. ${e}`)
|
94
|
-
if (!
|
95
|
-
throw new Error(`The contextual priority ${JSON.stringify(cp)}
|
96
|
-
}
|
97
|
-
if (!_.isInteger(cp.choose) || cp.choose < 0 || cp.choose >= cp.context.length) {
|
98
|
-
throw new Error(`The contextual priority ${JSON.stringify(cp)} is missing the "choose" property. That is an index into the "context" property of the operator that is to be prioritized. Valid values are between 0 and ${cp.context.length-1}.`)
|
93
|
+
if (!_.isArray(cp.choose)) {
|
94
|
+
throw new Error(`The contextual priority ${JSON.stringify(cp)} has an invalid "choose" value. The value should be a list of the operators in the context to consider for prioritization.`)
|
99
95
|
}
|
96
|
+
elist(cp.choose,
|
97
|
+
(element) => {
|
98
|
+
if (!element && element !== 0) {
|
99
|
+
throw new Error(`The value should be an index into the "context" property of the operator that is to be considered for prioritization.`)
|
100
|
+
}
|
101
|
+
if (!_.isInteger(element) || element < 0 || element >= cp.context.length) {
|
102
|
+
throw new Error(`The value should be an index into the "context" property of the operator that is to be considered for prioritization. Valid values are between 0 and ${cp.context.length-1}.`)
|
103
|
+
}
|
104
|
+
},
|
105
|
+
(index, e) => `The choose property in the contextual priority ${JSON.stringify(cp)} has an invalid index at position ${index}. ${e}`
|
106
|
+
)
|
100
107
|
}
|
101
108
|
|
102
109
|
const handleBridgeProps = (config, bridge) => {
|
@@ -570,6 +577,10 @@ const multiApiImpl = (initializer) => {
|
|
570
577
|
|
571
578
|
class Config {
|
572
579
|
|
580
|
+
toServer (config) {
|
581
|
+
return config_toServer(config)
|
582
|
+
}
|
583
|
+
|
573
584
|
inDevelopmentMode (call) {
|
574
585
|
config.developmentModeOn += 1
|
575
586
|
try {
|
@@ -919,8 +930,8 @@ class Config {
|
|
919
930
|
}
|
920
931
|
}
|
921
932
|
contextual_priority_valid(contextual_priority)
|
933
|
+
this.config.contextual_priorities.push(contextual_priority)
|
922
934
|
const cpServer = contextual_priorities_toServer(contextual_priority)
|
923
|
-
this.config.contextual_priorities.push(cpServer)
|
924
935
|
this._delta.json.contextual_priorities.push({ action: 'add', contextual_priority: cpServer })
|
925
936
|
}
|
926
937
|
|
@@ -2393,11 +2404,13 @@ class Config {
|
|
2393
2404
|
if (config.contextual_priorities) {
|
2394
2405
|
let contextual_priorities = config.contextual_priorities
|
2395
2406
|
contextual_priorities = contextual_priorities.map((cp) => {
|
2396
|
-
const
|
2397
|
-
|
2398
|
-
|
2399
|
-
|
2400
|
-
|
2407
|
+
const { context, choose } = cp
|
2408
|
+
return {
|
2409
|
+
context: context.map((id) => {
|
2410
|
+
return [toNS(id[0]), id[1]]
|
2411
|
+
}),
|
2412
|
+
choose
|
2413
|
+
}
|
2401
2414
|
})
|
2402
2415
|
config.contextual_priorities = contextual_priorities
|
2403
2416
|
}
|