mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2025-10-01 18:18:19 +00:00
C# bindings (#650)
* First workin version of the C# bindings * Update README.md Signed-off-by: mvenditto <venditto.matteo@gmail.com> * Added more docs + fixed prompt callback signature * build scripts revision * Added .editorconfig + fixed style issues --------- Signed-off-by: mvenditto <venditto.matteo@gmail.com>
This commit is contained in:
21
gpt4all-bindings/csharp/Gpt4All.Samples/Program.cs
Normal file
21
gpt4all-bindings/csharp/Gpt4All.Samples/Program.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Gpt4All;
|
||||
|
||||
var modelFactory = new Gpt4AllModelFactory();
|
||||
|
||||
var modelPath = args[0];
|
||||
|
||||
using var model = modelFactory.LoadModel(modelPath);
|
||||
|
||||
var input = args.Length > 1 ? args[1] : "Name 3 colors.";
|
||||
|
||||
var result = await model.GetStreamingPredictionAsync(
|
||||
input,
|
||||
PredictRequestOptions.Defaults);
|
||||
|
||||
await foreach (var token in result.GetPredictionStreamingAsync())
|
||||
{
|
||||
Console.Write(token);
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("DONE.");
|
Reference in New Issue
Block a user