cpee 2.1.139 → 2.1.141

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.
data/cockpit/js/llm.js CHANGED
@@ -10,6 +10,29 @@ function xhr_error(xhr) { //{{{
10
10
  }
11
11
  return xhr.statusText;
12
12
  } //}}}
13
+ function create_interaction_uuid() { //{{{
14
+ return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16));
15
+ } //}}}
16
+ function no_tokens() { //{{{
17
+ return { input: 0, output: 0 };
18
+ } //}}}
19
+ function used_tokens(xhr) { //{{{
20
+ let t = no_tokens();
21
+ let h = xhr && xhr.getResponseHeader ? xhr.getResponseHeader('CPEE-LLM-Used-Tokens') : null;
22
+ if (h) {
23
+ let i = h.match(/input=(\d+)/);
24
+ let o = h.match(/output=(\d+)/);
25
+ if (i) { t.input = parseInt(i[1]); }
26
+ if (o) { t.output = parseInt(o[1]); }
27
+ }
28
+ return t;
29
+ } //}}}
30
+ function add_tokens(a,b) { //{{{
31
+ return { input: a.input + b.input, output: a.output + b.output };
32
+ } //}}}
33
+ function with_tokens(text,tokens) { //{{{
34
+ return text + ' (' + tokens.input + ' ↑TK, ' + tokens.output + ' ↓TK)';
35
+ } //}}}
13
36
 
14
37
  function add_prompt(input,content) { //{{{
15
38
  const range = document.createRange();
@@ -20,7 +43,7 @@ function add_prompt(input,content) { //{{{
20
43
  document.execCommand('insertText', false, content);
21
44
  } //}}}
22
45
 
23
- function call_llm_service_intent(input, llm, llms, dslx, messages, documents, depth=0) { //{{{
46
+ function call_llm_service_intent(input, llm, llms, dslx, messages, documents, interaction, depth=0, tokens=no_tokens()) { //{{{
24
47
  let def = new $.Deferred();
25
48
 
26
49
  (async () => {
@@ -29,7 +52,7 @@ function call_llm_service_intent(input, llm, llms, dslx, messages, documents, de
29
52
  intent_form.append("user_input", new Blob([input], { type: "text/plain" }));
30
53
  intent_form.append("llm", new Blob([llm], { type: "text/plain" }));
31
54
 
32
- let intent = await $.ajax({
55
+ let intent_req = $.ajax({
33
56
  url: $('body').attr('current-llm-service') + '/intent/',
34
57
  data: intent_form,
35
58
  contentType: false,
@@ -37,17 +60,28 @@ function call_llm_service_intent(input, llm, llms, dslx, messages, documents, de
37
60
  cache: false,
38
61
  method: 'POST'
39
62
  });
63
+ let intent;
64
+ try {
65
+ intent = await intent_req;
66
+ tokens = add_tokens(tokens,used_tokens(intent_req));
67
+ send_expositions(interaction,[[{ 'type': 'Intent Handling', 'lifecycle': 'result', 'artefact': 'Tokens', 'llm': llm }, JSON.stringify(used_tokens(intent_req))]]);
68
+ } catch (xhr) {
69
+ tokens = add_tokens(tokens,used_tokens(xhr));
70
+ send_expositions(interaction,[[{ 'type': 'Intent Handling', 'lifecycle': 'failed', 'artefact': 'Tokens', 'llm': llm }, JSON.stringify(used_tokens(xhr))]]);
71
+ throw xhr;
72
+ }
40
73
 
41
74
  if (intent === null) {
42
75
  // 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);
76
+ ui.success(llms,with_tokens("Your request seems to be not about process modelling (or anything covered by the installed plugins).",tokens));
77
+ send_expositions(interaction,[[{ 'type': 'Intent Handling', 'lifecycle': 'denied', 'artefact': 'Message', 'llm': llm }, "Request denied. Only process modelling allowed."]]);
78
+ def.resolve(null,tokens);
45
79
  return;
46
80
  }
47
81
 
48
82
  if (typeof intent === 'object' && Object.keys(intent).length === 0) {
49
83
  // no specific plugin matched: proceed normally with the original input
50
- def.resolve(input);
84
+ def.resolve(input,tokens);
51
85
  return;
52
86
  }
53
87
 
@@ -66,19 +100,27 @@ function call_llm_service_intent(input, llm, llms, dslx, messages, documents, de
66
100
 
67
101
  let response;
68
102
  console.log(intent.url);
103
+ let plugin_req = $.ajax({
104
+ url: intent.url,
105
+ data: call_form,
106
+ cache: false,
107
+ contentType: false,
108
+ processData: false,
109
+ method: 'PUT'
110
+ });
69
111
  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
- });
112
+ response = await plugin_req;
113
+ tokens = add_tokens(tokens,used_tokens(plugin_req));
114
+ send_expositions(interaction,[[{ 'type': 'Intent Handling', 'lifecycle': 'result', 'artefact': 'Tokens', 'llm': llm }, JSON.stringify(used_tokens(plugin_req))]]);
78
115
  } catch (xhr) {
116
+ tokens = add_tokens(tokens,used_tokens(xhr));
79
117
  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);
118
+ ui.error(llms,with_tokens("The intent plugin \'" + trimmed_url.substr(trimmed_url.lastIndexOf('/') + 1) + "\' is not working properly.",tokens));
119
+ send_expositions(interaction,[
120
+ [{ 'type': 'Intent Handling', 'lifecycle': 'failed', 'artefact': 'Tokens', 'llm': llm }, JSON.stringify(used_tokens(xhr))],
121
+ [{ 'type': 'Intent Handling', 'lifecycle': 'failed', 'artefact': 'Message', 'llm': llm }, "The intent plugin \'" + trimmed_url.substr(trimmed_url.lastIndexOf('/') + 1) + "\' is not working properly."]
122
+ ]);
123
+ def.resolve(null,tokens);
82
124
  return;
83
125
  }
84
126
 
@@ -97,21 +139,23 @@ function call_llm_service_intent(input, llm, llms, dslx, messages, documents, de
97
139
  }
98
140
 
99
141
  if (intent.output == 'chat') {
100
- ui.success(llms,filled_output);
101
- def.resolve(null);
142
+ ui.success(llms,with_tokens(filled_output,tokens));
143
+ send_expositions(interaction,[[{ 'type': 'Intent Handling', 'lifecycle': 'result', 'artefact': 'LLM Text', 'llm': llm }, filled_output]]);
144
+ def.resolve(null,tokens);
102
145
  } else if (intent.output == 'reintent' && filled_output !== input && depth < 3) {
146
+ send_expositions(interaction,[[{ 'type': 'Intent Handling', 'lifecycle': 'intermediate', 'artefact': 'LLM Text', 'llm': llm }, filled_output]]);
103
147
  // repeat the process of looking for a plugin/intent, using the filled output as the new input
104
148
  // (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);
149
+ call_llm_service_intent(filled_output,llm,llms,dslx,messages,documents,interaction,depth + 1,tokens).done((result,rtokens) => {
150
+ def.resolve(result,rtokens);
151
+ }).fail((xhr,rtokens) => {
152
+ def.reject(xhr,rtokens);
109
153
  });
110
154
  } else {
111
- def.resolve(filled_output);
155
+ def.resolve(filled_output,tokens);
112
156
  }
113
157
  } catch (xhr) {
114
- def.reject(xhr);
158
+ def.reject(xhr,tokens);
115
159
  }
116
160
  })();
117
161
 
@@ -142,8 +186,8 @@ function call_llm_service_model(dslx,input,llm,prompt_type) { //{{{
142
186
  contentType: false,
143
187
  processData: false,
144
188
  method: 'POST',
145
- success: function(data){
146
- def.resolve(data);
189
+ success: function(data, status, xhr){
190
+ def.resolve(data, used_tokens(xhr));
147
191
  },
148
192
  error: function(xhr, status, data) {
149
193
  def.reject(xhr);
@@ -170,8 +214,8 @@ function call_llm_service_dataflow(model,input,llm) { //{{{
170
214
  contentType: false,
171
215
  processData: false,
172
216
  method: 'POST',
173
- success: function(data){
174
- def.resolve(data);
217
+ success: function(data, status, xhr){
218
+ def.resolve(data, used_tokens(xhr));
175
219
  },
176
220
  error: function(xhr, status, data) {
177
221
  def.reject(xhr);
@@ -196,8 +240,8 @@ function call_llm_service_validation(model,llm) { //{{{
196
240
  contentType: false,
197
241
  processData: false,
198
242
  method: 'POST',
199
- success: function(data){
200
- def.resolve(data);
243
+ success: function(data, status, xhr){
244
+ def.resolve(data, used_tokens(xhr));
201
245
  },
202
246
  error: function(xhr, status, data) {
203
247
  def.reject(xhr);
@@ -207,7 +251,7 @@ function call_llm_service_validation(model,llm) { //{{{
207
251
  return def.promise();
208
252
  } //}}}
209
253
 
210
- function call_llm_text_service(prompt,llms,action) { //{{{
254
+ function call_llm_text_service(prompt,llms,action,interaction) { //{{{
211
255
  let myllm = llms.find(":selected").val();
212
256
  if (myllm === undefined){ myllm = default_llm; }
213
257
  const info = save.attributes_raw.info;
@@ -224,7 +268,8 @@ function call_llm_text_service(prompt,llms,action) { //{{{
224
268
  contentType: false,
225
269
  processData: false,
226
270
  method: 'POST',
227
- success: function(data){
271
+ success: function(data, stat, xhr){
272
+ let tokens = used_tokens(xhr);
228
273
  if (action=="show"){
229
274
  add_prompt(prompt,data["output_text"]);
230
275
  } else if (action=="file") {
@@ -235,10 +280,19 @@ function call_llm_text_service(prompt,llms,action) { //{{{
235
280
  link.href = dataUri;
236
281
  link.click();
237
282
  };
238
- ui.success(llms,data.status);
283
+ ui.success(llms,with_tokens(data.status,tokens));
284
+ send_expositions(interaction,[
285
+ [{ 'type': 'LLM Text', 'lifecycle': 'result', 'artefact': 'Tokens', 'llm': myllm }, JSON.stringify(tokens)],
286
+ [{ 'type': 'LLM Text', 'lifecycle': 'result', 'artefact': 'Message', 'llm': myllm }, data.status]
287
+ ]);
239
288
  },
240
289
  error: function(xhr, stat, data) {
241
- ui.error(llms,xhr_error(xhr));
290
+ let tokens = used_tokens(xhr);
291
+ ui.error(llms,with_tokens(xhr_error(xhr),tokens));
292
+ send_expositions(interaction,[
293
+ [{ 'type': 'LLM Text', 'lifecycle': 'failed', 'artefact': 'Tokens', 'llm': myllm }, JSON.stringify(tokens)],
294
+ [{ 'type': 'LLM Text', 'lifecycle': 'failed', 'artefact': 'Message', 'llm': myllm }, xhr_error(xhr)]
295
+ ]);
242
296
  }
243
297
  });
244
298
  } //}}}
@@ -478,7 +532,7 @@ function diff_summary(model_old, model_new) { //{{{
478
532
  }
479
533
  } //}}}
480
534
 
481
- function set_cpee_model(cpee_xml,expositions=[]) { //{{{
535
+ function set_cpee_model(cpee_xml) { //{{{
482
536
  let root = $X(cpee_xml).get(0);
483
537
  if (root.childElementCount === 0) {
484
538
  root.textContent = '';
@@ -490,11 +544,6 @@ function set_cpee_model(cpee_xml,expositions=[]) { //{{{
490
544
  const blob = new Blob([cpee_xml], { type: "text/xml" });
491
545
  form_data.append("dslx", blob);
492
546
 
493
- for (const x of expositions) {
494
- const blobi = new Blob([x], { type: "text/plain" });
495
- form_data.append("exposition", blobi);
496
- }
497
-
498
547
  return $.ajax({
499
548
  type: "PUT",
500
549
  url: url + "/properties/dslx/",
@@ -505,9 +554,28 @@ function set_cpee_model(cpee_xml,expositions=[]) { //{{{
505
554
  });
506
555
  } //}}}
507
556
 
557
+ function send_expositions(interaction,expositions) { //{{{
558
+ if (expositions.length == 0) { return; }
559
+ const form_data = new FormData();
560
+ // 18510501 dont change status
561
+ form_data.append("status", new Blob(['<status xmlns="http://cpee.org/ns/properties/2.0"><id>18510501</id><message></message></status>'], { type: "text/xml" }));
562
+ for (const [info,body] of expositions) {
563
+ form_data.append("exposition_info", new Blob([JSON.stringify(Object.assign({ 'interaction': interaction }, info))], { type: "application/json" }));
564
+ form_data.append("exposition_body", new Blob([body === undefined || body === null ? '' : String(body)], { type: "text/plain" }));
565
+ }
566
+ return $.ajax({
567
+ type: "PUT",
568
+ url: url + "/properties/status/",
569
+ contentType: false,
570
+ processData: false,
571
+ data: form_data
572
+ });
573
+ } //}}}
574
+
508
575
  function empty_model(){ //{{{
509
576
  details_leave(false);
510
- set_cpee_model('<description xmlns="http://cpee.org/ns/description/1.0" xmlns:a="http://cpee.org/ns/annotation/1.0"/>',["Reset Context!"]);
577
+ send_expositions(create_interaction_uuid(),[[{ 'type': 'Reset', 'lifecycle': 'result', 'artefact': 'Message' },'Everything empty.']]);
578
+ set_cpee_model('<description xmlns="http://cpee.org/ns/description/1.0" xmlns:a="http://cpee.org/ns/annotation/1.0"/>');
511
579
  $('#dat_details').empty();
512
580
  } //}}}
513
581
 
@@ -555,6 +623,12 @@ function create(prompt,llms,generation,mode) {
555
623
  if (gen == 'dataflow') { prompt_type = 'adapt_endpoints'; }
556
624
  }
557
625
 
626
+ let tokens = no_tokens();
627
+ let interaction = create_interaction_uuid();
628
+ send_expositions(interaction,[
629
+ [{ 'type': 'Intent Handling', 'lifecycle': 'start', 'artefact': 'Message', 'llm': myllm }, 'User intent analysis'],
630
+ [{ 'type': 'Intent Handling', 'lifecycle': 'input', 'artefact': 'User Input' }, input]
631
+ ]);
558
632
  ui.querying(llms,'analyses user intent');
559
633
 
560
634
  let documents = save['documents'] ? save['documents'].save_object() : {};
@@ -564,16 +638,26 @@ function create(prompt,llms,generation,mode) {
564
638
 
565
639
  history_promise.then(function(history){
566
640
  let messages = JSON.stringify(history);
567
- call_llm_service_intent(input,myllm,llms,save['dslx'],messages,documents).done((piped) => {
568
- console.log(piped);
641
+ call_llm_service_intent(input,myllm,llms,save['dslx'],messages,documents,interaction).done((piped,itokens) => {
642
+ tokens = itokens;
569
643
  if (piped !== null) {
570
644
  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];
645
+ send_expositions(interaction,[[{ 'type': 'Model Generation', 'lifecycle': 'start', 'artefact': 'Message', 'llm': myllm }, (prompt_type.startsWith('generate_') ? 'Create' : 'Adapt') + ' model']]);
646
+ call_llm_service_model(save['dslx'],piped,myllm,prompt_type).done((data,mtokens) => {
647
+ tokens = add_tokens(tokens,mtokens);
648
+ send_expositions(interaction,[
649
+ [{ 'type': 'Model Generation', 'lifecycle': 'input', 'artefact': 'CPEE Tree' }, data.input_cpee],
650
+ [{ 'type': 'Model Generation', 'lifecycle': 'input', 'artefact': 'User Input' }, data.user_input],
651
+ [{ 'type': 'Model Generation', 'lifecycle': 'input', 'artefact': 'Mermaid' }, data.input_intermediate],
652
+ [{ 'type': 'Model Generation', 'lifecycle': 'result', 'artefact': 'Tokens', 'llm': data.used_llm }, JSON.stringify(mtokens)],
653
+ [{ 'type': 'Model Generation', 'lifecycle': 'result', 'artefact': 'Mermaid', 'llm': data.used_llm }, data.output_intermediate],
654
+ [{ 'type': 'Model Generation', 'lifecycle': 'result', 'artefact': 'CPEE Tree', 'llm': data.used_llm }, prompt_type == 'adapt_endpoints' ? $('> dslx > description',$X(data.output_cpee)).serializePrettyXML() : data.output_cpee]
655
+ ]);
573
656
  if (prompt_type == 'adapt_endpoints') {
574
657
  let testset = $X(data.output_cpee); //{{{
575
658
  let model = $('> dslx > description',testset);
576
659
  let endpoints = $('> endpoints',testset);
660
+ send_expositions(interaction,[[{ 'type': 'Model Generation', 'lifecycle': 'result', 'artefact': 'Endpoints', 'llm': data.used_llm }, endpoints.serializePrettyXML()]]);
577
661
  $.ajax({
578
662
  type: "PATCH",
579
663
  url: url + "/properties/endpoints/",
@@ -586,13 +670,16 @@ function create(prompt,llms,generation,mode) {
586
670
  });
587
671
 
588
672
  last_model_before_generation = save['dslx'];
589
- set_cpee_model(model.serializePrettyXML(),expositions);
673
+ set_cpee_model(model.serializePrettyXML());
590
674
 
591
- ui.success(llms,diff_summary(last_model_before_generation,model)); //}}}
675
+ let summary = diff_summary(last_model_before_generation,model);
676
+ ui.success(llms,with_tokens(summary,tokens));
592
677
  } else {
593
678
  if (gen == "dataflow") {
594
679
  ui.querying(llms,'selects endpoints and calculates dataflow'); //{{{
595
- call_llm_service_dataflow($X(data.output_cpee).serializePrettyXML(),input,myllm).done((data) => {
680
+ send_expositions(interaction,[[{ 'type': 'Dataflow', 'lifecycle': 'start', 'artefact': 'Message', 'llm': myllm }, 'Select endpoints and calculate dataflow']]);
681
+ call_llm_service_dataflow($X(data.output_cpee).serializePrettyXML(),input,myllm).done((data,dtokens) => {
682
+ tokens = add_tokens(tokens,dtokens);
596
683
  let url = $('body').attr('current-instance');
597
684
  $.ajax({
598
685
  type: "PATCH",
@@ -606,36 +693,68 @@ function create(prompt,llms,generation,mode) {
606
693
  });
607
694
 
608
695
  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) => {
696
+ send_expositions(interaction,[
697
+ [{ 'type': 'Dataflow', 'lifecycle': 'result', 'artefact': 'Tokens', 'llm': data.used_llm }, JSON.stringify(dtokens)],
698
+ [{ 'type': 'Dataflow', 'lifecycle': 'result', 'artefact': 'LLM Text', 'llm': data.used_llm }, data.dataflow],
699
+ [{ 'type': 'Dataflow', 'lifecycle': 'result', 'artefact': 'Endpoints', 'llm': data.used_llm }, data.endpoints],
700
+ [{ 'type': 'Dataflow', 'lifecycle': 'intermediate', 'artefact': 'CPEE Tree', 'llm': data.used_llm }, $X(data.output_cpee).serializePrettyXML()],
701
+ [{ 'type': 'Validation', 'lifecycle': 'start', 'artefact': 'Message', 'llm': myllm }, 'Validate dataflow']
702
+ ]);
703
+ call_llm_service_validation($X(data.output_cpee).serializePrettyXML(),myllm).done((data,vtokens) => {
704
+ tokens = add_tokens(tokens,vtokens);
611
705
  // for undo button
612
706
  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));
707
+ set_cpee_model($X(data.output_cpee).serializePrettyXML());
708
+ let summary = diff_summary(last_model_before_generation,data.output_cpee);
709
+ ui.success(llms,with_tokens(summary,tokens));
710
+ send_expositions(interaction,[
711
+ [{ 'type': 'Validation', 'lifecycle': 'result', 'artefact': 'Tokens', 'llm': myllm }, JSON.stringify(vtokens)],
712
+ [{ 'type': 'Validation', 'lifecycle': 'result', 'artefact': 'CPEE Tree', 'llm': myllm }, $X(data.output_cpee).serializePrettyXML()],
713
+ ]);
615
714
  })
616
715
  .fail((xhr) => {
617
- ui.error(llms,xhr_error(xhr));
716
+ tokens = add_tokens(tokens,used_tokens(xhr));
717
+ ui.error(llms,with_tokens(xhr_error(xhr),tokens));
718
+ send_expositions(interaction,[
719
+ [{ 'type': 'Validation', 'lifecycle': 'failed', 'artefact': 'Tokens', 'llm': myllm }, JSON.stringify(used_tokens(xhr))],
720
+ [{ 'type': 'Validation', 'lifecycle': 'failed', 'artefact': 'Message', 'llm': myllm }, xhr_error(xhr)]
721
+ ]);
618
722
  });
619
723
 
620
724
  })
621
725
  .fail((xhr) => {
622
- ui.error(llms,xhr_error(xhr));
726
+ tokens = add_tokens(tokens,used_tokens(xhr));
727
+ ui.error(llms,with_tokens(xhr_error(xhr),tokens));
728
+ send_expositions(interaction,[
729
+ [{ 'type': 'Dataflow', 'lifecycle': 'failed', 'artefact': 'Tokens', 'llm': myllm }, JSON.stringify(used_tokens(xhr))],
730
+ [{ 'type': 'Dataflow', 'lifecycle': 'failed', 'artefact': 'Message', 'llm': myllm }, xhr_error(xhr)]
731
+ ]);
623
732
  }); //}}}
624
733
  } else if (gen == "model") {
625
734
  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)); //}}}
735
+ set_cpee_model(data.output_cpee);
736
+ let summary = diff_summary(last_model_before_generation,data.output_cpee);
737
+ ui.success(llms,with_tokens(summary,tokens));
738
+ send_expositions(interaction,[[{ 'type': 'Model Generation', 'lifecycle': 'result', 'artefact': 'Change Summary' }, summary]]); //}}}
628
739
  } else {
629
- ui.success(llms,"Successfully done nothing");
740
+ ui.success(llms,with_tokens("Successfully done nothing",tokens));
741
+ send_expositions(interaction,[[{ 'type': 'Model Generation', 'lifecycle': 'result', 'artefact': 'Message' }, "Successfully done nothing"]]);
630
742
  }
631
743
  }
632
744
  })
633
745
  .fail((xhr) => {
634
- ui.error(llms,xhr_error(xhr));
746
+ tokens = add_tokens(tokens,used_tokens(xhr));
747
+ ui.error(llms,with_tokens(xhr_error(xhr),tokens));
748
+ send_expositions(interaction,[
749
+ [{ 'type': 'Model Generation', 'lifecycle': 'failed', 'artefact': 'Tokens', 'llm': myllm }, JSON.stringify(used_tokens(xhr))],
750
+ [{ 'type': 'Model Generation', 'lifecycle': 'failed', 'artefact': 'Message', 'llm': myllm }, xhr_error(xhr)]
751
+ ]);
635
752
  });
636
753
  }
637
- }).fail((xhr) => {
638
- ui.error(llms,xhr_error(xhr));
754
+ }).fail((xhr,itokens) => {
755
+ tokens = itokens || no_tokens();
756
+ ui.error(llms,with_tokens(xhr_error(xhr),tokens));
757
+ send_expositions(interaction,[[{ 'type': 'Intent Handling', 'lifecycle': 'failed', 'artefact': 'Message', 'llm': myllm }, xhr_error(xhr)]]);
639
758
  });
640
759
  });
641
760
  }
@@ -663,21 +782,29 @@ $(document).ready(async function() { //{{{
663
782
  $(document).on('click','#generate_itext_button',function(e){
664
783
  ui.clean();
665
784
  ui.querying($('#llms'),'thinks');
666
- call_llm_text_service($('#prompt'),$('#llms'),'file');
785
+ let interaction = create_interaction_uuid();
786
+ send_expositions(interaction,[[{ 'type': 'LLM Text', 'lifecycle': 'start', 'artefact': 'Message', 'llm': $('#llms').find(":selected").val() || default_llm }, 'Create text description of the CPEE-Tree (file)']]);
787
+ call_llm_text_service($('#prompt'),$('#llms'),'file',interaction);
667
788
  });
668
789
  $(document).on('click','#generate_text_button',function(e){
669
790
  ui.clean();
670
791
  ui.querying($('#llms'),'thinks');
671
- call_llm_text_service($('#prompt'),$('#llms'),'show');
792
+ let interaction = create_interaction_uuid();
793
+ send_expositions(interaction,[[{ 'type': 'LLM Text', 'lifecycle': 'start', 'artefact': 'Message', 'llm': $('#llms').find(":selected").val() || default_llm }, 'Create text description of the CPEE-Tree (prompt)']]);
794
+ call_llm_text_service($('#prompt'),$('#llms'),'show',interaction);
672
795
  });
673
796
  $(document).on('click','#prompt_undo_button',function(e){
674
797
  ui.clean();
675
798
  ui.input($('#llms'),'Undo');
676
799
  ui.querying($('#llms'),'thinks');
800
+ let interaction = create_interaction_uuid();
801
+ send_expositions(interaction,[[{ 'type': 'Undo', 'lifecycle': 'start', 'artefact': 'Message' }, 'Restore previous CPEE-Tree']]);
677
802
  load_last_model_before_generation().done(() => {
678
803
  ui.success($('#llms'),'Previous model restored.');
804
+ send_expositions(interaction,[[{ 'type': 'Undo', 'lifecycle': 'result', 'artefact': 'Message' }, 'Previous CPEE-Tree restored.']]);
679
805
  }).fail((xhr) => {
680
806
  ui.error($('#llms'),xhr_error(xhr));
807
+ send_expositions(interaction,[[{ 'type': 'Undo', 'lifecycle': 'failed', 'artefact': 'Message' }, xhr_error(xhr)]]);
681
808
  });
682
809
  });
683
810
  $(document).on('click','#prompt_attach_button',function(e){
@@ -10,6 +10,7 @@
10
10
  <from>Vienna</from>
11
11
  <to>Prague</to>
12
12
  </dataelements>
13
+ <documents/>
13
14
  <endpoints>
14
15
  <bookAir>https://cpee.org/services/airline.php</bookAir>
15
16
  <user>https-post://cpee.org/services/timeout-user.php</user>
@@ -22,11 +23,11 @@
22
23
  <receive>https-get://cpee.org/ing/correlators/message/receive/</receive>
23
24
  </endpoints>
24
25
  <attributes>
26
+ <info>Coopis 2010</info>
25
27
  <guarded>none</guarded>
26
28
  <modeltype>CPEE</modeltype>
27
29
  <theme>extended</theme>
28
30
  <guarded_id/>
29
- <info>Coopis 2010</info>
30
31
  <creator>Christine Ashcreek</creator>
31
32
  <author>Christine Ashcreek</author>
32
33
  <design_stage>development</design_stage>
@@ -38,7 +39,8 @@
38
39
  <description xmlns="http://cpee.org/ns/description/1.0">
39
40
  <call id="a1" endpoint="bookAir">
40
41
  <parameters>
41
- <label>Book Airline 1</label>
42
+ <label>Book Airline 12</label>
43
+ <color/>
42
44
  <method>:post</method>
43
45
  <arguments>
44
46
  <from>!data.from</from>
@@ -47,6 +49,7 @@
47
49
  </arguments>
48
50
  </parameters>
49
51
  <code>
52
+ <signal>false</signal>
50
53
  <prepare/>
51
54
  <finalize output="result">data.airline = result.value('id')
52
55
  data.costs += result.value('costs').to_f
@@ -55,6 +58,11 @@ status.update 1, 'Hotel'</finalize>
55
58
  <rescue output="result"/>
56
59
  </code>
57
60
  <annotations>
61
+ <_generic/>
62
+ <_logging_behavior>
63
+ <_exclude>false</_exclude>
64
+ <_include>false</_include>
65
+ </_logging_behavior>
58
66
  <_timing>
59
67
  <_timing_weight/>
60
68
  <_timing_avg/>
@@ -5,6 +5,8 @@ WFAdaptorManifestation = class extends WFAdaptorManifestationBase {
5
5
  this.rotated_labels = false;
6
6
  this.lr = true;
7
7
  this.wellformed_pre_test = true;
8
+ this.elements.alternative.illustrator.noindent = true;
9
+ this.elements.parallel_branch.illustrator.noindent = true;
8
10
  this.elements.loop.illustrator.resolve_symbol = function(node) {
9
11
  return $(node).attr('mode') == 'pre_test' ? 'loop_tail_pre' : 'loop_tail'; // pre_test loops look like post_test loops, but reversed
10
12
  };
data/cpee.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cpee"
3
- s.version = "2.1.139"
3
+ s.version = "2.1.141"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0-or-later"
6
6
  s.summary = "The cloud process execution engine (cpee.org). If you just need workflow execution, without a rest service exposing it, then use WEEL."