@tiledesk/tiledesk-tybot-connector 2.0.16-rc1 → 2.0.16-rc2
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/logs/app.log +1162 -0
- package/package.json +1 -1
- package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +47 -14
package/package.json
CHANGED
|
@@ -75,8 +75,10 @@ class DirAskGPTV2 {
|
|
|
75
75
|
let temperature;
|
|
76
76
|
let max_tokens;
|
|
77
77
|
let top_k;
|
|
78
|
+
let alpha;
|
|
78
79
|
let transcript;
|
|
79
80
|
let citations = false;
|
|
81
|
+
let chunks_only = false;
|
|
80
82
|
let engine;
|
|
81
83
|
//let default_context = "You are an helpful assistant for question-answering tasks.\nUse ONLY the following pieces of retrieved context to answer the question.\nIf you don't know the answer, just say that you don't know.\nIf none of the retrieved context answer the question, add this word to the end <NOANS>\n\n{context}";
|
|
82
84
|
|
|
@@ -123,10 +125,18 @@ class DirAskGPTV2 {
|
|
|
123
125
|
max_tokens = action.max_tokens;
|
|
124
126
|
}
|
|
125
127
|
|
|
128
|
+
if (action.alpha) {
|
|
129
|
+
alpha = action.alpha;
|
|
130
|
+
}
|
|
131
|
+
|
|
126
132
|
if (action.citations) {
|
|
127
133
|
citations = action.citations;
|
|
128
134
|
}
|
|
129
135
|
|
|
136
|
+
if (action.chunks_only) {
|
|
137
|
+
chunks_only = action.chunks_only;
|
|
138
|
+
}
|
|
139
|
+
|
|
130
140
|
let requestVariables = null;
|
|
131
141
|
requestVariables =
|
|
132
142
|
await TiledeskChatbot.allParametersStatic(
|
|
@@ -185,7 +195,7 @@ class DirAskGPTV2 {
|
|
|
185
195
|
return;
|
|
186
196
|
}
|
|
187
197
|
|
|
188
|
-
if (publicKey === true) {
|
|
198
|
+
if (publicKey === true && !chunks_only) {
|
|
189
199
|
let keep_going = await this.checkQuoteAvailability();
|
|
190
200
|
if (keep_going === false) {
|
|
191
201
|
this.logger.warn("[Ask Knowledge Base] Tokens quota exceeded. Skip the action")
|
|
@@ -199,6 +209,7 @@ class DirAskGPTV2 {
|
|
|
199
209
|
|
|
200
210
|
let ns;
|
|
201
211
|
|
|
212
|
+
console.log("namespace: ", namespace)
|
|
202
213
|
if (action.namespaceAsName) {
|
|
203
214
|
// Namespace could be an attribute
|
|
204
215
|
const filled_namespace = filler.fill(action.namespace, requestVariables)
|
|
@@ -209,6 +220,7 @@ class DirAskGPTV2 {
|
|
|
209
220
|
} else {
|
|
210
221
|
this.logger.native("[Ask Knowledge Base] Searching namespace by id ", namespace);
|
|
211
222
|
ns = await this.getNamespace(null, namespace);
|
|
223
|
+
console.log("ns ?: ", ns)
|
|
212
224
|
}
|
|
213
225
|
|
|
214
226
|
if (!ns) {
|
|
@@ -259,7 +271,16 @@ class DirAskGPTV2 {
|
|
|
259
271
|
if (max_tokens) {
|
|
260
272
|
json.max_tokens = max_tokens;
|
|
261
273
|
}
|
|
262
|
-
|
|
274
|
+
|
|
275
|
+
if (engine.type === 'serverless') {
|
|
276
|
+
json.search_type = 'hybrid';
|
|
277
|
+
json.alpha = alpha;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if (chunks_only && chunks_only === true) {
|
|
281
|
+
json.search_type = 'chunks';
|
|
282
|
+
}
|
|
283
|
+
|
|
263
284
|
if (!action.advancedPrompt) {
|
|
264
285
|
if (filled_context) {
|
|
265
286
|
json.system_context = filled_context + "\n" + contexts[model];
|
|
@@ -305,22 +326,34 @@ class DirAskGPTV2 {
|
|
|
305
326
|
}
|
|
306
327
|
else if (resbody.success === true) {
|
|
307
328
|
winston.debug("DirAskGPTV2 resbody: ", resbody);
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
329
|
+
if (chunks_only) {
|
|
330
|
+
await this.#assignAttributes(action, resbody.answer, resbody.source, resbody.chunks);
|
|
331
|
+
if (trueIntent) {
|
|
332
|
+
await this.#executeCondition(true, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
333
|
+
callback(true);
|
|
334
|
+
return;
|
|
313
335
|
}
|
|
314
|
-
|
|
315
|
-
|
|
336
|
+
callback();
|
|
337
|
+
return;
|
|
316
338
|
|
|
317
|
-
|
|
318
|
-
await this.#
|
|
319
|
-
|
|
339
|
+
} else {
|
|
340
|
+
await this.#assignAttributes(action, resbody.answer, resbody.source, resbody.content_chunks);
|
|
341
|
+
if (publicKey === true) {
|
|
342
|
+
let tokens_usage = {
|
|
343
|
+
tokens: resbody.prompt_token_size,
|
|
344
|
+
model: json.model
|
|
345
|
+
}
|
|
346
|
+
this.updateQuote(tokens_usage);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if (trueIntent) {
|
|
350
|
+
await this.#executeCondition(true, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
|
|
351
|
+
callback(true);
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
callback();
|
|
320
355
|
return;
|
|
321
356
|
}
|
|
322
|
-
callback();
|
|
323
|
-
return;
|
|
324
357
|
} else {
|
|
325
358
|
await this.#assignAttributes(action, answer, source);
|
|
326
359
|
if (falseIntent) {
|