make sample print usage and cleaner

This commit is contained in:
redthing1 2023-05-22 14:45:04 -07:00 committed by AT
parent dec8546abe
commit 63f57635d8

View File

@ -1,21 +1,22 @@
using Gpt4All; using Gpt4All;
var modelFactory = new Gpt4AllModelFactory(); var modelFactory = new Gpt4AllModelFactory();
if (args.Length < 2)
var modelPath = args[0]; {
Console.WriteLine($"Usage: Gpt4All.Samples <model-path> <prompt>");
using var model = modelFactory.LoadModel(modelPath); return;
}
var input = args.Length > 1 ? args[1] : "Name 3 colors.";
var modelPath = args[0];
var result = await model.GetStreamingPredictionAsync( var prompt = args[1];
input,
PredictRequestOptions.Defaults); using var model = modelFactory.LoadModel(modelPath);
await foreach (var token in result.GetPredictionStreamingAsync()) var result = await model.GetStreamingPredictionAsync(
{ prompt,
Console.Write(token); PredictRequestOptions.Defaults);
}
await foreach (var token in result.GetPredictionStreamingAsync())
Console.WriteLine(); {
Console.WriteLine("DONE."); Console.Write(token);
}