@tiledesk/tiledesk-tybot-connector 0.2.149-rc3 → 0.2.150

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,11 @@ available on:
17
17
  - Added flowError on JSONCondition when result = null
18
18
  - Added fix on Filler -->
19
19
 
20
+ # v0.2.150
21
+ - changed: AiPrompt action to improves errors management
22
+
23
+ # v0.2.149
24
+
20
25
  # v0.2.149-rc3
21
26
  - changed: context for gpt-40 and gpt-40-mini
22
27
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-tybot-connector",
3
- "version": "0.2.149-rc3",
3
+ "version": "0.2.150",
4
4
  "description": "Tiledesk Tybot connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -117,10 +117,12 @@ class DirAiPrompt {
117
117
  model: action.model,
118
118
  llm_key: key,
119
119
  temperature: action.temperature,
120
- max_tokens: action.max_tokens,
121
- system_context: filled_context,
120
+ max_tokens: action.max_tokens
122
121
  }
123
122
 
123
+ if (action.context) {
124
+ json.system_context = filled_context;
125
+ }
124
126
  if (transcript) {
125
127
  json.chat_history_dict = await this.transcriptToLLM(transcript);
126
128
  }
@@ -141,12 +143,19 @@ class DirAiPrompt {
141
143
  HTTPREQUEST, async (err, resbody) => {
142
144
  if (err) {
143
145
  if (this.log) {
144
- console.error("(httprequest) DirAiPrompt openai err:", err);
145
- console.error("(httprequest) DirAiPrompt openai err:", err.detail[0]?.msg);
146
+ console.error("(httprequest) DirAiPrompt openai err:", err.response.data);
146
147
  }
147
148
  await this.#assignAttributes(action, answer);
149
+ let error;
150
+ if (err.response?.data?.detail[0]) {
151
+ error = err.response.data.detail[0]?.msg;
152
+ } else if (err.response?.data?.detail?.answer) {
153
+ error = err.response.data.detail.answer;
154
+ } else {
155
+ error = JSON.stringify(err.response.data);
156
+ }
148
157
  if (falseIntent) {
149
- await this.chatbot.addParameter("flowError", "AiPrompt Error: " + err.response.data.detail[0]?.msg);
158
+ await this.chatbot.addParameter("flowError", "AiPrompt Error: " + error);
150
159
  await this.#executeCondition(false, trueIntent, trueIntentAttributes, falseIntent, falseIntentAttributes);
151
160
  callback(true);
152
161
  return;