Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions Examples/Examples.SimpleConsole/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
using MaIN.Core;
using MaIN.Core.Hub;
using MaIN.Domain.Models.Abstract;
using MaIN.Domain.Models.Concrete;

MaINBootstrapper.Initialize();

var model = AIHub.Model();
var modelContext = AIHub.Model();

var m = model.GetModel("gemma3:4b");
var x = model.GetModel("llama3.2:3b");
await model.DownloadAsync(x.Name);
// Get models using ModelRegistry
var gemma = modelContext.GetModel("gemma3-4b");
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assignment to gemma is useless, since its value is never read.

Suggested change
var gemma = modelContext.GetModel("gemma3-4b");
modelContext.GetModel("gemma3-4b");

Copilot uses AI. Check for mistakes.
var llama = modelContext.GetModel("llama3.2-3b");
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assignment to llama is useless, since its value is never read.

Suggested change
var llama = modelContext.GetModel("llama3.2-3b");

Copilot uses AI. Check for mistakes.

// Or use strongly-typed models directly
var gemma2b = new Gemma2_2b();
Console.WriteLine($"Model: {gemma2b.Name}, File: {gemma2b.FileName}");

// Download a model
await modelContext.DownloadAsync(gemma2b.Id);
3 changes: 2 additions & 1 deletion Examples/Examples/Chat/ChatCustomGrammarExample.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using MaIN.Core.Hub;
using MaIN.Domain.Entities;
using MaIN.Domain.Models;
using MaIN.Domain.Models.Concrete;
using Grammar = MaIN.Domain.Models.Grammar;

namespace Examples.Chat;
Expand All @@ -21,7 +22,7 @@ public async Task Start()
""", GrammarFormat.GBNF);

await AIHub.Chat()
.WithModel("gemma2:2b")
.WithModel<Gemma2_2b>()
.WithMessage("Generate random person")
.WithInferenceParams(new InferenceParams
{
Expand Down
4 changes: 3 additions & 1 deletion Examples/Examples/Chat/ChatExample.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MaIN.Core.Hub;
using MaIN.Domain.Models.Concrete;

namespace Examples.Chat;

Expand All @@ -8,8 +9,9 @@ public async Task Start()
{
Console.WriteLine("ChatExample is running!");

// Using strongly-typed model
await AIHub.Chat()
.WithModel("gemma2:2b")
.WithModel<Gemma2_2b>()
.WithMessage("Where do hedgehogs goes at night?")
.CompleteAsync(interactive: true);
}
Expand Down
3 changes: 2 additions & 1 deletion Examples/Examples/Chat/ChatExampleAnthropic.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Examples.Utils;
using MaIN.Core.Hub;
using MaIN.Domain.Models.Concrete;

namespace Examples.Chat;

Expand All @@ -11,7 +12,7 @@ public async Task Start()
Console.WriteLine("(Anthropic) ChatExample is running!");

await AIHub.Chat()
.WithModel("claude-sonnet-4-20250514")
.WithModel<ClaudeSonnet4>()
.WithMessage("Write a haiku about programming on Monday morning.")
.CompleteAsync(interactive: true);
}
Expand Down
14 changes: 13 additions & 1 deletion Examples/Examples/Chat/ChatExampleGemini.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using Examples.Utils;
using MaIN.Core.Hub;
using MaIN.Domain.Configuration;
using MaIN.Domain.Models.Abstract;
using MaIN.Domain.Models.Concrete;

namespace Examples.Chat;

Expand All @@ -10,8 +13,17 @@ public async Task Start()
GeminiExample.Setup(); //We need to provide Gemini API key
Console.WriteLine("(Gemini) ChatExample is running!");

// Get built-in Gemini 2.5 Flash model
var model = AIHub.Model().GetModel(new Gemini2_5Flash().Id);

// Or create the model manually if not available in the hub
var customModel = new GenericCloudModel(
"gemini-2.5-flash",
BackendType.Gemini
);

await AIHub.Chat()
.WithModel("gemini-2.5-flash")
.WithModel(customModel)
Comment on lines +16 to +26
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example shows creating a GenericCloudModel but the model is retrieved from the registry and not used. Either use the retrieved model variable or remove it. The comment suggests getting from the hub, but then a custom model is created and used instead. This could be confusing for users following the example.

Copilot uses AI. Check for mistakes.
.WithMessage("Is the killer whale the smartest animal?")
.CompleteAsync(interactive: true);
}
Expand Down
3 changes: 2 additions & 1 deletion Examples/Examples/Chat/ChatExampleGroqCloud.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Examples.Utils;
using MaIN.Core.Hub;
using MaIN.Domain.Models.Concrete;

namespace Examples.Chat;

Expand All @@ -11,7 +12,7 @@ public async Task Start()
Console.WriteLine("(GroqCloud) ChatExample is running!");

await AIHub.Chat()
.WithModel("llama-3.1-8b-instant")
.WithModel<Llama3_1_8bInstant>()
.WithMessage("Which color do people like the most?")
.CompleteAsync(interactive: true);
}
Expand Down
3 changes: 2 additions & 1 deletion Examples/Examples/Chat/ChatExampleOllama.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Examples.Utils;
using MaIN.Core.Hub;
using MaIN.Domain.Models.Concrete;

namespace Examples.Chat;

Expand All @@ -11,7 +12,7 @@ public async Task Start()
Console.WriteLine("(Ollama) ChatExample is running!");

await AIHub.Chat()
.WithModel("gemma3:4b")
.WithModel<OllamaGemma3_4b>()
.WithMessage("Write a short poem about the color green.")
.CompleteAsync(interactive: true);
}
Expand Down
3 changes: 2 additions & 1 deletion Examples/Examples/Chat/ChatExampleOpenAi.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Examples.Utils;
using MaIN.Core.Hub;
using MaIN.Domain.Models.Concrete;

namespace Examples.Chat;

Expand All @@ -12,7 +13,7 @@ public async Task Start()
Console.WriteLine("(OpenAi) ChatExample is running!");

await AIHub.Chat()
.WithModel("gpt-5-nano")
.WithModel<Gpt5Nano>()
.WithMessage("What do you consider to be the greatest invention in history?")
.CompleteAsync(interactive: true);
}
Expand Down
3 changes: 2 additions & 1 deletion Examples/Examples/Chat/ChatExampleToolsSimple.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Examples.Utils;
using MaIN.Core.Hub;
using MaIN.Core.Hub.Utils;
using MaIN.Domain.Models.Concrete;

namespace Examples.Chat;

Expand All @@ -13,7 +14,7 @@ public async Task Start()
Console.WriteLine("(OpenAi) ChatExample with tools is running!");

await AIHub.Chat()
.WithModel("gpt-5-nano")
.WithModel<Gpt5Nano>()
.WithMessage("What time is it right now?")
.WithTools(new ToolsConfigurationBuilder()
.AddTool(
Expand Down
3 changes: 2 additions & 1 deletion Examples/Examples/Chat/ChatExampleToolsSimpleLocalLLM.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Examples.Utils;
using MaIN.Core.Hub;
using MaIN.Core.Hub.Utils;
using MaIN.Domain.Models.Concrete;

namespace Examples.Chat;

Expand All @@ -11,7 +12,7 @@ public async Task Start()
Console.WriteLine("Local LLM ChatExample with tools is running!");

await AIHub.Chat()
.WithModel("gemma3:4b")
.WithModel<Gemma3_4b>()
.WithMessage("What time is it right now?")
.WithTools(new ToolsConfigurationBuilder()
.AddTool(
Expand Down
3 changes: 2 additions & 1 deletion Examples/Examples/Chat/ChatExampleXai.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Examples.Utils;
using MaIN.Core.Hub;
using MaIN.Domain.Models.Concrete;

namespace Examples.Chat;

Expand All @@ -11,7 +12,7 @@ public async Task Start()
Console.WriteLine("(xAI) ChatExample is running!");

await AIHub.Chat()
.WithModel("grok-3-beta")
.WithModel<Grok3Beta>()
.WithMessage("Is the killer whale cute?")
.CompleteAsync(interactive: true);
}
Expand Down
3 changes: 2 additions & 1 deletion Examples/Examples/Chat/ChatFromExistingExample.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Text.Json;
using MaIN.Core.Hub;
using MaIN.Domain.Exceptions.Chats;
using MaIN.Domain.Models.Concrete;

namespace Examples.Chat;

Expand All @@ -11,7 +12,7 @@ public async Task Start()
Console.WriteLine("ChatExample with files is running!");

var result = AIHub.Chat()
.WithModel("qwen2.5:0.5b");
.WithModel<Qwen2_5_0_5b>();

await result.WithMessage("What do you think about math theories?")
.CompleteAsync();
Expand Down
3 changes: 2 additions & 1 deletion Examples/Examples/Chat/ChatGrammarExampleGemini.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using MaIN.Core.Hub;
using MaIN.Domain.Entities;
using MaIN.Domain.Models;
using MaIN.Domain.Models.Concrete;

namespace Examples.Chat;

Expand Down Expand Up @@ -38,7 +39,7 @@ public async Task Start()
""";

await AIHub.Chat()
.WithModel("gemini-2.5-flash")
.WithModel<Gemini2_5Flash>()
.WithMessage("Generate random person")
.WithInferenceParams(new InferenceParams
{
Expand Down
3 changes: 2 additions & 1 deletion Examples/Examples/Chat/ChatWithFilesExample.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MaIN.Core.Hub;
using MaIN.Domain.Models.Concrete;

namespace Examples.Chat;

Expand All @@ -14,7 +15,7 @@ public async Task Start()
];

var result = await AIHub.Chat()
.WithModel("gemma3:4b")
.WithModel<Gemma3_4b>()
.WithMessage("You have 2 documents in memory. Whats the difference of work between Galileo and Copernicus?. Give answer based on the documents.")
.WithFiles(files)
.DisableCache()
Expand Down
3 changes: 2 additions & 1 deletion Examples/Examples/Chat/ChatWithFilesExampleGemini.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Examples.Utils;
using MaIN.Core.Hub;
using MaIN.Domain.Models.Concrete;

namespace Examples.Chat;

Expand All @@ -13,7 +14,7 @@ public async Task Start()
List<string> files = ["./Files/Nicolaus_Copernicus.pdf", "./Files/Galileo_Galilei.pdf"];

var result = await AIHub.Chat()
.WithModel("gemini-2.0-flash")
.WithModel<Gemini2_5Flash>()
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example uses Gemini2_5Flash but the code retrieves it and creates a custom GenericCloudModel with ID "gemini-2.5-flash". However, looking at CloudModels.cs, Gemini2_5Flash has ID "gemini-2.5-flash" (line 67). The issue is at line 17 in ChatWithFilesExampleGemini.cs where it should be using Gemini2_0Flash (ID "gemini-2.0-flash") based on the original code, not Gemini2_5Flash. This is a model version mismatch.

Suggested change
.WithModel<Gemini2_5Flash>()
.WithModel<Gemini2_0Flash>()

Copilot uses AI. Check for mistakes.
.WithMessage("You have 2 documents in memory. Whats the difference of work between Galileo and Copernicus?. Give answer based on the documents.")
.WithFiles(files)
.CompleteAsync(interactive: true);
Expand Down
3 changes: 2 additions & 1 deletion Examples/Examples/Chat/ChatWithFilesFromStreamExample.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MaIN.Core.Hub;
using MaIN.Domain.Models.Concrete;

namespace Examples.Chat;

Expand Down Expand Up @@ -37,7 +38,7 @@ public async Task Start()
}

var result = await AIHub.Chat()
.WithModel("qwen2.5:0.5b")
.WithModel<Qwen2_5_0_5b>()
.WithMessage("You have 2 documents in memory. Whats the difference of work between Galileo and Copernicus?. Give answer based on the documents.")
.WithFiles(fileStreams)
.CompleteAsync();
Expand Down
3 changes: 2 additions & 1 deletion Examples/Examples/Chat/ChatWithImageGenOpenAiExample.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Examples.Utils;
using MaIN.Core.Hub;
using MaIN.Domain.Models.Concrete;

namespace Examples.Chat;

Expand All @@ -11,7 +12,7 @@ public async Task Start()
OpenAiExample.Setup(); // We need to provide OpenAi API key

var result = await AIHub.Chat()
.WithModel("dall-e-3")
.WithModel<DallE3>()
.EnableVisual()
.WithMessage("Generate rock style cow playing guitar")
.CompleteAsync();
Expand Down
3 changes: 2 additions & 1 deletion Examples/Examples/Chat/ChatWithReasoningDeepSeekExample.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Examples.Utils;
using MaIN.Core.Hub;
using MaIN.Domain.Models.Concrete;

namespace Examples.Chat;

Expand All @@ -11,7 +12,7 @@ public async Task Start()
Console.WriteLine("(DeepSeek) ChatExample with reasoning is running!");

await AIHub.Chat()
.WithModel("deepseek-reasoner") // a model that supports reasoning
.WithModel<DeepSeekReasoner>() // a model that supports reasoning
.WithMessage("What chill pc game do you recommend?")
.CompleteAsync(interactive: true);
}
Expand Down
3 changes: 2 additions & 1 deletion Examples/Examples/Chat/ChatWithReasoningExample.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MaIN.Core.Hub;
using MaIN.Domain.Models.Concrete;

namespace Examples.Chat;

Expand All @@ -9,7 +10,7 @@ public async Task Start()
Console.WriteLine("ChatWithReasoningExample is running!");

await AIHub.Chat()
.WithModel("deepseekR1:1.5b")
.WithModel<DeepSeek_R1_1_5b>()
.WithMessage("Think about greatest poet of all time")
.CompleteAsync(interactive: true);
}
Expand Down
4 changes: 3 additions & 1 deletion Examples/Examples/Chat/ChatWithTextToSpeechExample.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using MaIN.Core.Hub;
using MaIN.Domain.Entities;
using MaIN.Domain.Models.Concrete;
using MaIN.Services.Services.TTSService;
#pragma warning disable CS0618 // Type or member is obsolete

Expand All @@ -18,7 +19,8 @@ public async Task Start()
var voice = VoiceService.GetVoice("af_heart")
.MixWith(VoiceService.GetVoice("bf_emma"));

await AIHub.Chat().WithModel("gemma2:2b")
await AIHub.Chat()
.WithModel<Gemma2_2b>()
.WithMessage("Generate a 4 sentence poem.")
.Speak(new TextToSpeechParams("kokoro:82m", voice, true))
.CompleteAsync(interactive: true);
Expand Down
7 changes: 3 additions & 4 deletions Examples/Examples/Chat/ChatWithVisionExample.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MaIN.Core.Hub;
using MaIN.Domain.Models.Concrete;

namespace Examples.Chat;

Expand All @@ -11,11 +12,9 @@ public async Task Start()

var image = await File.ReadAllBytesAsync(
Path.Combine(AppContext.BaseDirectory, "Files", "gamex.jpg"));

await AIHub.Chat()
.WithCustomModel("Llava1.6-Mistral",
path: "<path_to_model>.gguf",
mmProject: "<path_to_mmproj>.gguf")
.WithModel<Llava16Mistral_7b>()
.WithMessage("What can you see on the image?", image)
.CompleteAsync(interactive: true);
}
Expand Down
Loading
Loading