theprogrammablemind 7.4.0-beta.3 → 7.4.1-beta.0

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.
Files changed (3) hide show
  1. package/client.js +12 -3
  2. package/package.json +1 -1
  3. package/src/config.js +11 -2
package/client.js CHANGED
@@ -436,9 +436,12 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
436
436
  return { contextsPrime, generatedPrime, paraphrasesPrime, responsesPrime }
437
437
  }
438
438
 
439
- const doWithRetries = async (n, url, data) => {
439
+ const doWithRetries = async (n, url, queryParams, data) => {
440
+ if (!queryParams) {
441
+ queryParams = ''
442
+ }
440
443
  for (let i = 0; i < n; ++i) {
441
- const result = await fetch(`${url}/process`, {
444
+ const result = await fetch(`${url}/process${queryParams}`, {
442
445
  method: 'POST',
443
446
  body: JSON.stringify(data),
444
447
  timeout: 1000 * 60 * 5, // it does not respect this timeout so that's why I have the retries
@@ -511,6 +514,7 @@ const _process = async (config, query, { credentials, writeTests, isTest, saveDe
511
514
  config.server(credentials.server, credentials.key)
512
515
  }
513
516
  const url = config._server
517
+ const queryParams = config._queryParams || ''
514
518
  const retries = 2
515
519
  writeTests = !!writeTests
516
520
 
@@ -550,7 +554,7 @@ const _process = async (config, query, { credentials, writeTests, isTest, saveDe
550
554
  break;
551
555
  }
552
556
  data.utterance = queries[0]
553
- const json = await doWithRetries(retries, url, data)
557
+ const json = await doWithRetries(retries, url, queryParams, data)
554
558
  json.contexts = json.results
555
559
  delete json.results
556
560
  if (json.status !== 200) {
@@ -1220,6 +1224,7 @@ const knowledgeModule = async ({
1220
1224
  parser.add_argument('-r', '--retrain', { action: 'store_true', help: 'Get the server to retrain the neural nets' })
1221
1225
  parser.add_argument('-q', '--query', { help: 'Run the specified query' })
1222
1226
  parser.add_argument('-ip ', '--server', { help: 'Server to run against' })
1227
+ parser.add_argument('-qp ', '--queryParams', { help: 'Query params for the server call' })
1223
1228
  parser.add_argument('-qd', '--queryDelete', { help: 'Delete the specified query from the tests file' })
1224
1229
  parser.add_argument('-c', '--clean', { help: 'Remove data from the test files. a === association' })
1225
1230
  parser.add_argument('-od', '--objectDiff', { action: 'store_true', help: 'When showing the objects use a colour diff' })
@@ -1278,6 +1283,10 @@ const knowledgeModule = async ({
1278
1283
  config.server(args.server)
1279
1284
  }
1280
1285
 
1286
+ if (args.queryParams) {
1287
+ config.setQueryParams(args.queryParams)
1288
+ }
1289
+
1281
1290
  if (args.debug) {
1282
1291
  config.config.debug = true
1283
1292
  }
package/package.json CHANGED
@@ -61,6 +61,6 @@
61
61
  "json-stable-stringify": "^1.0.1",
62
62
  "node-fetch": "^2.6.1"
63
63
  },
64
- "version": "7.4.0-beta.3",
64
+ "version": "7.4.1-beta.0",
65
65
  "license": "ISC"
66
66
  }
package/src/config.js CHANGED
@@ -792,13 +792,22 @@ class Config {
792
792
  return this._key
793
793
  }
794
794
 
795
- server (server, apiKey) {
795
+ getQueryParams() {
796
+ return this._queryParams
797
+ }
798
+
799
+ setQueryParams(queryParams) {
800
+ this._queryParams = queryParams
801
+ }
802
+
803
+ server (server, apiKey, queryParams) {
796
804
  if (server) {
797
805
  this._server = server
798
806
  }
799
807
  if (apiKey) {
800
808
  this._key = apiKey
801
809
  }
810
+ this._queryParams = queryParams
802
811
 
803
812
  if (this._api && this._api.multiApi) {
804
813
  for (const key of Object.keys(this._api.apis)) {
@@ -2061,7 +2070,7 @@ class Config {
2061
2070
  more.valid()
2062
2071
  // copy so i don't have to copy later
2063
2072
  more = more.copy()
2064
- more.server(this._server, this._key)
2073
+ more.server(this._server, this._key, this._queryParams)
2065
2074
 
2066
2075
  this.loadOrder.addList(more.configs.map((km) => km.name || km.uuid))
2067
2076