askui 0.20.7 → 0.20.8
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/dist/cjs/core/inference-response/inference-response.d.ts +5 -0
- package/dist/cjs/execution/execution-runtime.d.ts +1 -0
- package/dist/cjs/execution/execution-runtime.js +6 -0
- package/dist/cjs/execution/inference-client.d.ts +3 -0
- package/dist/cjs/execution/inference-client.js +25 -0
- package/dist/cjs/execution/ui-control-client.d.ts +89 -0
- package/dist/cjs/execution/ui-control-client.js +94 -0
- package/dist/esm/core/inference-response/inference-response.d.ts +5 -0
- package/dist/esm/execution/execution-runtime.d.ts +1 -0
- package/dist/esm/execution/execution-runtime.js +6 -0
- package/dist/esm/execution/inference-client.d.ts +3 -0
- package/dist/esm/execution/inference-client.js +25 -0
- package/dist/esm/execution/ui-control-client.d.ts +89 -0
- package/dist/esm/execution/ui-control-client.js +94 -0
- package/package.json +1 -1
|
@@ -5,6 +5,11 @@ export interface InferenceResponseBody {
|
|
|
5
5
|
type: ModelType;
|
|
6
6
|
data: ModelType extends 'COMMANDS' ? ControlCommand : Annotation;
|
|
7
7
|
}
|
|
8
|
+
export interface VQAInferenceResponseBody {
|
|
9
|
+
data: {
|
|
10
|
+
response: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
8
13
|
export declare class InferenceResponse {
|
|
9
14
|
static fromJson(json: InferenceResponseBody, resizeRatio?: number, image?: string): ControlCommand | Annotation;
|
|
10
15
|
static createModels(type: ModelType, data: ModelType extends 'COMMANDS' ? ControlCommand : Annotation, resizeRatio: number, image?: string): ControlCommand | Annotation;
|
|
@@ -35,4 +35,5 @@ export declare class ExecutionRuntime {
|
|
|
35
35
|
takeScreenshotIfImageisNotProvided(imagePath?: string): Promise<string>;
|
|
36
36
|
getDetectedElements(instruction: string, customElementJson?: CustomElementJson[]): Promise<DetectedElement[]>;
|
|
37
37
|
annotateImage(imagePath?: string, customElementJson?: CustomElementJson[], elements?: DetectedElement[]): Promise<Annotation>;
|
|
38
|
+
predictVQA(prompt: string, config?: object): Promise<any>;
|
|
38
39
|
}
|
|
@@ -208,5 +208,11 @@ class ExecutionRuntime {
|
|
|
208
208
|
return this.inferenceClient.predictImageAnnotation(base64Image, customElements);
|
|
209
209
|
});
|
|
210
210
|
}
|
|
211
|
+
predictVQA(prompt, config) {
|
|
212
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
213
|
+
const base64Image = yield this.takeScreenshotIfImageisNotProvided();
|
|
214
|
+
return this.inferenceClient.predictVQAAnswer(prompt, base64Image, config);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
211
217
|
}
|
|
212
218
|
exports.ExecutionRuntime = ExecutionRuntime;
|
|
@@ -3,6 +3,7 @@ import { ControlCommand } from '../core/ui-control-commands';
|
|
|
3
3
|
import { CustomElement } from '../core/model/custom-element';
|
|
4
4
|
import { Annotation } from '../core/annotation/annotation';
|
|
5
5
|
import { DetectedElement } from '../core/model/annotation-result/detected-element';
|
|
6
|
+
import { VQAInferenceResponseBody } from '../core/inference-response/inference-response';
|
|
6
7
|
import { ModelCompositionBranch } from './model-composition-branch';
|
|
7
8
|
export declare class InferenceClient {
|
|
8
9
|
private readonly baseUrl;
|
|
@@ -16,8 +17,10 @@ export declare class InferenceClient {
|
|
|
16
17
|
isImageRequired(instruction: string): Promise<boolean>;
|
|
17
18
|
private resizeIfNeeded;
|
|
18
19
|
inference(customElements?: CustomElement[], image?: string, instruction?: string): Promise<ControlCommand | Annotation>;
|
|
20
|
+
vqaInference(image: string, prompt: string, config?: object): Promise<VQAInferenceResponseBody>;
|
|
19
21
|
private static logMetaInformation;
|
|
20
22
|
predictControlCommand(instruction: string, customElements?: CustomElement[], image?: string): Promise<ControlCommand>;
|
|
21
23
|
getDetectedElements(instruction: string, image: string, customElements?: CustomElement[]): Promise<DetectedElement[]>;
|
|
22
24
|
predictImageAnnotation(image: string, customElements?: CustomElement[]): Promise<Annotation>;
|
|
25
|
+
predictVQAAnswer(prompt: string, image: string, config?: object): Promise<any>;
|
|
23
26
|
}
|
|
@@ -35,6 +35,7 @@ class InferenceClient {
|
|
|
35
35
|
this.urls = {
|
|
36
36
|
inference: (0, url_join_1.default)(url, 'inference'),
|
|
37
37
|
isImageRequired: (0, url_join_1.default)(url, 'instruction', 'is-image-required'),
|
|
38
|
+
vqaInference: (0, url_join_1.default)(url, 'vqa', 'inference'),
|
|
38
39
|
};
|
|
39
40
|
this.httpClient.urlsToRetry = Object.values(this.urls);
|
|
40
41
|
if (this.resize !== undefined && this.resize <= 0) {
|
|
@@ -77,6 +78,17 @@ class InferenceClient {
|
|
|
77
78
|
return ui_control_commands_1.InferenceResponse.fromJson(response.body, resizedImage.resizeRatio, image);
|
|
78
79
|
});
|
|
79
80
|
}
|
|
81
|
+
vqaInference(image, prompt, config) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
const response = yield this.httpClient.post(this.urls.vqaInference, {
|
|
84
|
+
config,
|
|
85
|
+
image,
|
|
86
|
+
prompt,
|
|
87
|
+
});
|
|
88
|
+
InferenceClient.logMetaInformation(response);
|
|
89
|
+
return response.body;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
80
92
|
static logMetaInformation(response) {
|
|
81
93
|
if (response.headers['askui-usage-warnings'] !== undefined) {
|
|
82
94
|
logger_1.logger.warn(response.headers['askui-usage-warnings']);
|
|
@@ -109,5 +121,18 @@ class InferenceClient {
|
|
|
109
121
|
return inferenceResponse;
|
|
110
122
|
});
|
|
111
123
|
}
|
|
124
|
+
predictVQAAnswer(prompt, image, config) {
|
|
125
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
const inferenceResponse = yield this.vqaInference(image, prompt, config);
|
|
127
|
+
const { response } = inferenceResponse.data;
|
|
128
|
+
try {
|
|
129
|
+
return JSON.parse(response);
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
logger_1.logger.warn(`Response is no valid JSON: ${response}`);
|
|
133
|
+
}
|
|
134
|
+
return response;
|
|
135
|
+
});
|
|
136
|
+
}
|
|
112
137
|
}
|
|
113
138
|
exports.InferenceClient = InferenceClient;
|
|
@@ -59,6 +59,95 @@ export declare class UiControlClient extends ApiCommands {
|
|
|
59
59
|
private getAIElementsByNames;
|
|
60
60
|
fluentCommandExecutor(instructionString: string, context?: CommandExecutorContext): Promise<void>;
|
|
61
61
|
getterExecutor(instruction: string, context?: CommandExecutorContext): Promise<DetectedElement[]>;
|
|
62
|
+
/**
|
|
63
|
+
* Takes a prompt that contains a question you want to be answered
|
|
64
|
+
* or the data you want to have extracted from your screen.
|
|
65
|
+
*
|
|
66
|
+
* The optional 'config' can be used to specifiy the JSON schema the
|
|
67
|
+
* returned object shall have (https://json-schema.org).
|
|
68
|
+
*
|
|
69
|
+
* See the following examples on how to use it:
|
|
70
|
+
*
|
|
71
|
+
* let isWidgetsNew =
|
|
72
|
+
* await aui.ask(
|
|
73
|
+
* "Does the sidebar element 'Widgets' have a 'NEW' tag?",
|
|
74
|
+
* {
|
|
75
|
+
* json_schema: {
|
|
76
|
+
* "type": "boolean"
|
|
77
|
+
* }
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* Output of console.log(isWidgetsNew): true
|
|
81
|
+
*
|
|
82
|
+
* let newClients =
|
|
83
|
+
* await aui.ask(
|
|
84
|
+
* "How many new clients?",
|
|
85
|
+
* {
|
|
86
|
+
* json_schema: {
|
|
87
|
+
* "type": "number"
|
|
88
|
+
* }
|
|
89
|
+
* });
|
|
90
|
+
*
|
|
91
|
+
* Output of console.log(newClients): 9123
|
|
92
|
+
*
|
|
93
|
+
* let userNames =
|
|
94
|
+
* await aui.ask(
|
|
95
|
+
* "Return a list with the users names.",
|
|
96
|
+
* {
|
|
97
|
+
* json_schema: {
|
|
98
|
+
* "type": "array",
|
|
99
|
+
* "items": {
|
|
100
|
+
* "type": "string"
|
|
101
|
+
* }
|
|
102
|
+
* }
|
|
103
|
+
* });
|
|
104
|
+
*
|
|
105
|
+
* Output of console.log(userNames):
|
|
106
|
+
* [
|
|
107
|
+
* 'Yiorgos Avraamu',
|
|
108
|
+
* 'Avram Tsarios',
|
|
109
|
+
* 'Quintin Ed',
|
|
110
|
+
* 'Enéas Kwadwo',
|
|
111
|
+
* 'Agapetus Tadeáš'
|
|
112
|
+
* ]
|
|
113
|
+
*
|
|
114
|
+
* let users =
|
|
115
|
+
* await aui.ask(
|
|
116
|
+
* "Extract the users from the table.",
|
|
117
|
+
* {
|
|
118
|
+
* json_schema: {
|
|
119
|
+
* "type": "array",
|
|
120
|
+
* "items": {
|
|
121
|
+
* "type": "object",
|
|
122
|
+
* "properties": {
|
|
123
|
+
* "name": {
|
|
124
|
+
* "type": "string"
|
|
125
|
+
* },
|
|
126
|
+
* "usage": {
|
|
127
|
+
* "type": "number"
|
|
128
|
+
* }
|
|
129
|
+
* },
|
|
130
|
+
* "additionalProperties": false,
|
|
131
|
+
* "required": ["name", "usage"]
|
|
132
|
+
* },
|
|
133
|
+
* },
|
|
134
|
+
* });
|
|
135
|
+
*
|
|
136
|
+
* Output of console.log(users):
|
|
137
|
+
* [
|
|
138
|
+
* { name: 'Yiorgos Avraamu', usage: 50 },
|
|
139
|
+
* { name: 'Avram Tarasios', usage: 10 },
|
|
140
|
+
* { name: 'Quintin Ed', usage: 74 },
|
|
141
|
+
* { name: 'Eneás Kwadwo', usage: 98 },
|
|
142
|
+
* { name: 'Agapetus Tadeáš', usage: 22 }
|
|
143
|
+
* ]
|
|
144
|
+
*
|
|
145
|
+
* @param {string} prompt - The question you want to be answered or
|
|
146
|
+
* the data you want to have extracted.
|
|
147
|
+
* @param {Object} config - object that specifies the return json: {json_schema: {...}}.
|
|
148
|
+
* @returns {any} - The answer as JSON specified in the config object.
|
|
149
|
+
*/
|
|
150
|
+
ask(prompt: string, config?: object): Promise<any>;
|
|
62
151
|
private secretText;
|
|
63
152
|
private getAndResetSecretText;
|
|
64
153
|
/**
|
|
@@ -166,6 +166,100 @@ class UiControlClient extends dsl_1.ApiCommands {
|
|
|
166
166
|
]);
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Takes a prompt that contains a question you want to be answered
|
|
171
|
+
* or the data you want to have extracted from your screen.
|
|
172
|
+
*
|
|
173
|
+
* The optional 'config' can be used to specifiy the JSON schema the
|
|
174
|
+
* returned object shall have (https://json-schema.org).
|
|
175
|
+
*
|
|
176
|
+
* See the following examples on how to use it:
|
|
177
|
+
*
|
|
178
|
+
* let isWidgetsNew =
|
|
179
|
+
* await aui.ask(
|
|
180
|
+
* "Does the sidebar element 'Widgets' have a 'NEW' tag?",
|
|
181
|
+
* {
|
|
182
|
+
* json_schema: {
|
|
183
|
+
* "type": "boolean"
|
|
184
|
+
* }
|
|
185
|
+
* });
|
|
186
|
+
*
|
|
187
|
+
* Output of console.log(isWidgetsNew): true
|
|
188
|
+
*
|
|
189
|
+
* let newClients =
|
|
190
|
+
* await aui.ask(
|
|
191
|
+
* "How many new clients?",
|
|
192
|
+
* {
|
|
193
|
+
* json_schema: {
|
|
194
|
+
* "type": "number"
|
|
195
|
+
* }
|
|
196
|
+
* });
|
|
197
|
+
*
|
|
198
|
+
* Output of console.log(newClients): 9123
|
|
199
|
+
*
|
|
200
|
+
* let userNames =
|
|
201
|
+
* await aui.ask(
|
|
202
|
+
* "Return a list with the users names.",
|
|
203
|
+
* {
|
|
204
|
+
* json_schema: {
|
|
205
|
+
* "type": "array",
|
|
206
|
+
* "items": {
|
|
207
|
+
* "type": "string"
|
|
208
|
+
* }
|
|
209
|
+
* }
|
|
210
|
+
* });
|
|
211
|
+
*
|
|
212
|
+
* Output of console.log(userNames):
|
|
213
|
+
* [
|
|
214
|
+
* 'Yiorgos Avraamu',
|
|
215
|
+
* 'Avram Tsarios',
|
|
216
|
+
* 'Quintin Ed',
|
|
217
|
+
* 'Enéas Kwadwo',
|
|
218
|
+
* 'Agapetus Tadeáš'
|
|
219
|
+
* ]
|
|
220
|
+
*
|
|
221
|
+
* let users =
|
|
222
|
+
* await aui.ask(
|
|
223
|
+
* "Extract the users from the table.",
|
|
224
|
+
* {
|
|
225
|
+
* json_schema: {
|
|
226
|
+
* "type": "array",
|
|
227
|
+
* "items": {
|
|
228
|
+
* "type": "object",
|
|
229
|
+
* "properties": {
|
|
230
|
+
* "name": {
|
|
231
|
+
* "type": "string"
|
|
232
|
+
* },
|
|
233
|
+
* "usage": {
|
|
234
|
+
* "type": "number"
|
|
235
|
+
* }
|
|
236
|
+
* },
|
|
237
|
+
* "additionalProperties": false,
|
|
238
|
+
* "required": ["name", "usage"]
|
|
239
|
+
* },
|
|
240
|
+
* },
|
|
241
|
+
* });
|
|
242
|
+
*
|
|
243
|
+
* Output of console.log(users):
|
|
244
|
+
* [
|
|
245
|
+
* { name: 'Yiorgos Avraamu', usage: 50 },
|
|
246
|
+
* { name: 'Avram Tarasios', usage: 10 },
|
|
247
|
+
* { name: 'Quintin Ed', usage: 74 },
|
|
248
|
+
* { name: 'Eneás Kwadwo', usage: 98 },
|
|
249
|
+
* { name: 'Agapetus Tadeáš', usage: 22 }
|
|
250
|
+
* ]
|
|
251
|
+
*
|
|
252
|
+
* @param {string} prompt - The question you want to be answered or
|
|
253
|
+
* the data you want to have extracted.
|
|
254
|
+
* @param {Object} config - object that specifies the return json: {json_schema: {...}}.
|
|
255
|
+
* @returns {any} - The answer as JSON specified in the config object.
|
|
256
|
+
*/
|
|
257
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
258
|
+
ask(prompt, config) {
|
|
259
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
260
|
+
return this.executionRuntime.predictVQA(prompt, config);
|
|
261
|
+
});
|
|
262
|
+
}
|
|
169
263
|
getAndResetSecretText() {
|
|
170
264
|
const { secretText } = this;
|
|
171
265
|
this.secretText = undefined;
|
|
@@ -5,6 +5,11 @@ export interface InferenceResponseBody {
|
|
|
5
5
|
type: ModelType;
|
|
6
6
|
data: ModelType extends 'COMMANDS' ? ControlCommand : Annotation;
|
|
7
7
|
}
|
|
8
|
+
export interface VQAInferenceResponseBody {
|
|
9
|
+
data: {
|
|
10
|
+
response: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
8
13
|
export declare class InferenceResponse {
|
|
9
14
|
static fromJson(json: InferenceResponseBody, resizeRatio?: number, image?: string): ControlCommand | Annotation;
|
|
10
15
|
static createModels(type: ModelType, data: ModelType extends 'COMMANDS' ? ControlCommand : Annotation, resizeRatio: number, image?: string): ControlCommand | Annotation;
|
|
@@ -35,4 +35,5 @@ export declare class ExecutionRuntime {
|
|
|
35
35
|
takeScreenshotIfImageisNotProvided(imagePath?: string): Promise<string>;
|
|
36
36
|
getDetectedElements(instruction: string, customElementJson?: CustomElementJson[]): Promise<DetectedElement[]>;
|
|
37
37
|
annotateImage(imagePath?: string, customElementJson?: CustomElementJson[], elements?: DetectedElement[]): Promise<Annotation>;
|
|
38
|
+
predictVQA(prompt: string, config?: object): Promise<any>;
|
|
38
39
|
}
|
|
@@ -205,4 +205,10 @@ export class ExecutionRuntime {
|
|
|
205
205
|
return this.inferenceClient.predictImageAnnotation(base64Image, customElements);
|
|
206
206
|
});
|
|
207
207
|
}
|
|
208
|
+
predictVQA(prompt, config) {
|
|
209
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
210
|
+
const base64Image = yield this.takeScreenshotIfImageisNotProvided();
|
|
211
|
+
return this.inferenceClient.predictVQAAnswer(prompt, base64Image, config);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
208
214
|
}
|
|
@@ -3,6 +3,7 @@ import { ControlCommand } from '../core/ui-control-commands';
|
|
|
3
3
|
import { CustomElement } from '../core/model/custom-element';
|
|
4
4
|
import { Annotation } from '../core/annotation/annotation';
|
|
5
5
|
import { DetectedElement } from '../core/model/annotation-result/detected-element';
|
|
6
|
+
import { VQAInferenceResponseBody } from '../core/inference-response/inference-response';
|
|
6
7
|
import { ModelCompositionBranch } from './model-composition-branch';
|
|
7
8
|
export declare class InferenceClient {
|
|
8
9
|
private readonly baseUrl;
|
|
@@ -16,8 +17,10 @@ export declare class InferenceClient {
|
|
|
16
17
|
isImageRequired(instruction: string): Promise<boolean>;
|
|
17
18
|
private resizeIfNeeded;
|
|
18
19
|
inference(customElements?: CustomElement[], image?: string, instruction?: string): Promise<ControlCommand | Annotation>;
|
|
20
|
+
vqaInference(image: string, prompt: string, config?: object): Promise<VQAInferenceResponseBody>;
|
|
19
21
|
private static logMetaInformation;
|
|
20
22
|
predictControlCommand(instruction: string, customElements?: CustomElement[], image?: string): Promise<ControlCommand>;
|
|
21
23
|
getDetectedElements(instruction: string, image: string, customElements?: CustomElement[]): Promise<DetectedElement[]>;
|
|
22
24
|
predictImageAnnotation(image: string, customElements?: CustomElement[]): Promise<Annotation>;
|
|
25
|
+
predictVQAAnswer(prompt: string, image: string, config?: object): Promise<any>;
|
|
23
26
|
}
|
|
@@ -29,6 +29,7 @@ export class InferenceClient {
|
|
|
29
29
|
this.urls = {
|
|
30
30
|
inference: urljoin(url, 'inference'),
|
|
31
31
|
isImageRequired: urljoin(url, 'instruction', 'is-image-required'),
|
|
32
|
+
vqaInference: urljoin(url, 'vqa', 'inference'),
|
|
32
33
|
};
|
|
33
34
|
this.httpClient.urlsToRetry = Object.values(this.urls);
|
|
34
35
|
if (this.resize !== undefined && this.resize <= 0) {
|
|
@@ -71,6 +72,17 @@ export class InferenceClient {
|
|
|
71
72
|
return InferenceResponse.fromJson(response.body, resizedImage.resizeRatio, image);
|
|
72
73
|
});
|
|
73
74
|
}
|
|
75
|
+
vqaInference(image, prompt, config) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
const response = yield this.httpClient.post(this.urls.vqaInference, {
|
|
78
|
+
config,
|
|
79
|
+
image,
|
|
80
|
+
prompt,
|
|
81
|
+
});
|
|
82
|
+
InferenceClient.logMetaInformation(response);
|
|
83
|
+
return response.body;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
74
86
|
static logMetaInformation(response) {
|
|
75
87
|
if (response.headers['askui-usage-warnings'] !== undefined) {
|
|
76
88
|
logger.warn(response.headers['askui-usage-warnings']);
|
|
@@ -103,4 +115,17 @@ export class InferenceClient {
|
|
|
103
115
|
return inferenceResponse;
|
|
104
116
|
});
|
|
105
117
|
}
|
|
118
|
+
predictVQAAnswer(prompt, image, config) {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
const inferenceResponse = yield this.vqaInference(image, prompt, config);
|
|
121
|
+
const { response } = inferenceResponse.data;
|
|
122
|
+
try {
|
|
123
|
+
return JSON.parse(response);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
logger.warn(`Response is no valid JSON: ${response}`);
|
|
127
|
+
}
|
|
128
|
+
return response;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
106
131
|
}
|
|
@@ -59,6 +59,95 @@ export declare class UiControlClient extends ApiCommands {
|
|
|
59
59
|
private getAIElementsByNames;
|
|
60
60
|
fluentCommandExecutor(instructionString: string, context?: CommandExecutorContext): Promise<void>;
|
|
61
61
|
getterExecutor(instruction: string, context?: CommandExecutorContext): Promise<DetectedElement[]>;
|
|
62
|
+
/**
|
|
63
|
+
* Takes a prompt that contains a question you want to be answered
|
|
64
|
+
* or the data you want to have extracted from your screen.
|
|
65
|
+
*
|
|
66
|
+
* The optional 'config' can be used to specifiy the JSON schema the
|
|
67
|
+
* returned object shall have (https://json-schema.org).
|
|
68
|
+
*
|
|
69
|
+
* See the following examples on how to use it:
|
|
70
|
+
*
|
|
71
|
+
* let isWidgetsNew =
|
|
72
|
+
* await aui.ask(
|
|
73
|
+
* "Does the sidebar element 'Widgets' have a 'NEW' tag?",
|
|
74
|
+
* {
|
|
75
|
+
* json_schema: {
|
|
76
|
+
* "type": "boolean"
|
|
77
|
+
* }
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* Output of console.log(isWidgetsNew): true
|
|
81
|
+
*
|
|
82
|
+
* let newClients =
|
|
83
|
+
* await aui.ask(
|
|
84
|
+
* "How many new clients?",
|
|
85
|
+
* {
|
|
86
|
+
* json_schema: {
|
|
87
|
+
* "type": "number"
|
|
88
|
+
* }
|
|
89
|
+
* });
|
|
90
|
+
*
|
|
91
|
+
* Output of console.log(newClients): 9123
|
|
92
|
+
*
|
|
93
|
+
* let userNames =
|
|
94
|
+
* await aui.ask(
|
|
95
|
+
* "Return a list with the users names.",
|
|
96
|
+
* {
|
|
97
|
+
* json_schema: {
|
|
98
|
+
* "type": "array",
|
|
99
|
+
* "items": {
|
|
100
|
+
* "type": "string"
|
|
101
|
+
* }
|
|
102
|
+
* }
|
|
103
|
+
* });
|
|
104
|
+
*
|
|
105
|
+
* Output of console.log(userNames):
|
|
106
|
+
* [
|
|
107
|
+
* 'Yiorgos Avraamu',
|
|
108
|
+
* 'Avram Tsarios',
|
|
109
|
+
* 'Quintin Ed',
|
|
110
|
+
* 'Enéas Kwadwo',
|
|
111
|
+
* 'Agapetus Tadeáš'
|
|
112
|
+
* ]
|
|
113
|
+
*
|
|
114
|
+
* let users =
|
|
115
|
+
* await aui.ask(
|
|
116
|
+
* "Extract the users from the table.",
|
|
117
|
+
* {
|
|
118
|
+
* json_schema: {
|
|
119
|
+
* "type": "array",
|
|
120
|
+
* "items": {
|
|
121
|
+
* "type": "object",
|
|
122
|
+
* "properties": {
|
|
123
|
+
* "name": {
|
|
124
|
+
* "type": "string"
|
|
125
|
+
* },
|
|
126
|
+
* "usage": {
|
|
127
|
+
* "type": "number"
|
|
128
|
+
* }
|
|
129
|
+
* },
|
|
130
|
+
* "additionalProperties": false,
|
|
131
|
+
* "required": ["name", "usage"]
|
|
132
|
+
* },
|
|
133
|
+
* },
|
|
134
|
+
* });
|
|
135
|
+
*
|
|
136
|
+
* Output of console.log(users):
|
|
137
|
+
* [
|
|
138
|
+
* { name: 'Yiorgos Avraamu', usage: 50 },
|
|
139
|
+
* { name: 'Avram Tarasios', usage: 10 },
|
|
140
|
+
* { name: 'Quintin Ed', usage: 74 },
|
|
141
|
+
* { name: 'Eneás Kwadwo', usage: 98 },
|
|
142
|
+
* { name: 'Agapetus Tadeáš', usage: 22 }
|
|
143
|
+
* ]
|
|
144
|
+
*
|
|
145
|
+
* @param {string} prompt - The question you want to be answered or
|
|
146
|
+
* the data you want to have extracted.
|
|
147
|
+
* @param {Object} config - object that specifies the return json: {json_schema: {...}}.
|
|
148
|
+
* @returns {any} - The answer as JSON specified in the config object.
|
|
149
|
+
*/
|
|
150
|
+
ask(prompt: string, config?: object): Promise<any>;
|
|
62
151
|
private secretText;
|
|
63
152
|
private getAndResetSecretText;
|
|
64
153
|
/**
|
|
@@ -163,6 +163,100 @@ export class UiControlClient extends ApiCommands {
|
|
|
163
163
|
]);
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Takes a prompt that contains a question you want to be answered
|
|
168
|
+
* or the data you want to have extracted from your screen.
|
|
169
|
+
*
|
|
170
|
+
* The optional 'config' can be used to specifiy the JSON schema the
|
|
171
|
+
* returned object shall have (https://json-schema.org).
|
|
172
|
+
*
|
|
173
|
+
* See the following examples on how to use it:
|
|
174
|
+
*
|
|
175
|
+
* let isWidgetsNew =
|
|
176
|
+
* await aui.ask(
|
|
177
|
+
* "Does the sidebar element 'Widgets' have a 'NEW' tag?",
|
|
178
|
+
* {
|
|
179
|
+
* json_schema: {
|
|
180
|
+
* "type": "boolean"
|
|
181
|
+
* }
|
|
182
|
+
* });
|
|
183
|
+
*
|
|
184
|
+
* Output of console.log(isWidgetsNew): true
|
|
185
|
+
*
|
|
186
|
+
* let newClients =
|
|
187
|
+
* await aui.ask(
|
|
188
|
+
* "How many new clients?",
|
|
189
|
+
* {
|
|
190
|
+
* json_schema: {
|
|
191
|
+
* "type": "number"
|
|
192
|
+
* }
|
|
193
|
+
* });
|
|
194
|
+
*
|
|
195
|
+
* Output of console.log(newClients): 9123
|
|
196
|
+
*
|
|
197
|
+
* let userNames =
|
|
198
|
+
* await aui.ask(
|
|
199
|
+
* "Return a list with the users names.",
|
|
200
|
+
* {
|
|
201
|
+
* json_schema: {
|
|
202
|
+
* "type": "array",
|
|
203
|
+
* "items": {
|
|
204
|
+
* "type": "string"
|
|
205
|
+
* }
|
|
206
|
+
* }
|
|
207
|
+
* });
|
|
208
|
+
*
|
|
209
|
+
* Output of console.log(userNames):
|
|
210
|
+
* [
|
|
211
|
+
* 'Yiorgos Avraamu',
|
|
212
|
+
* 'Avram Tsarios',
|
|
213
|
+
* 'Quintin Ed',
|
|
214
|
+
* 'Enéas Kwadwo',
|
|
215
|
+
* 'Agapetus Tadeáš'
|
|
216
|
+
* ]
|
|
217
|
+
*
|
|
218
|
+
* let users =
|
|
219
|
+
* await aui.ask(
|
|
220
|
+
* "Extract the users from the table.",
|
|
221
|
+
* {
|
|
222
|
+
* json_schema: {
|
|
223
|
+
* "type": "array",
|
|
224
|
+
* "items": {
|
|
225
|
+
* "type": "object",
|
|
226
|
+
* "properties": {
|
|
227
|
+
* "name": {
|
|
228
|
+
* "type": "string"
|
|
229
|
+
* },
|
|
230
|
+
* "usage": {
|
|
231
|
+
* "type": "number"
|
|
232
|
+
* }
|
|
233
|
+
* },
|
|
234
|
+
* "additionalProperties": false,
|
|
235
|
+
* "required": ["name", "usage"]
|
|
236
|
+
* },
|
|
237
|
+
* },
|
|
238
|
+
* });
|
|
239
|
+
*
|
|
240
|
+
* Output of console.log(users):
|
|
241
|
+
* [
|
|
242
|
+
* { name: 'Yiorgos Avraamu', usage: 50 },
|
|
243
|
+
* { name: 'Avram Tarasios', usage: 10 },
|
|
244
|
+
* { name: 'Quintin Ed', usage: 74 },
|
|
245
|
+
* { name: 'Eneás Kwadwo', usage: 98 },
|
|
246
|
+
* { name: 'Agapetus Tadeáš', usage: 22 }
|
|
247
|
+
* ]
|
|
248
|
+
*
|
|
249
|
+
* @param {string} prompt - The question you want to be answered or
|
|
250
|
+
* the data you want to have extracted.
|
|
251
|
+
* @param {Object} config - object that specifies the return json: {json_schema: {...}}.
|
|
252
|
+
* @returns {any} - The answer as JSON specified in the config object.
|
|
253
|
+
*/
|
|
254
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
255
|
+
ask(prompt, config) {
|
|
256
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
257
|
+
return this.executionRuntime.predictVQA(prompt, config);
|
|
258
|
+
});
|
|
259
|
+
}
|
|
166
260
|
getAndResetSecretText() {
|
|
167
261
|
const { secretText } = this;
|
|
168
262
|
this.secretText = undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "askui",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "askui GmbH <info@askui.com> (http://www.askui.com/)",
|
|
6
6
|
"description": "Reliable, automated end-to-end-testing that depends on what is shown on your screen instead of the technology you are running on",
|