@docbrasil/api-systemmanager 1.1.80 → 1.1.82
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 → ai/index.js} +3 -0
- package/api/ai/sessions.js +243 -0
- package/dist/bundle.cjs +240 -0
- package/dist/bundle.mjs +1 -1
- package/doc/api.md +202 -47
- package/docs/AISession.html +2100 -0
- 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 +1 -1
- package/docs/Chart.html +1 -1
- package/docs/Dashboard.html +1 -1
- package/docs/Datasource.html +1 -1
- package/docs/Dispatch.html +1 -1
- 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/Kanban.html +1 -1
- package/docs/Login.html +1 -1
- package/docs/MyTasks.html +1 -1
- package/docs/MyndAI.html +5 -5
- package/docs/Notification.html +1 -1
- 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/Report.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 → ai_index.js.html} +6 -3
- package/docs/ai_sessions.js.html +360 -0
- package/docs/dispatch.js.html +1 -1
- 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 +1 -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_kanban.js.html +1 -1
- package/docs/user_my_tasks.js.html +1 -1
- package/docs/user_notification.js.html +1 -1
- 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 +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import Boom from '@hapi/boom';
|
|
3
3
|
import Joi from 'joi';
|
|
4
|
+
import AISession from './sessions.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Class using AI
|
|
@@ -15,6 +16,8 @@ class MyndAI {
|
|
|
15
16
|
const self = this;
|
|
16
17
|
self.parent = options.parent;
|
|
17
18
|
self._client = self.parent.dispatch.getClient();
|
|
19
|
+
|
|
20
|
+
self.sessions = new AISession(options);
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
/**
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import Boom from '@hapi/boom';
|
|
3
|
+
import Joi from 'joi';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Class for AI Session management
|
|
7
|
+
* @class
|
|
8
|
+
*/
|
|
9
|
+
class AISession {
|
|
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: authorization,
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
52
|
+
* @description Get full session data by document ID.
|
|
53
|
+
* Returns session, execution, activities, pages, triples and summary.
|
|
54
|
+
* @param {object} params Parameters
|
|
55
|
+
* @param {string} params.documentId The document ID to look up the session for
|
|
56
|
+
* @param {string} authorization Authorization token
|
|
57
|
+
* @return {Promise<object>} data The full session data
|
|
58
|
+
* @return {object} data.session The session object
|
|
59
|
+
* @return {object} data.execution The latest execution or null
|
|
60
|
+
* @return {array<object>} data.activities Activity log entries
|
|
61
|
+
* @return {array<object>} data.pages Extracted page objects
|
|
62
|
+
* @return {array<object>} data.triples Ontology triple objects
|
|
63
|
+
* @return {object} data.summary Document summary or null
|
|
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 = { documentId: 'doc-123' };
|
|
72
|
+
* const retData = await api.ai.sessions.getByDocument(params, authorization);
|
|
73
|
+
*/
|
|
74
|
+
async getByDocument(params, authorization) {
|
|
75
|
+
const self = this;
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
Joi.assert(params, Joi.object().required().error(new Error('params is required')));
|
|
79
|
+
Joi.assert(params.documentId, Joi.string().required().error(new Error('documentId is required')));
|
|
80
|
+
|
|
81
|
+
const apiCall = self._client
|
|
82
|
+
.get(`/agents/session/document/${params.documentId}`, self._setHeader(authorization));
|
|
83
|
+
|
|
84
|
+
return self._returnData(await apiCall);
|
|
85
|
+
} catch (ex) {
|
|
86
|
+
throw ex;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
92
|
+
* @description Update session document data (pages, triples, summary).
|
|
93
|
+
* Used by Scarface to push corrections or enrichments for a document.
|
|
94
|
+
* @param {object} params Parameters
|
|
95
|
+
* @param {string} params.documentId The document ID
|
|
96
|
+
* @param {array<object>} [params.pages] Page updates
|
|
97
|
+
* @param {number} params.pages.pageNumber 1-based page number
|
|
98
|
+
* @param {string} [params.pages.markdown] Updated markdown text
|
|
99
|
+
* @param {array<object>} [params.pages.entities] Updated entities
|
|
100
|
+
* @param {array<object>} [params.triples] New triples to add
|
|
101
|
+
* @param {number} params.triples.pageNumber Source page number
|
|
102
|
+
* @param {string} params.triples.subject Subject entity text
|
|
103
|
+
* @param {string} params.triples.predicate Relationship predicate
|
|
104
|
+
* @param {string} params.triples.object Object entity text
|
|
105
|
+
* @param {object} [params.summary] Summary field updates
|
|
106
|
+
* @param {string} [params.summary.documentName] Document name
|
|
107
|
+
* @param {number} [params.summary.entityCount] Total entity count
|
|
108
|
+
* @param {number} [params.summary.tripleCount] Total triple count
|
|
109
|
+
* @param {string} authorization Authorization token
|
|
110
|
+
* @return {Promise<object>} data The update results
|
|
111
|
+
* @return {array<object>} data.pages Page update results [{pageNumber, updated}]
|
|
112
|
+
* @return {object} data.triples Triple insert results {added: number}
|
|
113
|
+
* @return {object} data.summary Applied summary updates
|
|
114
|
+
* @public
|
|
115
|
+
* @async
|
|
116
|
+
* @example
|
|
117
|
+
*
|
|
118
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
119
|
+
* const api = new API();
|
|
120
|
+
* const authorization = '...';
|
|
121
|
+
* const params = {
|
|
122
|
+
* documentId: 'doc-123',
|
|
123
|
+
* pages: [
|
|
124
|
+
* { pageNumber: 1, markdown: '# Updated page content' }
|
|
125
|
+
* ],
|
|
126
|
+
* summary: {
|
|
127
|
+
* documentName: 'Patient Report.pdf',
|
|
128
|
+
* entityCount: 42,
|
|
129
|
+
* tripleCount: 15
|
|
130
|
+
* }
|
|
131
|
+
* };
|
|
132
|
+
* const retData = await api.ai.sessions.updateData(params, authorization);
|
|
133
|
+
*/
|
|
134
|
+
async updateData(params, authorization) {
|
|
135
|
+
const self = this;
|
|
136
|
+
|
|
137
|
+
try {
|
|
138
|
+
Joi.assert(params, Joi.object().required().error(new Error('params is required')));
|
|
139
|
+
Joi.assert(params.documentId, Joi.string().required().error(new Error('documentId is required')));
|
|
140
|
+
|
|
141
|
+
const { documentId, ...payload } = params;
|
|
142
|
+
|
|
143
|
+
const apiCall = self._client
|
|
144
|
+
.patch(`/agents/session/document/${documentId}`, payload, self._setHeader(authorization));
|
|
145
|
+
|
|
146
|
+
return self._returnData(await apiCall);
|
|
147
|
+
} catch (ex) {
|
|
148
|
+
throw ex;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
154
|
+
* @description Create a new agent session.
|
|
155
|
+
* Use this to create a session with full metadata before triggering execution.
|
|
156
|
+
* @param {object} params Parameters
|
|
157
|
+
* @param {string} params.agentType The agent type (e.g., 'doc-rlm-ingest')
|
|
158
|
+
* @param {object} [params.config] Agent configuration options
|
|
159
|
+
* @param {object} [params.metadata] Session metadata (documentId, pipelineVariant, analysisMode, etc.)
|
|
160
|
+
* @param {string} authorization Authorization token
|
|
161
|
+
* @return {Promise<object>} data The created session
|
|
162
|
+
* @return {string} data.sessionId The session ID
|
|
163
|
+
* @return {string} data.status The session status
|
|
164
|
+
* @public
|
|
165
|
+
* @async
|
|
166
|
+
* @example
|
|
167
|
+
*
|
|
168
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
169
|
+
* const api = new API();
|
|
170
|
+
* const authorization = '...';
|
|
171
|
+
* const params = {
|
|
172
|
+
* agentType: 'doc-rlm-ingest',
|
|
173
|
+
* metadata: {
|
|
174
|
+
* documentId: 'doc-123',
|
|
175
|
+
* documentName: 'Patient Report.pdf',
|
|
176
|
+
* pipelineVariant: 'A',
|
|
177
|
+
* analysisMode: 'full'
|
|
178
|
+
* }
|
|
179
|
+
* };
|
|
180
|
+
* const retData = await api.ai.sessions.create(params, authorization);
|
|
181
|
+
*/
|
|
182
|
+
async create(params, authorization) {
|
|
183
|
+
const self = this;
|
|
184
|
+
|
|
185
|
+
try {
|
|
186
|
+
Joi.assert(params, Joi.object().required().error(new Error('params is required')));
|
|
187
|
+
Joi.assert(params.agentType, Joi.string().required().error(new Error('agentType is required')));
|
|
188
|
+
|
|
189
|
+
const apiCall = self._client
|
|
190
|
+
.post('/agents/create', params, self._setHeader(authorization));
|
|
191
|
+
|
|
192
|
+
return self._returnData(await apiCall);
|
|
193
|
+
} catch (ex) {
|
|
194
|
+
throw ex;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
200
|
+
* @description Start execution on an existing agent session.
|
|
201
|
+
* @param {object} params Parameters
|
|
202
|
+
* @param {string} params.sessionId The session ID to execute
|
|
203
|
+
* @param {object} [params.input] Execution input (documentId, options, etc.)
|
|
204
|
+
* @param {string} authorization Authorization token
|
|
205
|
+
* @return {Promise<object>} data The execution data
|
|
206
|
+
* @return {string} data.executionId The execution ID
|
|
207
|
+
* @return {string} data.status The execution status
|
|
208
|
+
* @public
|
|
209
|
+
* @async
|
|
210
|
+
* @example
|
|
211
|
+
*
|
|
212
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
213
|
+
* const api = new API();
|
|
214
|
+
* const authorization = '...';
|
|
215
|
+
* const params = {
|
|
216
|
+
* sessionId: 'session-abc-123',
|
|
217
|
+
* input: {
|
|
218
|
+
* documentId: 'doc-123',
|
|
219
|
+
* options: { pipelineVariant: 'A', analysisMode: 'full' }
|
|
220
|
+
* }
|
|
221
|
+
* };
|
|
222
|
+
* const retData = await api.ai.sessions.execute(params, authorization);
|
|
223
|
+
*/
|
|
224
|
+
async execute(params, authorization) {
|
|
225
|
+
const self = this;
|
|
226
|
+
|
|
227
|
+
try {
|
|
228
|
+
Joi.assert(params, Joi.object().required().error(new Error('params is required')));
|
|
229
|
+
Joi.assert(params.sessionId, Joi.string().required().error(new Error('sessionId is required')));
|
|
230
|
+
|
|
231
|
+
const { sessionId, ...payload } = params;
|
|
232
|
+
|
|
233
|
+
const apiCall = self._client
|
|
234
|
+
.post(`/agents/${sessionId}/execute`, payload, self._setHeader(authorization));
|
|
235
|
+
|
|
236
|
+
return self._returnData(await apiCall);
|
|
237
|
+
} catch (ex) {
|
|
238
|
+
throw ex;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export default AISession;
|
package/dist/bundle.cjs
CHANGED
|
@@ -16117,6 +16117,244 @@ class External {
|
|
|
16117
16117
|
|
|
16118
16118
|
}
|
|
16119
16119
|
|
|
16120
|
+
/**
|
|
16121
|
+
* Class for AI Session management
|
|
16122
|
+
* @class
|
|
16123
|
+
*/
|
|
16124
|
+
class AISession {
|
|
16125
|
+
|
|
16126
|
+
constructor(options) {
|
|
16127
|
+
Joi__default["default"].assert(options, Joi__default["default"].object().required());
|
|
16128
|
+
Joi__default["default"].assert(options.parent, Joi__default["default"].object().required());
|
|
16129
|
+
|
|
16130
|
+
const self = this;
|
|
16131
|
+
self.parent = options.parent;
|
|
16132
|
+
self._client = self.parent.dispatch.getClient();
|
|
16133
|
+
}
|
|
16134
|
+
|
|
16135
|
+
/**
|
|
16136
|
+
* @author Augusto Pissarra <abernardo.br@gmail.com>
|
|
16137
|
+
* @description Get the return data and check for errors
|
|
16138
|
+
* @param {object} retData Response HTTP
|
|
16139
|
+
* @return {*}
|
|
16140
|
+
* @private
|
|
16141
|
+
*/
|
|
16142
|
+
_returnData(retData, def = {}) {
|
|
16143
|
+
if (retData.status !== 200) {
|
|
16144
|
+
throw Boom__default["default"].badRequest(___default["default"].get(retData, 'message', 'No error message reported!'))
|
|
16145
|
+
} else {
|
|
16146
|
+
return ___default["default"].get(retData, 'data', def);
|
|
16147
|
+
}
|
|
16148
|
+
}
|
|
16149
|
+
|
|
16150
|
+
/**
|
|
16151
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
16152
|
+
* @description Set header with new session
|
|
16153
|
+
* @param {string} session Session, token JWT
|
|
16154
|
+
* @return {object} header with new session
|
|
16155
|
+
* @private
|
|
16156
|
+
*/
|
|
16157
|
+
_setHeader(authorization) {
|
|
16158
|
+
return {
|
|
16159
|
+
headers: {
|
|
16160
|
+
Authorization: authorization,
|
|
16161
|
+
}
|
|
16162
|
+
};
|
|
16163
|
+
}
|
|
16164
|
+
|
|
16165
|
+
/**
|
|
16166
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
16167
|
+
* @description Get full session data by document ID.
|
|
16168
|
+
* Returns session, execution, activities, pages, triples and summary.
|
|
16169
|
+
* @param {object} params Parameters
|
|
16170
|
+
* @param {string} params.documentId The document ID to look up the session for
|
|
16171
|
+
* @param {string} authorization Authorization token
|
|
16172
|
+
* @return {Promise<object>} data The full session data
|
|
16173
|
+
* @return {object} data.session The session object
|
|
16174
|
+
* @return {object} data.execution The latest execution or null
|
|
16175
|
+
* @return {array<object>} data.activities Activity log entries
|
|
16176
|
+
* @return {array<object>} data.pages Extracted page objects
|
|
16177
|
+
* @return {array<object>} data.triples Ontology triple objects
|
|
16178
|
+
* @return {object} data.summary Document summary or null
|
|
16179
|
+
* @public
|
|
16180
|
+
* @async
|
|
16181
|
+
* @example
|
|
16182
|
+
*
|
|
16183
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
16184
|
+
* const api = new API();
|
|
16185
|
+
* const authorization = '...';
|
|
16186
|
+
* const params = { documentId: 'doc-123' };
|
|
16187
|
+
* const retData = await api.ai.sessions.getByDocument(params, authorization);
|
|
16188
|
+
*/
|
|
16189
|
+
async getByDocument(params, authorization) {
|
|
16190
|
+
const self = this;
|
|
16191
|
+
|
|
16192
|
+
try {
|
|
16193
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required().error(new Error('params is required')));
|
|
16194
|
+
Joi__default["default"].assert(params.documentId, Joi__default["default"].string().required().error(new Error('documentId is required')));
|
|
16195
|
+
|
|
16196
|
+
const apiCall = self._client
|
|
16197
|
+
.get(`/agents/session/document/${params.documentId}`, self._setHeader(authorization));
|
|
16198
|
+
|
|
16199
|
+
return self._returnData(await apiCall);
|
|
16200
|
+
} catch (ex) {
|
|
16201
|
+
throw ex;
|
|
16202
|
+
}
|
|
16203
|
+
}
|
|
16204
|
+
|
|
16205
|
+
/**
|
|
16206
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
16207
|
+
* @description Update session document data (pages, triples, summary).
|
|
16208
|
+
* Used by Scarface to push corrections or enrichments for a document.
|
|
16209
|
+
* @param {object} params Parameters
|
|
16210
|
+
* @param {string} params.documentId The document ID
|
|
16211
|
+
* @param {array<object>} [params.pages] Page updates
|
|
16212
|
+
* @param {number} params.pages.pageNumber 1-based page number
|
|
16213
|
+
* @param {string} [params.pages.markdown] Updated markdown text
|
|
16214
|
+
* @param {array<object>} [params.pages.entities] Updated entities
|
|
16215
|
+
* @param {array<object>} [params.triples] New triples to add
|
|
16216
|
+
* @param {number} params.triples.pageNumber Source page number
|
|
16217
|
+
* @param {string} params.triples.subject Subject entity text
|
|
16218
|
+
* @param {string} params.triples.predicate Relationship predicate
|
|
16219
|
+
* @param {string} params.triples.object Object entity text
|
|
16220
|
+
* @param {object} [params.summary] Summary field updates
|
|
16221
|
+
* @param {string} [params.summary.documentName] Document name
|
|
16222
|
+
* @param {number} [params.summary.entityCount] Total entity count
|
|
16223
|
+
* @param {number} [params.summary.tripleCount] Total triple count
|
|
16224
|
+
* @param {string} authorization Authorization token
|
|
16225
|
+
* @return {Promise<object>} data The update results
|
|
16226
|
+
* @return {array<object>} data.pages Page update results [{pageNumber, updated}]
|
|
16227
|
+
* @return {object} data.triples Triple insert results {added: number}
|
|
16228
|
+
* @return {object} data.summary Applied summary updates
|
|
16229
|
+
* @public
|
|
16230
|
+
* @async
|
|
16231
|
+
* @example
|
|
16232
|
+
*
|
|
16233
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
16234
|
+
* const api = new API();
|
|
16235
|
+
* const authorization = '...';
|
|
16236
|
+
* const params = {
|
|
16237
|
+
* documentId: 'doc-123',
|
|
16238
|
+
* pages: [
|
|
16239
|
+
* { pageNumber: 1, markdown: '# Updated page content' }
|
|
16240
|
+
* ],
|
|
16241
|
+
* summary: {
|
|
16242
|
+
* documentName: 'Patient Report.pdf',
|
|
16243
|
+
* entityCount: 42,
|
|
16244
|
+
* tripleCount: 15
|
|
16245
|
+
* }
|
|
16246
|
+
* };
|
|
16247
|
+
* const retData = await api.ai.sessions.updateData(params, authorization);
|
|
16248
|
+
*/
|
|
16249
|
+
async updateData(params, authorization) {
|
|
16250
|
+
const self = this;
|
|
16251
|
+
|
|
16252
|
+
try {
|
|
16253
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required().error(new Error('params is required')));
|
|
16254
|
+
Joi__default["default"].assert(params.documentId, Joi__default["default"].string().required().error(new Error('documentId is required')));
|
|
16255
|
+
|
|
16256
|
+
const { documentId, ...payload } = params;
|
|
16257
|
+
|
|
16258
|
+
const apiCall = self._client
|
|
16259
|
+
.patch(`/agents/session/document/${documentId}`, payload, self._setHeader(authorization));
|
|
16260
|
+
|
|
16261
|
+
return self._returnData(await apiCall);
|
|
16262
|
+
} catch (ex) {
|
|
16263
|
+
throw ex;
|
|
16264
|
+
}
|
|
16265
|
+
}
|
|
16266
|
+
|
|
16267
|
+
/**
|
|
16268
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
16269
|
+
* @description Create a new agent session.
|
|
16270
|
+
* Use this to create a session with full metadata before triggering execution.
|
|
16271
|
+
* @param {object} params Parameters
|
|
16272
|
+
* @param {string} params.agentType The agent type (e.g., 'doc-rlm-ingest')
|
|
16273
|
+
* @param {object} [params.config] Agent configuration options
|
|
16274
|
+
* @param {object} [params.metadata] Session metadata (documentId, pipelineVariant, analysisMode, etc.)
|
|
16275
|
+
* @param {string} authorization Authorization token
|
|
16276
|
+
* @return {Promise<object>} data The created session
|
|
16277
|
+
* @return {string} data.sessionId The session ID
|
|
16278
|
+
* @return {string} data.status The session status
|
|
16279
|
+
* @public
|
|
16280
|
+
* @async
|
|
16281
|
+
* @example
|
|
16282
|
+
*
|
|
16283
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
16284
|
+
* const api = new API();
|
|
16285
|
+
* const authorization = '...';
|
|
16286
|
+
* const params = {
|
|
16287
|
+
* agentType: 'doc-rlm-ingest',
|
|
16288
|
+
* metadata: {
|
|
16289
|
+
* documentId: 'doc-123',
|
|
16290
|
+
* documentName: 'Patient Report.pdf',
|
|
16291
|
+
* pipelineVariant: 'A',
|
|
16292
|
+
* analysisMode: 'full'
|
|
16293
|
+
* }
|
|
16294
|
+
* };
|
|
16295
|
+
* const retData = await api.ai.sessions.create(params, authorization);
|
|
16296
|
+
*/
|
|
16297
|
+
async create(params, authorization) {
|
|
16298
|
+
const self = this;
|
|
16299
|
+
|
|
16300
|
+
try {
|
|
16301
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required().error(new Error('params is required')));
|
|
16302
|
+
Joi__default["default"].assert(params.agentType, Joi__default["default"].string().required().error(new Error('agentType is required')));
|
|
16303
|
+
|
|
16304
|
+
const apiCall = self._client
|
|
16305
|
+
.post('/agents/create', params, self._setHeader(authorization));
|
|
16306
|
+
|
|
16307
|
+
return self._returnData(await apiCall);
|
|
16308
|
+
} catch (ex) {
|
|
16309
|
+
throw ex;
|
|
16310
|
+
}
|
|
16311
|
+
}
|
|
16312
|
+
|
|
16313
|
+
/**
|
|
16314
|
+
* @author Myndware <augusto.pissarra@myndware.com>
|
|
16315
|
+
* @description Start execution on an existing agent session.
|
|
16316
|
+
* @param {object} params Parameters
|
|
16317
|
+
* @param {string} params.sessionId The session ID to execute
|
|
16318
|
+
* @param {object} [params.input] Execution input (documentId, options, etc.)
|
|
16319
|
+
* @param {string} authorization Authorization token
|
|
16320
|
+
* @return {Promise<object>} data The execution data
|
|
16321
|
+
* @return {string} data.executionId The execution ID
|
|
16322
|
+
* @return {string} data.status The execution status
|
|
16323
|
+
* @public
|
|
16324
|
+
* @async
|
|
16325
|
+
* @example
|
|
16326
|
+
*
|
|
16327
|
+
* const API = require('@docbrasil/api-systemmanager');
|
|
16328
|
+
* const api = new API();
|
|
16329
|
+
* const authorization = '...';
|
|
16330
|
+
* const params = {
|
|
16331
|
+
* sessionId: 'session-abc-123',
|
|
16332
|
+
* input: {
|
|
16333
|
+
* documentId: 'doc-123',
|
|
16334
|
+
* options: { pipelineVariant: 'A', analysisMode: 'full' }
|
|
16335
|
+
* }
|
|
16336
|
+
* };
|
|
16337
|
+
* const retData = await api.ai.sessions.execute(params, authorization);
|
|
16338
|
+
*/
|
|
16339
|
+
async execute(params, authorization) {
|
|
16340
|
+
const self = this;
|
|
16341
|
+
|
|
16342
|
+
try {
|
|
16343
|
+
Joi__default["default"].assert(params, Joi__default["default"].object().required().error(new Error('params is required')));
|
|
16344
|
+
Joi__default["default"].assert(params.sessionId, Joi__default["default"].string().required().error(new Error('sessionId is required')));
|
|
16345
|
+
|
|
16346
|
+
const { sessionId, ...payload } = params;
|
|
16347
|
+
|
|
16348
|
+
const apiCall = self._client
|
|
16349
|
+
.post(`/agents/${sessionId}/execute`, payload, self._setHeader(authorization));
|
|
16350
|
+
|
|
16351
|
+
return self._returnData(await apiCall);
|
|
16352
|
+
} catch (ex) {
|
|
16353
|
+
throw ex;
|
|
16354
|
+
}
|
|
16355
|
+
}
|
|
16356
|
+
}
|
|
16357
|
+
|
|
16120
16358
|
/**
|
|
16121
16359
|
* Class using AI
|
|
16122
16360
|
* @class
|
|
@@ -16130,6 +16368,8 @@ class MyndAI {
|
|
|
16130
16368
|
const self = this;
|
|
16131
16369
|
self.parent = options.parent;
|
|
16132
16370
|
self._client = self.parent.dispatch.getClient();
|
|
16371
|
+
|
|
16372
|
+
self.sessions = new AISession(options);
|
|
16133
16373
|
}
|
|
16134
16374
|
|
|
16135
16375
|
/**
|