public async Task <ActionResult <PredictResponse> > ProcessVersionId(string modelName, [FromBody] PredictRequest request, CancellationToken token) { _logger.LogInformation($"{nameof(Question)}: {_json.Serialize(request)}"); if (request.IsValidRequest()) { return(StatusCode((int)HttpStatusCode.BadRequest)); } return(Ok(await _hostProxyService.Submit(modelName, request, token))); }
public async Task <ActionResult <PredictResponse> > Submit([FromBody] PredictRequest request) { _logger.LogInformation($"{nameof(Submit)}: {_json.Serialize(request)}"); if (!request.IsValidRequest()) { return(StatusCode((int)HttpStatusCode.BadRequest)); } switch (_executionContext.State) { case ExecutionState.Booting: case ExecutionState.Starting: case ExecutionState.Restarting: return(ReturnNotAvailable()); case ExecutionState.Running: try { PredictResponse hostResponse = await _predict.Submit(new Question { Sentence = request.Request ?? request.Sentence }); _logger.LogInformation($"{nameof(Submit)} answer: {_json.Serialize(hostResponse)}"); var result = new PredictResponse { Model = hostResponse.Model, Request = hostResponse.Request, Intents = hostResponse.Intents .OrderByDescending(x => x.Score) .Take(request.IntentLimit ?? int.MaxValue) .ToList(), }; return(Ok(result)); } catch (Exception ex) { _logger.LogError($"Exception from model. Ex={ex}"); throw; } default: _logger.LogError($"Failed: ExecutionState={_executionContext.State}"); return(StatusCode((int)HttpStatusCode.InternalServerError)); } }