cpee 2.1.140 → 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,18 +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
- send_expositions([[{ 'type': 'Intent Handling', 'lifecycle': 'denied', 'artefact': 'Message', 'llm': llm }, "Request denied. Only process modelling allowed."]]);
45
- 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);
46
79
  return;
47
80
  }
48
81
 
49
82
  if (typeof intent === 'object' && Object.keys(intent).length === 0) {
50
83
  // no specific plugin matched: proceed normally with the original input
51
- def.resolve(input);
84
+ def.resolve(input,tokens);
52
85
  return;
53
86
  }
54
87
 
@@ -67,20 +100,27 @@ function call_llm_service_intent(input, llm, llms, dslx, messages, documents, de
67
100
 
68
101
  let response;
69
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
+ });
70
111
  try {
71
- response = await $.ajax({
72
- url: intent.url,
73
- data: call_form,
74
- cache: false,
75
- contentType: false,
76
- processData: false,
77
- method: 'PUT'
78
- });
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))]]);
79
115
  } catch (xhr) {
116
+ tokens = add_tokens(tokens,used_tokens(xhr));
80
117
  let trimmed_url = intent.url.replace(/\/+$/, '');
81
- ui.error(llms,"The intent plugin \'" + trimmed_url.substr(trimmed_url.lastIndexOf('/') + 1) + "\' is not working properly.");
82
- send_expositions([[{ 'type': 'Intent Handling', 'lifecycle': 'failed', 'artefact': 'Message', 'llm': llm }, "The intent plugin \'" + trimmed_url.substr(trimmed_url.lastIndexOf('/') + 1) + "\' is not working properly."]]);
83
- 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);
84
124
  return;
85
125
  }
86
126
 
@@ -99,23 +139,23 @@ function call_llm_service_intent(input, llm, llms, dslx, messages, documents, de
99
139
  }
100
140
 
101
141
  if (intent.output == 'chat') {
102
- ui.success(llms,filled_output);
103
- send_expositions([[{ 'type': 'Intent Handling', 'lifecycle': 'result', 'artefact': 'LLM Text', 'llm': llm }, filled_output]]);
104
- 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);
105
145
  } else if (intent.output == 'reintent' && filled_output !== input && depth < 3) {
106
- send_expositions([[{ 'type': 'Intent Handling', 'lifecycle': 'intermediate', 'artefact': 'LLM Text', 'llm': llm }, filled_output]]);
146
+ send_expositions(interaction,[[{ 'type': 'Intent Handling', 'lifecycle': 'intermediate', 'artefact': 'LLM Text', 'llm': llm }, filled_output]]);
107
147
  // repeat the process of looking for a plugin/intent, using the filled output as the new input
108
148
  // (at most 3 times, to avoid endless plugin loops)
109
- call_llm_service_intent(filled_output,llm,llms,dslx,messages,documents,depth + 1).done((result) => {
110
- def.resolve(result);
111
- }).fail((xhr) => {
112
- 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);
113
153
  });
114
154
  } else {
115
- def.resolve(filled_output);
155
+ def.resolve(filled_output,tokens);
116
156
  }
117
157
  } catch (xhr) {
118
- def.reject(xhr);
158
+ def.reject(xhr,tokens);
119
159
  }
120
160
  })();
121
161
 
@@ -146,8 +186,8 @@ function call_llm_service_model(dslx,input,llm,prompt_type) { //{{{
146
186
  contentType: false,
147
187
  processData: false,
148
188
  method: 'POST',
149
- success: function(data){
150
- def.resolve(data);
189
+ success: function(data, status, xhr){
190
+ def.resolve(data, used_tokens(xhr));
151
191
  },
152
192
  error: function(xhr, status, data) {
153
193
  def.reject(xhr);
@@ -174,8 +214,8 @@ function call_llm_service_dataflow(model,input,llm) { //{{{
174
214
  contentType: false,
175
215
  processData: false,
176
216
  method: 'POST',
177
- success: function(data){
178
- def.resolve(data);
217
+ success: function(data, status, xhr){
218
+ def.resolve(data, used_tokens(xhr));
179
219
  },
180
220
  error: function(xhr, status, data) {
181
221
  def.reject(xhr);
@@ -200,8 +240,8 @@ function call_llm_service_validation(model,llm) { //{{{
200
240
  contentType: false,
201
241
  processData: false,
202
242
  method: 'POST',
203
- success: function(data){
204
- def.resolve(data);
243
+ success: function(data, status, xhr){
244
+ def.resolve(data, used_tokens(xhr));
205
245
  },
206
246
  error: function(xhr, status, data) {
207
247
  def.reject(xhr);
@@ -211,7 +251,7 @@ function call_llm_service_validation(model,llm) { //{{{
211
251
  return def.promise();
212
252
  } //}}}
213
253
 
214
- function call_llm_text_service(prompt,llms,action) { //{{{
254
+ function call_llm_text_service(prompt,llms,action,interaction) { //{{{
215
255
  let myllm = llms.find(":selected").val();
216
256
  if (myllm === undefined){ myllm = default_llm; }
217
257
  const info = save.attributes_raw.info;
@@ -228,7 +268,8 @@ function call_llm_text_service(prompt,llms,action) { //{{{
228
268
  contentType: false,
229
269
  processData: false,
230
270
  method: 'POST',
231
- success: function(data){
271
+ success: function(data, stat, xhr){
272
+ let tokens = used_tokens(xhr);
232
273
  if (action=="show"){
233
274
  add_prompt(prompt,data["output_text"]);
234
275
  } else if (action=="file") {
@@ -239,12 +280,19 @@ function call_llm_text_service(prompt,llms,action) { //{{{
239
280
  link.href = dataUri;
240
281
  link.click();
241
282
  };
242
- ui.success(llms,data.status);
243
- send_expositions([[{ 'type': 'LLM Text', 'lifecycle': 'result', 'artefact': 'Message', 'llm': myllm }, 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
+ ]);
244
288
  },
245
289
  error: function(xhr, stat, data) {
246
- ui.error(llms,xhr_error(xhr));
247
- send_expositions([[{ 'type': 'LLM Text', 'lifecycle': 'failed', 'artefact': 'Message', 'llm': myllm }, 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
+ ]);
248
296
  }
249
297
  });
250
298
  } //}}}
@@ -506,13 +554,13 @@ function set_cpee_model(cpee_xml) { //{{{
506
554
  });
507
555
  } //}}}
508
556
 
509
- function send_expositions(expositions) { // [[info,body],...], info is an object, e.g. { 'type': 'Dataflow' } {{{
557
+ function send_expositions(interaction,expositions) { //{{{
510
558
  if (expositions.length == 0) { return; }
511
559
  const form_data = new FormData();
512
560
  // 18510501 dont change status
513
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" }));
514
562
  for (const [info,body] of expositions) {
515
- form_data.append("exposition_info", new Blob([JSON.stringify(info)], { type: "application/json" }));
563
+ form_data.append("exposition_info", new Blob([JSON.stringify(Object.assign({ 'interaction': interaction }, info))], { type: "application/json" }));
516
564
  form_data.append("exposition_body", new Blob([body === undefined || body === null ? '' : String(body)], { type: "text/plain" }));
517
565
  }
518
566
  return $.ajax({
@@ -526,7 +574,7 @@ function send_expositions(expositions) { // [[info,body],...], info is an object
526
574
 
527
575
  function empty_model(){ //{{{
528
576
  details_leave(false);
529
- send_expositions([[{ 'type': 'Reset', 'lifecycle': 'result', 'artefact': 'Message' },'Everything empty.']]);
577
+ send_expositions(create_interaction_uuid(),[[{ 'type': 'Reset', 'lifecycle': 'result', 'artefact': 'Message' },'Everything empty.']]);
530
578
  set_cpee_model('<description xmlns="http://cpee.org/ns/description/1.0" xmlns:a="http://cpee.org/ns/annotation/1.0"/>');
531
579
  $('#dat_details').empty();
532
580
  } //}}}
@@ -575,9 +623,11 @@ function create(prompt,llms,generation,mode) {
575
623
  if (gen == 'dataflow') { prompt_type = 'adapt_endpoints'; }
576
624
  }
577
625
 
578
- send_expositions([
626
+ let tokens = no_tokens();
627
+ let interaction = create_interaction_uuid();
628
+ send_expositions(interaction,[
579
629
  [{ 'type': 'Intent Handling', 'lifecycle': 'start', 'artefact': 'Message', 'llm': myllm }, 'User intent analysis'],
580
- [{ 'type': 'Intent Handling', 'lifecycle': 'start', 'artefact': 'User Input' }, input]
630
+ [{ 'type': 'Intent Handling', 'lifecycle': 'input', 'artefact': 'User Input' }, input]
581
631
  ]);
582
632
  ui.querying(llms,'analyses user intent');
583
633
 
@@ -588,23 +638,26 @@ function create(prompt,llms,generation,mode) {
588
638
 
589
639
  history_promise.then(function(history){
590
640
  let messages = JSON.stringify(history);
591
- call_llm_service_intent(input,myllm,llms,save['dslx'],messages,documents).done((piped) => {
641
+ call_llm_service_intent(input,myllm,llms,save['dslx'],messages,documents,interaction).done((piped,itokens) => {
642
+ tokens = itokens;
592
643
  if (piped !== null) {
593
644
  ui.querying(llms,'creates model');
594
- send_expositions([[{ 'type': 'Model Generation', 'lifecycle': 'start', 'artefact': 'Message', 'llm': myllm }, (prompt_type.startsWith('generate_') ? 'Create' : 'Adapt') + ' model']]);
595
- call_llm_service_model(save['dslx'],piped,myllm,prompt_type).done((data) => {
596
- send_expositions([
597
- [{ 'type': 'Model Generation', 'lifecycle': 'start', 'artefact': 'CPEE Tree' }, data.input_cpee],
598
- [{ 'type': 'Model Generation', 'lifecycle': 'start', 'artefact': 'User Input' }, data.user_input],
599
- [{ 'type': 'Model Generation', 'lifecycle': 'start', 'artefact': 'Mermaid' }, data.input_intermediate],
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)],
600
653
  [{ 'type': 'Model Generation', 'lifecycle': 'result', 'artefact': 'Mermaid', 'llm': data.used_llm }, data.output_intermediate],
601
- [{ '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] // adapt_endpoints: the endpoints are a separate exposition
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]
602
655
  ]);
603
656
  if (prompt_type == 'adapt_endpoints') {
604
657
  let testset = $X(data.output_cpee); //{{{
605
658
  let model = $('> dslx > description',testset);
606
659
  let endpoints = $('> endpoints',testset);
607
- send_expositions([[{ 'type': 'Model Generation', 'lifecycle': 'result', 'artefact': 'Endpoints', 'llm': data.used_llm }, endpoints.serializePrettyXML()]]);
660
+ send_expositions(interaction,[[{ 'type': 'Model Generation', 'lifecycle': 'result', 'artefact': 'Endpoints', 'llm': data.used_llm }, endpoints.serializePrettyXML()]]);
608
661
  $.ajax({
609
662
  type: "PATCH",
610
663
  url: url + "/properties/endpoints/",
@@ -620,12 +673,13 @@ function create(prompt,llms,generation,mode) {
620
673
  set_cpee_model(model.serializePrettyXML());
621
674
 
622
675
  let summary = diff_summary(last_model_before_generation,model);
623
- ui.success(llms,summary);
676
+ ui.success(llms,with_tokens(summary,tokens));
624
677
  } else {
625
678
  if (gen == "dataflow") {
626
679
  ui.querying(llms,'selects endpoints and calculates dataflow'); //{{{
627
- send_expositions([[{ 'type': 'Dataflow', 'lifecycle': 'start', 'artefact': 'Message', 'llm': myllm }, 'Select endpoints and calculate dataflow']]);
628
- 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);
629
683
  let url = $('body').attr('current-instance');
630
684
  $.ajax({
631
685
  type: "PATCH",
@@ -639,53 +693,68 @@ function create(prompt,llms,generation,mode) {
639
693
  });
640
694
 
641
695
  ui.querying(llms,'validates dataflow');
642
- send_expositions([
696
+ send_expositions(interaction,[
697
+ [{ 'type': 'Dataflow', 'lifecycle': 'result', 'artefact': 'Tokens', 'llm': data.used_llm }, JSON.stringify(dtokens)],
643
698
  [{ 'type': 'Dataflow', 'lifecycle': 'result', 'artefact': 'LLM Text', 'llm': data.used_llm }, data.dataflow],
644
699
  [{ 'type': 'Dataflow', 'lifecycle': 'result', 'artefact': 'Endpoints', 'llm': data.used_llm }, data.endpoints],
645
700
  [{ 'type': 'Dataflow', 'lifecycle': 'intermediate', 'artefact': 'CPEE Tree', 'llm': data.used_llm }, $X(data.output_cpee).serializePrettyXML()],
646
701
  [{ 'type': 'Validation', 'lifecycle': 'start', 'artefact': 'Message', 'llm': myllm }, 'Validate dataflow']
647
702
  ]);
648
- call_llm_service_validation($X(data.output_cpee).serializePrettyXML(),myllm).done((data) => {
703
+ call_llm_service_validation($X(data.output_cpee).serializePrettyXML(),myllm).done((data,vtokens) => {
704
+ tokens = add_tokens(tokens,vtokens);
649
705
  // for undo button
650
706
  last_model_before_generation = save['dslx'];
651
707
  set_cpee_model($X(data.output_cpee).serializePrettyXML());
652
708
  let summary = diff_summary(last_model_before_generation,data.output_cpee);
653
- ui.success(llms,summary);
654
- send_expositions([
709
+ ui.success(llms,with_tokens(summary,tokens));
710
+ send_expositions(interaction,[
711
+ [{ 'type': 'Validation', 'lifecycle': 'result', 'artefact': 'Tokens', 'llm': myllm }, JSON.stringify(vtokens)],
655
712
  [{ 'type': 'Validation', 'lifecycle': 'result', 'artefact': 'CPEE Tree', 'llm': myllm }, $X(data.output_cpee).serializePrettyXML()],
656
- [{ 'type': 'Validation', 'lifecycle': 'result', 'artefact': 'Change Summary' }, summary]
657
713
  ]);
658
714
  })
659
715
  .fail((xhr) => {
660
- ui.error(llms,xhr_error(xhr));
661
- send_expositions([[{ 'type': 'Validation', 'lifecycle': 'failed', 'artefact': 'Message', 'llm': myllm }, 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
+ ]);
662
722
  });
663
723
 
664
724
  })
665
725
  .fail((xhr) => {
666
- ui.error(llms,xhr_error(xhr));
667
- send_expositions([[{ 'type': 'Dataflow', 'lifecycle': 'failed', 'artefact': 'Message', 'llm': myllm }, 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
+ ]);
668
732
  }); //}}}
669
733
  } else if (gen == "model") {
670
734
  last_model_before_generation = save['dslx']; //{{{
671
735
  set_cpee_model(data.output_cpee);
672
736
  let summary = diff_summary(last_model_before_generation,data.output_cpee);
673
- ui.success(llms,summary);
674
- send_expositions([[{ 'type': 'Model Generation', 'lifecycle': 'result', 'artefact': 'Change Summary' }, summary]]); //}}}
737
+ ui.success(llms,with_tokens(summary,tokens));
738
+ send_expositions(interaction,[[{ 'type': 'Model Generation', 'lifecycle': 'result', 'artefact': 'Change Summary' }, summary]]); //}}}
675
739
  } else {
676
- ui.success(llms,"Successfully done nothing");
677
- send_expositions([[{ 'type': 'Model Generation', 'lifecycle': 'result', 'artefact': 'Message' }, "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"]]);
678
742
  }
679
743
  }
680
744
  })
681
745
  .fail((xhr) => {
682
- ui.error(llms,xhr_error(xhr));
683
- send_expositions([[{ 'type': 'Model Generation', 'lifecycle': 'failed', 'artefact': 'Message', 'llm': myllm }, 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
+ ]);
684
752
  });
685
753
  }
686
- }).fail((xhr) => {
687
- ui.error(llms,xhr_error(xhr));
688
- send_expositions([[{ 'type': 'Intent Handling', 'lifecycle': 'failed', 'artefact': 'Message', 'llm': myllm }, 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)]]);
689
758
  });
690
759
  });
691
760
  }
@@ -713,26 +782,29 @@ $(document).ready(async function() { //{{{
713
782
  $(document).on('click','#generate_itext_button',function(e){
714
783
  ui.clean();
715
784
  ui.querying($('#llms'),'thinks');
716
- send_expositions([[{ 'type': 'LLM Text', 'lifecycle': 'start', 'artefact': 'Message', 'llm': $('#llms').find(":selected").val() || default_llm }, 'Create text description of the CPEE-Tree (file)']]);
717
- 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);
718
788
  });
719
789
  $(document).on('click','#generate_text_button',function(e){
720
790
  ui.clean();
721
791
  ui.querying($('#llms'),'thinks');
722
- send_expositions([[{ 'type': 'LLM Text', 'lifecycle': 'start', 'artefact': 'Message', 'llm': $('#llms').find(":selected").val() || default_llm }, 'Create text description of the CPEE-Tree (prompt)']]);
723
- 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);
724
795
  });
725
796
  $(document).on('click','#prompt_undo_button',function(e){
726
797
  ui.clean();
727
798
  ui.input($('#llms'),'Undo');
728
799
  ui.querying($('#llms'),'thinks');
729
- send_expositions([[{ 'type': 'Undo', 'lifecycle': 'start', 'artefact': 'Message' }, 'Restore previous CPEE-Tree']]);
800
+ let interaction = create_interaction_uuid();
801
+ send_expositions(interaction,[[{ 'type': 'Undo', 'lifecycle': 'start', 'artefact': 'Message' }, 'Restore previous CPEE-Tree']]);
730
802
  load_last_model_before_generation().done(() => {
731
803
  ui.success($('#llms'),'Previous model restored.');
732
- send_expositions([[{ 'type': 'Undo', 'lifecycle': 'result', 'artefact': 'Message' }, 'Previous CPEE-Tree restored.']]);
804
+ send_expositions(interaction,[[{ 'type': 'Undo', 'lifecycle': 'result', 'artefact': 'Message' }, 'Previous CPEE-Tree restored.']]);
733
805
  }).fail((xhr) => {
734
806
  ui.error($('#llms'),xhr_error(xhr));
735
- send_expositions([[{ 'type': 'Undo', 'lifecycle': 'failed', 'artefact': 'Message' }, xhr_error(xhr)]]);
807
+ send_expositions(interaction,[[{ 'type': 'Undo', 'lifecycle': 'failed', 'artefact': 'Message' }, xhr_error(xhr)]]);
736
808
  });
737
809
  });
738
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.140"
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."