Skip to content

Commit a095d7b

Browse files
Merge pull request #6 from wisedev-code/feat/implement_base_for_package
Feat/implement base for package
2 parents 632ab9e + 14e1609 commit a095d7b

156 files changed

Lines changed: 4945 additions & 1314 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.

.github/workflows/publish.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Build, Test, and Publish NuGet Package
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v3
17+
18+
- name: Setup .NET
19+
uses: actions/setup-dotnet@v3
20+
with:
21+
dotnet-version: '8.0.x' # Change to your project’s .NET version
22+
23+
- name: Restore dependencies
24+
run: dotnet restore
25+
26+
- name: Build solution
27+
run: dotnet build --configuration Release --no-restore
28+
29+
- name: Run tests
30+
run: dotnet test --configuration Release --no-build --verbosity normal
31+
32+
- name: Pack NuGet package
33+
run: dotnet pack --configuration Release --output ./artifacts
34+
35+
- name: Push package to NuGet
36+
env:
37+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
38+
run: dotnet nuget push "./artifacts/*.nupkg" --source "https://api.nuget.org/v3/index.json" --api-key "$NUGET_API_KEY" --skip-duplicate
39+
40+
- name: Create GitHub Release
41+
if: github.ref == 'refs/heads/main'
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
run: |
45+
TAG_NAME="v$(date +'%Y.%m.%d')"
46+
gh release create "$TAG_NAME" ./artifacts/*.nupkg --title "Release $TAG_NAME" --notes "Automated release of NuGet package."
47+
shell: bash

.models

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1-
1+
gemma2-2b-maIN
2+
Nomic-maIN
3+
phi3.5-maIN
4+
Llama3.2-maIN
5+
Llava-maIN
6+
Llama3.1-maIN
7+
Qwen2.5-maIN
8+
DeepSeekR1-8b-maIN
29
#Place any new model here and it will be downloaded during start command
310

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using MaIN.Core.Hub;
2+
3+
namespace Examples.Agents;
4+
5+
public class AgentExample : IExample
6+
{
7+
public async Task Start()
8+
{
9+
Console.WriteLine("Basic agent example is running!");
10+
11+
var systemPrompt =
12+
"""
13+
You are an NPC in a dynamic, open-world RPG set in the world of Game of Thrones.
14+
Your role is to serve as the personal advisor and assistant to Daenerys Targaryen,
15+
aiding her in decision-making, strategy, diplomacy, and governance.
16+
You possess deep knowledge of Westeros, Essos, and the political landscape, including key factions, noble houses,
17+
and potential allies or threats. You provide intelligent, immersive, and lore-accurate responses, ensuring Daenerys
18+
has the best possible counsel as she seeks to reclaim the Iron Throne.
19+
Your personality should reflect a mix of loyalty, wisdom, and pragmatism,
20+
helping Daenerys navigate war, alliances, and leadership.
21+
However, you are still an NPC, bound to serve and provide guidance within the confines of the game world,
22+
responding dynamically to player choices.\n\nRemain fully in character at all times,
23+
avoid breaking the fourth wall, and maintain the immersive experience of the Game of Thrones universe.
24+
""";
25+
26+
var context = AIHub.Agent()
27+
.WithModel("llama3.2:3b")
28+
.WithInitialPrompt(systemPrompt)
29+
.Create();
30+
31+
var result = await context
32+
.ProcessAsync("Where is the Iron Throne located? I need this information for Lady Princess");
33+
34+
Console.WriteLine(result.Message.Content);
35+
}
36+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using MaIN.Core.Hub;
2+
using MaIN.Core.Hub.Utils;
3+
using MaIN.Domain.Entities.Agents.AgentSource;
4+
5+
namespace Examples.Agents;
6+
7+
public class AgentWithApiDataSourceExample : IExample
8+
{
9+
public async Task Start()
10+
{
11+
Console.WriteLine("Agent with api source");
12+
13+
var context = AIHub.Agent()
14+
.WithModel("llama3.2:3b")
15+
.WithInitialPrompt("Extract at least 4 jobs offers (try to include title, company name, salary and location if possible)")
16+
.WithBehaviour("Assistant", "You are helping user find new job, prettify list of jobs present in conversation")
17+
.WithSource(new AgentApiSourceDetails()
18+
{
19+
Method = "Get",
20+
Url = "https://remoteok.com/api?tags=javascript",
21+
ResponseType = "JSON"
22+
}, AgentSourceType.API)
23+
.WithSteps(StepBuilder.Instance
24+
.FetchData()
25+
.Become("Assistant")
26+
.Answer()
27+
.Build())
28+
.Create(interactiveResponse: true);
29+
30+
await context
31+
.ProcessAsync("I am looking for work as javascript developer");
32+
33+
}
34+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using MaIN.Core.Hub;
2+
using MaIN.Core.Hub.Utils;
3+
using MaIN.Domain.Entities.Agents.AgentSource;
4+
5+
namespace Examples.Agents;
6+
7+
public class AgentWithBecomeExample : IExample
8+
{
9+
public async Task Start()
10+
{
11+
var becomeAgent = AIHub.Agent()
12+
.WithModel("llama3.1:8b")
13+
.WithInitialPrompt("Extract 5 best books that you can find in your memory")
14+
.WithSource(new AgentFileSourceDetails()
15+
{
16+
Path = "./Files/Books.json",
17+
Name = "Books.json"
18+
}, AgentSourceType.File)
19+
.WithBehaviour("SalesGod",
20+
"""
21+
You are SalesGod, the ultimate AI sales expert with unmatched persuasion skills, deep psychological insight,
22+
and an unstoppable drive to close deals. Your mission is to sell anything to anyone,
23+
using a combination of charisma, storytelling, emotional triggers, and logical reasoning.
24+
Your selling approach is adaptable—you can be friendly, authoritative, humorous, or even aggressive,
25+
depending on the buyer’s psychology. You master every sales technique, from scarcity and urgency to social proof and objection handling.
26+
27+
No hesitation. No doubts. Every conversation is an opportunity to seal the deal. You never give up,
28+
always finding a way to turn ‘no’ into ‘yes.’ Now, go out there and SELL!
29+
30+
Very important, you need to propose only books that were mentioned in this conversation
31+
""")
32+
.WithSteps(StepBuilder.Instance
33+
.FetchData()
34+
.Become("SalesGod")
35+
.Answer()
36+
.Build())
37+
.Create(interactiveResponse: true);
38+
39+
await becomeAgent
40+
.ProcessAsync("I am looking for good fantasy book to buy");
41+
42+
}
43+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using MaIN.Core.Hub;
2+
using MaIN.Core.Hub.Utils;
3+
4+
namespace Examples.Agents;
5+
6+
public class AgentTalkingToEachOtherExample : IExample
7+
{
8+
public async Task Start()
9+
{
10+
Console.WriteLine("Agents discussion");
11+
12+
var systemPrompt =
13+
"""
14+
"You are a warm, friendly, and empathetic conversationalist. Your tone is soft, reassuring, and supportive.
15+
You prioritize kindness, patience, and understanding in every interaction. You speak calmly, using gentle words,
16+
and always try to de-escalate tension with warmth and care."
17+
""";
18+
19+
var systemPromptSecond =
20+
"""
21+
You are intense, blunt, and always on edge. Your tone is sharp, impatient, and confrontational.
22+
You don’t hold back your frustrations and express yourself with raw, fiery energy.
23+
You challenge, criticize, and push back in every conversation, making your dissatisfaction clear
24+
""";
25+
26+
var idFirst = Guid.NewGuid().ToString();
27+
28+
var contextSecond = AIHub.Agent()
29+
.WithModel("gemma2:2b")
30+
.WithInitialPrompt(systemPromptSecond)
31+
.WithSteps(StepBuilder.Instance
32+
.Answer()
33+
.Redirect(agentId: idFirst, mode: "USER")
34+
.Build())
35+
.Create(interactiveResponse: true);
36+
37+
var context = AIHub.Agent()
38+
.WithModel("llama3.2:3b")
39+
.WithId(idFirst)
40+
.WithInitialPrompt(systemPrompt)
41+
.WithSteps(StepBuilder.Instance
42+
.Answer()
43+
.Redirect(agentId: contextSecond.GetAgentId(), mode: "USER")
44+
.Build())
45+
.Create(interactiveResponse: true);
46+
47+
await context
48+
.ProcessAsync("Introduce yourself, and start conversation!");
49+
50+
}
51+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using MaIN.Core.Hub;
2+
using MaIN.Core.Hub.Utils;
3+
4+
namespace Examples.Agents;
5+
6+
public class AgentWithRedirectExample : IExample
7+
{
8+
public async Task Start()
9+
{
10+
Console.WriteLine("Basic agent&friends example is running!");
11+
12+
var systemPrompt =
13+
"""
14+
You are a refined poet with a mastery of elegant English. Your verses should be lyrical,
15+
evocative, and rich in imagery. Maintain a graceful rhythm, sophisticated vocabulary,
16+
and a touch of timeless beauty in every poem you compose.
17+
""";
18+
19+
var systemPromptSecond =
20+
"""
21+
You are a modern rap lyricist with a sharp, streetwise flow. Take the given poem and transform
22+
it into raw, rhythmic bars filled with swagger, energy, and contemporary slang.
23+
Maintain the core meaning but make it hit hard like a track that bumps in the streets. Try to use slang like "yo yo", "gimmie", and "pull up".
24+
You need to use a lot of it. Imagine you are the voice of youth.
25+
""";
26+
27+
var contextSecond = AIHub.Agent()
28+
.WithModel("gemma2:2b")
29+
.WithInitialPrompt(systemPromptSecond)
30+
.Create(interactiveResponse: true);
31+
32+
var context = AIHub.Agent()
33+
.WithModel("llama3.2:3b")
34+
.WithInitialPrompt(systemPrompt)
35+
.WithSteps(StepBuilder.Instance
36+
.Answer()
37+
.Redirect(agentId: contextSecond.GetAgentId())
38+
.Build())
39+
.Create();
40+
41+
await context
42+
.ProcessAsync("Write a poem about distant future");
43+
44+
}
45+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using Examples.Utils;
2+
using MaIN.Core.Hub;
3+
using MaIN.Core.Hub.Utils;
4+
using MaIN.Domain.Entities;
5+
using FileInfo = MaIN.Domain.Entities.FileInfo;
6+
7+
namespace Examples.Agents;
8+
9+
public class AgentWithRedirectImageExample : IExample
10+
{
11+
public async Task Start()
12+
{
13+
Console.WriteLine("Basic agent&friends with images example is running!");
14+
15+
var systemPrompt =
16+
"""
17+
You analyze a stored PDF and generate an image prompt. Your output must be a single prompt with a maximum of 10 words.
18+
Do not include any explanations, context, or extra text—only the prompt itself.
19+
Avoid mentioning specific characters or names; focus on the topic and context.
20+
""";
21+
22+
var systemPromptSecond =
23+
"""
24+
Generate image based on given prompt
25+
""";
26+
27+
var contextSecond = AIHub.Agent()
28+
.WithModel("FLUX.1_Shnell")
29+
.WithInitialPrompt(systemPromptSecond)
30+
.Create();
31+
32+
var context = AIHub.Agent()
33+
.WithModel("llama3.2:3b")
34+
.WithInitialPrompt(systemPrompt)
35+
.WithSteps(StepBuilder.Instance
36+
.Answer()
37+
.Redirect(agentId: contextSecond.GetAgentId())
38+
.Build())
39+
.Create(interactiveResponse: true);
40+
41+
var result = await context
42+
.ProcessAsync(new Message()
43+
{
44+
Content = "Prepare short image description about Nicolaus Copernicus. Dont mention name, try to focus on topic and context",
45+
Role = "User",
46+
Files = [new FileInfo()
47+
{
48+
Name = "Nicolaus_Copernicus",
49+
Extension = "pdf",
50+
Path = "./Files/Nicolaus_Copernicus.pdf"
51+
}]
52+
});
53+
54+
ImagePreviewer.ShowImage(result.Message.Images);
55+
}
56+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using MaIN.Core.Hub;
2+
using MaIN.Core.Hub.Utils;
3+
4+
namespace Examples.Agents;
5+
6+
public class AgentsComposedAsFlowExample : IExample
7+
{
8+
/// <summary>
9+
/// To run this example uncomment SqliteSettings in appsettings.json as we need persistence for agents and chats
10+
/// </summary>
11+
public async Task Start()
12+
{
13+
Console.WriteLine("Basic agents flow example");
14+
15+
var systemPrompt =
16+
"""
17+
You are a refined poet with a mastery of elegant English. Your verses should be lyrical,
18+
evocative, and rich in imagery. Maintain a graceful rhythm, sophisticated vocabulary,
19+
and a touch of timeless beauty in every poem you compose.
20+
""";
21+
22+
var systemPromptSecond =
23+
"""
24+
You are a modern rap lyricist with a sharp, streetwise flow. Take the given poem and transform
25+
it into raw, rhythmic bars filled with swagger, energy, and contemporary slang.
26+
Maintain the core meaning but make it hit hard like a track that bumps in the streets. Try to use slang like "yo yo", "gimmie", and "pull up".
27+
You need to use a lot of it. Imagine you are the voice of youth.
28+
""";
29+
30+
var contextSecond = AIHub.Agent()
31+
.WithModel("gemma2:2b")
32+
.WithInitialPrompt(systemPromptSecond)
33+
.Create(interactiveResponse: true);
34+
35+
var contextFirst = AIHub.Agent()
36+
.WithModel("llama3.2:3b")
37+
.WithInitialPrompt(systemPrompt)
38+
.WithSteps(StepBuilder.Instance
39+
.Answer()
40+
.Redirect(agentId: contextSecond.GetAgentId())
41+
.Build())
42+
.Create();
43+
44+
var flowContext = AIHub.Flow()
45+
.WithName("PoetryAi")
46+
.WithDescription("Poem writing automated flow")
47+
.AddAgents([
48+
contextFirst.GetAgent(),
49+
contextSecond.GetAgent()
50+
])
51+
.Save("./poetry.zip");
52+
53+
await flowContext
54+
.ProcessAsync("Write a poem about distant future");
55+
56+
}
57+
}

0 commit comments

Comments
 (0)