Skip to content

Instantly share code, notes, and snippets.

@Adolfi
Created June 24, 2024 12:18
Show Gist options
  • Save Adolfi/f0937da192b313373d1847a56f215fd8 to your computer and use it in GitHub Desktop.
Save Adolfi/f0937da192b313373d1847a56f215fd8 to your computer and use it in GitHub Desktop.
[HttpGet]
[Route("/api/ml/consume")]
public IActionResult Consume(string question)
{
var loadedModel = context.Model.Load(Path.Combine(Directory.GetCurrentDirectory(), "data/faq-model.zip"), out var modelInputSchema);
var predictionEngine = context.Model.CreatePredictionEngine<FAQModel, PredictionModel>(loadedModel);
var prediction = predictionEngine.Predict(new FAQModel() { Question = question });
return Ok(prediction.PredictedAnswer);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment