@pairsystems/goodmem-client 1.0.2 → 1.0.4
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/README.md +191 -3
- package/dist/api/APIKeysApi.js +8 -8
- package/dist/api/EmbeddersApi.js +12 -12
- package/dist/api/LLMsApi.js +263 -0
- package/dist/api/MemoriesApi.js +104 -20
- package/dist/api/RerankersApi.js +12 -12
- package/dist/api/SpacesApi.js +18 -18
- package/dist/api/UsersApi.js +82 -15
- package/dist/index.js +131 -0
- package/dist/model/BinaryContent.js +129 -0
- package/dist/model/ChunkReference.js +9 -6
- package/dist/model/ContextItem.js +136 -0
- package/dist/model/CreateLLMResponse.js +146 -0
- package/dist/model/DistributionType.js +58 -0
- package/dist/model/EmbedderCreationRequest.js +15 -4
- package/dist/model/EmbedderResponse.js +15 -4
- package/dist/model/EmbedderWeight.js +125 -0
- package/dist/model/LLMCapabilities.js +132 -0
- package/dist/model/LLMCreationRequest.js +318 -0
- package/dist/model/LLMProviderType.js +83 -0
- package/dist/model/LLMResponse.js +366 -0
- package/dist/model/LLMSamplingParams.js +145 -0
- package/dist/model/LLMUpdateRequest.js +274 -0
- package/dist/model/ListLLMsResponse.js +132 -0
- package/dist/model/Memory.js +2 -6
- package/dist/model/MemoryChunkResponse.js +240 -0
- package/dist/model/PostProcessor.js +125 -0
- package/dist/model/ProviderType.js +5 -0
- package/dist/model/RetrieveMemoryEvent.js +8 -5
- package/dist/model/RetrieveMemoryRequest.js +219 -0
- package/dist/model/RetrievedItem.js +8 -5
- package/dist/model/SpaceKey.js +145 -0
- package/dist/streaming.js +249 -46
- package/package.json +3 -7
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
var _ApiClient = _interopRequireDefault(require("../ApiClient"));
|
|
8
8
|
var _ChunkReference = _interopRequireDefault(require("./ChunkReference"));
|
|
9
|
+
var _Memory = _interopRequireDefault(require("./Memory"));
|
|
9
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
11
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
11
12
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
@@ -62,9 +63,7 @@ var RetrievedItem = /*#__PURE__*/function () {
|
|
|
62
63
|
if (data) {
|
|
63
64
|
obj = obj || new RetrievedItem();
|
|
64
65
|
if (data.hasOwnProperty('memory')) {
|
|
65
|
-
obj['memory'] =
|
|
66
|
-
'String': Object
|
|
67
|
-
});
|
|
66
|
+
obj['memory'] = _Memory["default"].constructFromObject(data['memory']);
|
|
68
67
|
}
|
|
69
68
|
if (data.hasOwnProperty('chunk')) {
|
|
70
69
|
obj['chunk'] = _ChunkReference["default"].constructFromObject(data['chunk']);
|
|
@@ -81,6 +80,11 @@ var RetrievedItem = /*#__PURE__*/function () {
|
|
|
81
80
|
}, {
|
|
82
81
|
key: "validateJSON",
|
|
83
82
|
value: function validateJSON(data) {
|
|
83
|
+
// validate the optional field `memory`
|
|
84
|
+
if (data['memory']) {
|
|
85
|
+
// data not null
|
|
86
|
+
_Memory["default"].validateJSON(data['memory']);
|
|
87
|
+
}
|
|
84
88
|
// validate the optional field `chunk`
|
|
85
89
|
if (data['chunk']) {
|
|
86
90
|
// data not null
|
|
@@ -91,8 +95,7 @@ var RetrievedItem = /*#__PURE__*/function () {
|
|
|
91
95
|
}]);
|
|
92
96
|
}();
|
|
93
97
|
/**
|
|
94
|
-
*
|
|
95
|
-
* @member {Object.<String, Object>} memory
|
|
98
|
+
* @member {module:model/Memory} memory
|
|
96
99
|
*/
|
|
97
100
|
RetrievedItem.prototype['memory'] = undefined;
|
|
98
101
|
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _ApiClient = _interopRequireDefault(require("../ApiClient"));
|
|
8
|
+
var _EmbedderWeight = _interopRequireDefault(require("./EmbedderWeight"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
11
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
12
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
13
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
14
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
15
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
16
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
17
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
18
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /**
|
|
19
|
+
*
|
|
20
|
+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
21
|
+
*
|
|
22
|
+
* The version of the OpenAPI document:
|
|
23
|
+
*
|
|
24
|
+
*
|
|
25
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
26
|
+
* https://openapi-generator.tech
|
|
27
|
+
* Do not edit the class manually.
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* The SpaceKey model module.
|
|
32
|
+
* @module model/SpaceKey
|
|
33
|
+
* @version 1.0.0
|
|
34
|
+
*/
|
|
35
|
+
var SpaceKey = /*#__PURE__*/function () {
|
|
36
|
+
/**
|
|
37
|
+
* Constructs a new <code>SpaceKey</code>.
|
|
38
|
+
* Space configuration for retrieval operations with optional embedder weight overrides.
|
|
39
|
+
* @alias module:model/SpaceKey
|
|
40
|
+
* @param spaceId {String} The unique identifier for the space to search.
|
|
41
|
+
*/
|
|
42
|
+
function SpaceKey(spaceId) {
|
|
43
|
+
_classCallCheck(this, SpaceKey);
|
|
44
|
+
SpaceKey.initialize(this, spaceId);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Initializes the fields of this object.
|
|
49
|
+
* This method is used by the constructors of any subclasses, in order to implement multiple inheritance (mix-ins).
|
|
50
|
+
* Only for internal use.
|
|
51
|
+
*/
|
|
52
|
+
return _createClass(SpaceKey, null, [{
|
|
53
|
+
key: "initialize",
|
|
54
|
+
value: function initialize(obj, spaceId) {
|
|
55
|
+
obj['spaceId'] = spaceId;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Constructs a <code>SpaceKey</code> from a plain JavaScript object, optionally creating a new instance.
|
|
60
|
+
* Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
|
|
61
|
+
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
|
62
|
+
* @param {module:model/SpaceKey} obj Optional instance to populate.
|
|
63
|
+
* @return {module:model/SpaceKey} The populated <code>SpaceKey</code> instance.
|
|
64
|
+
*/
|
|
65
|
+
}, {
|
|
66
|
+
key: "constructFromObject",
|
|
67
|
+
value: function constructFromObject(data, obj) {
|
|
68
|
+
if (data) {
|
|
69
|
+
obj = obj || new SpaceKey();
|
|
70
|
+
if (data.hasOwnProperty('spaceId')) {
|
|
71
|
+
obj['spaceId'] = _ApiClient["default"].convertToType(data['spaceId'], 'String');
|
|
72
|
+
}
|
|
73
|
+
if (data.hasOwnProperty('embedderWeights')) {
|
|
74
|
+
obj['embedderWeights'] = _ApiClient["default"].convertToType(data['embedderWeights'], [_EmbedderWeight["default"]]);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return obj;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Validates the JSON data with respect to <code>SpaceKey</code>.
|
|
82
|
+
* @param {Object} data The plain JavaScript object bearing properties of interest.
|
|
83
|
+
* @return {boolean} to indicate whether the JSON data is valid with respect to <code>SpaceKey</code>.
|
|
84
|
+
*/
|
|
85
|
+
}, {
|
|
86
|
+
key: "validateJSON",
|
|
87
|
+
value: function validateJSON(data) {
|
|
88
|
+
// check to make sure all required properties are present in the JSON string
|
|
89
|
+
var _iterator = _createForOfIteratorHelper(SpaceKey.RequiredProperties),
|
|
90
|
+
_step;
|
|
91
|
+
try {
|
|
92
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
93
|
+
var property = _step.value;
|
|
94
|
+
if (!data.hasOwnProperty(property)) {
|
|
95
|
+
throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// ensure the json data is a string
|
|
99
|
+
} catch (err) {
|
|
100
|
+
_iterator.e(err);
|
|
101
|
+
} finally {
|
|
102
|
+
_iterator.f();
|
|
103
|
+
}
|
|
104
|
+
if (data['spaceId'] && !(typeof data['spaceId'] === 'string' || data['spaceId'] instanceof String)) {
|
|
105
|
+
throw new Error("Expected the field `spaceId` to be a primitive type in the JSON string but got " + data['spaceId']);
|
|
106
|
+
}
|
|
107
|
+
if (data['embedderWeights']) {
|
|
108
|
+
// data not null
|
|
109
|
+
// ensure the json data is an array
|
|
110
|
+
if (!Array.isArray(data['embedderWeights'])) {
|
|
111
|
+
throw new Error("Expected the field `embedderWeights` to be an array in the JSON data but got " + data['embedderWeights']);
|
|
112
|
+
}
|
|
113
|
+
// validate the optional field `embedderWeights` (array)
|
|
114
|
+
var _iterator2 = _createForOfIteratorHelper(data['embedderWeights']),
|
|
115
|
+
_step2;
|
|
116
|
+
try {
|
|
117
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
118
|
+
var item = _step2.value;
|
|
119
|
+
_EmbedderWeight["default"].validateJSON(item);
|
|
120
|
+
}
|
|
121
|
+
} catch (err) {
|
|
122
|
+
_iterator2.e(err);
|
|
123
|
+
} finally {
|
|
124
|
+
_iterator2.f();
|
|
125
|
+
}
|
|
126
|
+
;
|
|
127
|
+
}
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
}]);
|
|
131
|
+
}();
|
|
132
|
+
SpaceKey.RequiredProperties = ["spaceId"];
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The unique identifier for the space to search.
|
|
136
|
+
* @member {String} spaceId
|
|
137
|
+
*/
|
|
138
|
+
SpaceKey.prototype['spaceId'] = undefined;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Optional per-embedder weight overrides for this space. If not specified, database defaults are used.
|
|
142
|
+
* @member {Array.<module:model/EmbedderWeight>} embedderWeights
|
|
143
|
+
*/
|
|
144
|
+
SpaceKey.prototype['embedderWeights'] = undefined;
|
|
145
|
+
var _default = exports["default"] = SpaceKey;
|
package/dist/streaming.js
CHANGED
|
@@ -19,7 +19,7 @@ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol
|
|
|
19
19
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
20
20
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
21
21
|
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
22
|
-
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) {
|
|
22
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
23
23
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
24
24
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
25
25
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
@@ -113,6 +113,26 @@ var StreamingClient = exports.StreamingClient = /*#__PURE__*/function () {
|
|
|
113
113
|
if (request.generateAbstract !== undefined) {
|
|
114
114
|
params.append('generateAbstract', request.generateAbstract.toString());
|
|
115
115
|
}
|
|
116
|
+
|
|
117
|
+
// Add ChatPostProcessor parameters
|
|
118
|
+
if (request.ppLlmId) {
|
|
119
|
+
params.append('ppLlmId', request.ppLlmId);
|
|
120
|
+
}
|
|
121
|
+
if (request.ppRerankerId) {
|
|
122
|
+
params.append('ppRerankerId', request.ppRerankerId);
|
|
123
|
+
}
|
|
124
|
+
if (request.ppRelevanceThreshold !== undefined) {
|
|
125
|
+
params.append('ppRelevanceThreshold', request.ppRelevanceThreshold.toString());
|
|
126
|
+
}
|
|
127
|
+
if (request.ppLlmTemp !== undefined) {
|
|
128
|
+
params.append('ppLlmTemp', request.ppLlmTemp.toString());
|
|
129
|
+
}
|
|
130
|
+
if (request.ppMaxResults !== undefined) {
|
|
131
|
+
params.append('ppMaxResults', request.ppMaxResults.toString());
|
|
132
|
+
}
|
|
133
|
+
if (request.ppChronologicalResort !== undefined) {
|
|
134
|
+
params.append('ppChronologicalResort', request.ppChronologicalResort.toString());
|
|
135
|
+
}
|
|
116
136
|
fullURL = "".concat(endpoint, "?").concat(params.toString()); // Set appropriate headers
|
|
117
137
|
headers = {
|
|
118
138
|
'Accept': request.format === StreamingClient.StreamingFormat.SSE ? 'text/event-stream' : 'application/x-ndjson'
|
|
@@ -170,7 +190,7 @@ var StreamingClient = exports.StreamingClient = /*#__PURE__*/function () {
|
|
|
170
190
|
return _wrapAsyncGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
171
191
|
var reader, decoder, buffer, _yield$_awaitAsyncGen, done, value, lines, _iterator2, _step2, line, event, _event, _t, _t2, _t3;
|
|
172
192
|
return _regenerator().w(function (_context2) {
|
|
173
|
-
while (1) switch (_context2.n) {
|
|
193
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
174
194
|
case 0:
|
|
175
195
|
reader = response.body.getReader();
|
|
176
196
|
decoder = new TextDecoder();
|
|
@@ -282,7 +302,7 @@ var StreamingClient = exports.StreamingClient = /*#__PURE__*/function () {
|
|
|
282
302
|
return _wrapAsyncGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
283
303
|
var reader, decoder, buffer, _yield$_awaitAsyncGen2, done, value, events, _iterator3, _step3, eventText, event, _event2, _t4;
|
|
284
304
|
return _regenerator().w(function (_context3) {
|
|
285
|
-
while (1) switch (_context3.n) {
|
|
305
|
+
while (1) switch (_context3.p = _context3.n) {
|
|
286
306
|
case 0:
|
|
287
307
|
reader = response.body.getReader();
|
|
288
308
|
decoder = new TextDecoder();
|
|
@@ -442,6 +462,171 @@ var StreamingClient = exports.StreamingClient = /*#__PURE__*/function () {
|
|
|
442
462
|
}
|
|
443
463
|
return retrieveMemoryStreamSimple;
|
|
444
464
|
}()
|
|
465
|
+
/**
|
|
466
|
+
* Stream semantic memory retrieval results using ChatPostProcessor
|
|
467
|
+
*
|
|
468
|
+
* @param {AbortSignal} signal - Abort signal for cancellation
|
|
469
|
+
* @param {string} message - Primary query/message for semantic search
|
|
470
|
+
* @param {string[]} spaceIds - Array of space UUIDs to search within
|
|
471
|
+
* @param {number} [requestedSize] - Maximum number of memories to retrieve
|
|
472
|
+
* @param {boolean} [fetchMemory] - Whether to fetch memory definitions
|
|
473
|
+
* @param {boolean} [fetchMemoryContent] - Whether to fetch original content
|
|
474
|
+
* @param {string} [format] - Streaming format ('ndjson' or 'sse', defaults to 'ndjson')
|
|
475
|
+
* @param {string} [ppLlmId] - UUID of LLM for abstract generation
|
|
476
|
+
* @param {string} [ppRerankerId] - UUID of reranker for result reranking
|
|
477
|
+
* @param {number} [ppRelevanceThreshold] - Minimum relevance score
|
|
478
|
+
* @param {number} [ppLlmTemp] - LLM temperature for generation
|
|
479
|
+
* @param {number} [ppMaxResults] - Maximum results to return
|
|
480
|
+
* @param {boolean} [ppChronologicalResort] - Whether to resort by creation time
|
|
481
|
+
* @returns {Promise<AsyncIterableIterator<MemoryStreamResponse>>} Async iterator of streaming events
|
|
482
|
+
*/
|
|
483
|
+
)
|
|
484
|
+
}, {
|
|
485
|
+
key: "retrieveMemoryStreamChat",
|
|
486
|
+
value: (function () {
|
|
487
|
+
var _retrieveMemoryStreamChat = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(signal, message, spaceIds, requestedSize, fetchMemory, fetchMemoryContent, format, ppLlmId, ppRerankerId, ppRelevanceThreshold, ppLlmTemp, ppMaxResults, ppChronologicalResort) {
|
|
488
|
+
var request;
|
|
489
|
+
return _regenerator().w(function (_context5) {
|
|
490
|
+
while (1) switch (_context5.n) {
|
|
491
|
+
case 0:
|
|
492
|
+
request = {
|
|
493
|
+
message: message,
|
|
494
|
+
spaceIds: spaceIds,
|
|
495
|
+
requestedSize: requestedSize,
|
|
496
|
+
fetchMemory: fetchMemory,
|
|
497
|
+
fetchMemoryContent: fetchMemoryContent,
|
|
498
|
+
format: format || StreamingClient.StreamingFormat.NDJSON,
|
|
499
|
+
ppLlmId: ppLlmId,
|
|
500
|
+
ppRerankerId: ppRerankerId,
|
|
501
|
+
ppRelevanceThreshold: ppRelevanceThreshold,
|
|
502
|
+
ppLlmTemp: ppLlmTemp,
|
|
503
|
+
ppMaxResults: ppMaxResults,
|
|
504
|
+
ppChronologicalResort: ppChronologicalResort
|
|
505
|
+
};
|
|
506
|
+
return _context5.a(2, this.retrieveMemoryStream(signal, request));
|
|
507
|
+
}
|
|
508
|
+
}, _callee5, this);
|
|
509
|
+
}));
|
|
510
|
+
function retrieveMemoryStreamChat(_x6, _x7, _x8, _x9, _x0, _x1, _x10, _x11, _x12, _x13, _x14, _x15, _x16) {
|
|
511
|
+
return _retrieveMemoryStreamChat.apply(this, arguments);
|
|
512
|
+
}
|
|
513
|
+
return retrieveMemoryStreamChat;
|
|
514
|
+
}()
|
|
515
|
+
/**
|
|
516
|
+
* Stream semantic memory retrieval using advanced POST endpoint with custom post-processor
|
|
517
|
+
*
|
|
518
|
+
* @param {AbortSignal} signal - Abort signal for cancellation
|
|
519
|
+
* @param {AdvancedMemoryStreamRequest} request - Advanced request with post-processor config
|
|
520
|
+
* @returns {Promise<AsyncIterableIterator<MemoryStreamResponse>>} Async iterator of streaming events
|
|
521
|
+
*/
|
|
522
|
+
)
|
|
523
|
+
}, {
|
|
524
|
+
key: "retrieveMemoryStreamAdvanced",
|
|
525
|
+
value: (function () {
|
|
526
|
+
var _retrieveMemoryStreamAdvanced = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(signal, request) {
|
|
527
|
+
var requestBody, postProcessor, baseURL, endpoint, headers, response, errorText;
|
|
528
|
+
return _regenerator().w(function (_context6) {
|
|
529
|
+
while (1) switch (_context6.n) {
|
|
530
|
+
case 0:
|
|
531
|
+
if (request) {
|
|
532
|
+
_context6.n = 1;
|
|
533
|
+
break;
|
|
534
|
+
}
|
|
535
|
+
throw new Error('Request cannot be null');
|
|
536
|
+
case 1:
|
|
537
|
+
if (request.message) {
|
|
538
|
+
_context6.n = 2;
|
|
539
|
+
break;
|
|
540
|
+
}
|
|
541
|
+
throw new Error('Message is required');
|
|
542
|
+
case 2:
|
|
543
|
+
if (!request.format) {
|
|
544
|
+
request.format = StreamingClient.StreamingFormat.NDJSON;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// Build request body
|
|
548
|
+
requestBody = {
|
|
549
|
+
message: request.message,
|
|
550
|
+
spaceKeys: []
|
|
551
|
+
}; // Convert spaceIds to spaceKeys array
|
|
552
|
+
if (request.spaceIds && request.spaceIds.length > 0) {
|
|
553
|
+
request.spaceIds.forEach(function (spaceId) {
|
|
554
|
+
requestBody.spaceKeys.push({
|
|
555
|
+
spaceId: spaceId
|
|
556
|
+
});
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// Add optional parameters
|
|
561
|
+
if (request.requestedSize !== undefined) {
|
|
562
|
+
requestBody.requestedSize = request.requestedSize;
|
|
563
|
+
}
|
|
564
|
+
if (request.fetchMemory !== undefined) {
|
|
565
|
+
requestBody.fetchMemory = request.fetchMemory;
|
|
566
|
+
}
|
|
567
|
+
if (request.fetchMemoryContent !== undefined) {
|
|
568
|
+
requestBody.fetchMemoryContent = request.fetchMemoryContent;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// Add post-processor configuration
|
|
572
|
+
if (request.postProcessorName) {
|
|
573
|
+
postProcessor = {
|
|
574
|
+
name: request.postProcessorName
|
|
575
|
+
};
|
|
576
|
+
if (request.postProcessorConfig) {
|
|
577
|
+
postProcessor.config = request.postProcessorConfig;
|
|
578
|
+
}
|
|
579
|
+
requestBody.postProcessor = postProcessor;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
// Build URL for POST endpoint
|
|
583
|
+
baseURL = this.client.basePath || 'http://localhost:8080';
|
|
584
|
+
endpoint = "".concat(baseURL, "/v1/memories:retrieve"); // Set appropriate headers
|
|
585
|
+
headers = {
|
|
586
|
+
'Accept': request.format === StreamingClient.StreamingFormat.SSE ? 'text/event-stream' : 'application/x-ndjson',
|
|
587
|
+
'Content-Type': 'application/json'
|
|
588
|
+
}; // Add authentication headers
|
|
589
|
+
if (this.client.defaultHeaders) {
|
|
590
|
+
Object.assign(headers, this.client.defaultHeaders);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// Make the POST request
|
|
594
|
+
_context6.n = 3;
|
|
595
|
+
return fetch(endpoint, {
|
|
596
|
+
method: 'POST',
|
|
597
|
+
headers: headers,
|
|
598
|
+
body: JSON.stringify(requestBody),
|
|
599
|
+
signal: signal
|
|
600
|
+
});
|
|
601
|
+
case 3:
|
|
602
|
+
response = _context6.v;
|
|
603
|
+
if (response.ok) {
|
|
604
|
+
_context6.n = 5;
|
|
605
|
+
break;
|
|
606
|
+
}
|
|
607
|
+
_context6.n = 4;
|
|
608
|
+
return response.text();
|
|
609
|
+
case 4:
|
|
610
|
+
errorText = _context6.v;
|
|
611
|
+
throw new StreamError(errorText, response.status);
|
|
612
|
+
case 5:
|
|
613
|
+
if (!(request.format === StreamingClient.StreamingFormat.SSE)) {
|
|
614
|
+
_context6.n = 6;
|
|
615
|
+
break;
|
|
616
|
+
}
|
|
617
|
+
return _context6.a(2, this._processSSEStream(response));
|
|
618
|
+
case 6:
|
|
619
|
+
return _context6.a(2, this._processNDJSONStream(response));
|
|
620
|
+
case 7:
|
|
621
|
+
return _context6.a(2);
|
|
622
|
+
}
|
|
623
|
+
}, _callee6, this);
|
|
624
|
+
}));
|
|
625
|
+
function retrieveMemoryStreamAdvanced(_x17, _x18) {
|
|
626
|
+
return _retrieveMemoryStreamAdvanced.apply(this, arguments);
|
|
627
|
+
}
|
|
628
|
+
return retrieveMemoryStreamAdvanced;
|
|
629
|
+
}()
|
|
445
630
|
/**
|
|
446
631
|
* Collects all streaming results into an array
|
|
447
632
|
* @param {AbortSignal} signal - Abort signal for cancellation
|
|
@@ -460,43 +645,43 @@ var StreamingClient = exports.StreamingClient = /*#__PURE__*/function () {
|
|
|
460
645
|
* @returns {Promise<MemoryStreamResponse[]>} Array of streaming events
|
|
461
646
|
*/
|
|
462
647
|
function () {
|
|
463
|
-
var _streamWithTimeout = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
648
|
+
var _streamWithTimeout = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(message, spaceIds, timeoutMs) {
|
|
464
649
|
var controller, timeoutId, stream, results, _t5;
|
|
465
|
-
return _regenerator().w(function (
|
|
466
|
-
while (1) switch (
|
|
650
|
+
return _regenerator().w(function (_context7) {
|
|
651
|
+
while (1) switch (_context7.p = _context7.n) {
|
|
467
652
|
case 0:
|
|
468
653
|
controller = new AbortController();
|
|
469
654
|
timeoutId = setTimeout(function () {
|
|
470
655
|
return controller.abort();
|
|
471
656
|
}, timeoutMs);
|
|
472
|
-
|
|
473
|
-
|
|
657
|
+
_context7.p = 1;
|
|
658
|
+
_context7.n = 2;
|
|
474
659
|
return this.retrieveMemoryStreamSimple(controller.signal, message, spaceIds);
|
|
475
660
|
case 2:
|
|
476
|
-
stream =
|
|
477
|
-
|
|
661
|
+
stream = _context7.v;
|
|
662
|
+
_context7.n = 3;
|
|
478
663
|
return StreamingClient.collectStreamResults(controller.signal, stream);
|
|
479
664
|
case 3:
|
|
480
|
-
results =
|
|
665
|
+
results = _context7.v;
|
|
481
666
|
clearTimeout(timeoutId);
|
|
482
|
-
return
|
|
667
|
+
return _context7.a(2, results);
|
|
483
668
|
case 4:
|
|
484
|
-
|
|
485
|
-
_t5 =
|
|
669
|
+
_context7.p = 4;
|
|
670
|
+
_t5 = _context7.v;
|
|
486
671
|
clearTimeout(timeoutId);
|
|
487
672
|
if (!(_t5.name === 'AbortError' || _t5.message === 'Operation was aborted')) {
|
|
488
|
-
|
|
673
|
+
_context7.n = 5;
|
|
489
674
|
break;
|
|
490
675
|
}
|
|
491
676
|
throw new Error('Streaming operation timed out');
|
|
492
677
|
case 5:
|
|
493
678
|
throw _t5;
|
|
494
679
|
case 6:
|
|
495
|
-
return
|
|
680
|
+
return _context7.a(2);
|
|
496
681
|
}
|
|
497
|
-
},
|
|
682
|
+
}, _callee7, this, [[1, 4]]);
|
|
498
683
|
}));
|
|
499
|
-
function streamWithTimeout(
|
|
684
|
+
function streamWithTimeout(_x19, _x20, _x21) {
|
|
500
685
|
return _streamWithTimeout.apply(this, arguments);
|
|
501
686
|
}
|
|
502
687
|
return streamWithTimeout;
|
|
@@ -504,28 +689,28 @@ var StreamingClient = exports.StreamingClient = /*#__PURE__*/function () {
|
|
|
504
689
|
}], [{
|
|
505
690
|
key: "collectStreamResults",
|
|
506
691
|
value: (function () {
|
|
507
|
-
var _collectStreamResults = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
692
|
+
var _collectStreamResults = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(signal, stream) {
|
|
508
693
|
var results, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, event, _t6, _t7;
|
|
509
|
-
return _regenerator().w(function (
|
|
510
|
-
while (1) switch (
|
|
694
|
+
return _regenerator().w(function (_context8) {
|
|
695
|
+
while (1) switch (_context8.p = _context8.n) {
|
|
511
696
|
case 0:
|
|
512
697
|
results = [];
|
|
513
|
-
|
|
698
|
+
_context8.p = 1;
|
|
514
699
|
_iteratorAbruptCompletion = false;
|
|
515
700
|
_didIteratorError = false;
|
|
516
|
-
|
|
701
|
+
_context8.p = 2;
|
|
517
702
|
_iterator = _asyncIterator(stream);
|
|
518
703
|
case 3:
|
|
519
|
-
|
|
704
|
+
_context8.n = 4;
|
|
520
705
|
return _iterator.next();
|
|
521
706
|
case 4:
|
|
522
|
-
if (!(_iteratorAbruptCompletion = !(_step =
|
|
523
|
-
|
|
707
|
+
if (!(_iteratorAbruptCompletion = !(_step = _context8.v).done)) {
|
|
708
|
+
_context8.n = 7;
|
|
524
709
|
break;
|
|
525
710
|
}
|
|
526
711
|
event = _step.value;
|
|
527
712
|
if (!(signal && signal.aborted)) {
|
|
528
|
-
|
|
713
|
+
_context8.n = 5;
|
|
529
714
|
break;
|
|
530
715
|
}
|
|
531
716
|
throw new Error('Operation was aborted');
|
|
@@ -533,55 +718,55 @@ var StreamingClient = exports.StreamingClient = /*#__PURE__*/function () {
|
|
|
533
718
|
results.push(event);
|
|
534
719
|
case 6:
|
|
535
720
|
_iteratorAbruptCompletion = false;
|
|
536
|
-
|
|
721
|
+
_context8.n = 3;
|
|
537
722
|
break;
|
|
538
723
|
case 7:
|
|
539
|
-
|
|
724
|
+
_context8.n = 9;
|
|
540
725
|
break;
|
|
541
726
|
case 8:
|
|
542
|
-
|
|
543
|
-
_t6 =
|
|
727
|
+
_context8.p = 8;
|
|
728
|
+
_t6 = _context8.v;
|
|
544
729
|
_didIteratorError = true;
|
|
545
730
|
_iteratorError = _t6;
|
|
546
731
|
case 9:
|
|
547
|
-
|
|
548
|
-
|
|
732
|
+
_context8.p = 9;
|
|
733
|
+
_context8.p = 10;
|
|
549
734
|
if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
|
|
550
|
-
|
|
735
|
+
_context8.n = 11;
|
|
551
736
|
break;
|
|
552
737
|
}
|
|
553
|
-
|
|
738
|
+
_context8.n = 11;
|
|
554
739
|
return _iterator["return"]();
|
|
555
740
|
case 11:
|
|
556
|
-
|
|
741
|
+
_context8.p = 11;
|
|
557
742
|
if (!_didIteratorError) {
|
|
558
|
-
|
|
743
|
+
_context8.n = 12;
|
|
559
744
|
break;
|
|
560
745
|
}
|
|
561
746
|
throw _iteratorError;
|
|
562
747
|
case 12:
|
|
563
|
-
return
|
|
748
|
+
return _context8.f(11);
|
|
564
749
|
case 13:
|
|
565
|
-
return
|
|
750
|
+
return _context8.f(9);
|
|
566
751
|
case 14:
|
|
567
|
-
|
|
752
|
+
_context8.n = 17;
|
|
568
753
|
break;
|
|
569
754
|
case 15:
|
|
570
|
-
|
|
571
|
-
_t7 =
|
|
755
|
+
_context8.p = 15;
|
|
756
|
+
_t7 = _context8.v;
|
|
572
757
|
if (!(_t7.name === 'AbortError' || _t7.message === 'Operation was aborted')) {
|
|
573
|
-
|
|
758
|
+
_context8.n = 16;
|
|
574
759
|
break;
|
|
575
760
|
}
|
|
576
761
|
throw _t7;
|
|
577
762
|
case 16:
|
|
578
763
|
throw _t7;
|
|
579
764
|
case 17:
|
|
580
|
-
return
|
|
765
|
+
return _context8.a(2, results);
|
|
581
766
|
}
|
|
582
|
-
},
|
|
767
|
+
}, _callee8, null, [[10,, 11, 13], [2, 8, 9, 14], [1, 15]]);
|
|
583
768
|
}));
|
|
584
|
-
function collectStreamResults(
|
|
769
|
+
function collectStreamResults(_x22, _x23) {
|
|
585
770
|
return _collectStreamResults.apply(this, arguments);
|
|
586
771
|
}
|
|
587
772
|
return collectStreamResults;
|
|
@@ -598,6 +783,24 @@ var StreamingClient = exports.StreamingClient = /*#__PURE__*/function () {
|
|
|
598
783
|
* @property {boolean} [fetchMemoryContent] - Whether to fetch memory content details
|
|
599
784
|
* @property {boolean} [generateAbstract] - Whether to generate abstract
|
|
600
785
|
* @property {string} [format] - Streaming format (ndjson or sse)
|
|
786
|
+
* @property {string} [ppLlmId] - UUID of LLM for ChatPostProcessor
|
|
787
|
+
* @property {string} [ppRerankerId] - UUID of reranker for ChatPostProcessor
|
|
788
|
+
* @property {number} [ppRelevanceThreshold] - Minimum relevance score
|
|
789
|
+
* @property {number} [ppLlmTemp] - LLM temperature for generation
|
|
790
|
+
* @property {number} [ppMaxResults] - Maximum results to return
|
|
791
|
+
* @property {boolean} [ppChronologicalResort] - Whether to resort by creation time
|
|
792
|
+
*/
|
|
793
|
+
/**
|
|
794
|
+
* Advanced request parameters for streaming with custom post-processor
|
|
795
|
+
* @typedef {Object} AdvancedMemoryStreamRequest
|
|
796
|
+
* @property {string} message - The search message
|
|
797
|
+
* @property {string[]} [spaceIds] - Array of space IDs to search
|
|
798
|
+
* @property {number} [requestedSize] - Maximum number of results to return
|
|
799
|
+
* @property {boolean} [fetchMemory] - Whether to fetch memory content
|
|
800
|
+
* @property {boolean} [fetchMemoryContent] - Whether to fetch memory content details
|
|
801
|
+
* @property {string} [format] - Streaming format (ndjson or sse)
|
|
802
|
+
* @property {string} [postProcessorName] - Name of custom post-processor
|
|
803
|
+
* @property {Object} [postProcessorConfig] - Configuration for post-processor
|
|
601
804
|
*/
|
|
602
805
|
/**
|
|
603
806
|
* Streaming response event
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pairsystems/goodmem-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "JavaScript client for GoodMem API",
|
|
5
5
|
"license": "Unlicense",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -37,14 +37,10 @@
|
|
|
37
37
|
"@babel/preset-env": "^7.0.0",
|
|
38
38
|
"@babel/register": "^7.0.0",
|
|
39
39
|
"expect.js": "^0.3.1",
|
|
40
|
-
"mocha": "^
|
|
40
|
+
"mocha": "^8.0.1",
|
|
41
41
|
"sinon": "^7.2.0"
|
|
42
42
|
},
|
|
43
43
|
"files": [
|
|
44
44
|
"dist"
|
|
45
|
-
]
|
|
46
|
-
"publishConfig": {
|
|
47
|
-
"access": "public",
|
|
48
|
-
"registry": "https://registry.npmjs.org/"
|
|
49
|
-
}
|
|
45
|
+
]
|
|
50
46
|
}
|