cpee 2.1.139 → 2.1.140

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4905b33a763847f17365d1c97a5484f442479fe8450f2d5a4aab82d6dd54dbc3
4
- data.tar.gz: 9c47d46e1772354985c37ab76c0dc02a8f03258c9cbf6d9dca8cba38fa682c2c
3
+ metadata.gz: 12f61d71a9f8b618adb4b1f83a5cd0b136269d605bae0b26245bcf41e20b08b9
4
+ data.tar.gz: 5df999ab06315b3dca1d63563a4ca6790acc5f74374f07b91340771d00a03a69
5
5
  SHA512:
6
- metadata.gz: d907853a27e7fbabece090f51d73d9af346207dd28a0296263d2aa1570153e1b38c39ea6221c2e4874d8931efcd585e2cba83bbe9aecf838e0a675ab0ee717d1
7
- data.tar.gz: 1891663ab6c058606a44e3b65287f79ccfa0f43cbf37e96005ada06e3382ca59d27768df87bb0218a9bbae0f26c881a0c7f5600d293ecd86ad0165256ef3affc
6
+ metadata.gz: 1b766be12bd69af5048054bd243ab388f0d26a3040de4d6e838504f6d9904c33f6c564d9c4a438cff29d7445e73987a2563a1d0ef239f2954490172d13d48eb5
7
+ data.tar.gz: 460d38b25b3fe7848aa480554faca26eeca1d07741b4096c999a519e5f981f380734b8ccb234e96d8737edbf94d8b58554d6f95f25aca0b6b9dba474c066faf3
data/cockpit/js/llm.js CHANGED
@@ -41,6 +41,7 @@ function call_llm_service_intent(input, llm, llms, dslx, messages, documents, de
41
41
  if (intent === null) {
42
42
  // no intent matched at all
43
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."]]);
44
45
  def.resolve(null);
45
46
  return;
46
47
  }
@@ -78,6 +79,7 @@ function call_llm_service_intent(input, llm, llms, dslx, messages, documents, de
78
79
  } catch (xhr) {
79
80
  let trimmed_url = intent.url.replace(/\/+$/, '');
80
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."]]);
81
83
  def.resolve(null);
82
84
  return;
83
85
  }
@@ -98,8 +100,10 @@ function call_llm_service_intent(input, llm, llms, dslx, messages, documents, de
98
100
 
99
101
  if (intent.output == 'chat') {
100
102
  ui.success(llms,filled_output);
103
+ send_expositions([[{ 'type': 'Intent Handling', 'lifecycle': 'result', 'artefact': 'LLM Text', 'llm': llm }, filled_output]]);
101
104
  def.resolve(null);
102
105
  } 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]]);
103
107
  // repeat the process of looking for a plugin/intent, using the filled output as the new input
104
108
  // (at most 3 times, to avoid endless plugin loops)
105
109
  call_llm_service_intent(filled_output,llm,llms,dslx,messages,documents,depth + 1).done((result) => {
@@ -236,9 +240,11 @@ function call_llm_text_service(prompt,llms,action) { //{{{
236
240
  link.click();
237
241
  };
238
242
  ui.success(llms,data.status);
243
+ send_expositions([[{ 'type': 'LLM Text', 'lifecycle': 'result', 'artefact': 'Message', 'llm': myllm }, data.status]]);
239
244
  },
240
245
  error: function(xhr, stat, data) {
241
246
  ui.error(llms,xhr_error(xhr));
247
+ send_expositions([[{ 'type': 'LLM Text', 'lifecycle': 'failed', 'artefact': 'Message', 'llm': myllm }, xhr_error(xhr)]]);
242
248
  }
243
249
  });
244
250
  } //}}}
@@ -478,7 +484,7 @@ function diff_summary(model_old, model_new) { //{{{
478
484
  }
479
485
  } //}}}
480
486
 
481
- function set_cpee_model(cpee_xml,expositions=[]) { //{{{
487
+ function set_cpee_model(cpee_xml) { //{{{
482
488
  let root = $X(cpee_xml).get(0);
483
489
  if (root.childElementCount === 0) {
484
490
  root.textContent = '';
@@ -490,11 +496,6 @@ function set_cpee_model(cpee_xml,expositions=[]) { //{{{
490
496
  const blob = new Blob([cpee_xml], { type: "text/xml" });
491
497
  form_data.append("dslx", blob);
492
498
 
493
- for (const x of expositions) {
494
- const blobi = new Blob([x], { type: "text/plain" });
495
- form_data.append("exposition", blobi);
496
- }
497
-
498
499
  return $.ajax({
499
500
  type: "PUT",
500
501
  url: url + "/properties/dslx/",
@@ -505,9 +506,28 @@ function set_cpee_model(cpee_xml,expositions=[]) { //{{{
505
506
  });
506
507
  } //}}}
507
508
 
509
+ function send_expositions(expositions) { // [[info,body],...], info is an object, e.g. { 'type': 'Dataflow' } {{{
510
+ if (expositions.length == 0) { return; }
511
+ const form_data = new FormData();
512
+ // 18510501 dont change status
513
+ 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
+ for (const [info,body] of expositions) {
515
+ form_data.append("exposition_info", new Blob([JSON.stringify(info)], { type: "application/json" }));
516
+ form_data.append("exposition_body", new Blob([body === undefined || body === null ? '' : String(body)], { type: "text/plain" }));
517
+ }
518
+ return $.ajax({
519
+ type: "PUT",
520
+ url: url + "/properties/status/",
521
+ contentType: false,
522
+ processData: false,
523
+ data: form_data
524
+ });
525
+ } //}}}
526
+
508
527
  function empty_model(){ //{{{
509
528
  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!"]);
529
+ send_expositions([[{ 'type': 'Reset', 'lifecycle': 'result', 'artefact': 'Message' },'Everything empty.']]);
530
+ set_cpee_model('<description xmlns="http://cpee.org/ns/description/1.0" xmlns:a="http://cpee.org/ns/annotation/1.0"/>');
511
531
  $('#dat_details').empty();
512
532
  } //}}}
513
533
 
@@ -555,6 +575,10 @@ function create(prompt,llms,generation,mode) {
555
575
  if (gen == 'dataflow') { prompt_type = 'adapt_endpoints'; }
556
576
  }
557
577
 
578
+ send_expositions([
579
+ [{ 'type': 'Intent Handling', 'lifecycle': 'start', 'artefact': 'Message', 'llm': myllm }, 'User intent analysis'],
580
+ [{ 'type': 'Intent Handling', 'lifecycle': 'start', 'artefact': 'User Input' }, input]
581
+ ]);
558
582
  ui.querying(llms,'analyses user intent');
559
583
 
560
584
  let documents = save['documents'] ? save['documents'].save_object() : {};
@@ -565,15 +589,22 @@ function create(prompt,llms,generation,mode) {
565
589
  history_promise.then(function(history){
566
590
  let messages = JSON.stringify(history);
567
591
  call_llm_service_intent(input,myllm,llms,save['dslx'],messages,documents).done((piped) => {
568
- console.log(piped);
569
592
  if (piped !== null) {
570
593
  ui.querying(llms,'creates model');
594
+ send_expositions([[{ 'type': 'Model Generation', 'lifecycle': 'start', 'artefact': 'Message', 'llm': myllm }, (prompt_type.startsWith('generate_') ? 'Create' : 'Adapt') + ' model']]);
571
595
  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];
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],
600
+ [{ '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
602
+ ]);
573
603
  if (prompt_type == 'adapt_endpoints') {
574
604
  let testset = $X(data.output_cpee); //{{{
575
605
  let model = $('> dslx > description',testset);
576
606
  let endpoints = $('> endpoints',testset);
607
+ send_expositions([[{ 'type': 'Model Generation', 'lifecycle': 'result', 'artefact': 'Endpoints', 'llm': data.used_llm }, endpoints.serializePrettyXML()]]);
577
608
  $.ajax({
578
609
  type: "PATCH",
579
610
  url: url + "/properties/endpoints/",
@@ -586,12 +617,14 @@ function create(prompt,llms,generation,mode) {
586
617
  });
587
618
 
588
619
  last_model_before_generation = save['dslx'];
589
- set_cpee_model(model.serializePrettyXML(),expositions);
620
+ set_cpee_model(model.serializePrettyXML());
590
621
 
591
- ui.success(llms,diff_summary(last_model_before_generation,model)); //}}}
622
+ let summary = diff_summary(last_model_before_generation,model);
623
+ ui.success(llms,summary);
592
624
  } else {
593
625
  if (gen == "dataflow") {
594
626
  ui.querying(llms,'selects endpoints and calculates dataflow'); //{{{
627
+ send_expositions([[{ 'type': 'Dataflow', 'lifecycle': 'start', 'artefact': 'Message', 'llm': myllm }, 'Select endpoints and calculate dataflow']]);
595
628
  call_llm_service_dataflow($X(data.output_cpee).serializePrettyXML(),input,myllm).done((data) => {
596
629
  let url = $('body').attr('current-instance');
597
630
  $.ajax({
@@ -606,36 +639,53 @@ function create(prompt,llms,generation,mode) {
606
639
  });
607
640
 
608
641
  ui.querying(llms,'validates dataflow');
609
- expositions.push("# Dataflow:\n"+data.dataflow);
642
+ send_expositions([
643
+ [{ 'type': 'Dataflow', 'lifecycle': 'result', 'artefact': 'LLM Text', 'llm': data.used_llm }, data.dataflow],
644
+ [{ 'type': 'Dataflow', 'lifecycle': 'result', 'artefact': 'Endpoints', 'llm': data.used_llm }, data.endpoints],
645
+ [{ 'type': 'Dataflow', 'lifecycle': 'intermediate', 'artefact': 'CPEE Tree', 'llm': data.used_llm }, $X(data.output_cpee).serializePrettyXML()],
646
+ [{ 'type': 'Validation', 'lifecycle': 'start', 'artefact': 'Message', 'llm': myllm }, 'Validate dataflow']
647
+ ]);
610
648
  call_llm_service_validation($X(data.output_cpee).serializePrettyXML(),myllm).done((data) => {
611
649
  // for undo button
612
650
  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));
651
+ set_cpee_model($X(data.output_cpee).serializePrettyXML());
652
+ let summary = diff_summary(last_model_before_generation,data.output_cpee);
653
+ ui.success(llms,summary);
654
+ send_expositions([
655
+ [{ 'type': 'Validation', 'lifecycle': 'result', 'artefact': 'CPEE Tree', 'llm': myllm }, $X(data.output_cpee).serializePrettyXML()],
656
+ [{ 'type': 'Validation', 'lifecycle': 'result', 'artefact': 'Change Summary' }, summary]
657
+ ]);
615
658
  })
616
659
  .fail((xhr) => {
617
660
  ui.error(llms,xhr_error(xhr));
661
+ send_expositions([[{ 'type': 'Validation', 'lifecycle': 'failed', 'artefact': 'Message', 'llm': myllm }, xhr_error(xhr)]]);
618
662
  });
619
663
 
620
664
  })
621
665
  .fail((xhr) => {
622
666
  ui.error(llms,xhr_error(xhr));
667
+ send_expositions([[{ 'type': 'Dataflow', 'lifecycle': 'failed', 'artefact': 'Message', 'llm': myllm }, xhr_error(xhr)]]);
623
668
  }); //}}}
624
669
  } else if (gen == "model") {
625
670
  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)); //}}}
671
+ set_cpee_model(data.output_cpee);
672
+ 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]]); //}}}
628
675
  } else {
629
676
  ui.success(llms,"Successfully done nothing");
677
+ send_expositions([[{ 'type': 'Model Generation', 'lifecycle': 'result', 'artefact': 'Message' }, "Successfully done nothing"]]);
630
678
  }
631
679
  }
632
680
  })
633
681
  .fail((xhr) => {
634
682
  ui.error(llms,xhr_error(xhr));
683
+ send_expositions([[{ 'type': 'Model Generation', 'lifecycle': 'failed', 'artefact': 'Message', 'llm': myllm }, xhr_error(xhr)]]);
635
684
  });
636
685
  }
637
686
  }).fail((xhr) => {
638
687
  ui.error(llms,xhr_error(xhr));
688
+ send_expositions([[{ 'type': 'Intent Handling', 'lifecycle': 'failed', 'artefact': 'Message', 'llm': myllm }, xhr_error(xhr)]]);
639
689
  });
640
690
  });
641
691
  }
@@ -663,21 +713,26 @@ $(document).ready(async function() { //{{{
663
713
  $(document).on('click','#generate_itext_button',function(e){
664
714
  ui.clean();
665
715
  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)']]);
666
717
  call_llm_text_service($('#prompt'),$('#llms'),'file');
667
718
  });
668
719
  $(document).on('click','#generate_text_button',function(e){
669
720
  ui.clean();
670
721
  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)']]);
671
723
  call_llm_text_service($('#prompt'),$('#llms'),'show');
672
724
  });
673
725
  $(document).on('click','#prompt_undo_button',function(e){
674
726
  ui.clean();
675
727
  ui.input($('#llms'),'Undo');
676
728
  ui.querying($('#llms'),'thinks');
729
+ send_expositions([[{ 'type': 'Undo', 'lifecycle': 'start', 'artefact': 'Message' }, 'Restore previous CPEE-Tree']]);
677
730
  load_last_model_before_generation().done(() => {
678
731
  ui.success($('#llms'),'Previous model restored.');
732
+ send_expositions([[{ 'type': 'Undo', 'lifecycle': 'result', 'artefact': 'Message' }, 'Previous CPEE-Tree restored.']]);
679
733
  }).fail((xhr) => {
680
734
  ui.error($('#llms'),xhr_error(xhr));
735
+ send_expositions([[{ 'type': 'Undo', 'lifecycle': 'failed', 'artefact': 'Message' }, xhr_error(xhr)]]);
681
736
  });
682
737
  });
683
738
  $(document).on('click','#prompt_attach_button',function(e){
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.140"
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."
@@ -310,10 +310,29 @@ module CPEE
310
310
  end
311
311
  end #}}}
312
312
  class PutStatus < Riddl::Implementation #{{{
313
+ EXPOSITION_ONLY = 18510501 # status id that only carries expositions, the status stays as it is
314
+
313
315
  def self::set(id,opts,xml)
314
316
  doc = XML::Smart::string(xml)
315
317
  doc.register_namespace 'p', 'http://cpee.org/ns/properties/2.0'
316
- CPEE::Persistence::set_item(id,opts,'status',:id => doc.find('string(/p:status/p:id)').to_i, :message => doc.find('string(/p:status/p:message)'))
318
+ sid = doc.find('string(/p:status/p:id)').to_i
319
+ return if sid == EXPOSITION_ONLY
320
+ CPEE::Persistence::set_item(id,opts,'status',:id => sid, :message => doc.find('string(/p:status/p:message)'))
321
+ end
322
+
323
+ def self::expositions(id,opts,expositions) # [[info,body],...]
324
+ return if expositions.empty?
325
+ attrs = CPEE::Persistence::extract_list(id,opts,'attributes').to_h
326
+ change_uuid = CPEE::Persistence::extract_item(id,opts,'dslx/@change_uuid')
327
+ expositions.each do |info,body|
328
+ content = {
329
+ :change_uuid => change_uuid,
330
+ :exposition => body,
331
+ :info => info,
332
+ :attributes => attrs
333
+ }
334
+ CPEE::Message::send(:event,'description/exposition',File.join(opts[:url],'/'),id,attrs['uuid'],attrs['info'],content,opts[:redis])
335
+ end
317
336
  end
318
337
 
319
338
  def response
@@ -324,7 +343,16 @@ module CPEE
324
343
  elsif opts[:statemachine].final? id
325
344
  @status = 410
326
345
  else
346
+ begin
347
+ expositions = @p[1..-1].each_slice(2).map do |info,body|
348
+ [JSON.parse(info.value.read), body.value.read]
349
+ end
350
+ rescue JSON::ParserError => e
351
+ @status = 400
352
+ return Riddl::Parameter::Complex.new('error','text/plain','exposition_info is not valid JSON: ' + e.message)
353
+ end
327
354
  PutStatus::set id, opts, @p[0].value.read
355
+ PutStatus::expositions id, opts, expositions
328
356
  end
329
357
  nil
330
358
  end
@@ -844,7 +872,7 @@ module CPEE
844
872
  end
845
873
  end #}}}
846
874
 
847
- def self::set(id,opts,xml,exposition=[],copy=false)
875
+ def self::set(id,opts,xml,copy=false)
848
876
  dslx, dsl, de, ep = if copy
849
877
  PutDescription::transform(
850
878
  xml,
@@ -905,14 +933,6 @@ module CPEE
905
933
  PutDescription::backtransform_async(id,opts,dslx,tdslx,tdslxtype) if copy && tdslxtype == 'rest'
906
934
  PatchItems::set_hash('dataelements',id,opts,de) unless de.empty?
907
935
  PatchItems::set_hash('endpoints',id,opts,ep) unless ep.empty?
908
- exposition.each do |exp|
909
- content = {
910
- :change_uuid => change_uuid,
911
- :exposition => exp.value.read,
912
- :attributes => attrs
913
- }
914
- CPEE::Message::send(:event,'description/exposition',File.join(opts[:url],'/'),id,attrs['uuid'],attrs['info'],content,opts[:redis])
915
- end
916
936
  end
917
937
 
918
938
  def self::validate(xml,opts) # dslx against t_dslx.rng, returns the errors
@@ -944,7 +964,7 @@ module CPEE
944
964
  return Riddl::Parameter::Complex.new('error','text/plain',errors.join("\n"))
945
965
  end
946
966
  begin
947
- PutDescription::set(id,opts,xml,@p[1..-1],copy)
967
+ PutDescription::set(id,opts,xml,copy)
948
968
  rescue => e
949
969
  puts e.message
950
970
  puts e.backtrace
data/lib/properties.xml CHANGED
@@ -54,6 +54,10 @@
54
54
  <parameter name="status" mimetype="*/xml" handler="http://riddl.org/ns/handlers/relaxng">
55
55
  <xi:include href="properties/t_status.rng"/>
56
56
  </parameter>
57
+ <zeroOrMore>
58
+ <parameter name="exposition_info" mimetype="application/json"/>
59
+ <parameter name="exposition_body" mimetype="*"/>
60
+ </zeroOrMore>
57
61
  </message> <!--}}}-->
58
62
  <message name="integer"> <!--{{{-->
59
63
  <parameter name="value" type="integer"/>
@@ -141,16 +145,9 @@
141
145
  </message> <!--}}}-->
142
146
  <message name="dslx"> <!--{{{-->
143
147
  <parameter name="dslx" mimetype="*/xml"/>
144
-
145
- <zeroOrMore>
146
- <parameter name="exposition" mimetype="*"/>
147
- </zeroOrMore>
148
148
  </message> <!--}}}-->
149
149
  <message name="description"> <!--{{{-->
150
150
  <parameter name="description" mimetype="*"/>
151
- <zeroOrMore>
152
- <parameter name="exposition" mimetype="*"/>
153
- </zeroOrMore>
154
151
  </message> <!--}}}-->
155
152
 
156
153
  <message name="transformation"> <!--{{{-->
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpee
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.139
4
+ version: 2.1.140
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler