From dc7d0a5998589120d2eced4fd87b232fdec74368 Mon Sep 17 00:00:00 2001 From: Ralph Soika Date: Sun, 30 Nov 2025 22:52:04 +0100 Subject: [PATCH] impl condititionalDebugAdapter class --- .../ai/dynamixs/ConditionalDebugAdapter.java | 84 +- pom.xml | 2 +- workflow/en/invoice-demo-c-1.0.0.bpmn | 3225 +++++++++++++++++ workflow/en/offer-en-1.0.0.bpmn | 6 +- 4 files changed, 3312 insertions(+), 5 deletions(-) create mode 100644 workflow/en/invoice-demo-c-1.0.0.bpmn diff --git a/dynamixs-ai-app/src/main/java/ai/dynamixs/ConditionalDebugAdapter.java b/dynamixs-ai-app/src/main/java/ai/dynamixs/ConditionalDebugAdapter.java index f676e50..d14dbb7 100644 --- a/dynamixs-ai-app/src/main/java/ai/dynamixs/ConditionalDebugAdapter.java +++ b/dynamixs-ai-app/src/main/java/ai/dynamixs/ConditionalDebugAdapter.java @@ -4,10 +4,14 @@ import java.io.Serializable; import java.util.List; import java.util.logging.Logger; +import org.imixs.ai.ImixsAIContextHandler; +import org.imixs.ai.workflow.ImixsAIPromptService; +import org.imixs.ai.workflow.ImixsAIResultEvent; import org.imixs.ai.workflow.OpenAIAPIService; import org.imixs.workflow.ItemCollection; import org.imixs.workflow.engine.ConditionalExpressionEvent; import org.imixs.workflow.engine.WorkflowService; +import org.imixs.workflow.exceptions.AdapterException; import org.imixs.workflow.exceptions.PluginException; import org.imixs.workflow.faces.data.WorkflowEvent; @@ -16,6 +20,29 @@ import jakarta.inject.Inject; /** * Debug class to test CDI Events of type BPMNConditionEvent + * + * + * Note: To run this plugin the conditional configuration should look like this + * + *
+* {@code
+    
+    true
+    llm.service.endpoint
+    BOOLEAN
+    
+        {"n_predict": 16, "temperature": 0 }
+        
+        
+        
+        
+    
+    
+* }
+* 
+ * */ public class ConditionalDebugAdapter implements Serializable { @@ -24,23 +51,46 @@ public class ConditionalDebugAdapter implements Serializable { @Inject protected WorkflowService workflowService; + @Inject + protected ImixsAIPromptService imixsAIPromptService; + @Inject protected OpenAIAPIService llmService; + @Inject + ImixsAIContextHandler imixsAIContextHandler; + /** * Test method * * @param conditionEvent * @throws PluginException + * @throws AdapterException */ - public void onConditionEvent(@Observes ConditionalExpressionEvent conditionalEvent) throws PluginException { + public void onConditionEvent(@Observes ConditionalExpressionEvent conditionalEvent) + throws PluginException, AdapterException { List llmConditionDefinitions; + boolean llmAPIDebug = false; llmConditionDefinitions = workflowService.evalXMLExpressionList( conditionalEvent.getCondition(), "imixs-ai", "CONDITION", conditionalEvent.getWorkitem(), true); for (ItemCollection promptDefinition : llmConditionDefinitions) { + String llmAPIEndpoint = imixsAIPromptService.parseLLMEndpointByBPMN(promptDefinition); + String llmAPIResultEvent = promptDefinition.getItemValueString("result-event"); + String llmAPIResultItem = promptDefinition.getItemValueString("result-item"); + if ("true".equalsIgnoreCase(promptDefinition.getItemValueString("debug"))) { + llmAPIDebug = true; + } + + // get PromptDefintion template... + String prompt = "" + promptDefinition.getItemValueString("PromptDefinition") + + ""; + logger.info("PromptDefinition=" + prompt); + + imixsAIContextHandler.setWorkItem(conditionalEvent.getWorkitem()); + imixsAIContextHandler.addPromptDefinition(prompt); } @@ -51,4 +101,36 @@ public class ConditionalDebugAdapter implements Serializable { logger.info("We observe a WorkflowEvent"); } + + /** + * This observer method reacts on a ImixsAI Result event and evaluates a boolean + * value + * + * Note: To run this adapter the configuration should look like this + * + *
+    * {@code
+         
+             llm.service.endpoint
+             BOOLEAN
+         
+    * }
+    * 
+ * + * @param event + */ + public void onEvent(@Observes ImixsAIResultEvent event) { + if (event.getWorkitem() == null) { + return; + } + + // we only adapt the result in case the eventType===JSON + if ("BOOLEAN".equalsIgnoreCase(event.getEventType())) { + // get result string + String booleanString = event.getPromptResult(); + + logger.info("Prompt Boolean Result= " + booleanString); + + } + } } \ No newline at end of file diff --git a/pom.xml b/pom.xml index 74f6d0c..e34dcac 100644 --- a/pom.xml +++ b/pom.xml @@ -73,7 +73,7 @@ 3.1.3 5.1.0 3.2.1-SNAPSHOT - 1.1.3-SNAPSHOT + 1.1.4-SNAPSHOT 1.0.0-SNAPSHOT 1.0.0 9.9.1-4 diff --git a/workflow/en/invoice-demo-c-1.0.0.bpmn b/workflow/en/invoice-demo-c-1.0.0.bpmn new file mode 100644 index 0000000..4fb3f08 --- /dev/null +++ b/workflow/en/invoice-demo-c-1.0.0.bpmn @@ -0,0 +1,3225 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Mueller-Ahlhorn Email + +]]> + + + +]]> + + + + + + + + + + + + + + + + + + + + IntermediateCatchEvent_1 + IntermediateCatchEvent_6 + Task_2 + StartEvent_1 + Task_4 + IntermediateCatchEvent_5 + IntermediateCatchEvent_5000-20 + IntermediateCatchEvent_7 + + DataObject_2 + task_VRC0OA + event_07075Q + IntermediateCatchEvent_9 + event_sLhvNg + gateway_dCdQfA + event_K8bjNw + gateway_YmVj8g + IntermediateCatchEvent_13 + task_omZN4A + event_HBu5SQ + event_ykc34Q + event_kXkdQw + + + IntermediateCatchEvent_8 + Task_1 + ExclusiveGateway_2 + Task_3 + IntermediateCatchEvent_10 + Task_5 + EndEvent_2 + + TextAnnotation_3 + event_N8RIrQ + gateway_mAVLGQ + event_K5Sn6A + Task_6 + IntermediateCatchEvent_11 + EndEvent_1 + IntermediateCatchEvent_12 + event_6W9N4g + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + sequencenumber.xlsx + + TOTAL_NET + invoice.total.net + number + + + TOTAL_TAX + invoice.total.tax + number + + + TOTAL + invoice.total + number + +]]> + + + + + + + + + false + + + + + + + + + + sequenceFlow_IDx82g + SequenceFlow_5 + + + DataOutput_6 + + + DataOutput_6 + + + + + SequenceFlow_18 + + + + + + + + + txtlastcomment]]> + + + + + + + + + true + + + + + + + + + + + + + + + + + + + sequencenumber - customer.name, invoice.date (invoice.total invoice.currency)]]> + + + $workflowgroup - $workflowstatus]]> + SequenceFlow_20 + SequenceFlow_18 + SequenceFlow_8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + customer.ref + (^customer\.),sequencenumber|customer.number + false +]]> + + + + + + + + + + + + false + + + + + SequenceFlow_20 + + + + + + + + + + + invoice.total invoice.currency +
+Rechnungsdatum: invoice.date +
+txtlastcomment]]>
+
+ + + + + + + + sequencenumber - customer.name, invoice.date (invoice.total invoice.currency)]]> + + + true + + + + + + + + + + + + +
+ $workflowgroup - $workflowstatus]]> + SequenceFlow_48 + SequenceFlow_9 + SequenceFlow_28 + sequenceFlow_oCvQOA + sequenceFlow_tZVF2w +
+ + + + + + + txtlastcomment]]> + + + + + + + + + true + + + + + + + + + + + sequencenumber - customer.name, invoice.date (invoice.total invoice.currency)]]> + + + $workflowgroup - $workflowstatus]]> + sequenceFlow_0qudvA + SequenceFlow_47 + + + SequenceFlow_47 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + home]]> + + + + + + + + + + + + false + + + + + + + + + + + + SequenceFlow_28 + SequenceFlow_34 + + + + + + + txtlastcomment]]> + + + + + + + + + true + + + + + + + + + + + + + + + + sequencenumber - customer.name, invoice.date (invoice.total invoice.currency)]]> + + + $workflowgroup - $workflowstatus]]> + SequenceFlow_34 + sequenceFlow_ubRkbQ + sequenceFlow_VGbJBw + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]]> + + + + + + + + + + + + false + + + + SequenceFlow_48 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + home]]> + + + + + + + + + + + + false + + + + + + + SequenceFlow_22 + SequenceFlow_54 + + + + + txtlastcomment]]> + + + + + + + + + true + + + + + + + + + + + sequencenumber - customer.name, invoice.date (invoice.total invoice.currency)]]> + + + $workflowgroup - $workflowstatus]]> + SequenceFlow_54 + SequenceFlow_56 + + + + + + SequenceFlow_56 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ausgangsrechnung-template + sequencenumber.xlsx + true +]]> + + + + + + + + + + + + false + + + + + + + + SequenceFlow_10 + SequenceFlow_25 + + + DataOutput_1 + + + DataOutput_1 + + + + + sequenceFlow_ck1EvQ + SequenceFlow_9 + + sequenceFlow_0uIXPA + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + COLLABORA_CONVERTER_URL + sequencenumber.xlsx + pdf +]]> + + + + + + + + + space.name]]> + + + false + + + + + + SequenceFlow_7 + + + DataOutput_2 + + + DataOutput_2 + + + + SequenceFlow_5 + + + + + + + + + + + + + + txtlastcomment]]> + + + + + + + + + true + + + + + + + + + + + + + + + + + + sequencenumber - customer.name, invoice.date (invoice.total invoice.currency)]]> + + + $workflowgroup - $workflowstatus]]> + SequenceFlow_19 + sequenceFlow_hbRxpg + sequenceFlow_XLKH0w + sequenceFlow_IDx82g + sequenceFlow_mPM0GA + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + customer.ref + (^customer\.),sequencenumber|customer.number + false +]]> + + + + + + + + + + + + false + + + + SequenceFlow_8 + SequenceFlow_10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + sequencenumber.xlsx + + + F10 + invoice.date + + + F11 + invoice.duedate + + + + C10 + sequencenumber + + + C11 + customer.number + + + + + A4 + customer.name + + + A5 + customer.address + + + A6 + customer.address.sub + + + A7 + customer.country-customer.zip customer.city + + + A12 + customer.vat (VAT) + + + + F14 + invoice.currency + + + E22 + invoice.tax % + +TOTAL_NET + + +]]> + + + sequenceFlow_XLKH0w + + + DataOutput_3 + + + DataOutput_3 + + + + SequenceFlow_25 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + sequencenumber.*\.xlsx + + INVOICE_TOTAL + invoice.total + number + + + INVOICE_CURRENCY + invoice.currency + + +]]> + + + + + + + + + + + + false + + + + + SequenceFlow_19 + + + DataOutput_5 + + + DataOutput_5 + + + + + + + SequenceFlow_22 + + + + + + + + + + + + + + Verify payment via banking software + + + + + + + + + + + + txtlastcomment]]> + + + + + + + + + true + + + + + + + + + + + + + + + + + + sequencenumber - customer.name, invoice.date (invoice.total invoice.currency)]]> + + + $workflowgroup - $workflowstatus]]> + SequenceFlow_31 + sequenceFlow_b9RMyw + SequenceFlow_7 + sequenceFlow_KW7K3Q + + + + + + + + + + + + + + + + + Html-Header +E-Mail - Rechnungsversand (DE) +

+Debitor: customer.name (customer.number) +

+ + + + + + + + + + + + + + + + + + + + + + + + + +
RechnungsnummerDatumFälligkeitRechnungsbetragSaldoMahnstufe
invoice.numberinvoice.dateinvoice.duedateinvoice.total invoice.currencyinvoice.saldo invoice.currency$workflowstatus
+ +sequencenumber.pdf + +E-Mail - Versand Footer (DE) +Html-Footer +]]>
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + home +invoice.total + +]]> + + + + + + + + + false + + + + + + + + + + + + + +
+ + sequenceFlow_WMJa9Q + sequenceFlow_upVMug + + + DataOutput_5 + + + DataOutput_5 + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + sequencenumber.*\.xlsx + + INVOICE_TOTAL + invoice.total + number + + + INVOICE_CURRENCY + invoice.currency + + +]]> + + + + + + + + + + + + false + + + + + sequenceFlow_JClvDg + sequenceFlow_PL3AfA + sequenceFlow_tZVF2w + sequenceFlow_hbRxpg + + + DataOutput_5 + + + DataOutput_5 + + + + + + + + + + + + + + + + + sequenceFlow_KW7K3Q + sequenceFlow_WMJa9Q + sequenceFlow_JClvDg + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]]> + + + + + + + + + payment.amount]]> + + + false + + + + sequenceFlow_VGbJBw + sequenceFlow_oCvQOA + sequenceFlow_tXQ7zg + + + + + + + + + + sequenceFlow_tXQ7zg + sequenceFlow_0qudvA + sequenceFlow_0uIXPA + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 8000 + 101 + sequencenumber|invoice.number,process.ref,space.ref,$uniqueid|$workitemref,(^customer\.|^invoice\.) + /pages/workitems/workitem.jsf?id=$uniqueid + +]]> + + + + + + + + + + + + false + + + + sequenceFlow_ubRkbQ + + + + + + + sequenceFlow_mPM0GA + + + + + + + + sequenceFlow_upVMug + sequenceFlow_uaVUJA + sequenceFlow_kWtVWw + + + + + + + + + + + txtlastcomment]]> + + + + + + + + + true + + + + + + + + + + + + + + + + + + sequencenumber - customer.name, invoice.date (invoice.total invoice.currency)]]> + + + $workflowgroup - $workflowstatus]]> + SequenceFlow_31 + sequenceFlow_0qwg1A + sequenceFlow_b9RMyw + SequenceFlow_7 + sequenceFlow_M4z0XQ + sequenceFlow_PL3AfA + sequenceFlow_H0nRzA + + + + + true + llm.service.endpoint + BOOLEAN + + {"n_predict": 16, "temperature": 0 } + + + + + + +]]> + + + + + + + + + + + + + + + + + + + + Html-Header +E-Mail - Rechnungsversand (DE) +

+Debitor: customer.name (customer.number) +

+ + + + + + + + + + + + + + + + + + + + + + + + + +
RechnungsnummerDatumFälligkeitRechnungsbetragSaldoMahnstufe
invoice.numberinvoice.dateinvoice.duedateinvoice.total invoice.currencyinvoice.saldo invoice.currency$workflowstatus
+ +sequencenumber.pdf + +E-Mail - Versand Footer (DE) +Html-Footer +]]>
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + home +invoice.total + +]]> + + + + + + + + + false + + + + + + + + + + + + + +
+ + sequenceFlow_H0nRzA + sequenceFlow_2Ya9Zw + + + DataOutput_5 + + + DataOutput_5 + + +
+ + + + + + + + sequenceFlow_ck1EvQ + + + + + + + + + + sequenceFlow_uaVUJA + sequenceFlow_2Ya9Zw + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + customer.ref + (^customer\.),sequencenumber|customer.number + false +]]> + + + + + + + + + + + + false + + + + + sequenceFlow_kWtVWw + sequenceFlow_0qwg1A + + + + + + + + +
+ + + + true + + + + + + + + event_xk5bvA + task_o49ZbQ + event_aa80CA + event_075tKw + event_0OZbUw + task_069TOQ + event_00Qzlg + dataObject_5bv4XQ + event_AXI0OA + + + + + sequenceFlow_fbqmXQ + + + + + + + + txtlastcomment]]> + + + + + + + + + true + + + + + + + + + + + + + + + + + + + sequencenumber - customer.name, invoice.date (invoice.total invoice.currency)]]> + + + $workflowgroup - $workflowstatus]]> + SequenceFlow_18 + sequenceFlow_SO72uw + sequenceFlow_UjQlig + sequenceFlow_YD0PjA + sequenceFlow_cAuZ1g + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + customer.ref + (^customer\.),sequencenumber|customer.number + false +]]> + + + + + + + + + + + + false + + + + + sequenceFlow_SO72uw + + + + + + + + invoice.number vom invoice.date ]]> + + + + + + + + + Html-Header +E-Mail - Mahnlauf (DE) +
+dunning.text
+
+

+Debitor: customer.name (customer.number) +

+ + + + + + + + + + + + + + + + + + + + + + + + + +
RechnungsnummerDatumFälligkeitRechnungsbetragSaldoMahnstufe
invoice.numberinvoice.dateinvoice.duedateinvoice.total invoice.currencyinvoice.saldo invoice.currency$workflowstatus
+ +E-Mail - Mahnlauf Footer (DE) +Html-Footer +]]>
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + customer.ref + (^customer\.),sequencenumber|customer.number + false +]]> + + + + + + + + + + + + false + + + + + + + + + + +
+ + sequenceFlow_cAuZ1g + sequenceFlow_TPOOqw + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + + sequenceFlow_fbqmXQ + sequenceFlow_UjQlig + + + + + + + + + + + txtlastcomment]]> + + + + + + + + + true + + + + + + + + + + + + + + + + + + + sequencenumber - customer.name, invoice.date (invoice.total invoice.currency)]]> + + + $workflowgroup - $workflowstatus]]> + SequenceFlow_18 + sequenceFlow_UjQlig + sequenceFlow_TPOOqw + sequenceFlow_hgngAg + sequenceFlow_dmvj1A + + + + + + + sequenceFlow_hgngAg + + + + + + + + + + + + + + + + + + + + + + + + + + +]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + customer.ref + (^customer\.),sequencenumber|customer.number + false +]]> + + + + + + + + + + + + false + + + + + sequenceFlow_dmvj1A + sequenceFlow_YD0PjA + + + + + + + +
+ + + + + +<itemvalue>$workflowstatus</itemvalue> + +]]> + + + +]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/workflow/en/offer-en-1.0.0.bpmn b/workflow/en/offer-en-1.0.0.bpmn index 81fb475..7655eb9 100644 --- a/workflow/en/offer-en-1.0.0.bpmn +++ b/workflow/en/offer-en-1.0.0.bpmn @@ -1968,8 +1968,8 @@ Product Details: - - + + @@ -2079,7 +2079,7 @@ Product Details: - +