@tiledesk/tiledesk-tybot-connector 0.2.64 → 0.2.66-rc1
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/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
available on:
|
|
6
6
|
▶️ https://www.npmjs.com/package/@tiledesk/tiledesk-tybot-connector
|
|
7
7
|
|
|
8
|
+
# v0.2.66-rc1
|
|
9
|
+
- fix missing model in updateQuote
|
|
10
|
+
|
|
11
|
+
# v0.2.65
|
|
12
|
+
- fix OPENAI_APIKEY: removed Bearer prefix
|
|
8
13
|
|
|
9
14
|
# v0.2.64
|
|
10
15
|
- removed system parameters from /reserved/parameters
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiledesk/tiledesk-tybot-connector",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.66-rc1",
|
|
4
4
|
"description": "Tiledesk Tybot connector",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -24,13 +24,14 @@
|
|
|
24
24
|
"handlebars": "^4.7.7",
|
|
25
25
|
"jsonschema": "^1.4.1",
|
|
26
26
|
"jsonwebtoken": "^8.5.1",
|
|
27
|
+
"liquidjs": "^10.8.4",
|
|
27
28
|
"minimist-string": "^1.0.2",
|
|
28
29
|
"mongoose": "^6.3.5",
|
|
30
|
+
"multer": "^1.4.5-lts.1",
|
|
29
31
|
"nanoid": "^3.1.25",
|
|
30
32
|
"redis": "^3.1.2",
|
|
31
33
|
"uuid": "^3.3.3",
|
|
32
|
-
"vm2": "^3.9.13"
|
|
33
|
-
"liquidjs": "^10.8.4"
|
|
34
|
+
"vm2": "^3.9.13"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"mocha": "^8.4.0"
|
|
@@ -196,7 +196,10 @@ class DirAskGPTV2 {
|
|
|
196
196
|
else if (resbody.success === true) {
|
|
197
197
|
|
|
198
198
|
if (publicKey === true) {
|
|
199
|
-
let token_usage =
|
|
199
|
+
let token_usage = {
|
|
200
|
+
tokens: resbody.prompt_token_size,
|
|
201
|
+
model: json.model
|
|
202
|
+
}
|
|
200
203
|
this.updateQuote(server_base_url, token_usage);
|
|
201
204
|
}
|
|
202
205
|
|
|
@@ -47,7 +47,7 @@ class DirAssistant {
|
|
|
47
47
|
const url = filler.fill(action.url, requestAttributes);
|
|
48
48
|
// prompt => Mandatory
|
|
49
49
|
// assistantId => Mandatory
|
|
50
|
-
//
|
|
50
|
+
// threadIdAttribute => Optional // default "firstThread"
|
|
51
51
|
// assignResultTo => Optional // default "assistantReply"
|
|
52
52
|
// assignErrorTo => Optional // default "assistantError"
|
|
53
53
|
// action.settings.timeout => Optional
|
|
@@ -122,7 +122,7 @@ class DirAssistant {
|
|
|
122
122
|
|
|
123
123
|
this.timeout = this.#webrequest_timeout(action, 20000, 1, 300000);
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
let apikey = await this.getGPT_APIKEY();
|
|
126
126
|
if (this.log) {console.log("apikey:", apikey);}
|
|
127
127
|
if (!apikey) {
|
|
128
128
|
const reply = "DirAssistant gptkey is mandatory in Integrations";
|
|
@@ -134,6 +134,10 @@ class DirAssistant {
|
|
|
134
134
|
}
|
|
135
135
|
return;
|
|
136
136
|
}
|
|
137
|
+
else {
|
|
138
|
+
apikey = "Bearer " + apikey;
|
|
139
|
+
console.log("APIKEY::", apikey);
|
|
140
|
+
}
|
|
137
141
|
let threadId = null;
|
|
138
142
|
try {
|
|
139
143
|
threadId = requestAttributes[threadIdAttribute];
|
|
@@ -143,11 +147,15 @@ class DirAssistant {
|
|
|
143
147
|
const thread = await this.createThread(apikey);
|
|
144
148
|
if (this.log) {console.log("Thread crated.");}
|
|
145
149
|
threadId = thread.id;
|
|
150
|
+
await TiledeskChatbot.addParameterStatic(this.context.tdcache, this.context.requestId, threadIdAttribute, threadId);
|
|
146
151
|
if (this.log) {
|
|
147
152
|
console.log("thread:", thread);
|
|
148
153
|
console.log("threadId:", threadId);
|
|
149
154
|
}
|
|
150
155
|
}
|
|
156
|
+
else {
|
|
157
|
+
if (this.log) { console.log("Reusing threadId (used flow attribute:" + threadIdAttribute + "):", threadId); }
|
|
158
|
+
}
|
|
151
159
|
await this.addMessage(prompt, threadId, apikey);
|
|
152
160
|
if (this.log) {console.log("Message added.");}
|
|
153
161
|
await this.runThreadOnAssistant(assistantId, threadId, apikey);
|
|
@@ -502,11 +510,11 @@ class DirAssistant {
|
|
|
502
510
|
if (this.log) { console.log("DirAssistant INTEGRATIONS_HTTPREQUEST ", INTEGRATIONS_HTTPREQUEST) }
|
|
503
511
|
|
|
504
512
|
this.#myrequest(
|
|
505
|
-
INTEGRATIONS_HTTPREQUEST, async (err,
|
|
513
|
+
INTEGRATIONS_HTTPREQUEST, async (err, res) => {
|
|
506
514
|
if (err) {
|
|
507
515
|
resolve(null);
|
|
508
516
|
} else {
|
|
509
|
-
|
|
517
|
+
let integration = res.data;
|
|
510
518
|
if (integration &&
|
|
511
519
|
integration.value) {
|
|
512
520
|
resolve(integration.value.apikey)
|
|
@@ -563,7 +571,7 @@ class DirAssistant {
|
|
|
563
571
|
axios(axios_options)
|
|
564
572
|
.then((res) => {
|
|
565
573
|
if (this.log) {
|
|
566
|
-
console.log("Success Response:", res);
|
|
574
|
+
// console.log("Success Response:", res);
|
|
567
575
|
console.log("Response for url:", options.url);
|
|
568
576
|
console.log("Response headers:\n", JSON.stringify(res.headers));
|
|
569
577
|
}
|
|
@@ -57,6 +57,7 @@ class DirGptTask {
|
|
|
57
57
|
|
|
58
58
|
// default value
|
|
59
59
|
let answer = "No answer.";
|
|
60
|
+
let model = "gpt-3.5-turbo";
|
|
60
61
|
|
|
61
62
|
if (!action.question || action.question === '') {
|
|
62
63
|
console.error("Error: DirGptTask question attribute is mandatory. Executing condition false...")
|
|
@@ -81,6 +82,10 @@ class DirGptTask {
|
|
|
81
82
|
|
|
82
83
|
let max_tokens = action.max_tokens;
|
|
83
84
|
let temperature = action.temperature;
|
|
85
|
+
|
|
86
|
+
if (action.model) {
|
|
87
|
+
model = action.model;
|
|
88
|
+
}
|
|
84
89
|
|
|
85
90
|
if (this.log) {
|
|
86
91
|
console.log("DirGptTask max_tokens: ", max_tokens);
|
|
@@ -180,7 +185,10 @@ class DirGptTask {
|
|
|
180
185
|
await this.#assignAttributes(action, answer_json);
|
|
181
186
|
|
|
182
187
|
if (publicKey === true) {
|
|
183
|
-
let token_usage =
|
|
188
|
+
let token_usage = {
|
|
189
|
+
tokens: resbody.usage.total_tokens,
|
|
190
|
+
model: json.model
|
|
191
|
+
}
|
|
184
192
|
this.updateQuote(server_base_url, token_usage);
|
|
185
193
|
}
|
|
186
194
|
|