theprogrammablemind 7.3.1 → 7.3.2
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 +70 -14
- package/package.json +39 -39
- package/src/config.js +3 -0
package/client.js
CHANGED
@@ -270,16 +270,37 @@ const writeTest = (fn, query, objects, generated, paraphrases, responses, contex
|
|
270
270
|
writeTestFile(fn, tests)
|
271
271
|
}
|
272
272
|
|
273
|
-
const
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
273
|
+
const combineRange = (r1, r2) => {
|
274
|
+
let start = r2.start;
|
275
|
+
if (r1.start < r2.start) {
|
276
|
+
start = r1.start
|
277
|
+
}
|
278
|
+
let end = r2.end
|
279
|
+
if (r1.end > r2.end) {
|
280
|
+
end = r2.end
|
281
|
+
}
|
282
|
+
return { start, end }
|
283
|
+
}
|
284
|
+
|
285
|
+
const overlaps = (r1, context) => {
|
286
|
+
if (!context.range) {
|
287
|
+
return true;
|
288
|
+
}
|
289
|
+
const r2 = context.range
|
290
|
+
if (r1.start <= r2.end && r1.start >= r2.start) {
|
291
|
+
return true;
|
292
|
+
}
|
293
|
+
if (r1.end <= r2.end && r1.end >= r2.start) {
|
294
|
+
return true;
|
295
|
+
}
|
296
|
+
return false
|
297
|
+
}
|
298
|
+
|
299
|
+
const setupContexts = (rawContexts) => {
|
280
300
|
let first = true
|
301
|
+
const contexts = []
|
281
302
|
contexts.push({ marker: 'controlStart', controlRemove: true })
|
282
|
-
for (const context of
|
303
|
+
for (const context of rawContexts) {
|
283
304
|
if (first) {
|
284
305
|
first = false
|
285
306
|
} else {
|
@@ -288,14 +309,49 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
|
|
288
309
|
contexts.push(context)
|
289
310
|
}
|
290
311
|
contexts.push({ marker: 'controlEnd', controlRemove: true })
|
312
|
+
return contexts
|
313
|
+
}
|
314
|
+
|
315
|
+
const processContextsB = ({ config, hierarchy, semantics, generators, json, isTest, query, data, retries, url }) => {
|
316
|
+
// TODO fix this name to contextsPrime
|
317
|
+
const contextsPrime = []
|
318
|
+
const generatedPrime = []
|
319
|
+
const paraphrasesPrime = []
|
320
|
+
const responsesPrime = []
|
321
|
+
const contexts = setupContexts(json.contexts)
|
322
|
+
|
291
323
|
const objects = config.get('objects')
|
292
324
|
const args = { objects, isResponse: true, response: json, isTest, getObjects: getObjects(objects) }
|
293
325
|
setupArgs(args, config, json.logs, hierarchy)
|
294
326
|
const toDo = [...contexts]
|
295
327
|
args.insert = (context) => toDo.unshift(context)
|
328
|
+
let overlap, lastRange;
|
296
329
|
while (toDo.length > 0) {
|
297
|
-
args.calls.next()
|
298
330
|
const context = toDo.shift()
|
331
|
+
/*
|
332
|
+
if (false && query) {
|
333
|
+
if (config.wasChanged()) {
|
334
|
+
// process contexts that overlap
|
335
|
+
overlap = lastRange
|
336
|
+
} else {
|
337
|
+
config.watch()
|
338
|
+
}
|
339
|
+
if (overlap) {
|
340
|
+
if (overlaps(overlap, context)) {
|
341
|
+
// okay
|
342
|
+
query = query.slice(overlap.end+1)
|
343
|
+
data.utterance = query
|
344
|
+
debugger;
|
345
|
+
const json = await doWithRetries(retries, url, data)
|
346
|
+
toDo = setupContexts(json.contexts).slice(1) // take off the start context
|
347
|
+
}
|
348
|
+
overlap = undefined
|
349
|
+
}
|
350
|
+
lastRange = context.range
|
351
|
+
}
|
352
|
+
*/
|
353
|
+
|
354
|
+
args.calls.next()
|
299
355
|
let contextPrime = context
|
300
356
|
context.topLevel = true
|
301
357
|
try {
|
@@ -924,7 +980,7 @@ const build = async ({ config, target, beforeQuery, template, errorHandler = def
|
|
924
980
|
semantics: [],
|
925
981
|
associations: [],
|
926
982
|
}
|
927
|
-
const looper = (queries) => {
|
983
|
+
const looper = async (queries) => {
|
928
984
|
if (queries.length === 0) {
|
929
985
|
finish()
|
930
986
|
return
|
@@ -955,7 +1011,7 @@ const build = async ({ config, target, beforeQuery, template, errorHandler = def
|
|
955
1011
|
}
|
956
1012
|
|
957
1013
|
try {
|
958
|
-
const results = _process(config, query.query, { beforeQuery })
|
1014
|
+
const results = await _process(config, query.query, { beforeQuery })
|
959
1015
|
if (config.config.debug) {
|
960
1016
|
// TODO pass in the error handler like the other ones
|
961
1017
|
defaultInnerProcess(config, defaultErrorHandler, results)
|
@@ -967,7 +1023,7 @@ const build = async ({ config, target, beforeQuery, template, errorHandler = def
|
|
967
1023
|
results.key = { query: query.query, hierarchy }
|
968
1024
|
accumulators[property].push(results)
|
969
1025
|
accumulators.associations = accumulators.associations.concat(results.associations)
|
970
|
-
looper(queries)
|
1026
|
+
await looper(queries)
|
971
1027
|
} catch(e) {
|
972
1028
|
const error = { errors: [e], query: query.query };
|
973
1029
|
config.config.skipSemantics = null
|
@@ -979,7 +1035,7 @@ const build = async ({ config, target, beforeQuery, template, errorHandler = def
|
|
979
1035
|
const extraConfig = queryOrExtraConfig
|
980
1036
|
console.log('config', extraConfig)
|
981
1037
|
accumulators[property].push({ extraConfig: true, ...extraConfig })
|
982
|
-
looper(queries)
|
1038
|
+
await looper(queries)
|
983
1039
|
}
|
984
1040
|
}
|
985
1041
|
|
@@ -1031,7 +1087,7 @@ const build = async ({ config, target, beforeQuery, template, errorHandler = def
|
|
1031
1087
|
let todo = (template.queries || []).map((query) => { return { property: 'resultss', query, skipSemantics: false } })
|
1032
1088
|
todo = todo.concat((template.fragments || []).map((query) => { return Object.assign({}, toProperties(query), { property: 'fragments', skipSemantics: false }) }))
|
1033
1089
|
todo = todo.concat((template.semantics || []).map((definition) => { return { property: 'semantics', query: `${definition.from}\n${definition.to}`, skipSemantics: true } }))
|
1034
|
-
looper(Object.assign([], todo))
|
1090
|
+
await looper(Object.assign([], todo))
|
1035
1091
|
}
|
1036
1092
|
|
1037
1093
|
const knowledgeModule = async ({
|
package/package.json
CHANGED
@@ -1,4 +1,42 @@
|
|
1
1
|
{
|
2
|
+
"dependencies": {
|
3
|
+
"base-64": "^1.0.0",
|
4
|
+
"sort-json": "^2.0.0",
|
5
|
+
"json-stable-stringify": "^1.0.1",
|
6
|
+
"lodash": "^4.17.20",
|
7
|
+
"json-diff": "^1.0.3",
|
8
|
+
"uuid": "^8.3.2",
|
9
|
+
"readline": "^1.3.0",
|
10
|
+
"scriptjs": "^2.5.9",
|
11
|
+
"deep-equal": "^2.0.4",
|
12
|
+
"underscore": "^1.13.1",
|
13
|
+
"node-fetch": "^2.6.1",
|
14
|
+
"fs": "0.0.1-security"
|
15
|
+
},
|
16
|
+
"author": "dev@thinktelligence.com",
|
17
|
+
"devDependencies": {
|
18
|
+
"eslint-plugin-promise": "^5.1.0",
|
19
|
+
"eslint-config-standard": "^16.0.3",
|
20
|
+
"eslint-plugin-import": "^2.23.4",
|
21
|
+
"@typescript-eslint/eslint-plugin": "^4.28.4",
|
22
|
+
"eslint-plugin-node": "^11.1.0",
|
23
|
+
"@typescript-eslint/parser": "^4.28.4",
|
24
|
+
"jest": "^26.6.3",
|
25
|
+
"eslint": "^7.31.0"
|
26
|
+
},
|
27
|
+
"version": "7.3.2",
|
28
|
+
"scripts": {
|
29
|
+
"to:debug": "node inspect node_modules/.bin/jest --runInBand -t NEO",
|
30
|
+
"to": "node node_modules/.bin/jest --runInBand -t NEO",
|
31
|
+
"test": "jest --config ./jest.config.json",
|
32
|
+
"tod": "node inspect node_modules/.bin/jest --runInBand -t NEO",
|
33
|
+
"lint": "eslint \"**/*.js\"",
|
34
|
+
"test:debug": "node inspect node_modules/.bin/jest --runInBand --config ./jest.config.json",
|
35
|
+
"test:watch": "npm run test -- --watch",
|
36
|
+
"lint:fix": "eslint \"**/*.js\" --fix"
|
37
|
+
},
|
38
|
+
"license": "ISC",
|
39
|
+
"name": "theprogrammablemind",
|
2
40
|
"keywords": [
|
3
41
|
"NLP",
|
4
42
|
"NLU",
|
@@ -8,21 +46,6 @@
|
|
8
46
|
"natural language understanding",
|
9
47
|
"chatbot"
|
10
48
|
],
|
11
|
-
"author": "dev@thinktelligence.com",
|
12
|
-
"dependencies": {
|
13
|
-
"sort-json": "^2.0.0",
|
14
|
-
"scriptjs": "^2.5.9",
|
15
|
-
"deep-equal": "^2.0.4",
|
16
|
-
"readline": "^1.3.0",
|
17
|
-
"json-diff": "^1.0.3",
|
18
|
-
"uuid": "^8.3.2",
|
19
|
-
"node-fetch": "^2.6.1",
|
20
|
-
"json-stable-stringify": "^1.0.1",
|
21
|
-
"fs": "0.0.1-security",
|
22
|
-
"base-64": "^1.0.0",
|
23
|
-
"lodash": "^4.17.20",
|
24
|
-
"underscore": "^1.13.1"
|
25
|
-
},
|
26
49
|
"files": [
|
27
50
|
"client.js",
|
28
51
|
"index.js",
|
@@ -38,28 +61,5 @@
|
|
38
61
|
"src/generators.js",
|
39
62
|
"src/semantics.js"
|
40
63
|
],
|
41
|
-
"
|
42
|
-
"scripts": {
|
43
|
-
"test:watch": "npm run test -- --watch",
|
44
|
-
"tod": "node inspect node_modules/.bin/jest --runInBand -t NEO",
|
45
|
-
"to": "node node_modules/.bin/jest --runInBand -t NEO",
|
46
|
-
"lint:fix": "eslint \"**/*.js\" --fix",
|
47
|
-
"test": "jest --config ./jest.config.json",
|
48
|
-
"test:debug": "node inspect node_modules/.bin/jest --runInBand --config ./jest.config.json",
|
49
|
-
"lint": "eslint \"**/*.js\"",
|
50
|
-
"to:debug": "node inspect node_modules/.bin/jest --runInBand -t NEO"
|
51
|
-
},
|
52
|
-
"devDependencies": {
|
53
|
-
"eslint-config-standard": "^16.0.3",
|
54
|
-
"@typescript-eslint/eslint-plugin": "^4.28.4",
|
55
|
-
"eslint-plugin-promise": "^5.1.0",
|
56
|
-
"@typescript-eslint/parser": "^4.28.4",
|
57
|
-
"jest": "^26.6.3",
|
58
|
-
"eslint": "^7.31.0",
|
59
|
-
"eslint-plugin-node": "^11.1.0",
|
60
|
-
"eslint-plugin-import": "^2.23.4"
|
61
|
-
},
|
62
|
-
"license": "ISC",
|
63
|
-
"main": "index.js",
|
64
|
-
"version": "7.3.1"
|
64
|
+
"main": "index.js"
|
65
65
|
}
|