theprogrammablemind 7.6.0-beta.7 → 7.6.0-beta.8

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 CHANGED
@@ -173,18 +173,23 @@ const setupArgs = (args, config, logs, hierarchy) => {
173
173
  args.theDebugger = {
174
174
  breakOnSemantics: (value) => args.breakOnSemantics = value
175
175
  }
176
- args.s = (c) => config.getSemantics(logs).apply(args, c)
177
- args.g = (c) => config.getGenerators(logs).apply(args, c)
178
- args.gp = (c) => config.getGenerators(logs).apply({...args, assumed: {paraphrase: true, isResponse: false, response: false}}, c, {paraphrase: true, isResponse: false, response: false})
179
- args.gr = (c) => config.getGenerators(logs).apply({...args, assumed: {paraphrase: false, isResponse: true}}, { ...c, paraphrase: false, isResponse: true })
180
176
  if (!logs) {
181
177
  debugger
182
178
  }
183
- args.e = (c) => config.getEvaluator(args.s, args.calls, logs, c)
184
179
  args.log = (message) => logs.push(message)
185
- args.gs = gs(args.g)
186
- args.gsp = gs(args.gp)
187
- args.gsr = gs(args.gr)
180
+
181
+ args.addAssumedScoped = (args, assumed) => {
182
+ args.s = (c) => config.getSemantics(logs).apply(args, c)
183
+ args.g = (c) => config.getGenerators(logs).apply(args, c)
184
+ args.gp = (c) => config.getGenerators(logs).apply({...args, assumed: {paraphrase: true, isResponse: false, response: false}}, c, {paraphrase: true, isResponse: false, response: false})
185
+ args.gr = (c) => config.getGenerators(logs).apply({...args, assumed: {paraphrase: false, isResponse: true}}, { ...c, paraphrase: false, isResponse: true })
186
+ args.e = (c) => config.getEvaluator(args.s, args.calls, logs, c)
187
+ args.gs = gs(args.g)
188
+ args.gsp = gs(args.gp)
189
+ args.gsr = gs(args.gr)
190
+ }
191
+ // for semantics
192
+ args.addAssumedScoped(args, {})
188
193
  config.getAddedArgs(args)
189
194
  }
190
195
 
@@ -462,8 +467,8 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
462
467
  }
463
468
  // assumed = { paraphrase: true, response: false };
464
469
  assumed = { paraphrase: true, isResponse: false, response: false };
465
- args.g = (c) => config.getGenerators(json.logs).apply({...args, assumed}, c, assumed)
466
- args.gs = gs(args.g)
470
+ // args.g = (c) => config.getGenerators(json.logs).apply({...args, assumed}, c, assumed)
471
+ // args.gs = gs(args.g)
467
472
  if (generateParenthesized) {
468
473
  config.parenthesized = false
469
474
  }
@@ -474,8 +479,8 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
474
479
  paraphrasesParenthesized = config.getGenerators(json.logs).apply({...args, assumed}, contextPrime, assumed)
475
480
  config.parenthesized = false
476
481
  }
477
- args.g = (c) => config.getGenerators(json.logs).apply(args, c)
478
- args.gs = gs(args.g)
482
+ // args.g = (c) => config.getGenerators(json.logs).apply(args, c)
483
+ // args.gs = gs(args.g)
479
484
  contextsPrime.push(contextPrime)
480
485
  generatedPrime.push(generated)
481
486
  paraphrasesPrime.push(paraphrases)
package/package.json CHANGED
@@ -64,6 +64,6 @@
64
64
  "json-stable-stringify": "^1.0.1",
65
65
  "node-fetch": "^2.6.1"
66
66
  },
67
- "version": "7.6.0-beta.7",
67
+ "version": "7.6.0-beta.8",
68
68
  "license": "ISC"
69
69
  }
package/src/generators.js CHANGED
@@ -73,7 +73,8 @@ class Generator {
73
73
  return matches
74
74
  }
75
75
 
76
- apply (baseArgs, objects, g, gs, context, hierarchy, config, response, log, options = {}) {
76
+ // apply (baseArgs, objects, g, gs, context, hierarchy, config, response, log, options = {}) {
77
+ apply (baseArgs, objects, context, hierarchy, config, response, log, options = {}) {
77
78
  if (!log) {
78
79
  throw new Error('generators.apply argument log is required')
79
80
  }
@@ -103,12 +104,12 @@ class Generator {
103
104
  log,
104
105
  global:
105
106
  objects,
106
- g,
107
+ // g,
107
108
  n,
108
109
  hierarchy,
109
110
  context,
110
111
  uuid: this.uuid,
111
- gs,
112
+ // gs,
112
113
  config,
113
114
  response,
114
115
  api: this.getAPI(config),
@@ -179,6 +180,9 @@ class Generators {
179
180
  const hierarchy = args.hierarchy
180
181
  const response = args.response
181
182
 
183
+
184
+ // args = { ...args, ...args.getAssumedScoped(assumed) }
185
+ args.addAssumedScoped(args, assumed)
182
186
  context = Object.assign({}, context, args.assumed)
183
187
  let generated = ''
184
188
  let applied = false
@@ -186,23 +190,15 @@ class Generators {
186
190
  for (let igenerator = 0; igenerator < this.generators.length; ++igenerator) {
187
191
  const generator = this.generators[igenerator]
188
192
  if (generator.matches(args, objects, context, hierarchy, config, options)) {
189
- const g = (context, options) => {
190
- const r = this.apply(args, context, Object.assign({}, ((options||{}).assumed || {}), assumed), options)
191
- if (Array.isArray(r)) {
192
- return r.join(' ')
193
- } else {
194
- return r
195
- }
196
- }
197
193
  const log = (message) => { this.logs.push(message) }
198
194
  // this.logs.push(`Generators: applied ${generator.toString()}\n to\n ${JSON.stringify(context)}`)
199
195
  let errorMessage = 'The apply function did not return a value'
200
196
  try {
201
- generated= generator.apply(args, objects, g, args.gs, context, hierarchy, config, response, log)
197
+ generated= generator.apply(args, objects, context, hierarchy, config, response, log)
202
198
  } catch( e ) {
203
199
  // the next if handle this
204
200
  generated = null
205
- e.retryCall = () => generator.apply(args, objects, g, args.gs, context, hierarchy, config, response, log)
201
+ e.retryCall = () => generator.apply(args, objects, context, hierarchy, config, response, log)
206
202
  const help = 'The error has a retryCall property that will recall the function that failed.'
207
203
  if (e.stack && e.message) {
208
204
  const info = `${generator.notes ? generator.notes : ''}${generator.where ? generator.where : ''}`