@tiledesk/tiledesk-tybot-connector 0.2.149 → 0.2.151

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.151
21
+ - bug-fixed: context for gpt-40 and gpt-40-mini
22
+
23
+ # v0.2.150
24
+ - changed: AiPrompt action to improves errors management
25
+
20
26
  # v0.2.149
21
27
 
22
28
  # v0.2.149-rc3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-tybot-connector",
3
- "version": "0.2.149",
3
+ "version": "0.2.151",
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;
@@ -76,8 +76,8 @@ class DirAskGPTV2 {
76
76
  "gpt-3.5-turbo": "You are an helpful assistant for question-answering tasks.\nUse ONLY the pieces of retrieved context delimited by #### to answer the question.\nIf you don't know the answer, just say: \"I don't know<NOANS>\"\n\n####{context}####",
77
77
  "gpt-4": "You are an helpful assistant for question-answering tasks.\nUse ONLY the pieces of retrieved context delimited by #### to answer the question.\nIf you don't know the answer, just say that you don't know.\nIf and only if none of the retrieved context is useful for your task, add this word to the end <NOANS>\n\n####{context}####",
78
78
  "gpt-4-turbo-preview": "You are an helpful assistant for question-answering tasks.\nUse ONLY the pieces of retrieved context delimited by #### to answer the question.\nIf you don't know the answer, just say that you don't know.\nIf and only if none of the retrieved context is useful for your task, add this word to the end <NOANS>\n\n####{context}####",
79
- "gpt-4o": "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n 1. Answer in the same language of the user question, regardless of the retrieved context language\n 2. Use ONLY the pieces of the retrieved context to answer the question.\n 3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, return <NOANS>\n ==Retrieved context start==\n {{context}}\n ==Retrieved context end==",
80
- "gpt-4o-mini": "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n 1. Answer in the same language of the user question, regardless of the retrieved context language\n 2. Use ONLY the pieces of the retrieved context to answer the question.\n 3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, return <NOANS>\n ==Retrieved context start==\n {{context}}\n ==Retrieved context end=="
79
+ "gpt-4o": "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, return <NOANS>\n\n==Retrieved context start==\n{context}\n==Retrieved context end==",
80
+ "gpt-4o-mini": "You are an helpful assistant for question-answering tasks. Follow these steps carefully:\n1. Answer in the same language of the user question, regardless of the retrieved context language\n2. Use ONLY the pieces of the retrieved context to answer the question.\n3. If the retrieved context does not contain sufficient information to generate an accurate and informative answer, return <NOANS>\n\n==Retrieved context start==\n{context}\n==Retrieved context end=="
81
81
  }
82
82
 
83
83
  let source = null;