/**************************************************************************** * Copyright (c) 2022-2025 Imixs Software Solutions GmbH and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * https://www.eclipse.org/legal/epl-2.0 * * This Source Code may also be made available under the terms of the * GNU General Public License, version 2 or later (GPL-2.0-or-later), * which is available at https://www.gnu.org/licenses/old-licenses/gpl-2.0.html * * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later ****************************************************************************/ 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; /** * 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
}
*
*
* The tag 'debug' is optional
*
*
* @author rsoika
*
*/
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;
@Inject
private RAGService ragService;
@Override
public ItemCollection run(ItemCollection workitem, ItemCollection event) throws PluginException {
// do not run on Snapshots!
if (workitem.getType().startsWith("snapshot-")) {
// no op!
return workitem;
}
logger.info("├── running Dynamixs.AI Order Plugin");
// Update History....
updateOrderHistory(workitem);
// read optional configuration form the model or imixs.properties....
List