Skip to content

Commit 753a2a9

Browse files
committed
Merge branch 'main' into feature/claude
2 parents a2eefa2 + b2046a1 commit 753a2a9

77 files changed

Lines changed: 3364 additions & 82 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Examples/Examples.SimpleConsole/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
var model = AIHub.Model();
99

1010
var m = model.GetModel("gemma3:4b");
11-
1211
var x = model.GetModel("llama3.2:3b");
1312
await model.DownloadAsync(x.Name);
1413

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using Examples.Utils;
2+
using MaIN.Core.Hub;
3+
using MaIN.Core.Hub.Utils;
4+
using MaIN.Domain.Entities.Agents.AgentSource;
5+
using Microsoft.Identity.Client;
6+
7+
namespace Examples.Agents;
8+
9+
public class AgentWithKnowledgeFileExample : IExample
10+
{
11+
public async Task Start()
12+
{
13+
Console.WriteLine("Agent with knowledge base example");
14+
AIHub.Extensions.DisableLLamaLogs();
15+
var context = await AIHub.Agent()
16+
.WithModel("gemma3:4b")
17+
.WithInitialPrompt("""
18+
You are a helpful assistant that answers questions about a company. Try to
19+
help employees find answers to their questions. Company you work for is TechVibe Solutions.
20+
""")
21+
.WithKnowledge(KnowledgeBuilder.Instance
22+
.AddFile("people.md", "./Files/Knowledge/people.md",
23+
tags: ["workers", "employees", "company"])
24+
.AddFile("organization.md", "./Files/Knowledge/organization.md",
25+
tags:["company structure", "company policy", "company culture", "company overview"])
26+
.AddFile("events.md", "./Files/Knowledge/events.md",
27+
tags: ["company events", "company calendar", "company agenda"])
28+
.AddFile("office_layout.md", "./Files/Knowledge/office_layout.md",
29+
tags: ["company layout", "company facilities", "company environment", "office items", "supplies"]))
30+
.WithSteps(StepBuilder.Instance
31+
.AnswerUseKnowledge()
32+
.Build())
33+
.CreateAsync();
34+
35+
var result = await context
36+
.ProcessAsync("Hey! Where I can find some printer paper?");
37+
Console.WriteLine(result.Message.Content);;
38+
39+
}
40+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using Examples.Utils;
2+
using MaIN.Core.Hub;
3+
using MaIN.Core.Hub.Utils;
4+
using MaIN.Domain.Entities;
5+
using MaIN.Domain.Entities.Agents.AgentSource;
6+
using Microsoft.Identity.Client;
7+
8+
namespace Examples.Agents;
9+
10+
public class AgentWithKnowledgeWebExample : IExample
11+
{
12+
public async Task Start()
13+
{
14+
Console.WriteLine("Piano Learning Assistant with Focused Knowledge Sources");
15+
16+
AIHub.Extensions.DisableLLamaLogs();
17+
var context = await AIHub.Agent()
18+
.WithModel("llama3.2:3b")
19+
.WithMemoryParams(new MemoryParams(){ContextSize = 2137})
20+
.WithInitialPrompt("""
21+
You are an expert piano instructor specializing in teaching specific pieces,
22+
techniques, and solving common playing problems. Help students learn exact
23+
fingerings, chord progressions, and troubleshoot technical issues with
24+
detailed, step-by-step guidance for both classical and popular music.
25+
""")
26+
.WithKnowledge(KnowledgeBuilder.Instance
27+
.AddUrl("piano_scales_major", "https://www.pianoscales.org/major.html",
28+
tags: ["scale_fingerings", "c_major_scale", "d_major_scale", "fingering_patterns"])
29+
.AddUrl("piano_chord_database", "https://www.pianochord.org/",
30+
tags: ["chord_fingerings", "cmaj7_chord", "chord_inversions", "left_hand_chords"])
31+
.AddUrl("fundamentals_practice_book", "https://fundamentals-of-piano-practice.readthedocs.io/",
32+
tags: ["memorization_techniques", "mental_play_method", "practice_efficiency", "difficult_passages"])
33+
.AddUrl("hanon_exercises", "https://www.hanon-online.com/",
34+
tags: ["hanon_exercises", "finger_independence", "daily_technical_work", "exercise_1_through_20"])
35+
.AddUrl("sheet_music_reading",
36+
"https://www.simplifyingtheory.com/how-to-read-sheet-music-for-beginners/",
37+
tags: ["bass_clef_reading", "treble_clef_notes", "note_identification", "staff_reading_speed"])
38+
.AddUrl("piano_fundamentals", "https://music2me.com/en/magazine/learn-piano-in-13-steps",
39+
tags: ["proper_posture", "finger_numbering", "hand_position", "keyboard_orientation"])
40+
.AddUrl("theory_lessons", "https://www.8notes.com/theory/",
41+
tags: ["interval_identification", "key_signatures", "circle_of_fifths", "time_signatures"])
42+
.AddUrl("piano_terms", "https://www.libertyparkmusic.com/musical-terms-learning-piano/",
43+
tags: ["dynamics_markings", "tempo_markings", "articulation_symbols", "expression_terms"]))
44+
.WithSteps(StepBuilder.Instance
45+
.AnswerUseKnowledge()
46+
.Build())
47+
.CreateAsync();
48+
49+
var result = await context
50+
.ProcessAsync("I want to learn the C major scale. What's the exact fingering pattern for both hands?" + "I want short and concrete answer");
51+
52+
Console.WriteLine(result.Message.Content);
53+
}
54+
}

Examples/Examples/Chat/ChatExample.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ public async Task Start()
88
{
99
Console.WriteLine("ChatExample is running!");
1010

11-
var context = AIHub.Chat().WithModel("gemma2:2b");
12-
13-
await context
11+
await AIHub.Chat()
12+
.WithModel("gemma2:2b")
1413
.WithMessage("Where do hedgehogs goes at night?")
1514
.CompleteAsync(interactive: true);
1615
}

Examples/Examples/Chat/ChatWithImageGenOpenAiExample.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Examples.Utils;
22
using MaIN.Core.Hub;
3+
using MaIN.Domain.Models;
34

45
namespace Examples;
56

@@ -12,6 +13,7 @@ public async Task Start()
1213

1314
var result = await AIHub.Chat()
1415
.EnableVisual()
16+
.WithModel("dall-e-3")
1517
.WithMessage("Generate rock style cow playing guitar")
1618
.CompleteAsync();
1719

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using MaIN.Core.Hub;
2+
using MaIN.Domain.Entities;
3+
using MaIN.Services.Services.TTSService;
4+
5+
namespace Examples;
6+
7+
public class ChatWithTextToSpeechExample : IExample
8+
{
9+
private const string VoicePath = "<your-path-to-voices>";
10+
11+
public async Task Start()
12+
{
13+
Console.WriteLine("ChatWithTextToSpeech is running! Put on your headphones and press any key.");
14+
Console.ReadKey();
15+
16+
VoiceService.SetVoicesPath(VoicePath);
17+
var voice = VoiceService.GetVoice("af_heart")
18+
.MixWith(VoiceService.GetVoice("bf_emma"));
19+
20+
await AIHub.Chat().WithModel("gemma2:2b")
21+
.WithMessage("Generate a 4 sentence poem.")
22+
.Speak(new TextToSpeechParams("kokoro:82m", voice, true))
23+
.CompleteAsync(interactive: true);
24+
25+
Console.WriteLine("Done!");
26+
Console.ReadKey();
27+
}
28+
}

Examples/Examples/Examples.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,17 @@
3737
<None Update="Files\Books.json">
3838
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
3939
</None>
40+
<None Update="Files\Knowledge\events.md">
41+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
42+
</None>
43+
<None Update="Files\Knowledge\office_layout.md">
44+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
45+
</None>
46+
<None Update="Files\Knowledge\organization.md">
47+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
48+
</None>
49+
<None Update="Files\Knowledge\people.md">
50+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
51+
</None>
4052
</ItemGroup>
4153
</Project>

0 commit comments

Comments
 (0)