use of org.openhab.ui.habot.nlp.internal.OpenNLPInterpreter in project habot by ghys.
the class HABotResource method chat.
@POST
@RolesAllowed({ Role.USER, Role.ADMIN })
@Path("/chat")
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Send a query to HABot to interpret.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = ChatReply.class), @ApiResponse(code = 500, message = "An interpretation error occured") })
public Response chat(@HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @ApiParam(value = "language") String language, @ApiParam(value = "human language query", required = true) String query) throws Exception {
final Locale locale = (this.localeProvider != null && this.localeProvider.getLocale() != null) ? this.localeProvider.getLocale() : LocaleUtil.getLocale(language);
// interpret
OpenNLPInterpreter hli = (OpenNLPInterpreter) voiceManager.getHLI(OPENNLP_HLI);
if (hli == null) {
throw new InterpretationException("The OpenNLP interpreter is not available");
}
ChatReply reply = hli.reply(locale, query);
return Response.ok(reply).build();
}
Aggregations