/**************************************************************************** * 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.cognition; import java.util.List; import java.util.logging.Logger; import org.imixs.ai.workflow.ImixsAIPromptService; import org.imixs.workflow.ItemCollection; import org.imixs.workflow.engine.EventLogService; import org.imixs.workflow.engine.WorkflowService; import org.imixs.workflow.exceptions.PluginException; import ai.dynamixs.ChronicleTextBuilder; import jakarta.inject.Inject; /** * The CognitoPlugin is a generic plugin to generate an cognito.create.event. * This event is processed by the `CognitoEventService` to generate an AI based * workflow abstract *
* The plugin can be activated by the following workflow result tag * *
{@code
}
*
* * The embedded tag 'debug' is optional * *
* The prompt definition is either loaded from the corresponding BPMN event
* (DataObject) or generated as generic default template in case that no
* PromptDefinition is assigned to the current event.
*
*
* @author rsoika
*
*/
public class CognitoPlugin extends org.imixs.ai.rag.RAGIndexPlugin {
private static final Logger logger = Logger.getLogger(CognitoPlugin.class.getName());
@Inject
private WorkflowService workflowService;
@Inject
private EventLogService eventLogService;
@Inject
private ImixsAIPromptService imixsAIPromptService;
@Override
public ItemCollection run(ItemCollection workitem, ItemCollection event) throws PluginException {
// do only run on type = workitem!
if (!workitem.getType().equals("workitem")) {
// no op!
return workitem;
}
// read optional configuration form the model or imixs.properties....
List