aparavi-client 1.0.2
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/LICENSE +21 -0
- package/README.md +523 -0
- package/dist/aparavi-client-typescript-1.0.0.tgz +0 -0
- package/dist/aparavi-client-typescript-1.0.1.tgz +0 -0
- package/dist/cjs/client.js +1002 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/constants.js +37 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/core/DAPBase.js +313 -0
- package/dist/cjs/core/DAPBase.js.map +1 -0
- package/dist/cjs/core/DAPClient.js +173 -0
- package/dist/cjs/core/DAPClient.js.map +1 -0
- package/dist/cjs/core/TransportBase.js +131 -0
- package/dist/cjs/core/TransportBase.js.map +1 -0
- package/dist/cjs/core/TransportWebSocket.js +492 -0
- package/dist/cjs/core/TransportWebSocket.js.map +1 -0
- package/dist/cjs/exceptions/index.js +109 -0
- package/dist/cjs/exceptions/index.js.map +1 -0
- package/dist/cjs/index.js +56 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/schema/Doc.js +79 -0
- package/dist/cjs/schema/Doc.js.map +1 -0
- package/dist/cjs/schema/DocFilter.js +133 -0
- package/dist/cjs/schema/DocFilter.js.map +1 -0
- package/dist/cjs/schema/DocGroup.js +235 -0
- package/dist/cjs/schema/DocGroup.js.map +1 -0
- package/dist/cjs/schema/DocMetadata.js +57 -0
- package/dist/cjs/schema/DocMetadata.js.map +1 -0
- package/dist/cjs/schema/Question.js +414 -0
- package/dist/cjs/schema/Question.js.map +1 -0
- package/dist/cjs/schema/index.js +50 -0
- package/dist/cjs/schema/index.js.map +1 -0
- package/dist/cjs/types/client.js +26 -0
- package/dist/cjs/types/client.js.map +1 -0
- package/dist/cjs/types/data.js +26 -0
- package/dist/cjs/types/data.js.map +1 -0
- package/dist/cjs/types/events.js +119 -0
- package/dist/cjs/types/events.js.map +1 -0
- package/dist/cjs/types/index.js +50 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/types/pipeline.js +26 -0
- package/dist/cjs/types/pipeline.js.map +1 -0
- package/dist/cjs/types/task.js +115 -0
- package/dist/cjs/types/task.js.map +1 -0
- package/dist/cli/cli/aparavi.js +1401 -0
- package/dist/cli/cli/aparavi.js.map +1 -0
- package/dist/cli/src/client.js +1002 -0
- package/dist/cli/src/client.js.map +1 -0
- package/dist/cli/src/constants.js +37 -0
- package/dist/cli/src/constants.js.map +1 -0
- package/dist/cli/src/core/DAPBase.js +313 -0
- package/dist/cli/src/core/DAPBase.js.map +1 -0
- package/dist/cli/src/core/DAPClient.js +173 -0
- package/dist/cli/src/core/DAPClient.js.map +1 -0
- package/dist/cli/src/core/TransportBase.js +131 -0
- package/dist/cli/src/core/TransportBase.js.map +1 -0
- package/dist/cli/src/core/TransportWebSocket.js +492 -0
- package/dist/cli/src/core/TransportWebSocket.js.map +1 -0
- package/dist/cli/src/exceptions/index.js +109 -0
- package/dist/cli/src/exceptions/index.js.map +1 -0
- package/dist/cli/src/index.js +56 -0
- package/dist/cli/src/index.js.map +1 -0
- package/dist/cli/src/schema/Doc.js +79 -0
- package/dist/cli/src/schema/Doc.js.map +1 -0
- package/dist/cli/src/schema/DocFilter.js +133 -0
- package/dist/cli/src/schema/DocFilter.js.map +1 -0
- package/dist/cli/src/schema/DocGroup.js +235 -0
- package/dist/cli/src/schema/DocGroup.js.map +1 -0
- package/dist/cli/src/schema/DocMetadata.js +57 -0
- package/dist/cli/src/schema/DocMetadata.js.map +1 -0
- package/dist/cli/src/schema/Question.js +414 -0
- package/dist/cli/src/schema/Question.js.map +1 -0
- package/dist/cli/src/schema/index.js +50 -0
- package/dist/cli/src/schema/index.js.map +1 -0
- package/dist/cli/src/types/client.js +26 -0
- package/dist/cli/src/types/client.js.map +1 -0
- package/dist/cli/src/types/data.js +26 -0
- package/dist/cli/src/types/data.js.map +1 -0
- package/dist/cli/src/types/events.js +119 -0
- package/dist/cli/src/types/events.js.map +1 -0
- package/dist/cli/src/types/index.js +50 -0
- package/dist/cli/src/types/index.js.map +1 -0
- package/dist/cli/src/types/pipeline.js +26 -0
- package/dist/cli/src/types/pipeline.js.map +1 -0
- package/dist/cli/src/types/task.js +115 -0
- package/dist/cli/src/types/task.js.map +1 -0
- package/dist/esm/client.js +997 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/constants.js +34 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/core/DAPBase.js +309 -0
- package/dist/esm/core/DAPBase.js.map +1 -0
- package/dist/esm/core/DAPClient.js +169 -0
- package/dist/esm/core/DAPClient.js.map +1 -0
- package/dist/esm/core/TransportBase.js +127 -0
- package/dist/esm/core/TransportBase.js.map +1 -0
- package/dist/esm/core/TransportWebSocket.js +488 -0
- package/dist/esm/core/TransportWebSocket.js.map +1 -0
- package/dist/esm/exceptions/index.js +100 -0
- package/dist/esm/exceptions/index.js.map +1 -0
- package/dist/esm/index.js +40 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/schema/Doc.js +75 -0
- package/dist/esm/schema/Doc.js.map +1 -0
- package/dist/esm/schema/DocFilter.js +129 -0
- package/dist/esm/schema/DocFilter.js.map +1 -0
- package/dist/esm/schema/DocGroup.js +231 -0
- package/dist/esm/schema/DocGroup.js.map +1 -0
- package/dist/esm/schema/DocMetadata.js +53 -0
- package/dist/esm/schema/DocMetadata.js.map +1 -0
- package/dist/esm/schema/Question.js +409 -0
- package/dist/esm/schema/Question.js.map +1 -0
- package/dist/esm/schema/index.js +34 -0
- package/dist/esm/schema/index.js.map +1 -0
- package/dist/esm/types/client.js +25 -0
- package/dist/esm/types/client.js.map +1 -0
- package/dist/esm/types/data.js +25 -0
- package/dist/esm/types/data.js.map +1 -0
- package/dist/esm/types/events.js +116 -0
- package/dist/esm/types/events.js.map +1 -0
- package/dist/esm/types/index.js +34 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/pipeline.js +25 -0
- package/dist/esm/types/pipeline.js.map +1 -0
- package/dist/esm/types/task.js +112 -0
- package/dist/esm/types/task.js.map +1 -0
- package/dist/types/client.d.ts +395 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/constants.d.ts +34 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/core/DAPBase.d.ts +140 -0
- package/dist/types/core/DAPBase.d.ts.map +1 -0
- package/dist/types/core/DAPClient.d.ts +83 -0
- package/dist/types/core/DAPClient.d.ts.map +1 -0
- package/dist/types/core/TransportBase.d.ts +94 -0
- package/dist/types/core/TransportBase.d.ts.map +1 -0
- package/dist/types/core/TransportWebSocket.d.ts +78 -0
- package/dist/types/core/TransportWebSocket.d.ts.map +1 -0
- package/dist/types/exceptions/index.d.ts +81 -0
- package/dist/types/exceptions/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +36 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/schema/Doc.d.ts +69 -0
- package/dist/types/schema/Doc.d.ts.map +1 -0
- package/dist/types/schema/DocFilter.d.ts +101 -0
- package/dist/types/schema/DocFilter.d.ts.map +1 -0
- package/dist/types/schema/DocGroup.d.ts +113 -0
- package/dist/types/schema/DocGroup.d.ts.map +1 -0
- package/dist/types/schema/DocMetadata.d.ts +61 -0
- package/dist/types/schema/DocMetadata.d.ts.map +1 -0
- package/dist/types/schema/Question.d.ts +163 -0
- package/dist/types/schema/Question.d.ts.map +1 -0
- package/dist/types/schema/index.d.ts +34 -0
- package/dist/types/schema/index.d.ts.map +1 -0
- package/dist/types/types/client.d.ts +140 -0
- package/dist/types/types/client.d.ts.map +1 -0
- package/dist/types/types/data.d.ts +95 -0
- package/dist/types/types/data.d.ts.map +1 -0
- package/dist/types/types/events.d.ts +246 -0
- package/dist/types/types/events.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +34 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/pipeline.d.ts +61 -0
- package/dist/types/types/pipeline.d.ts.map +1 -0
- package/dist/types/types/task.d.ts +265 -0
- package/dist/types/types/task.d.ts.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2024 Aparavi Development Team
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Defines different types of questions and queries you can ask.
|
|
26
|
+
*/
|
|
27
|
+
export var QuestionType;
|
|
28
|
+
(function (QuestionType) {
|
|
29
|
+
QuestionType["QUESTION"] = "question";
|
|
30
|
+
QuestionType["SEMANTIC"] = "semantic";
|
|
31
|
+
QuestionType["KEYWORD"] = "keyword";
|
|
32
|
+
QuestionType["GET"] = "get";
|
|
33
|
+
QuestionType["PROMPT"] = "prompt";
|
|
34
|
+
})(QuestionType || (QuestionType = {}));
|
|
35
|
+
/**
|
|
36
|
+
* Handles AI responses from Aparavi chat operations.
|
|
37
|
+
*/
|
|
38
|
+
export class Answer {
|
|
39
|
+
constructor(expectJson = false) {
|
|
40
|
+
this.expectJson = expectJson;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Parse AI response text into JSON structure.
|
|
44
|
+
*/
|
|
45
|
+
static parseJson(value) {
|
|
46
|
+
// Clean up the response text
|
|
47
|
+
let cleanValue = value.trim()
|
|
48
|
+
.replace(/\r/g, '')
|
|
49
|
+
.replace(/\n/g, '')
|
|
50
|
+
.replace(/\t/g, ' ');
|
|
51
|
+
// Remove JSON code block markers if present
|
|
52
|
+
let offset = cleanValue.indexOf('```json');
|
|
53
|
+
if (offset >= 0) {
|
|
54
|
+
cleanValue = cleanValue.substring(offset + 7).trim();
|
|
55
|
+
offset = cleanValue.lastIndexOf('```');
|
|
56
|
+
if (offset >= 0) {
|
|
57
|
+
cleanValue = cleanValue.substring(0, offset).trim();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// Remove generic code block markers
|
|
61
|
+
offset = cleanValue.indexOf('```');
|
|
62
|
+
if (offset >= 0) {
|
|
63
|
+
cleanValue = cleanValue.substring(offset + 3).trim();
|
|
64
|
+
offset = cleanValue.lastIndexOf('```');
|
|
65
|
+
if (offset >= 0) {
|
|
66
|
+
cleanValue = cleanValue.substring(0, offset).trim();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Remove AI thinking steps (common with some models)
|
|
70
|
+
// Use a more compatible approach instead of the 's' flag
|
|
71
|
+
cleanValue = cleanValue.replace(/<think>[\s\S]*?<\/think>/g, '').trim();
|
|
72
|
+
// Parse the cleaned JSON
|
|
73
|
+
return JSON.parse(cleanValue);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Extract Python code from AI response.
|
|
77
|
+
*/
|
|
78
|
+
static parsePython(value) {
|
|
79
|
+
let offset = value.indexOf('```python');
|
|
80
|
+
if (offset >= 0) {
|
|
81
|
+
value = value.substring(offset + 9);
|
|
82
|
+
offset = value.lastIndexOf('```');
|
|
83
|
+
if (offset >= 0) {
|
|
84
|
+
value = value.substring(0, offset);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Set the AI response value (used internally by the system).
|
|
91
|
+
*/
|
|
92
|
+
setAnswer(value) {
|
|
93
|
+
if (this.expectJson) {
|
|
94
|
+
if (typeof value === 'object') {
|
|
95
|
+
this.answer = value;
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (typeof value === 'string') {
|
|
99
|
+
try {
|
|
100
|
+
this.answer = Answer.parseJson(value);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
throw new Error('Expected a JSON-compatible answer (object or array).');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
throw new Error('Expected a JSON-compatible answer (object or array).');
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
if (typeof value === 'object') {
|
|
111
|
+
this.answer = JSON.stringify(value);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (typeof value === 'string') {
|
|
115
|
+
this.answer = value;
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
throw new Error('Answer must be text, object, or array.');
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Get the response as plain text.
|
|
123
|
+
*/
|
|
124
|
+
getText() {
|
|
125
|
+
if (this.answer === undefined || this.answer === null) {
|
|
126
|
+
return '';
|
|
127
|
+
}
|
|
128
|
+
if (typeof this.answer === 'object') {
|
|
129
|
+
return JSON.stringify(this.answer);
|
|
130
|
+
}
|
|
131
|
+
return String(this.answer);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Get the response as structured JSON data.
|
|
135
|
+
*/
|
|
136
|
+
getJson() {
|
|
137
|
+
if (this.answer === undefined || this.answer === null) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
if (typeof this.answer === 'object') {
|
|
141
|
+
return this.answer;
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
return JSON.parse(String(this.answer));
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
throw new Error('Answer is not in JSON format.');
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Check if this answer contains JSON data.
|
|
152
|
+
*/
|
|
153
|
+
isJson() {
|
|
154
|
+
return this.expectJson;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Main class for asking questions to Aparavi's AI system.
|
|
159
|
+
*/
|
|
160
|
+
export class Question {
|
|
161
|
+
constructor(options = {}) {
|
|
162
|
+
this.type = QuestionType.SEMANTIC;
|
|
163
|
+
this.expectJson = false;
|
|
164
|
+
this.role = '';
|
|
165
|
+
this.instructions = [];
|
|
166
|
+
this.history = [];
|
|
167
|
+
this.examples = [];
|
|
168
|
+
this.context = [];
|
|
169
|
+
this.documents = [];
|
|
170
|
+
this.questions = [];
|
|
171
|
+
this.type = options.type || QuestionType.SEMANTIC;
|
|
172
|
+
this.filter = options.filter || {
|
|
173
|
+
fullTables: false,
|
|
174
|
+
fullDocuments: false,
|
|
175
|
+
offset: 0,
|
|
176
|
+
limit: 25,
|
|
177
|
+
useQuickRank: false,
|
|
178
|
+
useGroupRank: false,
|
|
179
|
+
followUpQuestions: 5,
|
|
180
|
+
context: false
|
|
181
|
+
};
|
|
182
|
+
this.expectJson = options.expectJson || false;
|
|
183
|
+
this.role = options.role || '';
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Add a custom instruction to guide the AI's response.
|
|
187
|
+
*/
|
|
188
|
+
addInstruction(title, instruction) {
|
|
189
|
+
this.instructions.push({
|
|
190
|
+
subtitle: title,
|
|
191
|
+
instructions: instruction
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Add an example to show the AI the kind of response you want.
|
|
196
|
+
*/
|
|
197
|
+
addExample(given, result) {
|
|
198
|
+
const resultString = typeof result === 'object'
|
|
199
|
+
? JSON.stringify(result)
|
|
200
|
+
: String(result);
|
|
201
|
+
this.examples.push({
|
|
202
|
+
given,
|
|
203
|
+
result: resultString
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Add context information to help the AI understand your question better.
|
|
208
|
+
*/
|
|
209
|
+
addContext(context) {
|
|
210
|
+
const contextItems = Array.isArray(context) ? context : [context];
|
|
211
|
+
for (const item of contextItems) {
|
|
212
|
+
if (typeof item === 'string') {
|
|
213
|
+
this.context.push(item);
|
|
214
|
+
}
|
|
215
|
+
else if (typeof item === 'object') {
|
|
216
|
+
this.context.push(String(item));
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
throw new Error(`Context item must be string or object, not ${typeof item}`);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Add a conversation history item for multi-turn chat.
|
|
225
|
+
*/
|
|
226
|
+
addHistory(item) {
|
|
227
|
+
this.history.push(item);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Add a question to ask the AI.
|
|
231
|
+
*/
|
|
232
|
+
addQuestion(question) {
|
|
233
|
+
this.questions.push({ text: question });
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Add specific documents for the AI to reference.
|
|
237
|
+
*/
|
|
238
|
+
addDocuments(documents) {
|
|
239
|
+
const docArray = Array.isArray(documents) ? documents : [documents];
|
|
240
|
+
for (const item of docArray) {
|
|
241
|
+
if (typeof item === 'string') {
|
|
242
|
+
this.documents.push({
|
|
243
|
+
type: 'Document',
|
|
244
|
+
page_content: item,
|
|
245
|
+
metadata: { objectId: '', chunkId: 0 }
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
this.documents.push(item);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Generate the complete prompt text for the AI (used internally).
|
|
255
|
+
*/
|
|
256
|
+
getPrompt(hasPreviousJsonFailed = false) {
|
|
257
|
+
const crlf = '\r\n';
|
|
258
|
+
let prompt = '';
|
|
259
|
+
// Helper functions for formatting different sections
|
|
260
|
+
let instructionId = 0;
|
|
261
|
+
let hasOutputInstructions = false;
|
|
262
|
+
const addPromptInstruction = (instruction) => {
|
|
263
|
+
if (!hasOutputInstructions) {
|
|
264
|
+
prompt += '### Instructions:' + crlf;
|
|
265
|
+
hasOutputInstructions = true;
|
|
266
|
+
}
|
|
267
|
+
prompt += ` ${instructionId + 1}) **${instruction.subtitle.trim()}**: ${instruction.instructions.trim()}` + crlf + crlf;
|
|
268
|
+
instructionId++;
|
|
269
|
+
};
|
|
270
|
+
let exampleId = 0;
|
|
271
|
+
const addPromptExample = (example) => {
|
|
272
|
+
const jsonBegin = this.expectJson ? '```json' + crlf : '';
|
|
273
|
+
const jsonEnd = this.expectJson ? '```' + crlf : '';
|
|
274
|
+
prompt += ` Example ${exampleId + 1}` + crlf;
|
|
275
|
+
prompt += ` **Given**: ${example.given.trim()}` + crlf;
|
|
276
|
+
prompt += ` **Expected output**: ${jsonBegin}${example.result.trim()}${jsonEnd}`;
|
|
277
|
+
exampleId++;
|
|
278
|
+
};
|
|
279
|
+
let contextId = 0;
|
|
280
|
+
let hasOutputContext = false;
|
|
281
|
+
const addPromptContext = (context) => {
|
|
282
|
+
if (!hasOutputContext) {
|
|
283
|
+
prompt += '### Context:' + crlf;
|
|
284
|
+
hasOutputContext = true;
|
|
285
|
+
}
|
|
286
|
+
prompt += ` ${contextId + 1}) ${context.trim()}` + crlf + crlf;
|
|
287
|
+
contextId++;
|
|
288
|
+
};
|
|
289
|
+
let documentId = 0;
|
|
290
|
+
let hasOutputDocuments = false;
|
|
291
|
+
const addPromptDocument = (document) => {
|
|
292
|
+
if (!hasOutputDocuments) {
|
|
293
|
+
prompt += '### Documents:' + crlf;
|
|
294
|
+
hasOutputDocuments = true;
|
|
295
|
+
}
|
|
296
|
+
const doc = document.page_content || '';
|
|
297
|
+
prompt += ` Document ${documentId + 1}) Content: ${doc.trim()}` + crlf;
|
|
298
|
+
documentId++;
|
|
299
|
+
};
|
|
300
|
+
// Add role if specified
|
|
301
|
+
if (this.role) {
|
|
302
|
+
prompt += this.role + crlf;
|
|
303
|
+
}
|
|
304
|
+
// Add default instruction if none provided
|
|
305
|
+
if (this.instructions.length === 0) {
|
|
306
|
+
addPromptInstruction({
|
|
307
|
+
subtitle: 'Answer the following questions',
|
|
308
|
+
instructions: 'I will provide the questions listed in order and then documents as context. Use the given context to provide an answer to the questions.'
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
// Add all instructions
|
|
312
|
+
for (const instruction of this.instructions) {
|
|
313
|
+
addPromptInstruction(instruction);
|
|
314
|
+
}
|
|
315
|
+
// Add JSON formatting instructions if needed
|
|
316
|
+
if (this.expectJson) {
|
|
317
|
+
addPromptInstruction({
|
|
318
|
+
subtitle: 'JSON Response Format',
|
|
319
|
+
instructions: `
|
|
320
|
+
- Respond **only** with a valid JSON structure.
|
|
321
|
+
- Properly escape all quotes within content strings
|
|
322
|
+
- No additional text, comments, or explanations.
|
|
323
|
+
- Ensure your answer is strictly valid JSON format.
|
|
324
|
+
- Double check the JSON response to ensure it is valid.
|
|
325
|
+
- Enclose the json with \`\`\`\`json\` and \` \`\`\` \` tags.
|
|
326
|
+
`
|
|
327
|
+
});
|
|
328
|
+
if (hasPreviousJsonFailed) {
|
|
329
|
+
addPromptInstruction({
|
|
330
|
+
subtitle: 'CRITICAL',
|
|
331
|
+
instructions: `
|
|
332
|
+
- Your previous response returned invalid JSON.
|
|
333
|
+
- Examine your JSON and ensure it is complete and follows the JSON standards.
|
|
334
|
+
`
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
// Add examples if provided
|
|
339
|
+
if (this.examples.length > 0) {
|
|
340
|
+
addPromptInstruction({
|
|
341
|
+
subtitle: 'Examples',
|
|
342
|
+
instructions: ''
|
|
343
|
+
});
|
|
344
|
+
for (const example of this.examples) {
|
|
345
|
+
addPromptExample(example);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
// Add conversation history
|
|
349
|
+
if (this.history.length > 0) {
|
|
350
|
+
prompt += '### Conversation History:' + crlf;
|
|
351
|
+
for (const item of this.history) {
|
|
352
|
+
prompt += ` ${item.role}: ${item.content}` + crlf;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
// Add questions
|
|
356
|
+
if (this.questions.length > 0) {
|
|
357
|
+
let questionNum = 1;
|
|
358
|
+
for (const question of this.questions) {
|
|
359
|
+
prompt += `Question ${questionNum}: ${question.text}` + crlf;
|
|
360
|
+
questionNum++;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
// Add context
|
|
364
|
+
for (const context of this.context) {
|
|
365
|
+
addPromptContext(context);
|
|
366
|
+
}
|
|
367
|
+
// Add documents
|
|
368
|
+
for (const document of this.documents) {
|
|
369
|
+
addPromptDocument(document);
|
|
370
|
+
}
|
|
371
|
+
return prompt;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Convert Question to dictionary for serialization.
|
|
375
|
+
*/
|
|
376
|
+
toDict() {
|
|
377
|
+
return {
|
|
378
|
+
type: this.type,
|
|
379
|
+
filter: this.filter,
|
|
380
|
+
expectJson: this.expectJson,
|
|
381
|
+
role: this.role,
|
|
382
|
+
instructions: this.instructions,
|
|
383
|
+
history: this.history,
|
|
384
|
+
examples: this.examples,
|
|
385
|
+
context: this.context,
|
|
386
|
+
documents: this.documents,
|
|
387
|
+
questions: this.questions
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Create Question from dictionary.
|
|
392
|
+
*/
|
|
393
|
+
static fromDict(data) {
|
|
394
|
+
const question = new Question({
|
|
395
|
+
type: data.type,
|
|
396
|
+
filter: data.filter,
|
|
397
|
+
expectJson: data.expectJson,
|
|
398
|
+
role: data.role
|
|
399
|
+
});
|
|
400
|
+
question.instructions = data.instructions || [];
|
|
401
|
+
question.history = data.history || [];
|
|
402
|
+
question.examples = data.examples || [];
|
|
403
|
+
question.context = data.context || [];
|
|
404
|
+
question.documents = data.documents || [];
|
|
405
|
+
question.questions = data.questions || [];
|
|
406
|
+
return question;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
//# sourceMappingURL=Question.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Question.js","sourceRoot":"","sources":["../../../aparavi-client/src/schema/Question.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAKH;;GAEG;AACH,MAAM,CAAN,IAAY,YAMX;AAND,WAAY,YAAY;IACvB,qCAAqB,CAAA;IACrB,qCAAqB,CAAA;IACrB,mCAAmB,CAAA;IACnB,2BAAW,CAAA;IACX,iCAAiB,CAAA;AAClB,CAAC,EANW,YAAY,KAAZ,YAAY,QAMvB;AA4CD;;GAEG;AACH,MAAM,OAAO,MAAM;IAIlB,YAAY,UAAU,GAAG,KAAK;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,KAAa;QAC7B,6BAA6B;QAC7B,IAAI,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE;aAC3B,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;aAClB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;aAClB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAEtB,4CAA4C;QAC5C,IA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1C,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2024 Aparavi Development Team
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Schema definitions for Aparavi data structures.
|
|
26
|
+
*
|
|
27
|
+
* Re-exports all schema classes and interfaces for convenient imports.
|
|
28
|
+
*/
|
|
29
|
+
export * from './Doc';
|
|
30
|
+
export * from './DocFilter';
|
|
31
|
+
export * from './DocGroup';
|
|
32
|
+
export * from './DocMetadata';
|
|
33
|
+
export * from './Question';
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../aparavi-client/src/schema/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;GAIG;AAEH,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2024 Aparavi Development Team
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../aparavi-client/src/types/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2024 Aparavi Development Team
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.js","sourceRoot":"","sources":["../../../aparavi-client/src/types/data.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2024 Aparavi Development Team
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Event type enumeration for sophisticated client subscription and event routing.
|
|
26
|
+
*
|
|
27
|
+
* This enumeration defines event categories used for intelligent event filtering
|
|
28
|
+
* and routing in multi-client environments. It enables clients to subscribe
|
|
29
|
+
* to specific types of events based on their needs and capabilities, reducing
|
|
30
|
+
* network traffic and improving system performance.
|
|
31
|
+
*
|
|
32
|
+
* Event Categories:
|
|
33
|
+
* ----------------
|
|
34
|
+
* NONE: Unsubscribe from all events (cleanup and disconnection)
|
|
35
|
+
* ALL: Subscribe to all events regardless of category (comprehensive monitoring)
|
|
36
|
+
* DEBUGGER: Debug-specific events for debugging protocol communication
|
|
37
|
+
* DETAIL: Real-time processing events requiring immediate client attention
|
|
38
|
+
* SUMMARY: Periodic status summaries suitable for dashboard monitoring
|
|
39
|
+
* OUTPUT: Standard output and logging messages
|
|
40
|
+
* FLOW: Pipeline flow events - component execution tracking
|
|
41
|
+
* TASK: Task lifecycle events - start, stop, state changes
|
|
42
|
+
*
|
|
43
|
+
* Subscription Strategies:
|
|
44
|
+
* -----------------------
|
|
45
|
+
* NONE: Used during client disconnection to stop all event delivery
|
|
46
|
+
* and perform cleanup of monitoring subscriptions.
|
|
47
|
+
*
|
|
48
|
+
* ALL: Comprehensive monitoring for administrative clients that need
|
|
49
|
+
* complete visibility into task execution and debugging activities.
|
|
50
|
+
*
|
|
51
|
+
* DEBUGGER: Debug protocol events including breakpoint hits, variable
|
|
52
|
+
* changes, stack traces, and debugging session management.
|
|
53
|
+
*
|
|
54
|
+
* DETAIL: Real-time processing events including object processing updates,
|
|
55
|
+
* error/warning messages, metrics updates, and immediate status
|
|
56
|
+
* changes requiring client response or display updates.
|
|
57
|
+
*
|
|
58
|
+
* SUMMARY: Periodic status summaries sent at CONST_STATUS_UPDATE_FREQ
|
|
59
|
+
* intervals containing complete task status, suitable for
|
|
60
|
+
* monitoring dashboards and periodic client updates.
|
|
61
|
+
*
|
|
62
|
+
* OUTPUT: Standard output and logging messages from task execution.
|
|
63
|
+
*
|
|
64
|
+
* FLOW: Pipeline flow events tracking component execution, data flow
|
|
65
|
+
* between pipeline stages, and processing pipeline status.
|
|
66
|
+
*
|
|
67
|
+
* TASK: Task lifecycle events including task start, stop, pause, resume,
|
|
68
|
+
* and state changes for task management interfaces.
|
|
69
|
+
*
|
|
70
|
+
* Network Optimization:
|
|
71
|
+
* --------------------
|
|
72
|
+
* Event filtering reduces network traffic by sending only relevant events
|
|
73
|
+
* to interested clients. SUMMARY subscriptions receive consolidated status
|
|
74
|
+
* updates rather than individual processing events, significantly reducing
|
|
75
|
+
* bandwidth usage for monitoring applications.
|
|
76
|
+
*
|
|
77
|
+
* Multi-Client Support:
|
|
78
|
+
* --------------------
|
|
79
|
+
* Different clients can subscribe to different event types simultaneously:
|
|
80
|
+
* - Debugging clients: DEBUGGER + DETAIL for comprehensive debugging
|
|
81
|
+
* - Monitoring dashboards: SUMMARY for efficient status tracking
|
|
82
|
+
* - Administrative tools: ALL for complete system visibility
|
|
83
|
+
* - Log viewers: OUTPUT for message monitoring
|
|
84
|
+
* - Pipeline managers: FLOW + TASK for execution tracking
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* // Subscribe to debugging and detail events
|
|
89
|
+
* const subscription = EVENT_TYPE.DEBUGGER | EVENT_TYPE.DETAIL;
|
|
90
|
+
*
|
|
91
|
+
* // Check if client wants specific events
|
|
92
|
+
* if (clientSubscription & EVENT_TYPE.SUMMARY) {
|
|
93
|
+
* sendSummaryUpdate(client, taskStatus);
|
|
94
|
+
* }
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export var EVENT_TYPE;
|
|
98
|
+
(function (EVENT_TYPE) {
|
|
99
|
+
/** No events - unsubscribe from all event types */
|
|
100
|
+
EVENT_TYPE[EVENT_TYPE["NONE"] = 0] = "NONE";
|
|
101
|
+
/** Debug protocol events - DAP and debugging-specific events like breakpoints, stack traces */
|
|
102
|
+
EVENT_TYPE[EVENT_TYPE["DEBUGGER"] = 1] = "DEBUGGER";
|
|
103
|
+
/** Real-time processing events - immediate updates for live monitoring */
|
|
104
|
+
EVENT_TYPE[EVENT_TYPE["DETAIL"] = 2] = "DETAIL";
|
|
105
|
+
/** Periodic status summaries - dashboard monitoring with reduced frequency */
|
|
106
|
+
EVENT_TYPE[EVENT_TYPE["SUMMARY"] = 4] = "SUMMARY";
|
|
107
|
+
/** Standard output and logging messages from task execution */
|
|
108
|
+
EVENT_TYPE[EVENT_TYPE["OUTPUT"] = 8] = "OUTPUT";
|
|
109
|
+
/** Pipeline flow events - component execution tracking and data flow visualization */
|
|
110
|
+
EVENT_TYPE[EVENT_TYPE["FLOW"] = 16] = "FLOW";
|
|
111
|
+
/** Task lifecycle events - start, stop, state changes, and task management */
|
|
112
|
+
EVENT_TYPE[EVENT_TYPE["TASK"] = 32] = "TASK";
|
|
113
|
+
/** Convenience combination - ALL events except NONE for comprehensive monitoring */
|
|
114
|
+
EVENT_TYPE[EVENT_TYPE["ALL"] = 63] = "ALL"; // Binary: 111111
|
|
115
|
+
})(EVENT_TYPE || (EVENT_TYPE = {}));
|
|
116
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../aparavi-client/src/types/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AACH,MAAM,CAAN,IAAY,UAwBX;AAxBD,WAAY,UAAU;IACrB,mDAAmD;IACnD,2CAAQ,CAAA;IAER,+FAA+F;IAC/F,mDAAiB,CAAA;IAEjB,0EAA0E;IAC1E,+CAAe,CAAA;IAEf,8EAA8E;IAC9E,iDAAgB,CAAA;IAEhB,+DAA+D;IAC/D,+CAAe,CAAA;IAEf,sFAAsF;IACtF,4CAAa,CAAA;IAEb,8EAA8E;IAC9E,4CAAa,CAAA;IAEb,oFAAoF;IACpF,0CAAwD,CAAA,CAAC,iBAAiB;AAC3E,CAAC,EAxBW,UAAU,KAAV,UAAU,QAwBrB"}
|