@docbrasil/api-systemmanager 1.1.29 → 1.1.31
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/api/ai.js +97 -0
- package/api/user/application.js +36 -0
- package/api/user/notification.js +38 -7
- package/dist/bundle.cjs +167 -7
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +94 -1
- package/docs/Admin.html +1 -1
- package/docs/AdminDocuments.html +1 -1
- package/docs/AdminForm.html +1 -1
- package/docs/AdminLists.html +1 -1
- package/docs/AdminMessage.html +1 -1
- package/docs/AdminNotification.html +1 -1
- package/docs/AdminPlugin.html +1 -1
- package/docs/AdminPolicy.html +1 -1
- package/docs/AdminProcesses.html +1 -1
- package/docs/AdminTask.html +1 -1
- package/docs/AdminUser.html +1 -1
- package/docs/Application.html +247 -1
- package/docs/Chart.html +1 -1
- package/docs/Dashboard.html +1 -1
- package/docs/Datasource.html +1 -1
- package/docs/Dispatch.html +3 -3
- package/docs/Documents.html +1 -1
- package/docs/External.html +1 -1
- package/docs/GeoLocation.html +1 -1
- package/docs/Help.html +1 -1
- package/docs/Login.html +1 -1
- package/docs/MyTasks.html +1 -1
- package/docs/MyndAI.html +650 -0
- package/docs/Notification.html +195 -3
- package/docs/Organization.html +1 -1
- package/docs/Page.html +1 -1
- package/docs/Process.html +1 -1
- package/docs/Register.html +1 -1
- package/docs/Session.html +1 -1
- package/docs/Settings.html +1 -1
- package/docs/Task.html +1 -1
- package/docs/TaskAvailable.html +1 -1
- package/docs/Updates.html +1 -1
- package/docs/User.html +1 -1
- package/docs/Users.html +1 -1
- package/docs/admin_doctypes.js.html +1 -1
- package/docs/admin_document.js.html +1 -1
- package/docs/admin_form.js.html +1 -1
- package/docs/admin_index.js.html +1 -1
- package/docs/admin_list.js.html +1 -1
- package/docs/admin_message.js.html +1 -1
- package/docs/admin_notification.js.html +1 -1
- package/docs/admin_organization.js.html +1 -1
- package/docs/admin_plugin.js.html +1 -1
- package/docs/admin_policy.js.html +1 -1
- package/docs/admin_processes.js.html +1 -1
- package/docs/admin_task.js.html +1 -1
- package/docs/admin_user.js.html +1 -1
- package/docs/ai.js.html +214 -0
- package/docs/dispatch.js.html +7 -2
- package/docs/external.js.html +1 -1
- package/docs/general_geoLocation.js.html +1 -1
- package/docs/general_index.js.html +1 -1
- package/docs/index.html +1 -1
- package/docs/login.js.html +1 -1
- package/docs/session.js.html +1 -1
- package/docs/user_application.js.html +37 -1
- package/docs/user_dashboard.js.html +1 -1
- package/docs/user_datasource.js.html +1 -1
- package/docs/user_document.js.html +1 -1
- package/docs/user_help.js.html +1 -1
- package/docs/user_index.js.html +1 -1
- package/docs/user_my_tasks.js.html +1 -1
- package/docs/user_notification.js.html +39 -8
- package/docs/user_organization.js.html +1 -1
- package/docs/user_page.js.html +1 -1
- package/docs/user_process.js.html +1 -1
- package/docs/user_register.js.html +1 -1
- package/docs/user_settings.js.html +1 -1
- package/docs/user_task.js.html +1 -1
- package/docs/user_task_available.js.html +1 -1
- package/docs/user_updates.js.html +1 -1
- package/docs/user_user.js.html +1 -1
- package/docs/utils_promises.js.html +1 -1
- package/index.js +2 -0
- package/package.json +1 -1
package/api/ai.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import Boom from '@hapi/boom';
|
|
3
|
+
import Joi from 'joi';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Class using AI
|
|
7
|
+
* @class
|
|
8
|
+
*/
|
|
9
|
+
class MyndAI {
|
|
10
|
+
|
|
11
|
+
constructor(options) {
|
|
12
|
+
Joi.assert(options, Joi.object().required());
|
|
13
|
+
Joi.assert(options.parent, Joi.object().required());
|
|
14
|
+
|
|
15
|
+
const self = this;
|
|
16
|
+
self.parent = options.parent;
|
|
17
|
+
self._client = self.parent.dispatch.getClient();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
22
|
+
* @description Get the return data and check for errors
|
|
23
|
+
* @param {object} retData Response HTTP
|
|
24
|
+
* @return {*}
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
_returnData(retData, def = {}) {
|
|
28
|
+
if (retData.status !== 200) {
|
|
29
|
+
throw Boom.badRequest(_.get(retData, 'message', 'No error message reported!'))
|
|
30
|
+
} else {
|
|
31
|
+
return _.get(retData, 'data', def);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
37
|
+
* @description Set header with new session
|
|
38
|
+
* @param {string} session Session, token JWT
|
|
39
|
+
* @return {object} header with new session
|
|
40
|
+
* @private
|
|
41
|
+
*/
|
|
42
|
+
_setHeader(authorization) {
|
|
43
|
+
return {
|
|
44
|
+
headers: {
|
|
45
|
+
authorization,
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
52
|
+
* @description Create new document
|
|
53
|
+
* @param {object} params Object for add new document
|
|
54
|
+
* @param {string} params.model The model to use for the explain
|
|
55
|
+
* @param {object} params.context The context to apply to a prompt
|
|
56
|
+
* @param {string} params.text The text to add to the prompt
|
|
57
|
+
* @param {array<base64>} params.medias Medias to add to the case in base64 (PDF, Image, Video, Audio)
|
|
58
|
+
* @param {string} params.propmpt The actual prompt with context and text to apply to
|
|
59
|
+
* @return {Promise<object>} data
|
|
60
|
+
* @return {boolean} data.success true|false for success
|
|
61
|
+
* @return {object} data.result the result of the AI call
|
|
62
|
+
* @return {string} data.result.response The actual text response according the prompt
|
|
63
|
+
* @return {number} data.result.tokens The quantity of token used in this request
|
|
64
|
+
* @public
|
|
65
|
+
* @async
|
|
66
|
+
* @example
|
|
67
|
+
*
|
|
68
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
69
|
+
* const api = new API();
|
|
70
|
+
* const authorization = '...';
|
|
71
|
+
* const params = {
|
|
72
|
+
* model: 'model-name',
|
|
73
|
+
* context: { name: 'Some name' },
|
|
74
|
+
* text: 'Say hello to the world',
|
|
75
|
+
* medias: ['...'],
|
|
76
|
+
* prompt: 'Write a story about {{name}} with the following theme: {{text}}',
|
|
77
|
+
* };
|
|
78
|
+
* const retData = await api.ai.explain(params, authorization);
|
|
79
|
+
*/
|
|
80
|
+
async explain(params, authorization) {
|
|
81
|
+
const self = this;
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
Joi.assert(params, Joi.object().required().error(new Error('params is required')));
|
|
85
|
+
Joi.assert(params.propmpt, Joi.string().required().error(new Error('Provide a prompt')));
|
|
86
|
+
|
|
87
|
+
const apiCall = self._client
|
|
88
|
+
.post('/agents/explain', params, self._setHeader(authorization));
|
|
89
|
+
|
|
90
|
+
return self._returnData(await apiCall);
|
|
91
|
+
} catch (ex) {
|
|
92
|
+
throw ex;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export default MyndAI;
|
package/api/user/application.js
CHANGED
|
@@ -84,6 +84,42 @@ class Application {
|
|
|
84
84
|
throw ex;
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
90
|
+
* @description Changes the application for a user in an organization
|
|
91
|
+
* @param {object} params Params to get task
|
|
92
|
+
* @param {object} params.applicationId The application id to change to
|
|
93
|
+
* @param {string} session Session, token JWT
|
|
94
|
+
* @returns {promise}
|
|
95
|
+
* @public
|
|
96
|
+
* @example
|
|
97
|
+
*
|
|
98
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
99
|
+
* const api = new API();
|
|
100
|
+
* const params = {
|
|
101
|
+
* applicationId: '55e4a3bd6be6b45210833fae',
|
|
102
|
+
* };
|
|
103
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
104
|
+
* await api.user.application.changeApplication(params, session);
|
|
105
|
+
*/
|
|
106
|
+
async changeApplication(params, session) {
|
|
107
|
+
const self = this;
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
Joi.assert(params, Joi.object().required(), 'Params to get task');
|
|
111
|
+
Joi.assert(params.applicationId, Joi.string().required(), 'The application id');
|
|
112
|
+
Joi.assert(session, Joi.string().required(), 'Session token JWT');
|
|
113
|
+
|
|
114
|
+
const { orgId} = params;
|
|
115
|
+
const apiCall = self._client
|
|
116
|
+
.put('/organizations/applications/change', { applicationId: params.applicationId }, self._setHeader(session));
|
|
117
|
+
|
|
118
|
+
return self._returnData(await apiCall);
|
|
119
|
+
} catch (ex) {
|
|
120
|
+
throw ex;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
87
123
|
}
|
|
88
124
|
|
|
89
125
|
export default Application;
|
package/api/user/notification.js
CHANGED
|
@@ -151,7 +151,7 @@ class Notification {
|
|
|
151
151
|
|
|
152
152
|
/**
|
|
153
153
|
* @author Myndware <augusto.pissarra@myndware.com>
|
|
154
|
-
* @description Set notification as
|
|
154
|
+
* @description Set notification as read
|
|
155
155
|
* @param {object} params Params to update the notification
|
|
156
156
|
* @param {string} params.id Notification Id
|
|
157
157
|
* @param {string} session JWT Token
|
|
@@ -170,14 +170,14 @@ class Notification {
|
|
|
170
170
|
*/
|
|
171
171
|
async setRead(params = {}, session) {
|
|
172
172
|
const self = this;
|
|
173
|
-
|
|
173
|
+
|
|
174
174
|
try {
|
|
175
175
|
Joi.assert(params, Joi.object().required());
|
|
176
176
|
Joi.assert(params.id, Joi.string().required());
|
|
177
177
|
Joi.assert(session, Joi.string().required());
|
|
178
|
-
|
|
178
|
+
|
|
179
179
|
const {id} = params;
|
|
180
|
-
|
|
180
|
+
|
|
181
181
|
const apiCall = self._client.put(`/organizations/notifications/${id}/read`, {}, self._setHeader(session));
|
|
182
182
|
return self._returnData(await apiCall);
|
|
183
183
|
} catch (ex) {
|
|
@@ -185,6 +185,37 @@ class Notification {
|
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
+
/**
|
|
189
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
190
|
+
* @description Set all notification of the logged user as read
|
|
191
|
+
* @param {string} session JWT Token
|
|
192
|
+
* @return {Promise}
|
|
193
|
+
* @public
|
|
194
|
+
* @async
|
|
195
|
+
* @example
|
|
196
|
+
*
|
|
197
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
198
|
+
* const api = new API();
|
|
199
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
200
|
+
* await api.user.notification.setReadAll(session);
|
|
201
|
+
*/
|
|
202
|
+
async setReadAll(session) {
|
|
203
|
+
const self = this;
|
|
204
|
+
|
|
205
|
+
try {
|
|
206
|
+
Joi.assert(params, Joi.object().required());
|
|
207
|
+
Joi.assert(params.id, Joi.string().required());
|
|
208
|
+
Joi.assert(session, Joi.string().required());
|
|
209
|
+
|
|
210
|
+
const {id} = params;
|
|
211
|
+
|
|
212
|
+
const apiCall = self._client.put(`/organizations/notifications/read/all`, {}, self._setHeader(session));
|
|
213
|
+
return self._returnData(await apiCall);
|
|
214
|
+
} catch (ex) {
|
|
215
|
+
throw ex;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
188
219
|
/**
|
|
189
220
|
* @author Myndware <augusto.pissarra@myndware.com>
|
|
190
221
|
* @description Set notification as unreaded
|
|
@@ -206,14 +237,14 @@ class Notification {
|
|
|
206
237
|
*/
|
|
207
238
|
async setUnread(params = {}, session) {
|
|
208
239
|
const self = this;
|
|
209
|
-
|
|
240
|
+
|
|
210
241
|
try {
|
|
211
242
|
Joi.assert(params, Joi.object().required());
|
|
212
243
|
Joi.assert(params.id, Joi.string().required());
|
|
213
244
|
Joi.assert(session, Joi.string().required());
|
|
214
|
-
|
|
245
|
+
|
|
215
246
|
const {id} = params;
|
|
216
|
-
|
|
247
|
+
|
|
217
248
|
const apiCall = self._client.put(`/organizations/notifications/${id}/unread`, {}, self._setHeader(session));
|
|
218
249
|
return self._returnData(await apiCall);
|
|
219
250
|
} catch (ex) {
|
package/dist/bundle.cjs
CHANGED
|
@@ -10473,7 +10473,7 @@ class Notification {
|
|
|
10473
10473
|
|
|
10474
10474
|
/**
|
|
10475
10475
|
* @author Myndware <augusto.pissarra@myndware.com>
|
|
10476
|
-
* @description Set notification as
|
|
10476
|
+
* @description Set notification as read
|
|
10477
10477
|
* @param {object} params Params to update the notification
|
|
10478
10478
|
* @param {string} params.id Notification Id
|
|
10479
10479
|
* @param {string} session JWT Token
|
|
@@ -10492,14 +10492,14 @@ class Notification {
|
|
|
10492
10492
|
*/
|
|
10493
10493
|
async setRead(params = {}, session) {
|
|
10494
10494
|
const self = this;
|
|
10495
|
-
|
|
10495
|
+
|
|
10496
10496
|
try {
|
|
10497
10497
|
Joi__default["default"].assert(params, Joi__default["default"].object().required());
|
|
10498
10498
|
Joi__default["default"].assert(params.id, Joi__default["default"].string().required());
|
|
10499
10499
|
Joi__default["default"].assert(session, Joi__default["default"].string().required());
|
|
10500
|
-
|
|
10500
|
+
|
|
10501
10501
|
const {id} = params;
|
|
10502
|
-
|
|
10502
|
+
|
|
10503
10503
|
const apiCall = self._client.put(`/organizations/notifications/${id}/read`, {}, self._setHeader(session));
|
|
10504
10504
|
return self._returnData(await apiCall);
|
|
10505
10505
|
} catch (ex) {
|
|
@@ -10507,6 +10507,37 @@ class Notification {
|
|
|
10507
10507
|
}
|
|
10508
10508
|
}
|
|
10509
10509
|
|
|
10510
|
+
/**
|
|
10511
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
10512
|
+
* @description Set all notification of the logged user as read
|
|
10513
|
+
* @param {string} session JWT Token
|
|
10514
|
+
* @return {Promise}
|
|
10515
|
+
* @public
|
|
10516
|
+
* @async
|
|
10517
|
+
* @example
|
|
10518
|
+
*
|
|
10519
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
10520
|
+
* const api = new API();
|
|
10521
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
10522
|
+
* await api.user.notification.setReadAll(session);
|
|
10523
|
+
*/
|
|
10524
|
+
async setReadAll(session) {
|
|
10525
|
+
const self = this;
|
|
10526
|
+
|
|
10527
|
+
try {
|
|
10528
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required());
|
|
10529
|
+
Joi__default["default"].assert(params.id, Joi__default["default"].string().required());
|
|
10530
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required());
|
|
10531
|
+
|
|
10532
|
+
const {id} = params;
|
|
10533
|
+
|
|
10534
|
+
const apiCall = self._client.put(`/organizations/notifications/read/all`, {}, self._setHeader(session));
|
|
10535
|
+
return self._returnData(await apiCall);
|
|
10536
|
+
} catch (ex) {
|
|
10537
|
+
throw ex;
|
|
10538
|
+
}
|
|
10539
|
+
}
|
|
10540
|
+
|
|
10510
10541
|
/**
|
|
10511
10542
|
* @author Myndware <augusto.pissarra@myndware.com>
|
|
10512
10543
|
* @description Set notification as unreaded
|
|
@@ -10528,14 +10559,14 @@ class Notification {
|
|
|
10528
10559
|
*/
|
|
10529
10560
|
async setUnread(params = {}, session) {
|
|
10530
10561
|
const self = this;
|
|
10531
|
-
|
|
10562
|
+
|
|
10532
10563
|
try {
|
|
10533
10564
|
Joi__default["default"].assert(params, Joi__default["default"].object().required());
|
|
10534
10565
|
Joi__default["default"].assert(params.id, Joi__default["default"].string().required());
|
|
10535
10566
|
Joi__default["default"].assert(session, Joi__default["default"].string().required());
|
|
10536
|
-
|
|
10567
|
+
|
|
10537
10568
|
const {id} = params;
|
|
10538
|
-
|
|
10569
|
+
|
|
10539
10570
|
const apiCall = self._client.put(`/organizations/notifications/${id}/unread`, {}, self._setHeader(session));
|
|
10540
10571
|
return self._returnData(await apiCall);
|
|
10541
10572
|
} catch (ex) {
|
|
@@ -11038,6 +11069,42 @@ class Application {
|
|
|
11038
11069
|
throw ex;
|
|
11039
11070
|
}
|
|
11040
11071
|
}
|
|
11072
|
+
|
|
11073
|
+
/**
|
|
11074
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
11075
|
+
* @description Changes the application for a user in an organization
|
|
11076
|
+
* @param {object} params Params to get task
|
|
11077
|
+
* @param {object} params.applicationId The application id to change to
|
|
11078
|
+
* @param {string} session Session, token JWT
|
|
11079
|
+
* @returns {promise}
|
|
11080
|
+
* @public
|
|
11081
|
+
* @example
|
|
11082
|
+
*
|
|
11083
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
11084
|
+
* const api = new API();
|
|
11085
|
+
* const params = {
|
|
11086
|
+
* applicationId: '55e4a3bd6be6b45210833fae',
|
|
11087
|
+
* };
|
|
11088
|
+
* const session = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
|
|
11089
|
+
* await api.user.application.changeApplication(params, session);
|
|
11090
|
+
*/
|
|
11091
|
+
async changeApplication(params, session) {
|
|
11092
|
+
const self = this;
|
|
11093
|
+
|
|
11094
|
+
try {
|
|
11095
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required(), 'Params to get task');
|
|
11096
|
+
Joi__default["default"].assert(params.applicationId, Joi__default["default"].string().required(), 'The application id');
|
|
11097
|
+
Joi__default["default"].assert(session, Joi__default["default"].string().required(), 'Session token JWT');
|
|
11098
|
+
|
|
11099
|
+
const { orgId} = params;
|
|
11100
|
+
const apiCall = self._client
|
|
11101
|
+
.put('/organizations/applications/change', { applicationId: params.applicationId }, self._setHeader(session));
|
|
11102
|
+
|
|
11103
|
+
return self._returnData(await apiCall);
|
|
11104
|
+
} catch (ex) {
|
|
11105
|
+
throw ex;
|
|
11106
|
+
}
|
|
11107
|
+
}
|
|
11041
11108
|
}
|
|
11042
11109
|
|
|
11043
11110
|
/**
|
|
@@ -13862,6 +13929,98 @@ class External {
|
|
|
13862
13929
|
|
|
13863
13930
|
}
|
|
13864
13931
|
|
|
13932
|
+
/**
|
|
13933
|
+
* Class using AI
|
|
13934
|
+
* @class
|
|
13935
|
+
*/
|
|
13936
|
+
class MyndAI {
|
|
13937
|
+
|
|
13938
|
+
constructor(options) {
|
|
13939
|
+
Joi__default["default"].assert(options, Joi__default["default"].object().required());
|
|
13940
|
+
Joi__default["default"].assert(options.parent, Joi__default["default"].object().required());
|
|
13941
|
+
|
|
13942
|
+
const self = this;
|
|
13943
|
+
self.parent = options.parent;
|
|
13944
|
+
self._client = self.parent.dispatch.getClient();
|
|
13945
|
+
}
|
|
13946
|
+
|
|
13947
|
+
/**
|
|
13948
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
13949
|
+
* @description Get the return data and check for errors
|
|
13950
|
+
* @param {object} retData Response HTTP
|
|
13951
|
+
* @return {*}
|
|
13952
|
+
* @private
|
|
13953
|
+
*/
|
|
13954
|
+
_returnData(retData, def = {}) {
|
|
13955
|
+
if (retData.status !== 200) {
|
|
13956
|
+
throw Boom__default["default"].badRequest(___default["default"].get(retData, 'message', 'No error message reported!'))
|
|
13957
|
+
} else {
|
|
13958
|
+
return ___default["default"].get(retData, 'data', def);
|
|
13959
|
+
}
|
|
13960
|
+
}
|
|
13961
|
+
|
|
13962
|
+
/**
|
|
13963
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
13964
|
+
* @description Set header with new session
|
|
13965
|
+
* @param {string} session Session, token JWT
|
|
13966
|
+
* @return {object} header with new session
|
|
13967
|
+
* @private
|
|
13968
|
+
*/
|
|
13969
|
+
_setHeader(authorization) {
|
|
13970
|
+
return {
|
|
13971
|
+
headers: {
|
|
13972
|
+
authorization,
|
|
13973
|
+
}
|
|
13974
|
+
};
|
|
13975
|
+
}
|
|
13976
|
+
|
|
13977
|
+
/**
|
|
13978
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
13979
|
+
* @description Create new document
|
|
13980
|
+
* @param {object} params Object for add new document
|
|
13981
|
+
* @param {string} params.model The model to use for the explain
|
|
13982
|
+
* @param {object} params.context The context to apply to a prompt
|
|
13983
|
+
* @param {string} params.text The text to add to the prompt
|
|
13984
|
+
* @param {array<base64>} params.medias Medias to add to the case in base64 (PDF, Image, Video, Audio)
|
|
13985
|
+
* @param {string} params.propmpt The actual prompt with context and text to apply to
|
|
13986
|
+
* @return {Promise<object>} data
|
|
13987
|
+
* @return {boolean} data.success true|false for success
|
|
13988
|
+
* @return {object} data.result the result of the AI call
|
|
13989
|
+
* @return {string} data.result.response The actual text response according the prompt
|
|
13990
|
+
* @return {number} data.result.tokens The quantity of token used in this request
|
|
13991
|
+
* @public
|
|
13992
|
+
* @async
|
|
13993
|
+
* @example
|
|
13994
|
+
*
|
|
13995
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
13996
|
+
* const api = new API();
|
|
13997
|
+
* const authorization = '...';
|
|
13998
|
+
* const params = {
|
|
13999
|
+
* model: 'model-name',
|
|
14000
|
+
* context: { name: 'Some name' },
|
|
14001
|
+
* text: 'Say hello to the world',
|
|
14002
|
+
* medias: ['...'],
|
|
14003
|
+
* prompt: 'Write a story about {{name}} with the following theme: {{text}}',
|
|
14004
|
+
* };
|
|
14005
|
+
* const retData = await api.ai.explain(params, authorization);
|
|
14006
|
+
*/
|
|
14007
|
+
async explain(params, authorization) {
|
|
14008
|
+
const self = this;
|
|
14009
|
+
|
|
14010
|
+
try {
|
|
14011
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required().error(new Error('params is required')));
|
|
14012
|
+
Joi__default["default"].assert(params.propmpt, Joi__default["default"].string().required().error(new Error('Provide a prompt')));
|
|
14013
|
+
|
|
14014
|
+
const apiCall = self._client
|
|
14015
|
+
.post('/agents/explain', params, self._setHeader(authorization));
|
|
14016
|
+
|
|
14017
|
+
return self._returnData(await apiCall);
|
|
14018
|
+
} catch (ex) {
|
|
14019
|
+
throw ex;
|
|
14020
|
+
}
|
|
14021
|
+
}
|
|
14022
|
+
}
|
|
14023
|
+
|
|
13865
14024
|
/**
|
|
13866
14025
|
* Class API
|
|
13867
14026
|
*/
|
|
@@ -13933,6 +14092,7 @@ class API {
|
|
|
13933
14092
|
self.user = new Users({parent: self});
|
|
13934
14093
|
self.admin = new Admin({parent: self});
|
|
13935
14094
|
self.external = new External({parent: self});
|
|
14095
|
+
self.ai = new MyndAI({parent: self});
|
|
13936
14096
|
}
|
|
13937
14097
|
}
|
|
13938
14098
|
|