cpee 2.1.135 → 2.1.139
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/cockpit/compliance-view.html +11 -19
- data/cockpit/compliance.html +11 -19
- data/cockpit/css/llm.css +3 -3
- data/cockpit/css/llmmodel.css +140 -0
- data/cockpit/css/model.css +0 -1
- data/cockpit/css/ui.css +13 -7
- data/cockpit/css/wfadaptor.css +15 -10
- data/cockpit/edit.html +11 -19
- data/cockpit/graph.html +8 -13
- data/cockpit/index.html +11 -19
- data/cockpit/js/details.js +27 -10
- data/cockpit/js/instance.js +219 -206
- data/cockpit/js/llm-ui-bubble.js +36 -0
- data/cockpit/js/llm-ui-status.js +34 -0
- data/cockpit/js/llm-ui.js +87 -0
- data/cockpit/js/llm.js +469 -121
- data/cockpit/js/parameters.js +45 -14
- data/cockpit/js/wfadaptor.js +402 -77
- data/cockpit/llm.html +16 -21
- data/cockpit/llmmodel.html +17 -23
- data/cockpit/model.html +8 -15
- data/cockpit/only_llm.html +14 -19
- data/cockpit/themes/THEMES.MD +4 -0
- data/cockpit/themes/base.js +1 -1
- data/cockpit/themes/packed/theme.js +3 -0
- data/cockpit/themes/presetlr/rngs/alternative.rng +28 -0
- data/cockpit/themes/presetlr/rngs/call.rng +249 -0
- data/cockpit/themes/presetlr/rngs/callmanipulate.rng +281 -0
- data/cockpit/themes/presetlr/rngs/choose.rng +27 -0
- data/cockpit/themes/presetlr/rngs/closed_loop.rng +62 -0
- data/cockpit/themes/presetlr/rngs/closed_loop_cancel.rng +5 -0
- data/cockpit/themes/presetlr/rngs/closed_loop_control.rng +31 -0
- data/cockpit/themes/presetlr/rngs/closed_loop_measuring.rng +12 -0
- data/cockpit/themes/presetlr/rngs/critical.rng +8 -0
- data/cockpit/themes/presetlr/rngs/escape.rng +5 -0
- data/cockpit/themes/presetlr/rngs/group.rng +3 -0
- data/cockpit/themes/presetlr/rngs/loop.rng +40 -0
- data/cockpit/themes/presetlr/rngs/manipulate.rng +76 -0
- data/cockpit/themes/presetlr/rngs/otherwise.rng +25 -0
- data/cockpit/themes/presetlr/rngs/parallel.rng +24 -0
- data/cockpit/themes/presetlr/rngs/parallel_branch.rng +5 -0
- data/cockpit/themes/presetlr/rngs/scripts.rng +23 -0
- data/cockpit/themes/presetlr/rngs/start.rng +143 -0
- data/cockpit/themes/presetlr/rngs/stop.rng +5 -0
- data/cockpit/themes/presetlr/rngs/terminate.rng +8 -0
- data/cockpit/themes/presetlr/rngs/wait_for_signal.rng +8 -0
- data/cockpit/themes/presetlr/symbols/alternative.svg +19 -0
- data/cockpit/themes/presetlr/symbols/arrow.svg +1 -0
- data/cockpit/themes/presetlr/symbols/call.svg +1 -0
- data/cockpit/themes/presetlr/symbols/call_sensor.svg +1 -0
- data/cockpit/themes/presetlr/symbols/callmanipulate.svg +1 -0
- data/cockpit/themes/presetlr/symbols/callmanipulate_sensor.svg +1 -0
- data/cockpit/themes/presetlr/symbols/callmanipulate_sensor_signal.svg +1 -0
- data/cockpit/themes/presetlr/symbols/callmanipulate_signal.svg +1 -0
- data/cockpit/themes/presetlr/symbols/choose.svg +15 -0
- data/cockpit/themes/presetlr/symbols/choose_exclusive.svg +15 -0
- data/cockpit/themes/presetlr/symbols/choose_exclusive_finish.svg +1 -0
- data/cockpit/themes/presetlr/symbols/choose_inclusive.svg +13 -0
- data/cockpit/themes/presetlr/symbols/choose_inclusive_finish.svg +1 -0
- data/cockpit/themes/presetlr/symbols/closed_loop.svg +1 -0
- data/cockpit/themes/presetlr/symbols/closed_loop_cancel.svg +1 -0
- data/cockpit/themes/presetlr/symbols/closed_loop_control.svg +1 -0
- data/cockpit/themes/presetlr/symbols/closed_loop_measuring.svg +1 -0
- data/cockpit/themes/presetlr/symbols/complex.svg +1 -0
- data/cockpit/themes/presetlr/symbols/critical.svg +1 -0
- data/cockpit/themes/presetlr/symbols/delete.svg +1 -0
- data/cockpit/themes/presetlr/symbols/end.svg +1 -0
- data/cockpit/themes/presetlr/symbols/escape.svg +1 -0
- data/cockpit/themes/presetlr/symbols/event_end.svg +1 -0
- data/cockpit/themes/presetlr/symbols/event_start.svg +1 -0
- data/cockpit/themes/presetlr/symbols/loop.svg +15 -0
- data/cockpit/themes/presetlr/symbols/loop_end.svg +15 -0
- data/cockpit/themes/presetlr/symbols/loop_end_pre.svg +15 -0
- data/cockpit/themes/presetlr/symbols/manipulate.svg +1 -0
- data/cockpit/themes/presetlr/symbols/mark.svg +1 -0
- data/cockpit/themes/presetlr/symbols/otherwise.svg +7 -0
- data/cockpit/themes/presetlr/symbols/parallel.svg +1 -0
- data/cockpit/themes/presetlr/symbols/parallel_branch.svg +7 -0
- data/cockpit/themes/presetlr/symbols/parallel_branch_event.svg +14 -0
- data/cockpit/themes/presetlr/symbols/parallel_branch_event_rev.svg +11 -0
- data/cockpit/themes/presetlr/symbols/parallel_branch_normal.svg +7 -0
- data/cockpit/themes/presetlr/symbols/parallel_eventbased_exclusive.svg +1 -0
- data/cockpit/themes/presetlr/symbols/parallel_eventbased_parallel.svg +1 -0
- data/cockpit/themes/presetlr/symbols/scripts.svg +1 -0
- data/cockpit/themes/presetlr/symbols/start.svg +1 -0
- data/cockpit/themes/presetlr/symbols/start_event.svg +1 -0
- data/cockpit/themes/presetlr/symbols/stop.svg +1 -0
- data/cockpit/themes/presetlr/symbols/terminate.svg +1 -0
- data/cockpit/themes/presetlr/symbols/wait_for_signal.svg +1 -0
- data/cockpit/themes/presetlr/theme.js +54 -0
- data/cockpit/themes/wellformed/rngs/alternative.rng +28 -0
- data/cockpit/themes/wellformed/rngs/call.rng +249 -0
- data/cockpit/themes/wellformed/rngs/callmanipulate.rng +281 -0
- data/cockpit/themes/wellformed/rngs/choose.rng +27 -0
- data/cockpit/themes/wellformed/rngs/closed_loop.rng +62 -0
- data/cockpit/themes/wellformed/rngs/closed_loop_cancel.rng +5 -0
- data/cockpit/themes/wellformed/rngs/closed_loop_control.rng +31 -0
- data/cockpit/themes/wellformed/rngs/closed_loop_measuring.rng +12 -0
- data/cockpit/themes/wellformed/rngs/critical.rng +8 -0
- data/cockpit/themes/wellformed/rngs/escape.rng +5 -0
- data/cockpit/themes/wellformed/rngs/group.rng +3 -0
- data/cockpit/themes/wellformed/rngs/loop.rng +40 -0
- data/cockpit/themes/wellformed/rngs/manipulate.rng +76 -0
- data/cockpit/themes/wellformed/rngs/otherwise.rng +25 -0
- data/cockpit/themes/wellformed/rngs/parallel.rng +24 -0
- data/cockpit/themes/wellformed/rngs/parallel_branch.rng +5 -0
- data/cockpit/themes/wellformed/rngs/scripts.rng +23 -0
- data/cockpit/themes/wellformed/rngs/start.rng +143 -0
- data/cockpit/themes/wellformed/rngs/stop.rng +5 -0
- data/cockpit/themes/wellformed/rngs/terminate.rng +8 -0
- data/cockpit/themes/wellformed/rngs/wait_for_signal.rng +8 -0
- data/cockpit/themes/wellformed/symbols/alternative.svg +1 -0
- data/cockpit/themes/wellformed/symbols/arrow.svg +1 -0
- data/cockpit/themes/wellformed/symbols/call.svg +1 -0
- data/cockpit/themes/wellformed/symbols/call_sensor.svg +1 -0
- data/cockpit/themes/wellformed/symbols/callmanipulate.svg +1 -0
- data/cockpit/themes/wellformed/symbols/callmanipulate_sensor.svg +1 -0
- data/cockpit/themes/wellformed/symbols/callmanipulate_sensor_signal.svg +1 -0
- data/cockpit/themes/wellformed/symbols/callmanipulate_signal.svg +1 -0
- data/cockpit/themes/wellformed/symbols/choose.svg +1 -0
- data/cockpit/themes/wellformed/symbols/choose_exclusive.svg +1 -0
- data/cockpit/themes/wellformed/symbols/choose_exclusive_finish.svg +1 -0
- data/cockpit/themes/wellformed/symbols/choose_inclusive.svg +1 -0
- data/cockpit/themes/wellformed/symbols/choose_inclusive_finish.svg +1 -0
- data/cockpit/themes/wellformed/symbols/closed_loop.svg +1 -0
- data/cockpit/themes/wellformed/symbols/closed_loop_cancel.svg +1 -0
- data/cockpit/themes/wellformed/symbols/closed_loop_control.svg +1 -0
- data/cockpit/themes/wellformed/symbols/closed_loop_measuring.svg +1 -0
- data/cockpit/themes/wellformed/symbols/complex.svg +1 -0
- data/cockpit/themes/wellformed/symbols/critical.svg +1 -0
- data/cockpit/themes/wellformed/symbols/delete.svg +1 -0
- data/cockpit/themes/wellformed/symbols/end.svg +1 -0
- data/cockpit/themes/wellformed/symbols/escape.svg +1 -0
- data/cockpit/themes/wellformed/symbols/event_end.svg +1 -0
- data/cockpit/themes/wellformed/symbols/event_start.svg +6 -0
- data/cockpit/themes/wellformed/symbols/loop.svg +1 -0
- data/cockpit/themes/wellformed/symbols/loop_end.svg +1 -0
- data/cockpit/themes/wellformed/symbols/manipulate.svg +1 -0
- data/cockpit/themes/wellformed/symbols/mark.svg +1 -0
- data/cockpit/themes/wellformed/symbols/otherwise.svg +1 -0
- data/cockpit/themes/wellformed/symbols/parallel.svg +1 -0
- data/cockpit/themes/wellformed/symbols/parallel_branch.svg +1 -0
- data/cockpit/themes/wellformed/symbols/parallel_branch_event.svg +1 -0
- data/cockpit/themes/wellformed/symbols/parallel_branch_event_rev.svg +11 -0
- data/cockpit/themes/wellformed/symbols/parallel_branch_normal.svg +1 -0
- data/cockpit/themes/wellformed/symbols/parallel_eventbased_exclusive.svg +1 -0
- data/cockpit/themes/wellformed/symbols/parallel_eventbased_parallel.svg +1 -0
- data/cockpit/themes/wellformed/symbols/scripts.svg +1 -0
- data/cockpit/themes/wellformed/symbols/start.svg +1 -0
- data/cockpit/themes/wellformed/symbols/start_event.svg +1 -0
- data/cockpit/themes/wellformed/symbols/stop.svg +1 -0
- data/cockpit/themes/wellformed/symbols/terminate.svg +1 -0
- data/cockpit/themes/wellformed/symbols/wait_for_signal.svg +1 -0
- data/cockpit/themes/wellformed/theme.js +32 -0
- data/cockpit/track.html +8 -13
- data/cpee.gemspec +3 -3
- data/lib/callbacks/callbacks.rng +4 -4
- data/lib/callbacks.xml +4 -4
- data/lib/cpee/constants.rb +4 -4
- data/lib/cpee/fail.rb +4 -4
- data/lib/cpee/implementation.rb +10 -4
- data/lib/cpee/implementation_callbacks.rb +6 -6
- data/lib/cpee/implementation_notifications.rb +8 -5
- data/lib/cpee/implementation_properties.rb +132 -12
- data/lib/cpee/json_pointer.rb +110 -0
- data/lib/cpee/message.rb +26 -6
- data/lib/cpee/persistence.rb +10 -4
- data/lib/cpee/redis.rb +12 -4
- data/lib/cpee/statemachine.rb +4 -4
- data/lib/cpee/value_helper.rb +4 -4
- data/lib/cpee.xml +4 -4
- data/lib/engine/executionhandler-list.rng +4 -4
- data/lib/engine/instance-info.rng +4 -4
- data/lib/engine/instances.rng +4 -4
- data/lib/engine.xml +4 -4
- data/lib/properties/t_dslx.rng +356 -0
- data/lib/properties/transformation.rng +14 -0
- data/lib/properties.xml +5 -4
- data/server/executionhandlers/eval/backend/opts.yaml +1 -1
- data/server/executionhandlers/eval/connection.rb +16 -7
- data/server/executionhandlers/eval/execution.rb +4 -4
- data/server/executionhandlers/ruby/backend/opts.yaml +1 -1
- data/server/executionhandlers/ruby/connection.rb +17 -9
- data/server/executionhandlers/ruby/controller.rb +21 -6
- data/server/executionhandlers/ruby/dsl_to_dslx.xsl +6 -2
- data/server/executionhandlers/ruby/execution.rb +4 -4
- data/server/resources/properties.empty +5 -4
- data/server/resources/properties.init +5 -4
- data/server/resources/topics.xml +4 -4
- data/server/routing/end.pid +1 -1
- data/server/routing/end.rb +4 -4
- data/server/routing/forward-events-00.pid +1 -1
- data/server/routing/forward-events.rb +34 -23
- data/server/routing/forward-votes.pid +1 -1
- data/server/routing/forward-votes.rb +60 -47
- data/server/routing/persist.pid +1 -1
- data/server/routing/persist.rb +53 -30
- data/tools/server/cpee +1 -1
- data/tools/server/resources/properties.init +4 -4
- metadata +142 -5
- data/cockpit/CPEE.xml +0 -8
- data/cockpit/Signavio.xml +0 -8
- data/cockpit/transformations.xml +0 -4
- /data/{COPYING → LICENSE} +0 -0
data/cockpit/js/llm.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var default_llm = "gemini-2.5-flash-lite";
|
|
4
|
-
|
|
5
|
-
function clean_llm_ui(status) { //{{{
|
|
6
|
-
status.empty();
|
|
7
|
-
status.removeClass('error').removeClass('success');
|
|
8
|
-
status.removeClass('error').removeClass('error');
|
|
9
|
-
status.removeClass('error').removeClass('loading');
|
|
10
|
-
} //}}}
|
|
1
|
+
var last_model_before_generation = undefined;
|
|
2
|
+
var default_llm = "gemini-3.1-flash-lite";
|
|
11
3
|
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
function xhr_error(xhr) { //{{{
|
|
5
|
+
if (xhr.responseJSON && xhr.responseJSON.error) {
|
|
6
|
+
return xhr.responseJSON.error;
|
|
7
|
+
}
|
|
8
|
+
if (xhr.responseText) {
|
|
9
|
+
return 'LLM Service not reachable (request status ' + xhr.status + ')!'
|
|
10
|
+
}
|
|
11
|
+
return xhr.statusText;
|
|
17
12
|
} //}}}
|
|
18
13
|
|
|
19
14
|
function add_prompt(input,content) { //{{{
|
|
@@ -25,6 +20,104 @@ function add_prompt(input,content) { //{{{
|
|
|
25
20
|
document.execCommand('insertText', false, content);
|
|
26
21
|
} //}}}
|
|
27
22
|
|
|
23
|
+
function call_llm_service_intent(input, llm, llms, dslx, messages, documents, depth=0) { //{{{
|
|
24
|
+
let def = new $.Deferred();
|
|
25
|
+
|
|
26
|
+
(async () => {
|
|
27
|
+
try {
|
|
28
|
+
const intent_form = new FormData();
|
|
29
|
+
intent_form.append("user_input", new Blob([input], { type: "text/plain" }));
|
|
30
|
+
intent_form.append("llm", new Blob([llm], { type: "text/plain" }));
|
|
31
|
+
|
|
32
|
+
let intent = await $.ajax({
|
|
33
|
+
url: $('body').attr('current-llm-service') + '/intent/',
|
|
34
|
+
data: intent_form,
|
|
35
|
+
contentType: false,
|
|
36
|
+
processData: false,
|
|
37
|
+
cache: false,
|
|
38
|
+
method: 'POST'
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (intent === null) {
|
|
42
|
+
// no intent matched at all
|
|
43
|
+
ui.success(llms,"Your request seems to be not about process modelling (or anything covered by the installed plugins).");
|
|
44
|
+
def.resolve(null);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (typeof intent === 'object' && Object.keys(intent).length === 0) {
|
|
49
|
+
// no specific plugin matched: proceed normally with the original input
|
|
50
|
+
def.resolve(input);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const call_form = new FormData();
|
|
55
|
+
call_form.append("user_input", new Blob([input], { type: "text/plain" }));
|
|
56
|
+
call_form.append("llm", new Blob([llm], { type: "text/plain" }));
|
|
57
|
+
(intent.required_input || []).forEach(function(name){
|
|
58
|
+
if (name === 'model') {
|
|
59
|
+
call_form.append("dslx", new Blob([dslx], { type: "text/xml" }));
|
|
60
|
+
} else if (name === 'documents') {
|
|
61
|
+
call_form.append("documents", new Blob([JSON.stringify(documents)], { type: "application/json" }));
|
|
62
|
+
} else if (name === 'messages') {
|
|
63
|
+
call_form.append("messages", new Blob([messages], { type: "text/plain" }));
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
let response;
|
|
68
|
+
console.log(intent.url);
|
|
69
|
+
try {
|
|
70
|
+
response = await $.ajax({
|
|
71
|
+
url: intent.url,
|
|
72
|
+
data: call_form,
|
|
73
|
+
cache: false,
|
|
74
|
+
contentType: false,
|
|
75
|
+
processData: false,
|
|
76
|
+
method: 'PUT'
|
|
77
|
+
});
|
|
78
|
+
} catch (xhr) {
|
|
79
|
+
let trimmed_url = intent.url.replace(/\/+$/, '');
|
|
80
|
+
ui.error(llms,"The intent plugin \'" + trimmed_url.substr(trimmed_url.lastIndexOf('/') + 1) + "\' is not working properly.");
|
|
81
|
+
def.resolve(null);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let filled_output;
|
|
86
|
+
if (intent.output_template) {
|
|
87
|
+
filled_output = intent.output_template;
|
|
88
|
+
if (response !== null && typeof response === 'object') {
|
|
89
|
+
Object.keys(response).forEach(function(key){
|
|
90
|
+
filled_output = filled_output.split('%%%' + key).join(response[key]);
|
|
91
|
+
});
|
|
92
|
+
} else {
|
|
93
|
+
filled_output = filled_output.replace('%%%', response);
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
filled_output = response;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (intent.output == 'chat') {
|
|
100
|
+
ui.success(llms,filled_output);
|
|
101
|
+
def.resolve(null);
|
|
102
|
+
} else if (intent.output == 'reintent' && filled_output !== input && depth < 3) {
|
|
103
|
+
// repeat the process of looking for a plugin/intent, using the filled output as the new input
|
|
104
|
+
// (at most 3 times, to avoid endless plugin loops)
|
|
105
|
+
call_llm_service_intent(filled_output,llm,llms,dslx,messages,documents,depth + 1).done((result) => {
|
|
106
|
+
def.resolve(result);
|
|
107
|
+
}).fail((xhr) => {
|
|
108
|
+
def.reject(xhr);
|
|
109
|
+
});
|
|
110
|
+
} else {
|
|
111
|
+
def.resolve(filled_output);
|
|
112
|
+
}
|
|
113
|
+
} catch (xhr) {
|
|
114
|
+
def.reject(xhr);
|
|
115
|
+
}
|
|
116
|
+
})();
|
|
117
|
+
|
|
118
|
+
return def.promise();
|
|
119
|
+
} //}}}
|
|
120
|
+
|
|
28
121
|
function call_llm_service_model(dslx,input,llm,prompt_type) { //{{{
|
|
29
122
|
const formData = new FormData();
|
|
30
123
|
const blob1 = new Blob([dslx], { type: "text/xml" });
|
|
@@ -59,12 +152,14 @@ function call_llm_service_model(dslx,input,llm,prompt_type) { //{{{
|
|
|
59
152
|
|
|
60
153
|
return def.promise();
|
|
61
154
|
} //}}}
|
|
62
|
-
function call_llm_service_dataflow(model,llm) { //{{{
|
|
155
|
+
function call_llm_service_dataflow(model,input,llm) { //{{{
|
|
63
156
|
const formData = new FormData();
|
|
64
157
|
const blob1 = new Blob([model], { type: "text/xml" });
|
|
65
158
|
formData.append("rpst_xml", blob1);
|
|
66
|
-
const blob2 = new Blob([
|
|
67
|
-
formData.append("
|
|
159
|
+
const blob2 = new Blob([input], { type: "text/plain" });
|
|
160
|
+
formData.append("user_input", blob2);
|
|
161
|
+
const blob3 = new Blob([llm], { type: "text/plain" });
|
|
162
|
+
formData.append("llm", blob3);
|
|
68
163
|
|
|
69
164
|
let def = new $.Deferred();
|
|
70
165
|
|
|
@@ -112,7 +207,7 @@ function call_llm_service_validation(model,llm) { //{{{
|
|
|
112
207
|
return def.promise();
|
|
113
208
|
} //}}}
|
|
114
209
|
|
|
115
|
-
function call_llm_text_service(
|
|
210
|
+
function call_llm_text_service(prompt,llms,action) { //{{{
|
|
116
211
|
let myllm = llms.find(":selected").val();
|
|
117
212
|
if (myllm === undefined){ myllm = default_llm; }
|
|
118
213
|
const info = save.attributes_raw.info;
|
|
@@ -140,16 +235,257 @@ function call_llm_text_service(status,prompt,llms,action) { //{{{
|
|
|
140
235
|
link.href = dataUri;
|
|
141
236
|
link.click();
|
|
142
237
|
};
|
|
143
|
-
|
|
144
|
-
set_success(status,data.status);
|
|
238
|
+
ui.success(llms,data.status);
|
|
145
239
|
},
|
|
146
240
|
error: function(xhr, stat, data) {
|
|
147
|
-
|
|
241
|
+
ui.error(llms,xhr_error(xhr));
|
|
148
242
|
}
|
|
149
243
|
});
|
|
150
244
|
} //}}}
|
|
151
245
|
|
|
246
|
+
function diff_summary_rec(el, nodes) { //{{{
|
|
247
|
+
function hash_str(str) {
|
|
248
|
+
let h = 0x811c9dc5;
|
|
249
|
+
for (let i = 0; i < str.length; i++) {
|
|
250
|
+
h ^= str.charCodeAt(i);
|
|
251
|
+
h = Math.imul(h, 0x01000193);
|
|
252
|
+
}
|
|
253
|
+
return (h >>> 0).toString(36);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function serialize_clean(node) {
|
|
257
|
+
let clone = node.cloneNode(true);
|
|
258
|
+
(function strip(n){
|
|
259
|
+
for (let i = n.childNodes.length - 1; i >= 0; i--) {
|
|
260
|
+
let c = n.childNodes[i];
|
|
261
|
+
if (c.nodeType === 3 && /^\s*$/.test(c.nodeValue)) { n.removeChild(c); }
|
|
262
|
+
else if (c.nodeType === 1) { strip(c); }
|
|
263
|
+
}
|
|
264
|
+
})(clone);
|
|
265
|
+
return new XMLSerializer().serializeToString(clone);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
$(el).children().each(function(){
|
|
269
|
+
let child = this;
|
|
270
|
+
let id = child.getAttribute('id');
|
|
271
|
+
let eid = child.getAttribute('eid');
|
|
272
|
+
if (id !== null) {
|
|
273
|
+
let fields = {};
|
|
274
|
+
for (let i = 0; i < child.attributes.length; i++) {
|
|
275
|
+
fields[child.attributes[i].name] = child.attributes[i].value;
|
|
276
|
+
}
|
|
277
|
+
$(child).children().each(function(){
|
|
278
|
+
let name = this.localName || this.nodeName;
|
|
279
|
+
if (name === 'parameters') {
|
|
280
|
+
$(this).children().each(function(){
|
|
281
|
+
let pname = this.localName || this.nodeName;
|
|
282
|
+
fields[pname] = serialize_clean(this);
|
|
283
|
+
});
|
|
284
|
+
} else {
|
|
285
|
+
fields[name] = serialize_clean(this);
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
nodes.push({ id: id, type: 'task', fingerprint: hash_str(serialize_clean(child)), fields: fields });
|
|
289
|
+
} else if (eid !== null) {
|
|
290
|
+
let fields = {};
|
|
291
|
+
for (let i = 0; i < child.attributes.length; i++) {
|
|
292
|
+
fields[child.attributes[i].name] = child.attributes[i].value;
|
|
293
|
+
}
|
|
294
|
+
let attr_parts = Object.keys(fields).sort().map(function(k){ return k + '=' + fields[k]; });
|
|
295
|
+
let child_parts = [];
|
|
296
|
+
$(child).children().each(function(){
|
|
297
|
+
let name = this.localName || this.nodeName;
|
|
298
|
+
if (name.charAt(0) === '_') {
|
|
299
|
+
let serialized = serialize_clean(this);
|
|
300
|
+
fields[name] = serialized;
|
|
301
|
+
child_parts.push(serialized);
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
let branch_names = ['parallel_branch','alternative','otherwise'];
|
|
305
|
+
let tag_name = child.localName || child.nodeName;
|
|
306
|
+
let type = branch_names.indexOf(tag_name) !== -1 ? 'branch' : 'gateway';
|
|
307
|
+
nodes.push({ id: eid, type: type, fingerprint: hash_str(attr_parts.concat(child_parts).join('|')), fields: fields });
|
|
308
|
+
}
|
|
309
|
+
diff_summary_rec(child, nodes);
|
|
310
|
+
});
|
|
311
|
+
} //}}}
|
|
312
|
+
function diff_summary(model_old, model_new) { //{{{
|
|
313
|
+
// depth_first traverse both model_old and model_new:
|
|
314
|
+
// all elements with an attribute @id are tasks
|
|
315
|
+
// all elements with an attribute @eid are a gateway, except parallel_branch, alternative and otherwise elements, which are a branch
|
|
316
|
+
// these are the ones included in the list that results from traversal
|
|
317
|
+
// while traversing:
|
|
318
|
+
// for any element that has an @id calculate a fingerprint that contains the whole content
|
|
319
|
+
// for any element that has an @eid calculate a fingerprint for all its attributes and direct children elements whos name starts with a _
|
|
320
|
+
|
|
321
|
+
// after traversal: compare the old_nodes with the new_nodes list by their ids and types (task, gateway)
|
|
322
|
+
// if nodes are in the old_nodes but not in the new_nodes they have been deleted
|
|
323
|
+
// if nodes are in the new_nodes but not in the old_nodes they have been added
|
|
324
|
+
// if nodes of the old_nodes are in a new position in the new_nodes they have been moved
|
|
325
|
+
// if the fingerprint of nodes is not identical, their parameters have been changed
|
|
326
|
+
// if the fingerprint of nodes is not identical, investigate which children or attributes of the nodes have differnt text content
|
|
327
|
+
|
|
328
|
+
// collect all the changes
|
|
329
|
+
|
|
330
|
+
// if more that 3 nodes are affected by any change summarize, combining types that share the same operation: "7 tasks, 3 gateways, and 2 branches have been added, 1 task has been changed"
|
|
331
|
+
// if 3 or less nodes are affected name them "Tasks a3, a2 and a1 have been moved. Parameters of node a1 have been changed."
|
|
332
|
+
// More examples: Task a1 had the attribute "color" changed.
|
|
333
|
+
// More examples: Task a1 had its "color" changed.
|
|
334
|
+
// More examples: Task a1 had its "parameters" changed.
|
|
335
|
+
|
|
336
|
+
// the function returns the textual summary of the differences.
|
|
337
|
+
|
|
338
|
+
function to_root(model) {
|
|
339
|
+
if (typeof model === 'string') { return $X(model).get(0); }
|
|
340
|
+
if (model && model.jquery) { return model.get(0); }
|
|
341
|
+
return model;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
let old_nodes = [];
|
|
345
|
+
let new_nodes = [];
|
|
346
|
+
diff_summary_rec(to_root(model_old), old_nodes);
|
|
347
|
+
diff_summary_rec(to_root(model_new), new_nodes);
|
|
348
|
+
|
|
349
|
+
let old_index = {};
|
|
350
|
+
old_nodes.forEach(function(n,i){ old_index[n.type + ':' + n.id] = { pos: i, node: n }; });
|
|
351
|
+
let new_index = {};
|
|
352
|
+
new_nodes.forEach(function(n,i){ new_index[n.type + ':' + n.id] = { pos: i, node: n }; });
|
|
353
|
+
|
|
354
|
+
let added = [];
|
|
355
|
+
let deleted = [];
|
|
356
|
+
let moved = [];
|
|
357
|
+
let changed = [];
|
|
358
|
+
|
|
359
|
+
old_nodes.forEach(function(n){
|
|
360
|
+
if (!(n.type + ':' + n.id in new_index)) { deleted.push({ id: n.id, type: n.type }); }
|
|
361
|
+
});
|
|
362
|
+
new_nodes.forEach(function(n){
|
|
363
|
+
if (!(n.type + ':' + n.id in old_index)) { added.push({ id: n.id, type: n.type }); }
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
let common_old_order = old_nodes.filter(function(n){ return (n.type + ':' + n.id) in new_index; }).map(function(n){ return n.type + ':' + n.id; });
|
|
367
|
+
let common_new_order = new_nodes.filter(function(n){ return (n.type + ':' + n.id) in old_index; }).map(function(n){ return n.type + ':' + n.id; });
|
|
368
|
+
let new_pos_of = {};
|
|
369
|
+
common_new_order.forEach(function(key,i){ new_pos_of[key] = i; });
|
|
370
|
+
|
|
371
|
+
// longest increasing subsequence of new-positions (in old order): the nodes that
|
|
372
|
+
// stay in relative order across both versions, i.e. did NOT move. Everything else
|
|
373
|
+
// did move. This avoids flagging every node between an actually-moved node's old
|
|
374
|
+
// and new position as "moved" too.
|
|
375
|
+
let seq = common_old_order.map(function(key){ return new_pos_of[key]; });
|
|
376
|
+
let dp = new Array(seq.length).fill(1);
|
|
377
|
+
let prev = new Array(seq.length).fill(-1);
|
|
378
|
+
let best = -1;
|
|
379
|
+
for (let i = 0; i < seq.length; i++) {
|
|
380
|
+
for (let j = 0; j < i; j++) {
|
|
381
|
+
if (seq[j] < seq[i] && dp[j] + 1 > dp[i]) {
|
|
382
|
+
dp[i] = dp[j] + 1;
|
|
383
|
+
prev[i] = j;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
if (best === -1 || dp[i] > dp[best]) { best = i; }
|
|
387
|
+
}
|
|
388
|
+
let in_lis = new Array(seq.length).fill(false);
|
|
389
|
+
for (let k = best; k !== -1; k = prev[k]) { in_lis[k] = true; }
|
|
390
|
+
|
|
391
|
+
common_old_order.forEach(function(key,i){
|
|
392
|
+
let old_entry = old_index[key];
|
|
393
|
+
let new_entry = new_index[key];
|
|
394
|
+
let id = old_entry.node.id;
|
|
395
|
+
let type = old_entry.node.type;
|
|
396
|
+
if (!in_lis[i]) { moved.push({ id: id, type: type }); }
|
|
397
|
+
if (old_entry.node.fingerprint !== new_entry.node.fingerprint) {
|
|
398
|
+
let old_fields = old_entry.node.fields;
|
|
399
|
+
let new_fields = new_entry.node.fields;
|
|
400
|
+
let field_names = Array.from(new Set(Object.keys(old_fields).concat(Object.keys(new_fields))));
|
|
401
|
+
let diff_fields = field_names.filter(function(f){ return old_fields[f] !== new_fields[f]; });
|
|
402
|
+
changed.push({ id: id, type: type, fields: diff_fields });
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
// when the llm fucks up the ids or eids, this result is fucked as well. And
|
|
407
|
+
// by fucking up i mean, omitting the ids, or changing them all. Oh well.
|
|
408
|
+
// Better than nothing.
|
|
409
|
+
|
|
410
|
+
let affected = new Set(added.concat(deleted,moved,changed).map(function(e){ return e.type + ':' + e.id; }));
|
|
411
|
+
if (affected.size === 0) {
|
|
412
|
+
return "No changes to the model have been made.";
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// constructing the output
|
|
416
|
+
function join_names(names) {
|
|
417
|
+
if (names.length <= 1) { return names.join(''); }
|
|
418
|
+
if (names.length === 2) { return names[0] + ' and ' + names[1]; }
|
|
419
|
+
return names.slice(0,-1).join(', ') + ' and ' + names[names.length-1];
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function type_word(type, count) {
|
|
423
|
+
if (type === 'task') { return count === 1 ? 'task' : 'tasks'; }
|
|
424
|
+
if (type === 'branch') { return count === 1 ? 'branch' : 'branches'; }
|
|
425
|
+
return count === 1 ? 'gateway' : 'gateways';
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
const categories = ['added','deleted','moved','changed'];
|
|
429
|
+
const lists = { added: added, deleted: deleted, moved: moved, changed: changed };
|
|
430
|
+
|
|
431
|
+
if (affected.size > 3) {
|
|
432
|
+
const action = { added: 'been added', deleted: 'been deleted', moved: 'been moved', changed: 'been changed' };
|
|
433
|
+
function join_oxford(items) {
|
|
434
|
+
if (items.length <= 1) { return items.join(''); }
|
|
435
|
+
if (items.length === 2) { return items[0] + ' and ' + items[1]; }
|
|
436
|
+
return items.slice(0,-1).join(', ') + ', and ' + items[items.length-1];
|
|
437
|
+
}
|
|
438
|
+
let parts = [];
|
|
439
|
+
categories.forEach(function(c){
|
|
440
|
+
let type_counts = ['task','gateway','branch'].map(function(t){
|
|
441
|
+
return { type: t, count: lists[c].filter(function(e){ return e.type === t; }).length };
|
|
442
|
+
}).filter(function(tc){ return tc.count > 0; });
|
|
443
|
+
if (type_counts.length === 0) { return; }
|
|
444
|
+
let pieces = type_counts.map(function(tc){ return tc.count + ' ' + type_word(tc.type, tc.count); });
|
|
445
|
+
let total = type_counts.reduce(function(sum,tc){ return sum + tc.count; }, 0);
|
|
446
|
+
let verb = total === 1 ? 'has' : 'have';
|
|
447
|
+
parts.push(join_oxford(pieces) + ' ' + verb + ' ' + action[c]);
|
|
448
|
+
});
|
|
449
|
+
let text = parts.join(', ') + '.';
|
|
450
|
+
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
451
|
+
} else {
|
|
452
|
+
let sentences = [];
|
|
453
|
+
const action = { added: 'added', deleted: 'deleted', moved: 'moved', changed: 'changed' };
|
|
454
|
+
categories.forEach(function(c){
|
|
455
|
+
['task','gateway','branch'].forEach(function(t){
|
|
456
|
+
let entries = lists[c].filter(function(e){ return e.type === t; });
|
|
457
|
+
if (entries.length === 0) { return; }
|
|
458
|
+
if (c === 'changed' && entries.length === 1) {
|
|
459
|
+
let e = entries[0];
|
|
460
|
+
let subj = e.type === 'task' ? 'Task ' : (e.type === 'branch' ? 'Branch ' : 'Gateway ');
|
|
461
|
+
let field_text;
|
|
462
|
+
if (e.fields.length === 0) {
|
|
463
|
+
field_text = '"parameters"';
|
|
464
|
+
} else {
|
|
465
|
+
field_text = join_names(e.fields.map(function(f){ return '"' + f + '"'; }));
|
|
466
|
+
}
|
|
467
|
+
sentences.push(subj + e.id + ' had its ' + field_text + ' changed.');
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
let names = join_names(entries.map(function(e){ return e.id; }));
|
|
471
|
+
let subj = type_word(t, entries.length);
|
|
472
|
+
subj = subj.charAt(0).toUpperCase() + subj.slice(1) + ' ';
|
|
473
|
+
let verb = entries.length === 1 ? ' has been ' : ' have been ';
|
|
474
|
+
sentences.push(subj + names + verb + action[c] + '.');
|
|
475
|
+
});
|
|
476
|
+
});
|
|
477
|
+
return sentences.join(' ');
|
|
478
|
+
}
|
|
479
|
+
} //}}}
|
|
480
|
+
|
|
152
481
|
function set_cpee_model(cpee_xml,expositions=[]) { //{{{
|
|
482
|
+
let root = $X(cpee_xml).get(0);
|
|
483
|
+
if (root.childElementCount === 0) {
|
|
484
|
+
root.textContent = '';
|
|
485
|
+
}
|
|
486
|
+
root.setAttribute('dir', save['graph_adaptor'] && save['graph_adaptor'].illustrator.lr ? 'lr' : 'td'); // layout direction of the theme
|
|
487
|
+
cpee_xml = new XMLSerializer().serializeToString(root);
|
|
488
|
+
|
|
153
489
|
const form_data = new FormData();
|
|
154
490
|
const blob = new Blob([cpee_xml], { type: "text/xml" });
|
|
155
491
|
form_data.append("dslx", blob);
|
|
@@ -159,42 +495,24 @@ function set_cpee_model(cpee_xml,expositions=[]) { //{{{
|
|
|
159
495
|
form_data.append("exposition", blobi);
|
|
160
496
|
}
|
|
161
497
|
|
|
162
|
-
$.ajax({
|
|
498
|
+
return $.ajax({
|
|
163
499
|
type: "PUT",
|
|
164
500
|
url: url + "/properties/dslx/",
|
|
165
501
|
contentType: false,
|
|
166
502
|
processData: false,
|
|
167
|
-
data: form_data
|
|
503
|
+
data: form_data,
|
|
504
|
+
error: report_model_failure
|
|
168
505
|
});
|
|
169
506
|
} //}}}
|
|
170
507
|
|
|
171
|
-
function set_success(status,success_text) { //{{{
|
|
172
|
-
status.text(success_text);
|
|
173
|
-
status.addClass('success');
|
|
174
|
-
status.removeClass('loading');
|
|
175
|
-
status.removeClass('error');
|
|
176
|
-
} //}}}
|
|
177
|
-
|
|
178
|
-
function set_error(status,error_text) { //{{{
|
|
179
|
-
status.text(error_text);
|
|
180
|
-
status.addClass('error');
|
|
181
|
-
status.removeClass('success');
|
|
182
|
-
status.removeClass('loading');
|
|
183
|
-
} //}}}
|
|
184
|
-
|
|
185
508
|
function empty_model(){ //{{{
|
|
509
|
+
details_leave(false);
|
|
186
510
|
set_cpee_model('<description xmlns="http://cpee.org/ns/description/1.0" xmlns:a="http://cpee.org/ns/annotation/1.0"/>',["Reset Context!"]);
|
|
187
511
|
$('#dat_details').empty();
|
|
188
512
|
} //}}}
|
|
189
|
-
function load_last_generated_model() { //{{{
|
|
190
|
-
set_cpee_model(last_generated_model === undefined ? save['dslx'] : last_generated_model);
|
|
191
|
-
} //}}}
|
|
192
|
-
function load_last_generated_model() { //{{{
|
|
193
|
-
set_cpee_model(last_generated_model === undefined ? save['dslx'] : last_generated_model);
|
|
194
|
-
} //}}}
|
|
195
513
|
|
|
196
514
|
function load_last_model_before_generation() { //{{{
|
|
197
|
-
set_cpee_model(last_model_before_generation === undefined ? save['dslx'] : last_model_before_generation);
|
|
515
|
+
return set_cpee_model(last_model_before_generation === undefined ? save['dslx'] : last_model_before_generation);
|
|
198
516
|
} //}}}
|
|
199
517
|
|
|
200
518
|
function load_file_content(files) { //{{{
|
|
@@ -204,23 +522,26 @@ function load_file_content(files) { //{{{
|
|
|
204
522
|
}
|
|
205
523
|
var reader = new FileReader();
|
|
206
524
|
reader.onload = function(){
|
|
207
|
-
|
|
208
|
-
add_prompt('prompt',reader.result);
|
|
525
|
+
ui.clean();
|
|
526
|
+
add_prompt($('#prompt'),reader.result);
|
|
209
527
|
}
|
|
210
528
|
reader.onerror = function(){ console.log("reader error"); }
|
|
211
529
|
reader.onabort = function(){ console.log("reader abort"); }
|
|
212
530
|
reader.readAsText(files[0]);
|
|
213
531
|
} //}}}
|
|
214
532
|
|
|
215
|
-
function create(
|
|
216
|
-
|
|
533
|
+
function create(prompt,llms,generation,mode) {
|
|
534
|
+
ui.clean();
|
|
217
535
|
|
|
218
536
|
// Imagine I want to implement a smart home system to control the lights in
|
|
219
537
|
// the dining room. Depending on the current lighting conditions, the
|
|
220
538
|
// system would automatically adjust the brightness—either increasing or
|
|
221
539
|
// reducing it as needed—and turn the lights off completely at night.
|
|
222
540
|
|
|
223
|
-
let input = prompt.text();
|
|
541
|
+
let input = prompt.text();
|
|
542
|
+
if (input.trim() === '') { return; }
|
|
543
|
+
prompt.empty();
|
|
544
|
+
ui.input(llms,input);
|
|
224
545
|
let myllm = llms.find(":selected").val();
|
|
225
546
|
let prompt_type = mode.find(":selected").val();
|
|
226
547
|
let gen = generation.find(":selected").val();
|
|
@@ -234,70 +555,88 @@ function create(status,prompt,llms,generation,mode) {
|
|
|
234
555
|
if (gen == 'dataflow') { prompt_type = 'adapt_endpoints'; }
|
|
235
556
|
}
|
|
236
557
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
url: url + "/properties/endpoints/",
|
|
267
|
-
contentType: 'text/xml',
|
|
268
|
-
headers: {
|
|
269
|
-
'Content-ID': 'endpoints',
|
|
270
|
-
'CPEE-Event-Source': myid
|
|
271
|
-
},
|
|
272
|
-
data: data.endpoints
|
|
273
|
-
});
|
|
558
|
+
ui.querying(llms,'analyses user intent');
|
|
559
|
+
|
|
560
|
+
let documents = save['documents'] ? save['documents'].save_object() : {};
|
|
561
|
+
let history_promise = (typeof($('body').attr('current-document-store')) != "undefined" && documents && ('chat_history' in documents))
|
|
562
|
+
? do_parameters_get_document_exec('chat_history',10)
|
|
563
|
+
: $.Deferred().resolve([]).promise();
|
|
564
|
+
|
|
565
|
+
history_promise.then(function(history){
|
|
566
|
+
let messages = JSON.stringify(history);
|
|
567
|
+
call_llm_service_intent(input,myllm,llms,save['dslx'],messages,documents).done((piped) => {
|
|
568
|
+
console.log(piped);
|
|
569
|
+
if (piped !== null) {
|
|
570
|
+
ui.querying(llms,'creates model');
|
|
571
|
+
call_llm_service_model(save['dslx'],piped,myllm,prompt_type).done((data) => {
|
|
572
|
+
let expositions = ["<!-- Input CPEE-Tree -->\n"+data.input_cpee,"# User Input:\n"+data.user_input,"# Used LLM:\n"+data.used_llm,"%% Input Intermediate\n"+data.input_intermediate,"%% Output Intermediate\n"+data.output_intermediate,"<!-- Output CPEE-Tree -->\n"+data.output_cpee];
|
|
573
|
+
if (prompt_type == 'adapt_endpoints') {
|
|
574
|
+
let testset = $X(data.output_cpee); //{{{
|
|
575
|
+
let model = $('> dslx > description',testset);
|
|
576
|
+
let endpoints = $('> endpoints',testset);
|
|
577
|
+
$.ajax({
|
|
578
|
+
type: "PATCH",
|
|
579
|
+
url: url + "/properties/endpoints/",
|
|
580
|
+
contentType: 'text/xml',
|
|
581
|
+
headers: {
|
|
582
|
+
'Content-ID': 'endpoints',
|
|
583
|
+
'CPEE-Event-Source': myid
|
|
584
|
+
},
|
|
585
|
+
data: endpoints.serializePrettyXML()
|
|
586
|
+
});
|
|
274
587
|
|
|
275
|
-
querying_llm_ui(status,llms,'validates dataflow');
|
|
276
|
-
expositions.push("# Dataflow:\n"+data.dataflow);
|
|
277
|
-
call_llm_service_validation($X(data.output_cpee).serializePrettyXML(),myllm).done((data) => {
|
|
278
|
-
// for undo button
|
|
279
588
|
last_model_before_generation = save['dslx'];
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
|
|
589
|
+
set_cpee_model(model.serializePrettyXML(),expositions);
|
|
590
|
+
|
|
591
|
+
ui.success(llms,diff_summary(last_model_before_generation,model)); //}}}
|
|
592
|
+
} else {
|
|
593
|
+
if (gen == "dataflow") {
|
|
594
|
+
ui.querying(llms,'selects endpoints and calculates dataflow'); //{{{
|
|
595
|
+
call_llm_service_dataflow($X(data.output_cpee).serializePrettyXML(),input,myllm).done((data) => {
|
|
596
|
+
let url = $('body').attr('current-instance');
|
|
597
|
+
$.ajax({
|
|
598
|
+
type: "PATCH",
|
|
599
|
+
url: url + "/properties/endpoints/",
|
|
600
|
+
contentType: 'text/xml',
|
|
601
|
+
headers: {
|
|
602
|
+
'Content-ID': 'endpoints',
|
|
603
|
+
'CPEE-Event-Source': myid
|
|
604
|
+
},
|
|
605
|
+
data: data.endpoints
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
ui.querying(llms,'validates dataflow');
|
|
609
|
+
expositions.push("# Dataflow:\n"+data.dataflow);
|
|
610
|
+
call_llm_service_validation($X(data.output_cpee).serializePrettyXML(),myllm).done((data) => {
|
|
611
|
+
// for undo button
|
|
612
|
+
last_model_before_generation = save['dslx'];
|
|
613
|
+
set_cpee_model($X(data.output_cpee).serializePrettyXML(),expositions);
|
|
614
|
+
ui.success(llms,diff_summary(last_model_before_generation,data.output_cpee));
|
|
615
|
+
})
|
|
616
|
+
.fail((xhr) => {
|
|
617
|
+
ui.error(llms,xhr_error(xhr));
|
|
618
|
+
});
|
|
619
|
+
|
|
620
|
+
})
|
|
621
|
+
.fail((xhr) => {
|
|
622
|
+
ui.error(llms,xhr_error(xhr));
|
|
623
|
+
}); //}}}
|
|
624
|
+
} else if (gen == "model") {
|
|
625
|
+
last_model_before_generation = save['dslx']; //{{{
|
|
626
|
+
set_cpee_model(data.output_cpee,expositions);
|
|
627
|
+
ui.success(llms,diff_summary(last_model_before_generation,data.output_cpee)); //}}}
|
|
628
|
+
} else {
|
|
629
|
+
ui.success(llms,"Successfully done nothing");
|
|
630
|
+
}
|
|
631
|
+
}
|
|
285
632
|
})
|
|
286
633
|
.fail((xhr) => {
|
|
287
|
-
|
|
634
|
+
ui.error(llms,xhr_error(xhr));
|
|
288
635
|
});
|
|
289
|
-
} else if (gen == "model") {
|
|
290
|
-
last_model_before_generation = save['dslx'];
|
|
291
|
-
last_generated_model = data.output_cpee;
|
|
292
|
-
set_cpee_model(data.output_cpee,expositions);
|
|
293
|
-
set_success(status,data.status);
|
|
294
|
-
} else {
|
|
295
|
-
set_success(status,"Successfully done nothing");
|
|
296
636
|
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
set_error(status,xhr.responseJSON.error);
|
|
637
|
+
}).fail((xhr) => {
|
|
638
|
+
ui.error(llms,xhr_error(xhr));
|
|
639
|
+
});
|
|
301
640
|
});
|
|
302
641
|
}
|
|
303
642
|
|
|
@@ -309,32 +648,37 @@ $(document).ready(async function() { //{{{
|
|
|
309
648
|
let mode_active = await $.get('css/mode_active.svg', 'xml').then(function(data) { return $(data.documentElement); });
|
|
310
649
|
|
|
311
650
|
$(document).on('keydown','#prompt',function(e){
|
|
312
|
-
|
|
651
|
+
ui.clean();
|
|
313
652
|
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
|
|
314
|
-
create($('#
|
|
653
|
+
create($('#prompt'),$('#llms'),$('#generation'),$('#mode'));
|
|
315
654
|
}
|
|
316
655
|
});
|
|
317
656
|
$(document).on('click','#prompt_submit_button',function(e){
|
|
318
|
-
create($('#
|
|
657
|
+
create($('#prompt'),$('#llms'),$('#generation'),$('#mode'));
|
|
319
658
|
});
|
|
320
659
|
$(document).on('click','#prompt_reset_button',function(e){
|
|
321
|
-
|
|
660
|
+
ui.clean();
|
|
322
661
|
empty_model();
|
|
323
662
|
});
|
|
324
663
|
$(document).on('click','#generate_itext_button',function(e){
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
call_llm_text_service($('#
|
|
664
|
+
ui.clean();
|
|
665
|
+
ui.querying($('#llms'),'thinks');
|
|
666
|
+
call_llm_text_service($('#prompt'),$('#llms'),'file');
|
|
328
667
|
});
|
|
329
668
|
$(document).on('click','#generate_text_button',function(e){
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
call_llm_text_service($('#
|
|
669
|
+
ui.clean();
|
|
670
|
+
ui.querying($('#llms'),'thinks');
|
|
671
|
+
call_llm_text_service($('#prompt'),$('#llms'),'show');
|
|
333
672
|
});
|
|
334
673
|
$(document).on('click','#prompt_undo_button',function(e){
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
674
|
+
ui.clean();
|
|
675
|
+
ui.input($('#llms'),'Undo');
|
|
676
|
+
ui.querying($('#llms'),'thinks');
|
|
677
|
+
load_last_model_before_generation().done(() => {
|
|
678
|
+
ui.success($('#llms'),'Previous model restored.');
|
|
679
|
+
}).fail((xhr) => {
|
|
680
|
+
ui.error($('#llms'),xhr_error(xhr));
|
|
681
|
+
});
|
|
338
682
|
});
|
|
339
683
|
$(document).on('click','#prompt_attach_button',function(e){
|
|
340
684
|
document.getElementById('loadtxt').click();
|
|
@@ -389,4 +733,8 @@ $(document).ready(async function() { //{{{
|
|
|
389
733
|
e.stopPropagation();
|
|
390
734
|
load_file_content(e.originalEvent.dataTransfer.files);
|
|
391
735
|
});
|
|
736
|
+
|
|
737
|
+
document.addEventListener('documents:loaded', function (e) {
|
|
738
|
+
ui.init();
|
|
739
|
+
}, { capture: false, once: true } );
|
|
392
740
|
}); //}}}
|