theprogrammablemind 7.5.8-beta.16 → 7.5.8-beta.18
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 +13 -6
- package/package.json +1 -1
- package/src/config.js +21 -11
package/client.js
CHANGED
@@ -298,7 +298,6 @@ const writeTest = (fn, query, objects, generated, paraphrases, responses, contex
|
|
298
298
|
}
|
299
299
|
associations.sort()
|
300
300
|
// tests[query] = sortJson({ paraphrases, responses, contexts, objects: convertToStable(objects), associations, metadata, config, developerTest: saveDeveloper }, { depth: 25 })
|
301
|
-
debugger
|
302
301
|
results = sortJson({
|
303
302
|
query,
|
304
303
|
paraphrases,
|
@@ -418,6 +417,7 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
|
|
418
417
|
if (json.has_errors) {
|
419
418
|
throw new Error('There are errors in the logs. Run with the -d flag and grep for Error')
|
420
419
|
}
|
420
|
+
const generateParenthesized = isTest || (commandLineArgs && commandLineArgs.save)
|
421
421
|
if (!config.get('skipSemantics')) {
|
422
422
|
if (!config.doMotivations(args, context)) {
|
423
423
|
const semantics = config.getSemantics(json.logs)
|
@@ -439,7 +439,7 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
|
|
439
439
|
let assumed = { isResponse: true };
|
440
440
|
const generated = contextPrime.isResponse ? config.getGenerators(json.logs).apply(args, contextPrime, assumed)[0] : ''
|
441
441
|
let generatedParenthesized = []
|
442
|
-
if (
|
442
|
+
if (generateParenthesized) {
|
443
443
|
config.parenthesized = true
|
444
444
|
generatedParenthesized = contextPrime.isResponse ? config.getGenerators(json.logs).apply(args, contextPrime, assumed)[0] : ''
|
445
445
|
config.parenthesized = false
|
@@ -452,12 +452,12 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
|
|
452
452
|
args.gs = gs(args.g)
|
453
453
|
args.gsp = gs(args.gsp)
|
454
454
|
args.gsr = gs(args.gr)
|
455
|
-
if (
|
455
|
+
if (generateParenthesized) {
|
456
456
|
config.parenthesized = false
|
457
457
|
}
|
458
458
|
const paraphrases = config.getGenerators(json.logs).apply(args, contextPrime, assumed)[0]
|
459
459
|
let paraphrasesParenthesized = []
|
460
|
-
if (
|
460
|
+
if (generateParenthesized) {
|
461
461
|
config.parenthesized = true
|
462
462
|
paraphrasesParenthesized = config.getGenerators(json.logs).apply(args, contextPrime, assumed)[0]
|
463
463
|
config.parenthesized = false
|
@@ -471,7 +471,7 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
|
|
471
471
|
contextsPrime.push(contextPrime)
|
472
472
|
generatedPrime.push(generated)
|
473
473
|
paraphrasesPrime.push(paraphrases)
|
474
|
-
if (
|
474
|
+
if (generateParenthesized) {
|
475
475
|
paraphrasesParenthesizedPrime.push(paraphrasesParenthesized)
|
476
476
|
generatedParenthesizedPrime.push(generatedParenthesized)
|
477
477
|
}
|
@@ -1352,9 +1352,15 @@ const knowledgeModule = async ({
|
|
1352
1352
|
beforeTests = () => {},
|
1353
1353
|
afterTests = () => {},
|
1354
1354
|
beforeTest = () => {},
|
1355
|
-
afterTest = () => {}
|
1355
|
+
afterTest = () => {},
|
1356
|
+
...rest
|
1356
1357
|
} = {}) => {
|
1357
1358
|
|
1359
|
+
const unknownArgs = Object.keys(rest)
|
1360
|
+
if (unknownArgs.length > 0) {
|
1361
|
+
throw new Error(`Unknown arguments to knowledgeModule: ${unknownArgs.join()}`)
|
1362
|
+
}
|
1363
|
+
|
1358
1364
|
config.beforeQuery = beforeQuery
|
1359
1365
|
config.beforeTests = beforeTests
|
1360
1366
|
config.afterTests = afterTests
|
@@ -1940,3 +1946,4 @@ module.exports = {
|
|
1940
1946
|
flattens,
|
1941
1947
|
writeTest
|
1942
1948
|
}
|
1949
|
+
|
package/package.json
CHANGED
package/src/config.js
CHANGED
@@ -90,12 +90,20 @@ const contextual_priority_valid = (cp) => {
|
|
90
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.`)
|
91
91
|
}
|
92
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}`)
|
93
|
-
if (!
|
94
|
-
throw new Error(`The contextual priority ${JSON.stringify(cp)}
|
95
|
-
}
|
96
|
-
if (!_.isInteger(cp.choose) || cp.choose < 0 || cp.choose >= cp.context.length) {
|
97
|
-
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.`)
|
98
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
|
+
)
|
99
107
|
}
|
100
108
|
|
101
109
|
const handleBridgeProps = (config, bridge) => {
|
@@ -922,8 +930,8 @@ class Config {
|
|
922
930
|
}
|
923
931
|
}
|
924
932
|
contextual_priority_valid(contextual_priority)
|
933
|
+
this.config.contextual_priorities.push(contextual_priority)
|
925
934
|
const cpServer = contextual_priorities_toServer(contextual_priority)
|
926
|
-
this.config.contextual_priorities.push(cpServer)
|
927
935
|
this._delta.json.contextual_priorities.push({ action: 'add', contextual_priority: cpServer })
|
928
936
|
}
|
929
937
|
|
@@ -2396,11 +2404,13 @@ class Config {
|
|
2396
2404
|
if (config.contextual_priorities) {
|
2397
2405
|
let contextual_priorities = config.contextual_priorities
|
2398
2406
|
contextual_priorities = contextual_priorities.map((cp) => {
|
2399
|
-
const
|
2400
|
-
|
2401
|
-
|
2402
|
-
|
2403
|
-
|
2407
|
+
const { context, choose } = cp
|
2408
|
+
return {
|
2409
|
+
context: context.map((id) => {
|
2410
|
+
return [toNS(id[0]), id[1]]
|
2411
|
+
}),
|
2412
|
+
choose
|
2413
|
+
}
|
2404
2414
|
})
|
2405
2415
|
config.contextual_priorities = contextual_priorities
|
2406
2416
|
}
|