Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,19 @@

public class AIChatModelCallExecutor implements CallableTask<CallAgentAI> {

private CallAgentAIExecutor executor;

@Override
public void init(CallAgentAI task, WorkflowApplication application, ResourceLoader loader) {}
public void init(CallAgentAI task, WorkflowApplication application, ResourceLoader loader) {
executor = new CallAgentAIExecutor(task);
}

@Override
public CompletableFuture<WorkflowModel> apply(
WorkflowContext workflowContext, TaskContext taskContext, WorkflowModel input) {
WorkflowModelFactory modelFactory = workflowContext.definition().application().modelFactory();
if (taskContext.task() instanceof CallAgentAI agenticAI) {
return CompletableFuture.completedFuture(
modelFactory.fromAny(new CallAgentAIExecutor().execute(agenticAI, input.asJavaObject())));
}
throw new IllegalArgumentException(
"AIChatModelCallExecutor can only process CallAgentAI tasks, but received: "
+ taskContext.task().getClass().getName());
return CompletableFuture.completedFuture(
modelFactory.fromAny(executor.execute(input.asJavaObject())));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@

public class CallAgentAIExecutor {

private final CallAgentAI callAgentAI;

private static final Cognisphere cognisphere = new Cognisphere();

public Object execute(CallAgentAI callAgentAI, Object input) {
public CallAgentAIExecutor(CallAgentAI callAgentAI) {
this.callAgentAI = callAgentAI;
}

public Object execute( Object input) {
AgentExecutor agentExecutor = AgentUtil.agentToExecutor(callAgentAI.getAgentInstance());

Map<String, Object> output = (Map<String, Object>) input;
Expand Down