@tiledesk/tiledesk-tybot-connector 0.2.110 → 0.2.112
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
|
@@ -17,6 +17,12 @@ available on:
|
|
|
17
17
|
- Added flowError on JSONCondition when result = null
|
|
18
18
|
- Added fix on Filler -->
|
|
19
19
|
|
|
20
|
+
# v0.2.112 -> test
|
|
21
|
+
- Fix index name in DirAskGPTV2
|
|
22
|
+
|
|
23
|
+
# v0.2.111 -> test
|
|
24
|
+
- Updated DirAskGPTV2 with engine support
|
|
25
|
+
|
|
20
26
|
# v0.2.110 -> test
|
|
21
27
|
- Added DirMoveToUnassigned
|
|
22
28
|
- Added DirConnectBlock
|
package/package.json
CHANGED
|
@@ -67,6 +67,7 @@ class DirAskGPTV2 {
|
|
|
67
67
|
let top_k;
|
|
68
68
|
let transcript;
|
|
69
69
|
let citations = false;
|
|
70
|
+
let engine;
|
|
70
71
|
//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}";
|
|
71
72
|
|
|
72
73
|
let contexts = {
|
|
@@ -174,15 +175,23 @@ class DirAskGPTV2 {
|
|
|
174
175
|
return;
|
|
175
176
|
}
|
|
176
177
|
}
|
|
178
|
+
let ns;
|
|
177
179
|
|
|
178
|
-
|
|
179
180
|
if (action.namespaceAsName) {
|
|
180
181
|
// Namespace could be an attribute
|
|
181
182
|
const filled_namespace = filler.fill(action.namespace, requestVariables)
|
|
182
|
-
|
|
183
183
|
// namespace = await this.getNamespaceIdFromName(server_base_url, action.namespace)
|
|
184
|
-
|
|
184
|
+
ns = await this.getNamespace(server_base_url, filled_namespace, null);
|
|
185
|
+
namespace = ns.id;
|
|
185
186
|
if (this.log) { console.log("DirAskGPT - Retrieved namespace id from name ", namespace); }
|
|
187
|
+
} else {
|
|
188
|
+
ns = await this.getNamespace(server_base_url, null, namespace);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (ns.engine) {
|
|
192
|
+
engine = ns.engine;
|
|
193
|
+
} else {
|
|
194
|
+
engine = await this.setDefaultEngine()
|
|
186
195
|
}
|
|
187
196
|
|
|
188
197
|
if (!namespace) {
|
|
@@ -200,7 +209,8 @@ class DirAskGPTV2 {
|
|
|
200
209
|
gptkey: key,
|
|
201
210
|
namespace: namespace,
|
|
202
211
|
model: model,
|
|
203
|
-
citations: citations
|
|
212
|
+
citations: citations,
|
|
213
|
+
engine: engine
|
|
204
214
|
};
|
|
205
215
|
if (top_k) {
|
|
206
216
|
json.top_k = top_k;
|
|
@@ -575,9 +585,8 @@ class DirAskGPTV2 {
|
|
|
575
585
|
return objectTranscript;
|
|
576
586
|
}
|
|
577
587
|
|
|
578
|
-
async
|
|
588
|
+
async getNamespace(server_base_url, name, id) {
|
|
579
589
|
return new Promise((resolve) => {
|
|
580
|
-
|
|
581
590
|
const HTTPREQUEST = {
|
|
582
591
|
url: server_base_url + "/" + this.context.projectId + "/kb/namespace/all",
|
|
583
592
|
headers: {
|
|
@@ -587,7 +596,6 @@ class DirAskGPTV2 {
|
|
|
587
596
|
method: "GET"
|
|
588
597
|
}
|
|
589
598
|
if (this.log) { console.log("DirAskGPT get all namespaces HTTPREQUEST", HTTPREQUEST); }
|
|
590
|
-
|
|
591
599
|
this.#myrequest(
|
|
592
600
|
HTTPREQUEST, async (err, namespaces) => {
|
|
593
601
|
if (err) {
|
|
@@ -595,18 +603,65 @@ class DirAskGPTV2 {
|
|
|
595
603
|
resolve(null)
|
|
596
604
|
} else {
|
|
597
605
|
if (this.log) { console.log("(httprequest) DirAskGPT get all namespaces resbody: ", namespaces); }
|
|
606
|
+
if (name) {
|
|
607
|
+
let namespace = namespaces.find(n => n.name === name);
|
|
608
|
+
resolve(namespace);
|
|
609
|
+
} else {
|
|
610
|
+
let namespace = namespaces.find(n => n.id === id);
|
|
611
|
+
resolve(namespace);
|
|
612
|
+
}
|
|
598
613
|
|
|
599
|
-
let namespace = namespaces.find(n => n.name === name);
|
|
600
|
-
let namespace_id = namespace.id;
|
|
601
|
-
|
|
602
|
-
resolve(namespace_id);
|
|
603
614
|
}
|
|
604
615
|
}
|
|
605
616
|
)
|
|
606
617
|
})
|
|
618
|
+
}
|
|
607
619
|
|
|
620
|
+
async setDefaultEngine() {
|
|
621
|
+
return new Promise((resolve) => {
|
|
622
|
+
let engine = {
|
|
623
|
+
name: "pinecone",
|
|
624
|
+
type: "pod",
|
|
625
|
+
apikey: "",
|
|
626
|
+
vector_size: 1536,
|
|
627
|
+
index_name: "pugliai-tiledesk"
|
|
628
|
+
}
|
|
629
|
+
resolve(engine);
|
|
630
|
+
})
|
|
608
631
|
}
|
|
609
632
|
|
|
633
|
+
// async getNamespaceIdFromName(server_base_url, name) {
|
|
634
|
+
// return new Promise((resolve) => {
|
|
635
|
+
|
|
636
|
+
// const HTTPREQUEST = {
|
|
637
|
+
// url: server_base_url + "/" + this.context.projectId + "/kb/namespace/all",
|
|
638
|
+
// headers: {
|
|
639
|
+
// 'Content-Type': 'application/json',
|
|
640
|
+
// 'Authorization': 'JWT ' + this.context.token
|
|
641
|
+
// },
|
|
642
|
+
// method: "GET"
|
|
643
|
+
// }
|
|
644
|
+
// if (this.log) { console.log("DirAskGPT get all namespaces HTTPREQUEST", HTTPREQUEST); }
|
|
645
|
+
|
|
646
|
+
// this.#myrequest(
|
|
647
|
+
// HTTPREQUEST, async (err, namespaces) => {
|
|
648
|
+
// if (err) {
|
|
649
|
+
// console.error("(httprequest) DirAskGPT get all namespaces err: ", err);
|
|
650
|
+
// resolve(null)
|
|
651
|
+
// } else {
|
|
652
|
+
// if (this.log) { console.log("(httprequest) DirAskGPT get all namespaces resbody: ", namespaces); }
|
|
653
|
+
|
|
654
|
+
// let namespace = namespaces.find(n => n.name === name);
|
|
655
|
+
// let namespace_id = namespace.id;
|
|
656
|
+
|
|
657
|
+
// resolve(namespace_id);
|
|
658
|
+
// }
|
|
659
|
+
// }
|
|
660
|
+
// )
|
|
661
|
+
// })
|
|
662
|
+
|
|
663
|
+
// }
|
|
664
|
+
|
|
610
665
|
|
|
611
666
|
}
|
|
612
667
|
|