Skip to content

Commit

Permalink
error handling with missing input field
Browse files Browse the repository at this point in the history
Signed-off-by: yuye-aws <[email protected]>
  • Loading branch information
yuye-aws committed Jul 16, 2024
1 parent acc51f1 commit ed36bed
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public KnowledgeBaseTool(Client client, String modelId) {
@SuppressWarnings("unchecked")
public <T> void run(Map<String, String> parameters, ActionListener<T> listener) {
String text = parameters.get(INPUT_FIELD);
if (StringUtils.isBlank(text)) {
throw new IllegalArgumentException("[" + INPUT_FIELD + "] is null or empty, can not process it in knowledge base tool.");
}

RemoteInferenceInputDataSet inputDataSet = RemoteInferenceInputDataSet
.builder()
.parameters(Collections.singletonMap(INPUT_FIELD, text))
Expand Down

0 comments on commit ed36bed

Please sign in to comment.