Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making memory and llm spec optional fields #398

Merged
merged 3 commits into from
Jan 11, 2024
Merged
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 @@ -13,7 +13,6 @@
import org.opensearch.ExceptionsHelper;
import org.opensearch.common.Nullable;
import org.opensearch.core.action.ActionListener;
import org.opensearch.core.rest.RestStatus;
import org.opensearch.flowframework.exception.FlowFrameworkException;
import org.opensearch.flowframework.indices.FlowFrameworkIndicesHandler;
import org.opensearch.flowframework.util.ParseUtils;
Expand Down Expand Up @@ -176,30 +175,23 @@
llmModelId = getLlmModelId(previousNodeInputs, outputs);
}

// Case when modelId is not present at all
if (llmModelId == null) {
registerAgentModelFuture.completeExceptionally(
new FlowFrameworkException(
"llm model id is not provided for workflow: " + workflowId + " on node: " + currentNodeId,
RestStatus.BAD_REQUEST
)
);
return registerAgentModelFuture;
}

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

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

if (description != null) {
builder.description(description);
}
if (memory != null) {
builder.memory(memory);
}
if (llmSpec != null) {
builder.llm(llmSpec);
}

builder.type(type)
.llm(llmSpec)
.tools(toolsList)
.parameters(parameters)
.memory(memory)
.createdTime(createdTime)
.lastUpdateTime(lastUpdateTime)
.appType(appType);
Expand Down Expand Up @@ -264,10 +256,7 @@

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 for workflow: " + workflowId + " on node: " + currentNodeId,
RestStatus.BAD_REQUEST
);
return null;

Check warning on line 259 in src/main/java/org/opensearch/flowframework/workflow/RegisterAgentStep.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/flowframework/workflow/RegisterAgentStep.java#L259

Added line #L259 was not covered by tests
}
LLMSpec.LLMSpecBuilder builder = LLMSpec.builder();
builder.modelId(llmModelId);
Expand All @@ -279,6 +268,9 @@
}

private MLMemorySpec getMLMemorySpec(Object mlMemory) {
if (mlMemory == null) {
return null;

Check warning on line 272 in src/main/java/org/opensearch/flowframework/workflow/RegisterAgentStep.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/flowframework/workflow/RegisterAgentStep.java#L272

Added line #L272 was not covered by tests
}

Map<?, ?> map = (Map<?, ?>) mlMemory;
String type = null;
Expand Down
Loading