diff --git a/dynamixs-ai-app/src/main/java/ai/dynamixs/RAGDefaultIndexPlugin.java b/dynamixs-ai-app/src/main/java/ai/dynamixs/OrderPlugin.java
similarity index 56%
rename from dynamixs-ai-app/src/main/java/ai/dynamixs/RAGDefaultIndexPlugin.java
rename to dynamixs-ai-app/src/main/java/ai/dynamixs/OrderPlugin.java
index 4370d09..4c4156c 100644
--- a/dynamixs-ai-app/src/main/java/ai/dynamixs/RAGDefaultIndexPlugin.java
+++ b/dynamixs-ai-app/src/main/java/ai/dynamixs/OrderPlugin.java
@@ -14,29 +14,37 @@
package ai.dynamixs;
+import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import org.imixs.ai.rag.RAGService;
import org.imixs.workflow.ItemCollection;
+import org.imixs.workflow.WorkflowKernel;
import org.imixs.workflow.engine.WorkflowService;
import org.imixs.workflow.exceptions.AdapterException;
import org.imixs.workflow.exceptions.PluginException;
+import org.imixs.workflow.exceptions.QueryException;
import jakarta.inject.Inject;
/**
- * This RAGIndexPlugin extends the default imixs-ai RAGIndexPlugin.
- *
- * In the mode INDEX this plugins generates a default prompt template if no
- * prompt definition was found. This is to simplify the models.
+ * The OrderPlugin is a generic plugin for Order workflows.
+ *
+ * The plugin collects a list of $uniqueids for the last 5 orders for the given
+ * customer.ref. The list is stored in the item `order.history.ref`
+ *
+ *
+ * The plugin extends the default imixs-ai RAGIndexPlugin. In the mode INDEX
+ * this plugins generates a default prompt template.This is to simplify the
+ * models.
*
*
*
{@code
-
+
false
-
+
}
*
*
@@ -46,10 +54,11 @@ import jakarta.inject.Inject;
* @author rsoika
*
*/
-public class RAGDefaultIndexPlugin extends org.imixs.ai.rag.RAGIndexPlugin {
-
- private static final Logger logger = Logger.getLogger(RAGDefaultIndexPlugin.class.getName());
+public class OrderPlugin extends org.imixs.ai.rag.RAGIndexPlugin {
+ private static final Logger logger = Logger.getLogger(OrderPlugin.class.getName());
+ public static final String LINK_PROPERTY = "$workitemref";
+ public static final int MAX_HISTORY_RESULT = 5;
@Inject
private WorkflowService workflowService;
@@ -65,10 +74,13 @@ public class RAGDefaultIndexPlugin extends org.imixs.ai.rag.RAGIndexPlugin {
return workitem;
}
- logger.info("├── running Dynamixs.AI RAGPlugin");
+ logger.info("├── running Dynamixs.AI Order Plugin");
+
+ // Update History....
+ updateOrderHistory(workitem);
// read optional configuration form the model or imixs.properties....
- List ragIndexDefinitions = workflowService.evalWorkflowResultXML(event, "imixs-ai",
+ List ragIndexDefinitions = workflowService.evalWorkflowResultXML(event, "dynamixs-ai",
RAGService.RAG_INDEX, workitem, false);
try {
@@ -85,18 +97,54 @@ public class RAGDefaultIndexPlugin extends org.imixs.ai.rag.RAGIndexPlugin {
workitem.setItemValue("ai.chronicle.summary", promptTemplate);
indexDefinition.setItemValue("promptTemplate", embedTemplate(promptTemplate));
ragService.createIndex(ragIndexDefinitions, workitem, event);
- return workitem;
}
-
}
-
- // default behavior
- return super.run(workitem, event);
-
} catch (AdapterException e) {
throw new PluginException(e);
}
+ return workitem;
+ }
+
+ /**
+ * This method updates the item `order.history.ref` with the latest 5 orders for
+ * the current customer
+ *
+ * @param workitem
+ */
+ private void updateOrderHistory(ItemCollection workitem) {
+
+ workitem.removeItem("order.history.ref");
+ String customerRef = workitem.getItemValueString("customer.ref");
+ if (!customerRef.isEmpty()) {
+ // append customer ref to $workitemref
+ workitem.appendItemValueUnique("$workitemref", customerRef);
+
+ // collect all history orders....
+
+ String sQuery = "(";
+ sQuery = " (type:\"workitem\" OR type:\"workitemarchive\") AND (" + LINK_PROPERTY + ":\"" + customerRef
+ + "\") AND ($workflowgroup:\"" + workitem.getWorkflowGroup() + "\")";
+
+ List orderHistory = null;
+ try {
+ orderHistory = workflowService.getDocumentService().findStubs(sQuery, MAX_HISTORY_RESULT, 0,
+ WorkflowKernel.LASTEVENTDATE, true);
+ } catch (QueryException e) {
+ e.printStackTrace();
+ }
+ if (orderHistory != null) {
+ List orderHistoryRefList = new ArrayList<>();
+ for (ItemCollection order : orderHistory) {
+ if (!workitem.getUniqueID().equals(order.getUniqueID())) { // skip current id!
+ orderHistoryRefList.add(order.getUniqueID());
+ }
+ }
+ workitem.setItemValue("order.history.ref", orderHistoryRefList);
+ }
+
+ }
+
}
/**
diff --git a/workflow/en/offer-en-1.0.1.bpmn b/workflow/en/offer-en-1.0.1.bpmn
index b562eb6..b5373df 100644
--- a/workflow/en/offer-en-1.0.1.bpmn
+++ b/workflow/en/offer-en-1.0.1.bpmn
@@ -20,7 +20,9 @@
-
+
+
+
@@ -67,6 +69,8 @@
dataObject_80W0PA
event_niR0HA
event_LHADMg
+ event_d4UiTw
+ dataObject_Nw0oQQ
@@ -99,6 +103,7 @@
event_pxwPEw
dataObject_QIYhww
textAnnotation_ASEpEw
+ event_XQ7hGQ
@@ -110,21 +115,6 @@
-
- Product: _name
-EAN: _ean
-Category: _category
-Brand: _brand
-
-Description:
-_description
-
-Price: _price _currency
-Stock: _stock
-Size: _size
-Color: _color
-]]>
-
@@ -152,6 +142,14 @@ Color: _color
+
+ Customer: customer.name
+E-Mail: customer.email
+Address: customer.country customer.zip-customer.city customer.address
+
+
+]]>
+
$workflowgroup - $workflowstatus]]>
sequenceFlow_UIpo9Q
@@ -166,10 +164,12 @@ Color: _color
-
-
+
+
+
+
- _color
-
- Product: _name
-EAN: _ean
-Category: _category
-Brand: _brand
-
-Description:
-_description
-
-Price: _price _currency
-Stock: _stock
-Size: _size
-Color: _color
-]]>
-
@@ -230,6 +215,14 @@ Color: _color
+
+ Customer: customer.name
+E-Mail: customer.email
+Address: customer.country customer.zip-customer.city customer.address
+
+
+]]>
+
$workflowgroup - $workflowstatus]]>
SequenceFlow_42
@@ -240,21 +233,6 @@ Color: _color
-
- Product: _name
-EAN: _ean
-Category: _category
-Brand: _brand
-
-Description:
-_description
-
-Price: _price _currency
-Stock: _stock
-Size: _size
-Color: _color
-]]>
-
@@ -278,6 +256,14 @@ Color: _color
+
+ Customer: customer.name
+E-Mail: customer.email
+Address: customer.country customer.zip-customer.city customer.address
+
+
+]]>
+
$workflowgroup - $workflowstatus]]>
SequenceFlow_17
@@ -288,21 +274,6 @@ Color: _color
-
- Product: _name
-EAN: _ean
-Category: _category
-Brand: _brand
-
-Description:
-_description
-
-Price: _price _currency
-Stock: _stock
-Size: _size
-Color: _color
-]]>
-
@@ -326,6 +297,14 @@ Color: _color
+
+ Customer: customer.name
+E-Mail: customer.email
+Address: customer.country customer.zip-customer.city customer.address
+
+
+]]>
+
$workflowgroup - $workflowstatus]]>
SequenceFlow_21
@@ -501,21 +480,6 @@ Betrag: _amount (Brutto € _amount_brutto
-
- Product: _name
-EAN: _ean
-Category: _category
-Brand: _brand
-
-Description:
-_description
-
-Price: _price _currency
-Stock: _stock
-Size: _size
-Color: _color
-]]>
-
@@ -541,6 +505,14 @@ Color: _color
+
+ Customer: customer.name
+E-Mail: customer.email
+Address: customer.country customer.zip-customer.city customer.address
+
+
+]]>
+
$workflowgroup - $workflowstatus]]>
SequenceFlow_26
@@ -780,21 +752,6 @@ Betrag: _amount (Brutto € _amount_brutto
-
- Product: _name
-EAN: _ean
-Category: _category
-Brand: _brand
-
-Description:
-_description
-
-Price: _price _currency
-Stock: _stock
-Size: _size
-Color: _color
-]]>
-
@@ -818,6 +775,14 @@ Color: _color
+
+ Customer: customer.name
+E-Mail: customer.email
+Address: customer.country customer.zip-customer.city customer.address
+
+
+]]>
+
$workflowgroup - $workflowstatus]]>
SequenceFlow_41
@@ -1043,21 +1008,6 @@ result.isValid=true;
-
- Product: _name
-EAN: _ean
-Category: _category
-Brand: _brand
-
-Description:
-_description
-
-Price: _price _currency
-Stock: _stock
-Size: _size
-Color: _color
-]]>
-
@@ -1085,6 +1035,14 @@ Color: _color
+
+ Customer: customer.name
+E-Mail: customer.email
+Address: customer.country customer.zip-customer.city customer.address
+
+
+]]>
+
$workflowgroup - $workflowstatus]]>
sequenceFlow_WRPdIA
@@ -1092,7 +1050,7 @@ Color: _color
sequenceFlow_hkBSvg
sequenceFlow_0Q20mA
-
+
@@ -1152,7 +1110,11 @@ Color: _color
1400
true
-]]>
+
+ [customer.ref]
+ (^customer\.)
+ false
+]]>
@@ -1189,21 +1151,6 @@ Color: _color
-
- Product: _name
-EAN: _ean
-Category: _category
-Brand: _brand
-
-Description:
-_description
-
-Price: _price _currency
-Stock: _stock
-Size: _size
-Color: _color
-]]>
-
@@ -1231,10 +1178,18 @@ Color: _color
+
+ Customer: customer.name
+E-Mail: customer.email
+Address: customer.country customer.zip-customer.city customer.address
+
+
+]]>
+
$workflowgroup - $workflowstatus]]>
sequenceFlow_4DUFiA
- sequenceFlow_HGD9Yw
+ sequenceFlow_RgZeeQ
sequenceFlow_HfDRCQ
sequenceFlow_BM0t3w
sequenceFlow_ytbNEQ
@@ -1242,7 +1197,7 @@ Color: _color
-
+
@@ -1573,7 +1528,7 @@ Product Details:
-
+
@@ -1655,21 +1610,6 @@ Product Details:
-
- Product: _name
-EAN: _ean
-Category: _category
-Brand: _brand
-
-Description:
-_description
-
-Price: _price _currency
-Stock: _stock
-Size: _size
-Color: _color
-]]>
-
@@ -1697,6 +1637,14 @@ Color: _color
+
+ Customer: customer.name
+E-Mail: customer.email
+Address: customer.country customer.zip-customer.city customer.address
+
+
+]]>
+
$workflowgroup - $workflowstatus]]>
sequenceFlow_WRPdIA
@@ -1709,7 +1657,7 @@ Color: _color
sequenceFlow_6UcPtw
-
+
@@ -1787,7 +1735,7 @@ Color: _color
sequenceFlow_kkTZbA
sequenceFlow_6UcPtw
- sequenceFlow_HGD9Yw
+ sequenceFlow_ELk13Q
sequenceFlow_InfPdQ
@@ -1805,16 +1753,13 @@ Color: _color
-
-
-
-
+
@@ -2094,10 +2039,10 @@ Color: _color
-
+
https://embeddings.llama.cpp.imixs.com/
true
-
+
]]>
@@ -2120,21 +2065,6 @@ Color: _color
-
- Product: _name
-EAN: _ean
-Category: _category
-Brand: _brand
-
-Description:
-_description
-
-Price: _price _currency
-Stock: _stock
-Size: _size
-Color: _color
-]]>
-
@@ -2158,6 +2088,14 @@ Color: _color
+
+ Customer: customer.name
+E-Mail: customer.email
+Address: customer.country customer.zip-customer.city customer.address
+
+
+]]>
+
$workflowgroup - $workflowstatus]]>
SequenceFlow_40
@@ -2172,18 +2110,12 @@ Color: _color
- Product: _name
-EAN: _ean
-Category: _category
-Brand: _brand
+ Customer: customer.name
+E-Mail: customer.email
+Address: customer.country customer.zip-customer.city customer.address
+
-Description:
-_description
-
-Price: _price _currency
-Stock: _stock
-Size: _size
-Color: _color
+
]]>
@@ -2213,6 +2145,7 @@ Color: _color
$workflowgroup - $workflowstatus]]>
sequenceFlow_FFp2sQ
sequenceFlow_zyO0wQ
+ sequenceFlow_lrFxKQ
sequenceFlow_VtEF4g
sequenceFlow_11vZNA
@@ -2343,7 +2276,7 @@ No general advice. Only project-specific facts and insights.]]]]>
sequenceFlow_VtEF4g
-
+
@@ -2460,12 +2393,226 @@ Dann das LLM die Final Summary erstellen lassen
Und erst am Ende alles zurück ins RAG - inklusive der Anfrage des Kunden und des Angebots!]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [customer.ref]
+ (^customer\.),sequencenumber|customer.number
+ false
+]]>
+
+
+
+
+
+
+
+
+ false
+
+
+
+ sequenceFlow_lrFxKQ
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+ llm.service.endpoint
+ {"n_predict": 4096, "temperature": 0.7}
+ customer.summary
+ true
+
+false]]>
+
+
+
+ sequenceFlow_ELk13Q
+ sequenceFlow_RgZeeQ
+
+ sequenceFlow_InfPdQ
+
+
+
+
+
+
+
+ {"n_predict": 4096, "temperature": 0.3, "top_p": 0.9}
+
+
+
+ customer.name
+
+# Recent Project Insights:
+
+
+Created: $created
+ai.workflow.summary
+
+-----------------------------------------------------------------------------
+]]]]>
+
+ ]]>
+
+
+
+
+
+
+
+
+
+
true
+
+
+
+
+
+
+
@@ -2575,18 +2722,18 @@ Und erst am Ende alles zurück ins RAG - inklusive der Anfrage des Kunden und de
-
+
-
+
-
+
-
+
@@ -2605,36 +2752,36 @@ Und erst am Ende alles zurück ins RAG - inklusive der Anfrage des Kunden und de
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -2694,6 +2841,27 @@ Und erst am Ende alles zurück ins RAG - inklusive der Anfrage des Kunden und de
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -2791,8 +2959,8 @@ Und erst am Ende alles zurück ins RAG - inklusive der Anfrage des Kunden und de
-
-
+
+
@@ -2847,30 +3015,31 @@ Und erst am Ende alles zurück ins RAG - inklusive der Anfrage des Kunden und de
-
-
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
+
@@ -2881,9 +3050,9 @@ Und erst am Ende alles zurück ins RAG - inklusive der Anfrage des Kunden und de
-
+
-
+
@@ -2910,52 +3079,48 @@ Und erst am Ende alles zurück ins RAG - inklusive der Anfrage des Kunden und de
-
-
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
@@ -2967,10 +3132,10 @@ Und erst am Ende alles zurück ins RAG - inklusive der Anfrage des Kunden und de
-
-
-
-
+
+
+
+
@@ -2979,10 +3144,8 @@ Und erst am Ende alles zurück ins RAG - inklusive der Anfrage des Kunden und de
-
-
-
-
+
+
@@ -3036,6 +3199,36 @@ Und erst am Ende alles zurück ins RAG - inklusive der Anfrage des Kunden und de
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+