@digipair/skill-chatbot 0.0.1 → 0.0.3

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/few_shot.cjs.js CHANGED
@@ -1,7 +1,277 @@
1
1
  'use strict';
2
2
 
3
3
  var index = require('./index.cjs2.js');
4
- require('@digipair/engine');
4
+
5
+ // Default generic "any" values are for backwards compatibility.
6
+ function _assert_this_initialized$1(self) {
7
+ if (self === void 0) {
8
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
9
+ }
10
+ return self;
11
+ }
12
+ function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
13
+ try {
14
+ var info = gen[key](arg);
15
+ var value = info.value;
16
+ } catch (error) {
17
+ reject(error);
18
+ return;
19
+ }
20
+ if (info.done) {
21
+ resolve(value);
22
+ } else {
23
+ Promise.resolve(value).then(_next, _throw);
24
+ }
25
+ }
26
+ function _async_to_generator$1(fn) {
27
+ return function() {
28
+ var self = this, args = arguments;
29
+ return new Promise(function(resolve, reject) {
30
+ var gen = fn.apply(self, args);
31
+ function _next(value) {
32
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
33
+ }
34
+ function _throw(err) {
35
+ asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
36
+ }
37
+ _next(undefined);
38
+ });
39
+ };
40
+ }
41
+ function _class_call_check$1(instance, Constructor) {
42
+ if (!(instance instanceof Constructor)) {
43
+ throw new TypeError("Cannot call a class as a function");
44
+ }
45
+ }
46
+ function _defineProperties$1(target, props) {
47
+ for(var i = 0; i < props.length; i++){
48
+ var descriptor = props[i];
49
+ descriptor.enumerable = descriptor.enumerable || false;
50
+ descriptor.configurable = true;
51
+ if ("value" in descriptor) descriptor.writable = true;
52
+ Object.defineProperty(target, descriptor.key, descriptor);
53
+ }
54
+ }
55
+ function _create_class$1(Constructor, protoProps, staticProps) {
56
+ if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
57
+ if (staticProps) _defineProperties$1(Constructor, staticProps);
58
+ return Constructor;
59
+ }
60
+ function _get_prototype_of$1(o) {
61
+ _get_prototype_of$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
62
+ return o.__proto__ || Object.getPrototypeOf(o);
63
+ };
64
+ return _get_prototype_of$1(o);
65
+ }
66
+ function _inherits$1(subClass, superClass) {
67
+ if (typeof superClass !== "function" && superClass !== null) {
68
+ throw new TypeError("Super expression must either be null or a function");
69
+ }
70
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
71
+ constructor: {
72
+ value: subClass,
73
+ writable: true,
74
+ configurable: true
75
+ }
76
+ });
77
+ if (superClass) _set_prototype_of$1(subClass, superClass);
78
+ }
79
+ function _possible_constructor_return$1(self, call) {
80
+ if (call && (_type_of$1(call) === "object" || typeof call === "function")) {
81
+ return call;
82
+ }
83
+ return _assert_this_initialized$1(self);
84
+ }
85
+ function _set_prototype_of$1(o, p) {
86
+ _set_prototype_of$1 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
87
+ o.__proto__ = p;
88
+ return o;
89
+ };
90
+ return _set_prototype_of$1(o, p);
91
+ }
92
+ function _type_of$1(obj) {
93
+ "@swc/helpers - typeof";
94
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
95
+ }
96
+ function _is_native_reflect_construct$1() {
97
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
98
+ if (Reflect.construct.sham) return false;
99
+ if (typeof Proxy === "function") return true;
100
+ try {
101
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
102
+ return true;
103
+ } catch (e) {
104
+ return false;
105
+ }
106
+ }
107
+ function _create_super$1(Derived) {
108
+ var hasNativeReflectConstruct = _is_native_reflect_construct$1();
109
+ return function _createSuperInternal() {
110
+ var Super = _get_prototype_of$1(Derived), result;
111
+ if (hasNativeReflectConstruct) {
112
+ var NewTarget = _get_prototype_of$1(this).constructor;
113
+ result = Reflect.construct(Super, arguments, NewTarget);
114
+ } else {
115
+ result = Super.apply(this, arguments);
116
+ }
117
+ return _possible_constructor_return$1(this, result);
118
+ };
119
+ }
120
+ function _ts_generator$1(thisArg, body) {
121
+ var f, y, t, g, _ = {
122
+ label: 0,
123
+ sent: function() {
124
+ if (t[0] & 1) throw t[1];
125
+ return t[1];
126
+ },
127
+ trys: [],
128
+ ops: []
129
+ };
130
+ return g = {
131
+ next: verb(0),
132
+ "throw": verb(1),
133
+ "return": verb(2)
134
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
135
+ return this;
136
+ }), g;
137
+ function verb(n) {
138
+ return function(v) {
139
+ return step([
140
+ n,
141
+ v
142
+ ]);
143
+ };
144
+ }
145
+ function step(op) {
146
+ if (f) throw new TypeError("Generator is already executing.");
147
+ while(_)try {
148
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
149
+ if (y = 0, t) op = [
150
+ op[0] & 2,
151
+ t.value
152
+ ];
153
+ switch(op[0]){
154
+ case 0:
155
+ case 1:
156
+ t = op;
157
+ break;
158
+ case 4:
159
+ _.label++;
160
+ return {
161
+ value: op[1],
162
+ done: false
163
+ };
164
+ case 5:
165
+ _.label++;
166
+ y = op[1];
167
+ op = [
168
+ 0
169
+ ];
170
+ continue;
171
+ case 7:
172
+ op = _.ops.pop();
173
+ _.trys.pop();
174
+ continue;
175
+ default:
176
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
177
+ _ = 0;
178
+ continue;
179
+ }
180
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
181
+ _.label = op[1];
182
+ break;
183
+ }
184
+ if (op[0] === 6 && _.label < t[1]) {
185
+ _.label = t[1];
186
+ t = op;
187
+ break;
188
+ }
189
+ if (t && _.label < t[2]) {
190
+ _.label = t[2];
191
+ _.ops.push(op);
192
+ break;
193
+ }
194
+ if (t[2]) _.ops.pop();
195
+ _.trys.pop();
196
+ continue;
197
+ }
198
+ op = body.call(thisArg, _);
199
+ } catch (e) {
200
+ op = [
201
+ 6,
202
+ e
203
+ ];
204
+ y = 0;
205
+ } finally{
206
+ f = t = 0;
207
+ }
208
+ if (op[0] & 5) throw op[1];
209
+ return {
210
+ value: op[0] ? op[1] : void 0,
211
+ done: true
212
+ };
213
+ }
214
+ }
215
+ /**
216
+ * Abstract class that serves as a base for creating chat prompt
217
+ * templates. It extends the BasePromptTemplate.
218
+ */ var BaseChatPromptTemplate = /*#__PURE__*/ function(BasePromptTemplate) {
219
+ _inherits$1(BaseChatPromptTemplate, BasePromptTemplate);
220
+ var _super = _create_super$1(BaseChatPromptTemplate);
221
+ function BaseChatPromptTemplate(input) {
222
+ _class_call_check$1(this, BaseChatPromptTemplate);
223
+ return _super.call(this, input);
224
+ }
225
+ _create_class$1(BaseChatPromptTemplate, [
226
+ {
227
+ key: "format",
228
+ value: function format(values) {
229
+ var _this = this;
230
+ return _async_to_generator$1(function() {
231
+ return _ts_generator$1(this, function(_state) {
232
+ switch(_state.label){
233
+ case 0:
234
+ return [
235
+ 4,
236
+ _this.formatPromptValue(values)
237
+ ];
238
+ case 1:
239
+ return [
240
+ 2,
241
+ _state.sent().toString()
242
+ ];
243
+ }
244
+ });
245
+ })();
246
+ }
247
+ },
248
+ {
249
+ key: "formatPromptValue",
250
+ value: function formatPromptValue(values) {
251
+ var _this = this;
252
+ return _async_to_generator$1(function() {
253
+ var resultMessages;
254
+ return _ts_generator$1(this, function(_state) {
255
+ switch(_state.label){
256
+ case 0:
257
+ return [
258
+ 4,
259
+ _this.formatMessages(values)
260
+ ];
261
+ case 1:
262
+ resultMessages = _state.sent();
263
+ return [
264
+ 2,
265
+ new index.ChatPromptValue(resultMessages)
266
+ ];
267
+ }
268
+ });
269
+ })();
270
+ }
271
+ }
272
+ ]);
273
+ return BaseChatPromptTemplate;
274
+ }(index.BasePromptTemplate);
5
275
 
6
276
  function _array_like_to_array(arr, len) {
7
277
  if (len == null || len > arr.length) len = arr.length;
@@ -882,7 +1152,7 @@ function _ts_generator(thisArg, body) {
882
1152
  }
883
1153
  ]);
884
1154
  return FewShotChatMessagePromptTemplate;
885
- }(index.BaseChatPromptTemplate);
1155
+ }(BaseChatPromptTemplate);
886
1156
 
887
1157
  exports.FewShotChatMessagePromptTemplate = FewShotChatMessagePromptTemplate;
888
1158
  exports.FewShotPromptTemplate = FewShotPromptTemplate;