Skip to content

Commit

Permalink
Includ workflow id and current node id in the exception message (open…
Browse files Browse the repository at this point in the history
…search-project#262)

Includ workflow id and current node id in the exception message during registe agent step

Signed-off-by: Jackie Han <[email protected]>
  • Loading branch information
jackiehanyang authored and dbwiddis committed Dec 15, 2023
1 parent 5682c22 commit 4123229
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public CompletableFuture<WorkflowData> execute(
Map<String, String> previousNodeInputs
) throws IOException {

String workflowId = currentNodeInputs.getWorkflowId();

CompletableFuture<WorkflowData> registerAgentModelFuture = new CompletableFuture<>();

ActionListener<MLRegisterAgentResponse> actionListener = new ActionListener<>() {
Expand All @@ -92,7 +94,7 @@ public void onResponse(MLRegisterAgentResponse mlRegisterAgentResponse) {
String resourceName = WorkflowResources.getResourceByWorkflowStep(getName());
logger.info("Agent registration successful for the agent {}", mlRegisterAgentResponse.getAgentId());
flowFrameworkIndicesHandler.updateResourceInStateIndex(
currentNodeInputs.getWorkflowId(),
workflowId,
currentNodeId,
getName(),
mlRegisterAgentResponse.getAgentId(),
Expand All @@ -101,7 +103,7 @@ public void onResponse(MLRegisterAgentResponse mlRegisterAgentResponse) {
registerAgentModelFuture.complete(
new WorkflowData(
Map.ofEntries(Map.entry(resourceName, mlRegisterAgentResponse.getAgentId())),
currentNodeInputs.getWorkflowId(),
workflowId,
currentNodeId
)
);
Expand Down Expand Up @@ -168,12 +170,15 @@ public void onFailure(Exception e) {
// Case when modelId is not present at all
if (llmModelId == null) {
registerAgentModelFuture.completeExceptionally(
new FlowFrameworkException("llm model id is not provided", RestStatus.BAD_REQUEST)
new FlowFrameworkException(
"llm model id is not provided for workflow: " + workflowId + " on node: " + currentNodeId,
RestStatus.BAD_REQUEST
)
);
return registerAgentModelFuture;
}

LLMSpec llmSpec = getLLMSpec(llmModelId, llmParameters);
LLMSpec llmSpec = getLLMSpec(llmModelId, llmParameters, workflowId, currentNodeId);

MLAgentBuilder builder = MLAgent.builder().name(name);

Expand Down Expand Up @@ -246,9 +251,12 @@ private String getLlmModelId(Map<String, String> previousNodeInputs, Map<String,
return llmModelId;
}

private LLMSpec getLLMSpec(String llmModelId, Map<String, String> llmParameters) {
private LLMSpec getLLMSpec(String llmModelId, Map<String, String> llmParameters, String workflowId, String currentNodeId) {
if (llmModelId == null) {
throw new FlowFrameworkException("model id for llm is null", RestStatus.BAD_REQUEST);
throw new FlowFrameworkException(
"model id for llm is null for workflow: " + workflowId + " on node: " + currentNodeId,
RestStatus.BAD_REQUEST
);
}
LLMSpec.LLMSpecBuilder builder = LLMSpec.builder();
builder.modelId(llmModelId);
Expand Down

0 comments on commit 4123229

Please sign in to comment.