Skip to content
Prev Previous commit
Next Next commit
fixing empty labels handling
  • Loading branch information
benwtrent committed Sep 27, 2021
commit 5210ae0e3a737d4701551e9e69dc89ac974b8a62
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public String getHypothesisTemplate() {
}

public List<String> getLabels() {
return labels;
return Optional.ofNullable(labels).orElse(List.of());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public NlpTask.RequestBuilder getRequestBuilder(NlpConfig nlpConfig) {
} else {
labels = this.labels;
}
if (this.labels == null || this.labels.length == 0) {
throw ExceptionsHelper.badRequestException("zero_shot_classification requires non-empty [labels]");
}
return new RequestBuilder(tokenizer, labels, hypothesisTemplate);
}

Expand Down